Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394...
[linux-2.6-block.git] / fs / cifs / cifspdu.h
CommitLineData
1da177e4
LT
1/*
2 * fs/cifs/cifspdu.h
3 *
bf820679 4 * Copyright (c) International Business Machines Corp., 2002,2005
1da177e4
LT
5 * Author(s): Steve French (sfrench@us.ibm.com)
6 *
7 * This library is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15 * the GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software
3979877e 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1da177e4
LT
20 */
21
22#ifndef _CIFSPDU_H
23#define _CIFSPDU_H
24
25#include <net/sock.h>
26
3979877e
SF
27#ifdef CONFIG_CIFS_WEAK_PW_HASH
28#define LANMAN_PROT 0
9ac00b7d
SF
29#define LANMAN2_PROT 1
30#define CIFS_PROT 2
3979877e 31#else
1da177e4 32#define CIFS_PROT 0
3979877e
SF
33#endif
34#define POSIX_PROT CIFS_PROT+1
35#define BAD_PROT 0xFFFF
1da177e4
LT
36
37/* SMB command codes */
38/* Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
39 (ie which include no useful data other than the SMB error code itself).
40 Knowing this helps avoid response buffer allocations and copy in some cases */
41#define SMB_COM_CREATE_DIRECTORY 0x00 /* trivial response */
42#define SMB_COM_DELETE_DIRECTORY 0x01 /* trivial response */
43#define SMB_COM_CLOSE 0x04 /* triv req/rsp, timestamp ignored */
44#define SMB_COM_DELETE 0x06 /* trivial response */
45#define SMB_COM_RENAME 0x07 /* trivial response */
6b8edfe0 46#define SMB_COM_QUERY_INFORMATION 0x08 /* aka getattr */
1da177e4
LT
47#define SMB_COM_SETATTR 0x09 /* trivial response */
48#define SMB_COM_LOCKING_ANDX 0x24 /* trivial response */
49#define SMB_COM_COPY 0x29 /* trivial rsp, fail filename ignrd*/
a9d02ad4 50#define SMB_COM_OPEN_ANDX 0x2D /* Legacy open for old servers */
1da177e4
LT
51#define SMB_COM_READ_ANDX 0x2E
52#define SMB_COM_WRITE_ANDX 0x2F
53#define SMB_COM_TRANSACTION2 0x32
54#define SMB_COM_TRANSACTION2_SECONDARY 0x33
55#define SMB_COM_FIND_CLOSE2 0x34 /* trivial response */
56#define SMB_COM_TREE_DISCONNECT 0x71 /* trivial response */
57#define SMB_COM_NEGOTIATE 0x72
58#define SMB_COM_SESSION_SETUP_ANDX 0x73
59#define SMB_COM_LOGOFF_ANDX 0x74 /* trivial response */
60#define SMB_COM_TREE_CONNECT_ANDX 0x75
61#define SMB_COM_NT_TRANSACT 0xA0
62#define SMB_COM_NT_TRANSACT_SECONDARY 0xA1
63#define SMB_COM_NT_CREATE_ANDX 0xA2
ff5dbd9e 64#define SMB_COM_NT_CANCEL 0xA4 /* no response */
1da177e4
LT
65#define SMB_COM_NT_RENAME 0xA5 /* trivial response */
66
67/* Transact2 subcommand codes */
68#define TRANS2_OPEN 0x00
69#define TRANS2_FIND_FIRST 0x01
70#define TRANS2_FIND_NEXT 0x02
71#define TRANS2_QUERY_FS_INFORMATION 0x03
ac67055e 72#define TRANS2_SET_FS_INFORMATION 0x04
1da177e4
LT
73#define TRANS2_QUERY_PATH_INFORMATION 0x05
74#define TRANS2_SET_PATH_INFORMATION 0x06
75#define TRANS2_QUERY_FILE_INFORMATION 0x07
76#define TRANS2_SET_FILE_INFORMATION 0x08
77#define TRANS2_GET_DFS_REFERRAL 0x10
78#define TRANS2_REPORT_DFS_INCOSISTENCY 0x11
79
80/* NT Transact subcommand codes */
81#define NT_TRANSACT_CREATE 0x01
82#define NT_TRANSACT_IOCTL 0x02
83#define NT_TRANSACT_SET_SECURITY_DESC 0x03
84#define NT_TRANSACT_NOTIFY_CHANGE 0x04
85#define NT_TRANSACT_RENAME 0x05
86#define NT_TRANSACT_QUERY_SECURITY_DESC 0x06
87#define NT_TRANSACT_GET_USER_QUOTA 0x07
88#define NT_TRANSACT_SET_USER_QUOTA 0x08
89
ec637e3f
SF
90#define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */
91/* future chained NTCreateXReadX bigger, but for time being NTCreateX biggest */
92/* among the requests (NTCreateX response is bigger with wct of 34) */
93#define MAX_CIFS_HDR_SIZE 0x58 /* 4 len + 32 hdr + (2*24 wct) + 2 bct + 2 pad */
94#define CIFS_SMALL_PATH 120 /* allows for (448-88)/3 */
1da177e4
LT
95
96/* internal cifs vfs structures */
97/*****************************************************************
98 * All constants go here
99 *****************************************************************
100 */
101
102/*
103 * Starting value for maximum SMB size negotiation
104 */
105#define CIFS_MAX_MSGSIZE (4*4096)
106
107/*
108 * Size of encrypted user password in bytes
109 */
110#define CIFS_ENCPWD_SIZE (16)
111
112/*
113 * Size of the crypto key returned on the negotiate SMB in bytes
114 */
115#define CIFS_CRYPTO_KEY_SIZE (8)
116
117/*
118 * Size of the session key (crypto key encrypted with the password
119 */
7c7b25bc 120#define CIFS_SESS_KEY_SIZE (24)
1da177e4
LT
121
122/*
123 * Maximum user name length
124 */
125#define CIFS_UNLEN (20)
126
127/*
128 * Flags on SMB open
129 */
130#define SMBOPEN_WRITE_THROUGH 0x4000
131#define SMBOPEN_DENY_ALL 0x0010
132#define SMBOPEN_DENY_WRITE 0x0020
133#define SMBOPEN_DENY_READ 0x0030
134#define SMBOPEN_DENY_NONE 0x0040
135#define SMBOPEN_READ 0x0000
136#define SMBOPEN_WRITE 0x0001
137#define SMBOPEN_READWRITE 0x0002
138#define SMBOPEN_EXECUTE 0x0003
139
140#define SMBOPEN_OCREATE 0x0010
141#define SMBOPEN_OTRUNC 0x0002
142#define SMBOPEN_OAPPEND 0x0001
143
144/*
145 * SMB flag definitions
146 */
0753ca7b 147#define SMBFLG_EXTD_LOCK 0x01 /* server supports lock-read write-unlock smb */
1da177e4
LT
148#define SMBFLG_RCV_POSTED 0x02 /* obsolete */
149#define SMBFLG_RSVD 0x04
0753ca7b
SF
150#define SMBFLG_CASELESS 0x08 /* all pathnames treated as caseless (off
151 implies case sensitive file handling request) */
1da177e4
LT
152#define SMBFLG_CANONICAL_PATH_FORMAT 0x10 /* obsolete */
153#define SMBFLG_OLD_OPLOCK 0x20 /* obsolete */
154#define SMBFLG_OLD_OPLOCK_NOTIFY 0x40 /* obsolete */
155#define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */
156
157/*
158 * SMB flag2 definitions
159 */
0753ca7b
SF
160#define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1) /* can send long (non-8.3)
161 path names in response */
1da177e4
LT
162#define SMBFLG2_KNOWS_EAS cpu_to_le16(2)
163#define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4)
164#define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40)
165#define SMBFLG2_EXT_SEC cpu_to_le16(0x800)
166#define SMBFLG2_DFS cpu_to_le16(0x1000)
167#define SMBFLG2_PAGING_IO cpu_to_le16(0x2000)
168#define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)
169#define SMBFLG2_UNICODE cpu_to_le16(0x8000)
170
171/*
172 * These are the file access permission bits defined in CIFS for the
173 * NTCreateAndX as well as the level 0x107
174 * TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO
175 * responds with the AccessFlags.
176 * The AccessFlags specifies the access permissions a caller has to the
177 * file and can have any suitable combination of the following values:
178 */
179
0753ca7b
SF
180#define FILE_READ_DATA 0x00000001 /* Data can be read from the file */
181#define FILE_WRITE_DATA 0x00000002 /* Data can be written to the file */
182#define FILE_APPEND_DATA 0x00000004 /* Data can be appended to the file */
183#define FILE_READ_EA 0x00000008 /* Extended attributes associated */
184 /* with the file can be read */
185#define FILE_WRITE_EA 0x00000010 /* Extended attributes associated */
186 /* with the file can be written */
187#define FILE_EXECUTE 0x00000020 /*Data can be read into memory from */
188 /* the file using system paging I/O */
1da177e4 189#define FILE_DELETE_CHILD 0x00000040
0753ca7b
SF
190#define FILE_READ_ATTRIBUTES 0x00000080 /* Attributes associated with the */
191 /* file can be read */
192#define FILE_WRITE_ATTRIBUTES 0x00000100 /* Attributes associated with the */
193 /* file can be written */
194#define DELETE 0x00010000 /* The file can be deleted */
195#define READ_CONTROL 0x00020000 /* The access control list and */
196 /* ownership associated with the */
197 /* file can be read */
198#define WRITE_DAC 0x00040000 /* The access control list and */
199 /* ownership associated with the */
200 /* file can be written. */
201#define WRITE_OWNER 0x00080000 /* Ownership information associated */
202 /* with the file can be written */
203#define SYNCHRONIZE 0x00100000 /* The file handle can waited on to */
204 /* synchronize with the completion */
205 /* of an input/output request */
1da177e4
LT
206#define GENERIC_ALL 0x10000000
207#define GENERIC_EXECUTE 0x20000000
208#define GENERIC_WRITE 0x40000000
209#define GENERIC_READ 0x80000000
210 /* In summary - Relevant file */
211 /* access flags from CIFS are */
212 /* file_read_data, file_write_data */
0753ca7b 213 /* file_execute, file_read_attributes*/
1da177e4
LT
214 /* write_dac, and delete. */
215
216/*
217 * Invalid readdir handle
218 */
219#define CIFS_NO_HANDLE 0xFFFF
220
221/* IPC$ in ASCII */
222#define CIFS_IPC_RESOURCE "\x49\x50\x43\x24"
223
224/* IPC$ in Unicode */
225#define CIFS_IPC_UNICODE_RESOURCE "\x00\x49\x00\x50\x00\x43\x00\x24\x00\x00"
226
227/* Unicode Null terminate 2 bytes of 0 */
228#define UNICODE_NULL "\x00\x00"
229#define ASCII_NULL 0x00
230
231/*
232 * Server type values (returned on EnumServer API
233 */
234#define CIFS_SV_TYPE_DC 0x00000008
235#define CIFS_SV_TYPE_BACKDC 0x00000010
236
237/*
238 * Alias type flags (From EnumAlias API call
239 */
240#define CIFS_ALIAS_TYPE_FILE 0x0001
241#define CIFS_SHARE_TYPE_FILE 0x0000
242
243/*
244 * File Attribute flags
245 */
246#define ATTR_READONLY 0x0001
247#define ATTR_HIDDEN 0x0002
248#define ATTR_SYSTEM 0x0004
249#define ATTR_VOLUME 0x0008
250#define ATTR_DIRECTORY 0x0010
251#define ATTR_ARCHIVE 0x0020
252#define ATTR_DEVICE 0x0040
253#define ATTR_NORMAL 0x0080
254#define ATTR_TEMPORARY 0x0100
255#define ATTR_SPARSE 0x0200
256#define ATTR_REPARSE 0x0400
257#define ATTR_COMPRESSED 0x0800
0753ca7b
SF
258#define ATTR_OFFLINE 0x1000 /* ie file not immediately available -
259 on offline storage */
1da177e4
LT
260#define ATTR_NOT_CONTENT_INDEXED 0x2000
261#define ATTR_ENCRYPTED 0x4000
262#define ATTR_POSIX_SEMANTICS 0x01000000
263#define ATTR_BACKUP_SEMANTICS 0x02000000
264#define ATTR_DELETE_ON_CLOSE 0x04000000
265#define ATTR_SEQUENTIAL_SCAN 0x08000000
266#define ATTR_RANDOM_ACCESS 0x10000000
267#define ATTR_NO_BUFFERING 0x20000000
268#define ATTR_WRITE_THROUGH 0x80000000
269
270/* ShareAccess flags */
271#define FILE_NO_SHARE 0x00000000
272#define FILE_SHARE_READ 0x00000001
273#define FILE_SHARE_WRITE 0x00000002
274#define FILE_SHARE_DELETE 0x00000004
275#define FILE_SHARE_ALL 0x00000007
276
277/* CreateDisposition flags */
278#define FILE_SUPERSEDE 0x00000000
279#define FILE_OPEN 0x00000001
280#define FILE_CREATE 0x00000002
281#define FILE_OPEN_IF 0x00000003
282#define FILE_OVERWRITE 0x00000004
283#define FILE_OVERWRITE_IF 0x00000005
284
285/* CreateOptions */
286#define CREATE_NOT_FILE 0x00000001 /* if set must not be file */
287#define CREATE_WRITE_THROUGH 0x00000002
eda3c029
SF
288#define CREATE_SEQUENTIAL 0x00000004
289#define CREATE_SYNC_ALERT 0x00000010
290#define CREATE_ASYNC_ALERT 0x00000020
291#define CREATE_NOT_DIR 0x00000040 /* if set must not be directory */
292#define CREATE_NO_EA_KNOWLEDGE 0x00000200
293#define CREATE_EIGHT_DOT_THREE 0x00000400
1da177e4
LT
294#define CREATE_RANDOM_ACCESS 0x00000800
295#define CREATE_DELETE_ON_CLOSE 0x00001000
eda3c029 296#define CREATE_OPEN_BY_ID 0x00002000
1da177e4 297#define OPEN_REPARSE_POINT 0x00200000
eda3c029
SF
298#define CREATE_OPTIONS_MASK 0x007FFFFF
299#define CREATE_OPTION_SPECIAL 0x20000000 /* system. NB not sent over wire */
1da177e4
LT
300
301/* ImpersonationLevel flags */
302#define SECURITY_ANONYMOUS 0
303#define SECURITY_IDENTIFICATION 1
304#define SECURITY_IMPERSONATION 2
305#define SECURITY_DELEGATION 3
306
307/* SecurityFlags */
308#define SECURITY_CONTEXT_TRACKING 0x01
309#define SECURITY_EFFECTIVE_ONLY 0x02
310
311/*
312 * Default PID value, used in all SMBs where the PID is not important
313 */
314#define CIFS_DFT_PID 0x1234
315
316/*
317 * We use the same routine for Copy and Move SMBs. This flag is used to
318 * distinguish
319 */
320#define CIFS_COPY_OP 1
321#define CIFS_RENAME_OP 2
322
323#define GETU16(var) (*((__u16 *)var)) /* BB check for endian issues */
324#define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */
325
1da177e4 326struct smb_hdr {
0753ca7b
SF
327 __u32 smb_buf_length; /* big endian on wire *//* BB length is only two
328 or three bytes - with one or two byte type preceding it that are
329 zero - we could mask the type byte off just in case BB */
1da177e4
LT
330 __u8 Protocol[4];
331 __u8 Command;
332 union {
333 struct {
334 __u8 ErrorClass;
335 __u8 Reserved;
336 __le16 Error;
0753ca7b 337 } __attribute__((packed)) DosError;
1da177e4 338 __le32 CifsError;
0753ca7b 339 } __attribute__((packed)) Status;
1da177e4
LT
340 __u8 Flags;
341 __le16 Flags2; /* note: le */
342 __le16 PidHigh;
343 union {
344 struct {
345 __le32 SequenceNumber; /* le */
346 __u32 Reserved; /* zero */
0753ca7b 347 } __attribute__((packed)) Sequence;
1da177e4 348 __u8 SecuritySignature[8]; /* le */
0753ca7b 349 } __attribute__((packed)) Signature;
1da177e4
LT
350 __u8 pad[2];
351 __u16 Tid;
352 __le16 Pid;
353 __u16 Uid;
354 __u16 Mid;
355 __u8 WordCount;
0753ca7b 356} __attribute__((packed));
1da177e4
LT
357/* given a pointer to an smb_hdr retrieve the value of byte count */
358#define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) ) )
e4eb295d 359#define BCC_LE(smb_var) ( *(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) ) )
1da177e4
LT
360/* given a pointer to an smb_hdr retrieve the pointer to the byte area */
361#define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) + 2 )
362
363/*
364 * Computer Name Length
365 */
366#define CNLEN 15
367
368/*
369 * Share Name Length @S8A
370 * Note: This length is limited by the SMB used to get @S8A
371 * the Share info. NetShareEnum only returns 13 @S8A
372 * chars, including the null termination. @S8A
373 */
374#define SNLEN 12 /*@S8A */
375
376/*
377 * Comment Length
378 */
379#define MAXCOMMENTLEN 40
380
381/*
382 * The OS/2 maximum path name
383 */
384#define MAX_PATHCONF 256
385
386/*
387 * SMB frame definitions (following must be packed structs)
388 * See the SNIA CIFS Specification for details.
389 *
390 * The Naming convention is the lower case version of the
391 * smb command code name for the struct and this is typedef to the
392 * uppercase version of the same name with the prefix SMB_ removed
393 * for brevity. Although typedefs are not commonly used for
394 * structure definitions in the Linux kernel, their use in the
395 * CIFS standards document, which this code is based on, may
396 * make this one of the cases where typedefs for structures make
397 * sense to improve readability for readers of the standards doc.
398 * Typedefs can always be removed later if they are too distracting
399 * and they are only used for the CIFSs PDUs themselves, not
400 * internal cifs vfs structures
401 *
402 */
403
404typedef struct negotiate_req {
405 struct smb_hdr hdr; /* wct = 0 */
406 __le16 ByteCount;
407 unsigned char DialectsArray[1];
0753ca7b 408} __attribute__((packed)) NEGOTIATE_REQ;
1da177e4 409
3979877e
SF
410/* Dialect index is 13 for LANMAN */
411
b815f1e5
SF
412#define MIN_TZ_ADJ (15 * 60) /* minimum grid for timezones in seconds */
413
3979877e
SF
414typedef struct lanman_neg_rsp {
415 struct smb_hdr hdr; /* wct = 13 */
416 __le16 DialectIndex;
417 __le16 SecurityMode;
418 __le16 MaxBufSize;
419 __le16 MaxMpxCount;
420 __le16 MaxNumberVcs;
421 __le16 RawMode;
422 __le32 SessionKey;
175ec9e1
SF
423 struct {
424 __le16 Time;
425 __le16 Date;
426 } __attribute__((packed)) SrvTime;
3979877e
SF
427 __le16 ServerTimeZone;
428 __le16 EncryptionKeyLength;
429 __le16 Reserved;
430 __u16 ByteCount;
431 unsigned char EncryptionKey[1];
432} __attribute__((packed)) LANMAN_NEG_RSP;
433
254e55ed
SF
434#define READ_RAW_ENABLE 1
435#define WRITE_RAW_ENABLE 2
436#define RAW_ENABLE (READ_RAW_ENABLE | WRITE_RAW_ENABLE)
437
1da177e4
LT
438typedef struct negotiate_rsp {
439 struct smb_hdr hdr; /* wct = 17 */
440 __le16 DialectIndex;
441 __u8 SecurityMode;
442 __le16 MaxMpxCount;
443 __le16 MaxNumberVcs;
444 __le32 MaxBufferSize;
445 __le32 MaxRawSize;
446 __le32 SessionKey;
447 __le32 Capabilities; /* see below */
448 __le32 SystemTimeLow;
449 __le32 SystemTimeHigh;
450 __le16 ServerTimeZone;
451 __u8 EncryptionKeyLength;
452 __u16 ByteCount;
453 union {
0753ca7b 454 unsigned char EncryptionKey[1]; /* cap extended security off */
1da177e4
LT
455 /* followed by Domain name - if extended security is off */
456 /* followed by 16 bytes of server GUID */
0753ca7b 457 /* then security blob if cap_extended_security negotiated */
1da177e4
LT
458 struct {
459 unsigned char GUID[16];
460 unsigned char SecurityBlob[1];
0753ca7b
SF
461 } __attribute__((packed)) extended_response;
462 } __attribute__((packed)) u;
463} __attribute__((packed)) NEGOTIATE_RSP;
1da177e4
LT
464
465/* SecurityMode bits */
466#define SECMODE_USER 0x01 /* off indicates share level security */
467#define SECMODE_PW_ENCRYPT 0x02
468#define SECMODE_SIGN_ENABLED 0x04 /* SMB security signatures enabled */
469#define SECMODE_SIGN_REQUIRED 0x08 /* SMB security signatures required */
470
471/* Negotiate response Capabilities */
472#define CAP_RAW_MODE 0x00000001
473#define CAP_MPX_MODE 0x00000002
474#define CAP_UNICODE 0x00000004
475#define CAP_LARGE_FILES 0x00000008
476#define CAP_NT_SMBS 0x00000010 /* implies CAP_NT_FIND */
477#define CAP_RPC_REMOTE_APIS 0x00000020
478#define CAP_STATUS32 0x00000040
479#define CAP_LEVEL_II_OPLOCKS 0x00000080
480#define CAP_LOCK_AND_READ 0x00000100
481#define CAP_NT_FIND 0x00000200
482#define CAP_DFS 0x00001000
483#define CAP_INFOLEVEL_PASSTHRU 0x00002000
484#define CAP_LARGE_READ_X 0x00004000
485#define CAP_LARGE_WRITE_X 0x00008000
486#define CAP_UNIX 0x00800000
487#define CAP_RESERVED 0x02000000
488#define CAP_BULK_TRANSFER 0x20000000
489#define CAP_COMPRESSED_DATA 0x40000000
490#define CAP_EXTENDED_SECURITY 0x80000000
491
492typedef union smb_com_session_setup_andx {
493 struct { /* request format */
494 struct smb_hdr hdr; /* wct = 12 */
495 __u8 AndXCommand;
496 __u8 AndXReserved;
497 __le16 AndXOffset;
498 __le16 MaxBufferSize;
499 __le16 MaxMpxCount;
500 __le16 VcNumber;
501 __u32 SessionKey;
502 __le16 SecurityBlobLength;
503 __u32 Reserved;
504 __le32 Capabilities; /* see below */
505 __le16 ByteCount;
506 unsigned char SecurityBlob[1]; /* followed by */
507 /* STRING NativeOS */
508 /* STRING NativeLanMan */
0753ca7b
SF
509 } __attribute__((packed)) req; /* NTLM request format (with
510 extended security */
1da177e4
LT
511
512 struct { /* request format */
513 struct smb_hdr hdr; /* wct = 13 */
514 __u8 AndXCommand;
515 __u8 AndXReserved;
516 __le16 AndXOffset;
517 __le16 MaxBufferSize;
518 __le16 MaxMpxCount;
519 __le16 VcNumber;
520 __u32 SessionKey;
0753ca7b
SF
521 __le16 CaseInsensitivePasswordLength; /* ASCII password len */
522 __le16 CaseSensitivePasswordLength; /* Unicode password length*/
1da177e4
LT
523 __u32 Reserved; /* see below */
524 __le32 Capabilities;
525 __le16 ByteCount;
0753ca7b 526 unsigned char CaseInsensitivePassword[1]; /* followed by: */
1da177e4
LT
527 /* unsigned char * CaseSensitivePassword; */
528 /* STRING AccountName */
529 /* STRING PrimaryDomain */
530 /* STRING NativeOS */
531 /* STRING NativeLanMan */
0753ca7b
SF
532 } __attribute__((packed)) req_no_secext; /* NTLM request format (without
533 extended security */
1da177e4
LT
534
535 struct { /* default (NTLM) response format */
536 struct smb_hdr hdr; /* wct = 4 */
537 __u8 AndXCommand;
538 __u8 AndXReserved;
539 __le16 AndXOffset;
540 __le16 Action; /* see below */
541 __le16 SecurityBlobLength;
542 __u16 ByteCount;
543 unsigned char SecurityBlob[1]; /* followed by */
544/* unsigned char * NativeOS; */
545/* unsigned char * NativeLanMan; */
546/* unsigned char * PrimaryDomain; */
f64b23ae 547 } __attribute__((packed)) resp; /* NTLM response with or without extended sec*/
1da177e4
LT
548
549 struct { /* request format */
550 struct smb_hdr hdr; /* wct = 10 */
551 __u8 AndXCommand;
552 __u8 AndXReserved;
553 __le16 AndXOffset;
554 __le16 MaxBufferSize;
555 __le16 MaxMpxCount;
556 __le16 VcNumber;
557 __u32 SessionKey;
3979877e
SF
558 __le16 PasswordLength;
559 __u32 Reserved; /* encrypt key len and offset */
1da177e4
LT
560 __le16 ByteCount;
561 unsigned char AccountPassword[1]; /* followed by */
562 /* STRING AccountName */
563 /* STRING PrimaryDomain */
564 /* STRING NativeOS */
565 /* STRING NativeLanMan */
0a4b92c0 566 } __attribute__((packed)) old_req; /* pre-NTLM (LANMAN2.1) req format */
1da177e4
LT
567
568 struct { /* default (NTLM) response format */
569 struct smb_hdr hdr; /* wct = 3 */
570 __u8 AndXCommand;
571 __u8 AndXReserved;
572 __le16 AndXOffset;
573 __le16 Action; /* see below */
574 __u16 ByteCount;
575 unsigned char NativeOS[1]; /* followed by */
576/* unsigned char * NativeLanMan; */
577/* unsigned char * PrimaryDomain; */
0a4b92c0 578 } __attribute__((packed)) old_resp; /* pre-NTLM (LANMAN2.1) response */
0753ca7b 579} __attribute__((packed)) SESSION_SETUP_ANDX;
1da177e4 580
f64b23ae
SF
581/* format of NLTMv2 Response ie "case sensitive password" hash when NTLMv2 */
582
583struct ntlmssp2_name {
584 __le16 type;
585 __le16 length;
586/* char name[length]; */
587} __attribute__((packed));
588
589struct ntlmv2_resp {
590 char ntlmv2_hash[CIFS_ENCPWD_SIZE];
6d027cfd 591 __le32 blob_signature;
f64b23ae
SF
592 __u32 reserved;
593 __le64 time;
594 __u64 client_chal; /* random */
595 __u32 reserved2;
596 struct ntlmssp2_name names[1];
597 /* array of name entries could follow ending in minimum 4 byte struct */
598} __attribute__((packed));
599
600
1da177e4
LT
601#define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux"
602
603/* Capabilities bits (for NTLM SessSetup request) */
604#define CAP_UNICODE 0x00000004
605#define CAP_LARGE_FILES 0x00000008
606#define CAP_NT_SMBS 0x00000010
607#define CAP_STATUS32 0x00000040
608#define CAP_LEVEL_II_OPLOCKS 0x00000080
0753ca7b
SF
609#define CAP_NT_FIND 0x00000200 /* reserved should be zero
610 (because NT_SMBs implies the same thing?) */
1da177e4
LT
611#define CAP_BULK_TRANSFER 0x20000000
612#define CAP_EXTENDED_SECURITY 0x80000000
613
614/* Action bits */
615#define GUEST_LOGIN 1
616
617typedef struct smb_com_tconx_req {
618 struct smb_hdr hdr; /* wct = 4 */
619 __u8 AndXCommand;
620 __u8 AndXReserved;
621 __le16 AndXOffset;
622 __le16 Flags; /* see below */
623 __le16 PasswordLength;
624 __le16 ByteCount;
625 unsigned char Password[1]; /* followed by */
626/* STRING Path *//* \\server\share name */
627 /* STRING Service */
0753ca7b 628} __attribute__((packed)) TCONX_REQ;
1da177e4
LT
629
630typedef struct smb_com_tconx_rsp {
f64b23ae
SF
631 struct smb_hdr hdr; /* wct = 3 note that Win2000 has sent wct = 7
632 in some cases on responses. Four unspecified
633 words followed OptionalSupport */
1da177e4
LT
634 __u8 AndXCommand;
635 __u8 AndXReserved;
636 __le16 AndXOffset;
637 __le16 OptionalSupport; /* see below */
638 __u16 ByteCount;
639 unsigned char Service[1]; /* always ASCII, not Unicode */
640 /* STRING NativeFileSystem */
0753ca7b 641} __attribute__((packed)) TCONX_RSP;
1da177e4
LT
642
643/* tree connect Flags */
644#define DISCONNECT_TID 0x0001
645#define TCON_EXTENDED_SECINFO 0x0008
646/* OptionalSupport bits */
0753ca7b
SF
647#define SMB_SUPPORT_SEARCH_BITS 0x0001 /* "must have" directory search bits
648 (exclusive searches supported) */
1da177e4
LT
649#define SMB_SHARE_IS_IN_DFS 0x0002
650
651typedef struct smb_com_logoff_andx_req {
652 struct smb_hdr hdr; /* wct = 2 */
653 __u8 AndXCommand;
654 __u8 AndXReserved;
655 __u16 AndXOffset;
656 __u16 ByteCount;
0753ca7b 657} __attribute__((packed)) LOGOFF_ANDX_REQ;
1da177e4
LT
658
659typedef struct smb_com_logoff_andx_rsp {
660 struct smb_hdr hdr; /* wct = 2 */
661 __u8 AndXCommand;
662 __u8 AndXReserved;
663 __u16 AndXOffset;
664 __u16 ByteCount;
0753ca7b 665} __attribute__((packed)) LOGOFF_ANDX_RSP;
1da177e4 666
86c96b4b
SF
667typedef union smb_com_tree_disconnect { /* as an altetnative can use flag on
668 tree_connect PDU to effect disconnect */
669 /* tdis is probably simplest SMB PDU */
1da177e4
LT
670 struct {
671 struct smb_hdr hdr; /* wct = 0 */
672 __u16 ByteCount; /* bcc = 0 */
0753ca7b 673 } __attribute__((packed)) req;
1da177e4
LT
674 struct {
675 struct smb_hdr hdr; /* wct = 0 */
676 __u16 ByteCount; /* bcc = 0 */
0753ca7b
SF
677 } __attribute__((packed)) resp;
678} __attribute__((packed)) TREE_DISCONNECT;
1da177e4
LT
679
680typedef struct smb_com_close_req {
681 struct smb_hdr hdr; /* wct = 3 */
682 __u16 FileID;
b815f1e5 683 __u32 LastWriteTime; /* should be zero or -1 */
1da177e4 684 __u16 ByteCount; /* 0 */
0753ca7b 685} __attribute__((packed)) CLOSE_REQ;
1da177e4
LT
686
687typedef struct smb_com_close_rsp {
688 struct smb_hdr hdr; /* wct = 0 */
689 __u16 ByteCount; /* bct = 0 */
0753ca7b 690} __attribute__((packed)) CLOSE_RSP;
1da177e4
LT
691
692typedef struct smb_com_findclose_req {
693 struct smb_hdr hdr; /* wct = 1 */
694 __u16 FileID;
695 __u16 ByteCount; /* 0 */
0753ca7b 696} __attribute__((packed)) FINDCLOSE_REQ;
1da177e4
LT
697
698/* OpenFlags */
a9d02ad4 699#define REQ_MORE_INFO 0x00000001 /* legacy (OPEN_AND_X) only */
1da177e4
LT
700#define REQ_OPLOCK 0x00000002
701#define REQ_BATCHOPLOCK 0x00000004
702#define REQ_OPENDIRONLY 0x00000008
703
704typedef struct smb_com_open_req { /* also handles create */
705 struct smb_hdr hdr; /* wct = 24 */
706 __u8 AndXCommand;
707 __u8 AndXReserved;
708 __le16 AndXOffset;
709 __u8 Reserved; /* Must Be Zero */
710 __le16 NameLength;
711 __le32 OpenFlags;
712 __le32 RootDirectoryFid;
713 __le32 DesiredAccess;
714 __le64 AllocationSize;
715 __le32 FileAttributes;
716 __le32 ShareAccess;
717 __le32 CreateDisposition;
718 __le32 CreateOptions;
719 __le32 ImpersonationLevel;
720 __u8 SecurityFlags;
721 __le16 ByteCount;
722 char fileName[1];
0753ca7b 723} __attribute__((packed)) OPEN_REQ;
1da177e4
LT
724
725/* open response: oplock levels */
726#define OPLOCK_NONE 0
727#define OPLOCK_EXCLUSIVE 1
728#define OPLOCK_BATCH 2
729#define OPLOCK_READ 3 /* level 2 oplock */
730
731/* open response for CreateAction shifted left */
732#define CIFS_CREATE_ACTION 0x20000 /* file created */
733
734typedef struct smb_com_open_rsp {
735 struct smb_hdr hdr; /* wct = 34 BB */
736 __u8 AndXCommand;
737 __u8 AndXReserved;
738 __le16 AndXOffset;
739 __u8 OplockLevel;
740 __u16 Fid;
741 __le32 CreateAction;
742 __le64 CreationTime;
743 __le64 LastAccessTime;
744 __le64 LastWriteTime;
745 __le64 ChangeTime;
746 __le32 FileAttributes;
747 __le64 AllocationSize;
748 __le64 EndOfFile;
749 __le16 FileType;
750 __le16 DeviceState;
751 __u8 DirectoryFlag;
752 __u16 ByteCount; /* bct = 0 */
0753ca7b 753} __attribute__((packed)) OPEN_RSP;
1da177e4 754
a9d02ad4
SF
755/* format of legacy open request */
756typedef struct smb_com_openx_req {
757 struct smb_hdr hdr; /* wct = 15 */
758 __u8 AndXCommand;
759 __u8 AndXReserved;
760 __le16 AndXOffset;
761 __le16 OpenFlags;
762 __le16 Mode;
763 __le16 Sattr; /* search attributes */
764 __le16 FileAttributes; /* dos attrs */
765 __le32 CreateTime; /* os2 format */
766 __le16 OpenFunction;
767 __le32 EndOfFile;
768 __le32 Timeout;
769 __le32 Reserved;
70ca734a 770 __le16 ByteCount; /* file name follows */
a9d02ad4 771 char fileName[1];
0753ca7b 772} __attribute__((packed)) OPENX_REQ;
a9d02ad4
SF
773
774typedef struct smb_com_openx_rsp {
775 struct smb_hdr hdr; /* wct = 15 */
776 __u8 AndXCommand;
777 __u8 AndXReserved;
778 __le16 AndXOffset;
779 __u16 Fid;
780 __le16 FileAttributes;
781 __le32 LastWriteTime; /* os2 format */
782 __le32 EndOfFile;
783 __le16 Access;
784 __le16 FileType;
785 __le16 IPCState;
786 __le16 Action;
787 __u32 FileId;
788 __u16 Reserved;
789 __u16 ByteCount;
0753ca7b 790} __attribute__((packed)) OPENX_RSP;
a9d02ad4
SF
791
792/* Legacy write request for older servers */
793typedef struct smb_com_writex_req {
794 struct smb_hdr hdr; /* wct = 12 */
795 __u8 AndXCommand;
796 __u8 AndXReserved;
797 __le16 AndXOffset;
798 __u16 Fid;
799 __le32 OffsetLow;
800 __u32 Reserved; /* Timeout */
801 __le16 WriteMode; /* 1 = write through */
802 __le16 Remaining;
803 __le16 Reserved2;
804 __le16 DataLengthLow;
805 __le16 DataOffset;
806 __le16 ByteCount;
807 __u8 Pad; /* BB check for whether padded to DWORD boundary and optimum performance here */
808 char Data[0];
0753ca7b 809} __attribute__((packed)) WRITEX_REQ;
a9d02ad4 810
1da177e4
LT
811typedef struct smb_com_write_req {
812 struct smb_hdr hdr; /* wct = 14 */
813 __u8 AndXCommand;
814 __u8 AndXReserved;
815 __le16 AndXOffset;
816 __u16 Fid;
817 __le32 OffsetLow;
818 __u32 Reserved;
819 __le16 WriteMode;
820 __le16 Remaining;
821 __le16 DataLengthHigh;
822 __le16 DataLengthLow;
823 __le16 DataOffset;
824 __le32 OffsetHigh;
825 __le16 ByteCount;
826 __u8 Pad; /* BB check for whether padded to DWORD boundary and optimum performance here */
827 char Data[0];
0753ca7b 828} __attribute__((packed)) WRITE_REQ;
1da177e4
LT
829
830typedef struct smb_com_write_rsp {
831 struct smb_hdr hdr; /* wct = 6 */
832 __u8 AndXCommand;
833 __u8 AndXReserved;
834 __le16 AndXOffset;
835 __le16 Count;
836 __le16 Remaining;
837 __le16 CountHigh;
838 __u16 Reserved;
839 __u16 ByteCount;
0753ca7b 840} __attribute__((packed)) WRITE_RSP;
1da177e4 841
a9d02ad4
SF
842/* legacy read request for older servers */
843typedef struct smb_com_readx_req {
844 struct smb_hdr hdr; /* wct = 10 */
845 __u8 AndXCommand;
846 __u8 AndXReserved;
847 __le16 AndXOffset;
848 __u16 Fid;
849 __le32 OffsetLow;
850 __le16 MaxCount;
851 __le16 MinCount; /* obsolete */
852 __le32 Reserved;
853 __le16 Remaining;
854 __le16 ByteCount;
0753ca7b 855} __attribute__((packed)) READX_REQ;
a9d02ad4 856
1da177e4
LT
857typedef struct smb_com_read_req {
858 struct smb_hdr hdr; /* wct = 12 */
859 __u8 AndXCommand;
860 __u8 AndXReserved;
861 __le16 AndXOffset;
862 __u16 Fid;
863 __le32 OffsetLow;
864 __le16 MaxCount;
865 __le16 MinCount; /* obsolete */
866 __le32 MaxCountHigh;
867 __le16 Remaining;
868 __le32 OffsetHigh;
869 __le16 ByteCount;
0753ca7b 870} __attribute__((packed)) READ_REQ;
1da177e4
LT
871
872typedef struct smb_com_read_rsp {
873 struct smb_hdr hdr; /* wct = 12 */
874 __u8 AndXCommand;
875 __u8 AndXReserved;
876 __le16 AndXOffset;
877 __le16 Remaining;
878 __le16 DataCompactionMode;
879 __le16 Reserved;
880 __le16 DataLength;
881 __le16 DataOffset;
882 __le16 DataLengthHigh;
883 __u64 Reserved2;
884 __u16 ByteCount;
885 __u8 Pad; /* BB check for whether padded to DWORD boundary and optimum performance here */
886 char Data[1];
0753ca7b 887} __attribute__((packed)) READ_RSP;
1da177e4
LT
888
889typedef struct locking_andx_range {
890 __le16 Pid;
891 __le16 Pad;
892 __le32 OffsetHigh;
893 __le32 OffsetLow;
894 __le32 LengthHigh;
895 __le32 LengthLow;
0753ca7b 896} __attribute__((packed)) LOCKING_ANDX_RANGE;
1da177e4
LT
897
898#define LOCKING_ANDX_SHARED_LOCK 0x01
899#define LOCKING_ANDX_OPLOCK_RELEASE 0x02
900#define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
901#define LOCKING_ANDX_CANCEL_LOCK 0x08
902#define LOCKING_ANDX_LARGE_FILES 0x10 /* always on for us */
903
904typedef struct smb_com_lock_req {
905 struct smb_hdr hdr; /* wct = 8 */
906 __u8 AndXCommand;
907 __u8 AndXReserved;
908 __le16 AndXOffset;
909 __u16 Fid;
910 __u8 LockType;
911 __u8 OplockLevel;
912 __le32 Timeout;
913 __le16 NumberOfUnlocks;
914 __le16 NumberOfLocks;
915 __le16 ByteCount;
916 LOCKING_ANDX_RANGE Locks[1];
0753ca7b 917} __attribute__((packed)) LOCK_REQ;
1da177e4 918
08547b03
SF
919/* lock type */
920#define CIFS_RDLCK 0
921#define CIFS_WRLCK 1
922#define CIFS_UNLCK 2
f654bac2
SF
923typedef struct cifs_posix_lock {
924 __le16 lock_type; /* 0 = Read, 1 = Write, 2 = Unlock */
925 __le16 lock_flags; /* 1 = Wait (only valid for setlock) */
926 __le32 pid;
927 __le64 start;
928 __le64 length;
929 /* BB what about additional owner info to identify network client */
0753ca7b 930} __attribute__((packed)) CIFS_POSIX_LOCK;
f654bac2 931
1da177e4
LT
932typedef struct smb_com_lock_rsp {
933 struct smb_hdr hdr; /* wct = 2 */
934 __u8 AndXCommand;
935 __u8 AndXReserved;
936 __le16 AndXOffset;
937 __u16 ByteCount;
0753ca7b 938} __attribute__((packed)) LOCK_RSP;
1da177e4
LT
939
940typedef struct smb_com_rename_req {
941 struct smb_hdr hdr; /* wct = 1 */
942 __le16 SearchAttributes; /* target file attributes */
943 __le16 ByteCount;
944 __u8 BufferFormat; /* 4 = ASCII or Unicode */
945 unsigned char OldFileName[1];
946 /* followed by __u8 BufferFormat2 */
947 /* followed by NewFileName */
0753ca7b 948} __attribute__((packed)) RENAME_REQ;
1da177e4
LT
949
950 /* copy request flags */
951#define COPY_MUST_BE_FILE 0x0001
952#define COPY_MUST_BE_DIR 0x0002
953#define COPY_TARGET_MODE_ASCII 0x0004 /* if not set, binary */
954#define COPY_SOURCE_MODE_ASCII 0x0008 /* if not set, binary */
955#define COPY_VERIFY_WRITES 0x0010
956#define COPY_TREE 0x0020
957
958typedef struct smb_com_copy_req {
959 struct smb_hdr hdr; /* wct = 3 */
960 __u16 Tid2;
961 __le16 OpenFunction;
962 __le16 Flags;
963 __le16 ByteCount;
964 __u8 BufferFormat; /* 4 = ASCII or Unicode */
965 unsigned char OldFileName[1];
966 /* followed by __u8 BufferFormat2 */
967 /* followed by NewFileName string */
0753ca7b 968} __attribute__((packed)) COPY_REQ;
1da177e4
LT
969
970typedef struct smb_com_copy_rsp {
971 struct smb_hdr hdr; /* wct = 1 */
972 __le16 CopyCount; /* number of files copied */
973 __u16 ByteCount; /* may be zero */
974 __u8 BufferFormat; /* 0x04 - only present if errored file follows */
975 unsigned char ErrorFileName[1]; /* only present if error in copy */
0753ca7b 976} __attribute__((packed)) COPY_RSP;
1da177e4
LT
977
978#define CREATE_HARD_LINK 0x103
979#define MOVEFILE_COPY_ALLOWED 0x0002
980#define MOVEFILE_REPLACE_EXISTING 0x0001
981
982typedef struct smb_com_nt_rename_req { /* A5 - also used for create hardlink */
983 struct smb_hdr hdr; /* wct = 4 */
984 __le16 SearchAttributes; /* target file attributes */
985 __le16 Flags; /* spec says Information Level */
986 __le32 ClusterCount;
987 __le16 ByteCount;
988 __u8 BufferFormat; /* 4 = ASCII or Unicode */
989 unsigned char OldFileName[1];
990 /* followed by __u8 BufferFormat2 */
991 /* followed by NewFileName */
0753ca7b 992} __attribute__((packed)) NT_RENAME_REQ;
1da177e4
LT
993
994typedef struct smb_com_rename_rsp {
995 struct smb_hdr hdr; /* wct = 0 */
996 __u16 ByteCount; /* bct = 0 */
0753ca7b 997} __attribute__((packed)) RENAME_RSP;
1da177e4
LT
998
999typedef struct smb_com_delete_file_req {
1000 struct smb_hdr hdr; /* wct = 1 */
1001 __le16 SearchAttributes;
1002 __le16 ByteCount;
1003 __u8 BufferFormat; /* 4 = ASCII */
1004 unsigned char fileName[1];
0753ca7b 1005} __attribute__((packed)) DELETE_FILE_REQ;
1da177e4
LT
1006
1007typedef struct smb_com_delete_file_rsp {
1008 struct smb_hdr hdr; /* wct = 0 */
1009 __u16 ByteCount; /* bct = 0 */
0753ca7b 1010} __attribute__((packed)) DELETE_FILE_RSP;
1da177e4
LT
1011
1012typedef struct smb_com_delete_directory_req {
1013 struct smb_hdr hdr; /* wct = 0 */
1014 __le16 ByteCount;
1015 __u8 BufferFormat; /* 4 = ASCII */
1016 unsigned char DirName[1];
0753ca7b 1017} __attribute__((packed)) DELETE_DIRECTORY_REQ;
1da177e4
LT
1018
1019typedef struct smb_com_delete_directory_rsp {
1020 struct smb_hdr hdr; /* wct = 0 */
1021 __u16 ByteCount; /* bct = 0 */
0753ca7b 1022} __attribute__((packed)) DELETE_DIRECTORY_RSP;
1da177e4
LT
1023
1024typedef struct smb_com_create_directory_req {
1025 struct smb_hdr hdr; /* wct = 0 */
1026 __le16 ByteCount;
1027 __u8 BufferFormat; /* 4 = ASCII */
1028 unsigned char DirName[1];
0753ca7b 1029} __attribute__((packed)) CREATE_DIRECTORY_REQ;
1da177e4
LT
1030
1031typedef struct smb_com_create_directory_rsp {
1032 struct smb_hdr hdr; /* wct = 0 */
1033 __u16 ByteCount; /* bct = 0 */
0753ca7b 1034} __attribute__((packed)) CREATE_DIRECTORY_RSP;
1da177e4 1035
6b8edfe0
SF
1036typedef struct smb_com_query_information_req {
1037 struct smb_hdr hdr; /* wct = 0 */
1038 __le16 ByteCount; /* 1 + namelen + 1 */
1039 __u8 BufferFormat; /* 4 = ASCII */
1040 unsigned char FileName[1];
0753ca7b 1041} __attribute__((packed)) QUERY_INFORMATION_REQ;
6b8edfe0
SF
1042
1043typedef struct smb_com_query_information_rsp {
1044 struct smb_hdr hdr; /* wct = 10 */
1045 __le16 attr;
1046 __le32 last_write_time;
1047 __le32 size;
1048 __u16 reserved[5];
1049 __le16 ByteCount; /* bcc = 0 */
0753ca7b 1050} __attribute__((packed)) QUERY_INFORMATION_RSP;
6b8edfe0 1051
1da177e4
LT
1052typedef struct smb_com_setattr_req {
1053 struct smb_hdr hdr; /* wct = 8 */
1054 __le16 attr;
1055 __le16 time_low;
1056 __le16 time_high;
1057 __le16 reserved[5]; /* must be zero */
1058 __u16 ByteCount;
1059 __u8 BufferFormat; /* 4 = ASCII */
1060 unsigned char fileName[1];
0753ca7b 1061} __attribute__((packed)) SETATTR_REQ;
1da177e4
LT
1062
1063typedef struct smb_com_setattr_rsp {
1064 struct smb_hdr hdr; /* wct = 0 */
1065 __u16 ByteCount; /* bct = 0 */
0753ca7b 1066} __attribute__((packed)) SETATTR_RSP;
1da177e4
LT
1067
1068/* empty wct response to setattr */
1069
0a4b92c0
SF
1070/*******************************************************/
1071/* NT Transact structure defintions follow */
1072/* Currently only ioctl, acl (get security descriptor) */
1073/* and notify are implemented */
1074/*******************************************************/
1075typedef struct smb_com_ntransact_req {
1076 struct smb_hdr hdr; /* wct >= 19 */
1077 __u8 MaxSetupCount;
1078 __u16 Reserved;
1079 __le32 TotalParameterCount;
1080 __le32 TotalDataCount;
1081 __le32 MaxParameterCount;
1082 __le32 MaxDataCount;
1083 __le32 ParameterCount;
1084 __le32 ParameterOffset;
1085 __le32 DataCount;
1086 __le32 DataOffset;
1087 __u8 SetupCount; /* four setup words follow subcommand */
1088 /* SNIA spec incorrectly included spurious pad here */
1089 __le16 SubCommand; /* 2 = IOCTL/FSCTL */
1090 /* SetupCount words follow then */
1091 __le16 ByteCount;
1092 __u8 Pad[3];
1093 __u8 Parms[0];
1094} __attribute__((packed)) NTRANSACT_REQ;
1095
1096typedef struct smb_com_ntransact_rsp {
1097 struct smb_hdr hdr; /* wct = 18 */
1098 __u8 Reserved[3];
1099 __le32 TotalParameterCount;
1100 __le32 TotalDataCount;
1101 __le32 ParameterCount;
1102 __le32 ParameterOffset;
1103 __le32 ParameterDisplacement;
1104 __le32 DataCount;
1105 __le32 DataOffset;
1106 __le32 DataDisplacement;
1107 __u8 SetupCount; /* 0 */
1108 __u16 ByteCount;
1109 /* __u8 Pad[3]; */
1110 /* parms and data follow */
1111} __attribute__((packed)) NTRANSACT_RSP;
1112
1da177e4
LT
1113typedef struct smb_com_transaction_ioctl_req {
1114 struct smb_hdr hdr; /* wct = 23 */
1115 __u8 MaxSetupCount;
1116 __u16 Reserved;
1117 __le32 TotalParameterCount;
1118 __le32 TotalDataCount;
1119 __le32 MaxParameterCount;
1120 __le32 MaxDataCount;
1121 __le32 ParameterCount;
1122 __le32 ParameterOffset;
1123 __le32 DataCount;
1124 __le32 DataOffset;
1125 __u8 SetupCount; /* four setup words follow subcommand */
1126 /* SNIA spec incorrectly included spurious pad here */
0a4b92c0 1127 __le16 SubCommand; /* 2 = IOCTL/FSCTL */
1da177e4
LT
1128 __le32 FunctionCode;
1129 __u16 Fid;
0a4b92c0
SF
1130 __u8 IsFsctl; /* 1 = File System Control 0 = device control (IOCTL) */
1131 __u8 IsRootFlag; /* 1 = apply command to root of share (must be DFS) */
1da177e4
LT
1132 __le16 ByteCount;
1133 __u8 Pad[3];
1134 __u8 Data[1];
0753ca7b 1135} __attribute__((packed)) TRANSACT_IOCTL_REQ;
1da177e4
LT
1136
1137typedef struct smb_com_transaction_ioctl_rsp {
1138 struct smb_hdr hdr; /* wct = 19 */
1139 __u8 Reserved[3];
1140 __le32 TotalParameterCount;
1141 __le32 TotalDataCount;
1142 __le32 ParameterCount;
1143 __le32 ParameterOffset;
1144 __le32 ParameterDisplacement;
1145 __le32 DataCount;
1146 __le32 DataOffset;
1147 __le32 DataDisplacement;
1148 __u8 SetupCount; /* 1 */
1149 __le16 ReturnedDataLen;
1150 __u16 ByteCount;
0753ca7b 1151} __attribute__((packed)) TRANSACT_IOCTL_RSP;
1da177e4 1152
0a4b92c0
SF
1153#define CIFS_ACL_OWNER 1
1154#define CIFS_ACL_GROUP 2
1155#define CIFS_ACL_DACL 4
1156#define CIFS_ACL_SACL 8
1157
1158typedef struct smb_com_transaction_qsec_req {
1159 struct smb_hdr hdr; /* wct = 19 */
1160 __u8 MaxSetupCount;
1161 __u16 Reserved;
1162 __le32 TotalParameterCount;
1163 __le32 TotalDataCount;
1164 __le32 MaxParameterCount;
1165 __le32 MaxDataCount;
1166 __le32 ParameterCount;
1167 __le32 ParameterOffset;
1168 __le32 DataCount;
1169 __le32 DataOffset;
1170 __u8 SetupCount; /* no setup words follow subcommand */
1171 /* SNIA spec incorrectly included spurious pad here */
1172 __le16 SubCommand; /* 6 = QUERY_SECURITY_DESC */
1173 __le16 ByteCount; /* bcc = 3 + 8 */
1174 __u8 Pad[3];
1175 __u16 Fid;
1176 __u16 Reserved2;
1177 __le32 AclFlags;
1178} __attribute__((packed)) QUERY_SEC_DESC_REQ;
1179
1da177e4
LT
1180typedef struct smb_com_transaction_change_notify_req {
1181 struct smb_hdr hdr; /* wct = 23 */
1182 __u8 MaxSetupCount;
1183 __u16 Reserved;
1184 __le32 TotalParameterCount;
1185 __le32 TotalDataCount;
1186 __le32 MaxParameterCount;
1187 __le32 MaxDataCount;
1188 __le32 ParameterCount;
1189 __le32 ParameterOffset;
1190 __le32 DataCount;
1191 __le32 DataOffset;
1192 __u8 SetupCount; /* four setup words follow subcommand */
1193 /* SNIA spec incorrectly included spurious pad here */
1194 __le16 SubCommand;/* 4 = Change Notify */
1195 __le32 CompletionFilter; /* operation to monitor */
1196 __u16 Fid;
1197 __u8 WatchTree; /* 1 = Monitor subdirectories */
1198 __u8 Reserved2;
1199 __le16 ByteCount;
0a4b92c0 1200/* __u8 Pad[3];*/
1da177e4 1201/* __u8 Data[1];*/
0753ca7b 1202} __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_REQ;
1da177e4 1203
0a4b92c0
SF
1204/* BB eventually change to use generic ntransact rsp struct
1205 and validation routine */
1da177e4
LT
1206typedef struct smb_com_transaction_change_notify_rsp {
1207 struct smb_hdr hdr; /* wct = 18 */
1208 __u8 Reserved[3];
1209 __le32 TotalParameterCount;
1210 __le32 TotalDataCount;
1211 __le32 ParameterCount;
1212 __le32 ParameterOffset;
1213 __le32 ParameterDisplacement;
1214 __le32 DataCount;
1215 __le32 DataOffset;
1216 __le32 DataDisplacement;
1217 __u8 SetupCount; /* 0 */
1218 __u16 ByteCount;
1219 /* __u8 Pad[3]; */
0753ca7b 1220} __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_RSP;
1da177e4
LT
1221/* Completion Filter flags for Notify */
1222#define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
1223#define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
1224#define FILE_NOTIFY_CHANGE_NAME 0x00000003
1225#define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
1226#define FILE_NOTIFY_CHANGE_SIZE 0x00000008
1227#define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
1228#define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
1229#define FILE_NOTIFY_CHANGE_CREATION 0x00000040
1230#define FILE_NOTIFY_CHANGE_EA 0x00000080
1231#define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
1232#define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
1233#define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
1234#define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1235
1236#define FILE_ACTION_ADDED 0x00000001
1237#define FILE_ACTION_REMOVED 0x00000002
1238#define FILE_ACTION_MODIFIED 0x00000003
1239#define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
1240#define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
1241#define FILE_ACTION_ADDED_STREAM 0x00000006
1242#define FILE_ACTION_REMOVED_STREAM 0x00000007
1243#define FILE_ACTION_MODIFIED_STREAM 0x00000008
1244
1245/* response contains array of the following structures */
1246struct file_notify_information {
1247 __le32 NextEntryOffset;
1248 __le32 Action;
1249 __le32 FileNameLength;
1250 __u8 FileName[0];
0753ca7b 1251} __attribute__((packed));
1da177e4
LT
1252
1253struct reparse_data {
1254 __u32 ReparseTag;
1255 __u16 ReparseDataLength;
1256 __u16 Reserved;
1257 __u16 AltNameOffset;
1258 __u16 AltNameLen;
1259 __u16 TargetNameOffset;
1260 __u16 TargetNameLen;
1261 char LinkNamesBuf[1];
0753ca7b 1262} __attribute__((packed));
1da177e4
LT
1263
1264struct cifs_quota_data {
1265 __u32 rsrvd1; /* 0 */
1266 __u32 sid_size;
1267 __u64 rsrvd2; /* 0 */
1268 __u64 space_used;
1269 __u64 soft_limit;
1270 __u64 hard_limit;
1271 char sid[1]; /* variable size? */
0753ca7b 1272} __attribute__((packed));
1da177e4
LT
1273
1274/* quota sub commands */
1275#define QUOTA_LIST_CONTINUE 0
1276#define QUOTA_LIST_START 0x100
1277#define QUOTA_FOR_SID 0x101
1278
1279struct trans2_req {
1280 /* struct smb_hdr hdr precedes. Set wct = 14+ */
1281 __le16 TotalParameterCount;
1282 __le16 TotalDataCount;
1283 __le16 MaxParameterCount;
1284 __le16 MaxDataCount;
1285 __u8 MaxSetupCount;
1286 __u8 Reserved;
1287 __le16 Flags;
1288 __le32 Timeout;
1289 __u16 Reserved2;
1290 __le16 ParameterCount;
1291 __le16 ParameterOffset;
1292 __le16 DataCount;
1293 __le16 DataOffset;
1294 __u8 SetupCount;
1295 __u8 Reserved3;
1296 __le16 SubCommand; /* 1st setup word - SetupCount words follow */
1297 __le16 ByteCount;
0753ca7b 1298} __attribute__((packed));
1da177e4
LT
1299
1300struct smb_t2_req {
1301 struct smb_hdr hdr;
1302 struct trans2_req t2_req;
0753ca7b 1303} __attribute__((packed));
1da177e4
LT
1304
1305struct trans2_resp {
1306 /* struct smb_hdr hdr precedes. Note wct = 10 + setup count */
1307 __le16 TotalParameterCount;
1308 __le16 TotalDataCount;
1309 __u16 Reserved;
1310 __le16 ParameterCount;
1311 __le16 ParameterOffset;
1312 __le16 ParameterDisplacement;
1313 __le16 DataCount;
1314 __le16 DataOffset;
1315 __le16 DataDisplacement;
1316 __u8 SetupCount;
1317 __u8 Reserved1;
1318 /* SetupWords[SetupCount];
1319 __u16 ByteCount;
1320 __u16 Reserved2;*/
1321 /* data area follows */
0753ca7b 1322} __attribute__((packed));
1da177e4
LT
1323
1324struct smb_t2_rsp {
1325 struct smb_hdr hdr;
1326 struct trans2_resp t2_rsp;
0753ca7b 1327} __attribute__((packed));
1da177e4
LT
1328
1329/* PathInfo/FileInfo infolevels */
1330#define SMB_INFO_STANDARD 1
1331#define SMB_SET_FILE_EA 2
1332#define SMB_QUERY_FILE_EA_SIZE 2
1333#define SMB_INFO_QUERY_EAS_FROM_LIST 3
1334#define SMB_INFO_QUERY_ALL_EAS 4
1335#define SMB_INFO_IS_NAME_VALID 6
1336#define SMB_QUERY_FILE_BASIC_INFO 0x101
1337#define SMB_QUERY_FILE_STANDARD_INFO 0x102
1338#define SMB_QUERY_FILE_EA_INFO 0x103
1339#define SMB_QUERY_FILE_NAME_INFO 0x104
1340#define SMB_QUERY_FILE_ALLOCATION_INFO 0x105
1341#define SMB_QUERY_FILE_END_OF_FILEINFO 0x106
1342#define SMB_QUERY_FILE_ALL_INFO 0x107
1343#define SMB_QUERY_ALT_NAME_INFO 0x108
1344#define SMB_QUERY_FILE_STREAM_INFO 0x109
1345#define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
1346#define SMB_QUERY_FILE_UNIX_BASIC 0x200
1347#define SMB_QUERY_FILE_UNIX_LINK 0x201
1348#define SMB_QUERY_POSIX_ACL 0x204
1349#define SMB_QUERY_XATTR 0x205
1350#define SMB_QUERY_ATTR_FLAGS 0x206 /* append,immutable etc. */
f654bac2
SF
1351#define SMB_QUERY_POSIX_PERMISSION 0x207
1352#define SMB_QUERY_POSIX_LOCK 0x208
2fe87f02 1353/* #define SMB_POSIX_OPEN 0x209 */
1da177e4
LT
1354#define SMB_QUERY_FILE_INTERNAL_INFO 0x3ee
1355#define SMB_QUERY_FILE_ACCESS_INFO 0x3f0
1356#define SMB_QUERY_FILE_NAME_INFO2 0x3f1 /* 0x30 bytes */
1357#define SMB_QUERY_FILE_POSITION_INFO 0x3f6
1358#define SMB_QUERY_FILE_MODE_INFO 0x3f8
1359#define SMB_QUERY_FILE_ALGN_INFO 0x3f9
1360
1361
1362#define SMB_SET_FILE_BASIC_INFO 0x101
1363#define SMB_SET_FILE_DISPOSITION_INFO 0x102
1364#define SMB_SET_FILE_ALLOCATION_INFO 0x103
1365#define SMB_SET_FILE_END_OF_FILE_INFO 0x104
1366#define SMB_SET_FILE_UNIX_BASIC 0x200
1367#define SMB_SET_FILE_UNIX_LINK 0x201
1368#define SMB_SET_FILE_UNIX_HLINK 0x203
1369#define SMB_SET_POSIX_ACL 0x204
1370#define SMB_SET_XATTR 0x205
1371#define SMB_SET_ATTR_FLAGS 0x206 /* append, immutable etc. */
f654bac2 1372#define SMB_SET_POSIX_LOCK 0x208
2fe87f02 1373#define SMB_POSIX_OPEN 0x209
1da177e4
LT
1374#define SMB_SET_FILE_BASIC_INFO2 0x3ec
1375#define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo level too */
1376#define SMB_FILE_ALL_INFO2 0x3fa
1377#define SMB_SET_FILE_ALLOCATION_INFO2 0x3fb
1378#define SMB_SET_FILE_END_OF_FILE_INFO2 0x3fc
1379#define SMB_FILE_MOVE_CLUSTER_INFO 0x407
1380#define SMB_FILE_QUOTA_INFO 0x408
1381#define SMB_FILE_REPARSEPOINT_INFO 0x409
1382#define SMB_FILE_MAXIMUM_INFO 0x40d
1383
1384/* Find File infolevels */
5bafd765
SF
1385#define SMB_FIND_FILE_INFO_STANDARD 0x001
1386#define SMB_FIND_FILE_QUERY_EA_SIZE 0x002
1387#define SMB_FIND_FILE_QUERY_EAS_FROM_LIST 0x003
1da177e4
LT
1388#define SMB_FIND_FILE_DIRECTORY_INFO 0x101
1389#define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
1390#define SMB_FIND_FILE_NAMES_INFO 0x103
1391#define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
1392#define SMB_FIND_FILE_ID_FULL_DIR_INFO 0x105
1393#define SMB_FIND_FILE_ID_BOTH_DIR_INFO 0x106
1394#define SMB_FIND_FILE_UNIX 0x202
1395
1396typedef struct smb_com_transaction2_qpi_req {
1397 struct smb_hdr hdr; /* wct = 14+ */
1398 __le16 TotalParameterCount;
1399 __le16 TotalDataCount;
1400 __le16 MaxParameterCount;
1401 __le16 MaxDataCount;
1402 __u8 MaxSetupCount;
1403 __u8 Reserved;
1404 __le16 Flags;
1405 __le32 Timeout;
1406 __u16 Reserved2;
1407 __le16 ParameterCount;
1408 __le16 ParameterOffset;
1409 __le16 DataCount;
1410 __le16 DataOffset;
1411 __u8 SetupCount;
1412 __u8 Reserved3;
1413 __le16 SubCommand; /* one setup word */
1414 __le16 ByteCount;
1415 __u8 Pad;
1416 __le16 InformationLevel;
1417 __u32 Reserved4;
1418 char FileName[1];
0753ca7b 1419} __attribute__((packed)) TRANSACTION2_QPI_REQ;
1da177e4
LT
1420
1421typedef struct smb_com_transaction2_qpi_rsp {
1422 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1423 struct trans2_resp t2;
1424 __u16 ByteCount;
1425 __u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */
0753ca7b 1426} __attribute__((packed)) TRANSACTION2_QPI_RSP;
1da177e4
LT
1427
1428typedef struct smb_com_transaction2_spi_req {
1429 struct smb_hdr hdr; /* wct = 15 */
1430 __le16 TotalParameterCount;
1431 __le16 TotalDataCount;
1432 __le16 MaxParameterCount;
1433 __le16 MaxDataCount;
1434 __u8 MaxSetupCount;
1435 __u8 Reserved;
1436 __le16 Flags;
1437 __le32 Timeout;
1438 __u16 Reserved2;
1439 __le16 ParameterCount;
1440 __le16 ParameterOffset;
1441 __le16 DataCount;
1442 __le16 DataOffset;
1443 __u8 SetupCount;
1444 __u8 Reserved3;
1445 __le16 SubCommand; /* one setup word */
1446 __le16 ByteCount;
1447 __u8 Pad;
1448 __u16 Pad1;
1449 __le16 InformationLevel;
1450 __u32 Reserved4;
1451 char FileName[1];
0753ca7b 1452} __attribute__((packed)) TRANSACTION2_SPI_REQ;
1da177e4
LT
1453
1454typedef struct smb_com_transaction2_spi_rsp {
1455 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1456 struct trans2_resp t2;
1457 __u16 ByteCount;
1458 __u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */
0753ca7b 1459} __attribute__((packed)) TRANSACTION2_SPI_RSP;
1da177e4
LT
1460
1461struct set_file_rename {
1462 __le32 overwrite; /* 1 = overwrite dest */
1463 __u32 root_fid; /* zero */
1464 __le32 target_name_len;
1465 char target_name[0]; /* Must be unicode */
0753ca7b 1466} __attribute__((packed));
1da177e4
LT
1467
1468struct smb_com_transaction2_sfi_req {
1469 struct smb_hdr hdr; /* wct = 15 */
1470 __le16 TotalParameterCount;
1471 __le16 TotalDataCount;
1472 __le16 MaxParameterCount;
1473 __le16 MaxDataCount;
1474 __u8 MaxSetupCount;
1475 __u8 Reserved;
1476 __le16 Flags;
1477 __le32 Timeout;
1478 __u16 Reserved2;
1479 __le16 ParameterCount;
1480 __le16 ParameterOffset;
1481 __le16 DataCount;
1482 __le16 DataOffset;
1483 __u8 SetupCount;
1484 __u8 Reserved3;
1485 __le16 SubCommand; /* one setup word */
1486 __le16 ByteCount;
1487 __u8 Pad;
1488 __u16 Pad1;
1489 __u16 Fid;
1490 __le16 InformationLevel;
1491 __u16 Reserved4;
0753ca7b 1492} __attribute__((packed));
1da177e4
LT
1493
1494struct smb_com_transaction2_sfi_rsp {
1495 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1496 struct trans2_resp t2;
1497 __u16 ByteCount;
f654bac2
SF
1498 __u16 Reserved2; /* parameter word reserved -
1499 present for infolevels > 100 */
0753ca7b 1500} __attribute__((packed));
f654bac2
SF
1501
1502struct smb_t2_qfi_req {
1503 struct smb_hdr hdr;
1504 struct trans2_req t2;
1505 __u8 Pad;
f654bac2
SF
1506 __u16 Fid;
1507 __le16 InformationLevel;
0753ca7b 1508} __attribute__((packed));
1da177e4 1509
f654bac2
SF
1510struct smb_t2_qfi_rsp {
1511 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1512 struct trans2_resp t2;
1513 __u16 ByteCount;
1514 __u16 Reserved2; /* parameter word reserved -
1515 present for infolevels > 100 */
0753ca7b 1516} __attribute__((packed));
1da177e4
LT
1517
1518/*
1519 * Flags on T2 FINDFIRST and FINDNEXT
1520 */
1521#define CIFS_SEARCH_CLOSE_ALWAYS 0x0001
1522#define CIFS_SEARCH_CLOSE_AT_END 0x0002
1523#define CIFS_SEARCH_RETURN_RESUME 0x0004
1524#define CIFS_SEARCH_CONTINUE_FROM_LAST 0x0008
1525#define CIFS_SEARCH_BACKUP_SEARCH 0x0010
1526
1527/*
1528 * Size of the resume key on FINDFIRST and FINDNEXT calls
1529 */
1530#define CIFS_SMB_RESUME_KEY_SIZE 4
1531
1532typedef struct smb_com_transaction2_ffirst_req {
1533 struct smb_hdr hdr; /* wct = 15 */
1534 __le16 TotalParameterCount;
1535 __le16 TotalDataCount;
1536 __le16 MaxParameterCount;
1537 __le16 MaxDataCount;
1538 __u8 MaxSetupCount;
1539 __u8 Reserved;
1540 __le16 Flags;
1541 __le32 Timeout;
1542 __u16 Reserved2;
1543 __le16 ParameterCount;
1544 __le16 ParameterOffset;
1545 __le16 DataCount;
1546 __le16 DataOffset;
1547 __u8 SetupCount; /* one */
1548 __u8 Reserved3;
1549 __le16 SubCommand; /* TRANS2_FIND_FIRST */
1550 __le16 ByteCount;
1551 __u8 Pad;
1552 __le16 SearchAttributes;
1553 __le16 SearchCount;
1554 __le16 SearchFlags;
1555 __le16 InformationLevel;
1556 __le32 SearchStorageType;
1557 char FileName[1];
0753ca7b 1558} __attribute__((packed)) TRANSACTION2_FFIRST_REQ;
1da177e4
LT
1559
1560typedef struct smb_com_transaction2_ffirst_rsp {
1561 struct smb_hdr hdr; /* wct = 10 */
1562 struct trans2_resp t2;
1563 __u16 ByteCount;
0753ca7b 1564} __attribute__((packed)) TRANSACTION2_FFIRST_RSP;
1da177e4
LT
1565
1566typedef struct smb_com_transaction2_ffirst_rsp_parms {
1567 __u16 SearchHandle;
1568 __le16 SearchCount;
1569 __le16 EndofSearch;
1570 __le16 EAErrorOffset;
1571 __le16 LastNameOffset;
0753ca7b 1572} __attribute__((packed)) T2_FFIRST_RSP_PARMS;
1da177e4
LT
1573
1574typedef struct smb_com_transaction2_fnext_req {
1575 struct smb_hdr hdr; /* wct = 15 */
1576 __le16 TotalParameterCount;
1577 __le16 TotalDataCount;
1578 __le16 MaxParameterCount;
1579 __le16 MaxDataCount;
1580 __u8 MaxSetupCount;
1581 __u8 Reserved;
1582 __le16 Flags;
1583 __le32 Timeout;
1584 __u16 Reserved2;
1585 __le16 ParameterCount;
1586 __le16 ParameterOffset;
1587 __le16 DataCount;
1588 __le16 DataOffset;
1589 __u8 SetupCount; /* one */
1590 __u8 Reserved3;
1591 __le16 SubCommand; /* TRANS2_FIND_NEXT */
1592 __le16 ByteCount;
1593 __u8 Pad;
1594 __u16 SearchHandle;
1595 __le16 SearchCount;
1596 __le16 InformationLevel;
1597 __u32 ResumeKey;
1598 __le16 SearchFlags;
1599 char ResumeFileName[1];
0753ca7b 1600} __attribute__((packed)) TRANSACTION2_FNEXT_REQ;
1da177e4
LT
1601
1602typedef struct smb_com_transaction2_fnext_rsp {
1603 struct smb_hdr hdr; /* wct = 10 */
1604 struct trans2_resp t2;
1605 __u16 ByteCount;
0753ca7b 1606} __attribute__((packed)) TRANSACTION2_FNEXT_RSP;
1da177e4
LT
1607
1608typedef struct smb_com_transaction2_fnext_rsp_parms {
1609 __le16 SearchCount;
1610 __le16 EndofSearch;
1611 __le16 EAErrorOffset;
1612 __le16 LastNameOffset;
0753ca7b 1613} __attribute__((packed)) T2_FNEXT_RSP_PARMS;
1da177e4
LT
1614
1615/* QFSInfo Levels */
1616#define SMB_INFO_ALLOCATION 1
1617#define SMB_INFO_VOLUME 2
1618#define SMB_QUERY_FS_VOLUME_INFO 0x102
1619#define SMB_QUERY_FS_SIZE_INFO 0x103
1620#define SMB_QUERY_FS_DEVICE_INFO 0x104
1621#define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
1622#define SMB_QUERY_CIFS_UNIX_INFO 0x200
1623#define SMB_QUERY_POSIX_FS_INFO 0x201
1624#define SMB_QUERY_LABEL_INFO 0x3ea
1625#define SMB_QUERY_FS_QUOTA_INFO 0x3ee
1626#define SMB_QUERY_FS_FULL_SIZE_INFO 0x3ef
1627#define SMB_QUERY_OBJECTID_INFO 0x3f0
1628
1629typedef struct smb_com_transaction2_qfsi_req {
1630 struct smb_hdr hdr; /* wct = 14+ */
1631 __le16 TotalParameterCount;
1632 __le16 TotalDataCount;
1633 __le16 MaxParameterCount;
1634 __le16 MaxDataCount;
1635 __u8 MaxSetupCount;
1636 __u8 Reserved;
1637 __le16 Flags;
1638 __le32 Timeout;
1639 __u16 Reserved2;
1640 __le16 ParameterCount;
1641 __le16 ParameterOffset;
1642 __le16 DataCount;
1643 __le16 DataOffset;
1644 __u8 SetupCount;
1645 __u8 Reserved3;
1646 __le16 SubCommand; /* one setup word */
1647 __le16 ByteCount;
1648 __u8 Pad;
1649 __le16 InformationLevel;
0753ca7b 1650} __attribute__((packed)) TRANSACTION2_QFSI_REQ;
1da177e4
LT
1651
1652typedef struct smb_com_transaction_qfsi_rsp {
1653 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1654 struct trans2_resp t2;
1655 __u16 ByteCount;
1656 __u8 Pad; /* may be three bytes *//* followed by data area */
0753ca7b 1657} __attribute__((packed)) TRANSACTION2_QFSI_RSP;
1da177e4 1658
ac67055e
JA
1659
1660/* SETFSInfo Levels */
1661#define SMB_SET_CIFS_UNIX_INFO 0x200
1662typedef struct smb_com_transaction2_setfsi_req {
1663 struct smb_hdr hdr; /* wct = 15 */
1664 __le16 TotalParameterCount;
1665 __le16 TotalDataCount;
1666 __le16 MaxParameterCount;
1667 __le16 MaxDataCount;
1668 __u8 MaxSetupCount;
1669 __u8 Reserved;
1670 __le16 Flags;
1671 __le32 Timeout;
1672 __u16 Reserved2;
1673 __le16 ParameterCount; /* 4 */
1674 __le16 ParameterOffset;
1675 __le16 DataCount; /* 12 */
1676 __le16 DataOffset;
1677 __u8 SetupCount; /* one */
1678 __u8 Reserved3;
1679 __le16 SubCommand; /* TRANS2_SET_FS_INFORMATION */
1680 __le16 ByteCount;
1681 __u8 Pad;
1682 __u16 FileNum; /* Parameters start. */
1683 __le16 InformationLevel;/* Parameters end. */
1684 __le16 ClientUnixMajor; /* Data start. */
1685 __le16 ClientUnixMinor;
1686 __le64 ClientUnixCap; /* Data end */
0753ca7b 1687} __attribute__((packed)) TRANSACTION2_SETFSI_REQ;
ac67055e
JA
1688
1689typedef struct smb_com_transaction2_setfsi_rsp {
1690 struct smb_hdr hdr; /* wct = 10 */
1691 struct trans2_resp t2;
1692 __u16 ByteCount;
0753ca7b 1693} __attribute__((packed)) TRANSACTION2_SETFSI_RSP;
ac67055e
JA
1694
1695
1da177e4
LT
1696typedef struct smb_com_transaction2_get_dfs_refer_req {
1697 struct smb_hdr hdr; /* wct = 15 */
1698 __le16 TotalParameterCount;
1699 __le16 TotalDataCount;
1700 __le16 MaxParameterCount;
1701 __le16 MaxDataCount;
1702 __u8 MaxSetupCount;
1703 __u8 Reserved;
1704 __le16 Flags;
1705 __le32 Timeout;
1706 __u16 Reserved2;
1707 __le16 ParameterCount;
1708 __le16 ParameterOffset;
1709 __le16 DataCount;
1710 __le16 DataOffset;
1711 __u8 SetupCount;
1712 __u8 Reserved3;
1713 __le16 SubCommand; /* one setup word */
1714 __le16 ByteCount;
1715 __u8 Pad[3]; /* Win2K has sent 0x0F01 (max resp length perhaps?) followed by one byte pad - doesn't seem to matter though */
1716 __le16 MaxReferralLevel;
1717 char RequestFileName[1];
0753ca7b 1718} __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_REQ;
1da177e4
LT
1719
1720typedef struct dfs_referral_level_3 {
1721 __le16 VersionNumber;
1722 __le16 ReferralSize;
1723 __le16 ServerType; /* 0x0001 = CIFS server */
1724 __le16 ReferralFlags; /* or proximity - not clear which since always set to zero - SNIA spec says 0x01 means strip off PathConsumed chars before submitting RequestFileName to remote node */
1725 __le16 TimeToLive;
1726 __le16 Proximity;
1727 __le16 DfsPathOffset;
1728 __le16 DfsAlternatePathOffset;
1729 __le16 NetworkAddressOffset;
0753ca7b 1730} __attribute__((packed)) REFERRAL3;
1da177e4
LT
1731
1732typedef struct smb_com_transaction_get_dfs_refer_rsp {
1733 struct smb_hdr hdr; /* wct = 10 */
1734 struct trans2_resp t2;
1735 __u16 ByteCount;
1736 __u8 Pad;
1737 __le16 PathConsumed;
1738 __le16 NumberOfReferrals;
1739 __le16 DFSFlags;
1740 __u16 Pad2;
1741 REFERRAL3 referrals[1]; /* array of level 3 dfs_referral structures */
1742 /* followed by the strings pointed to by the referral structures */
0753ca7b 1743} __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_RSP;
1da177e4
LT
1744
1745/* DFS Flags */
1746#define DFSREF_REFERRAL_SERVER 0x0001
1747#define DFSREF_STORAGE_SERVER 0x0002
1748
1749/* IOCTL information */
1750/* List of ioctl function codes that look to be of interest to remote clients like this. */
1751/* Need to do some experimentation to make sure they all work remotely. */
1752/* Some of the following such as the encryption/compression ones would be */
1753/* invoked from tools via a specialized hook into the VFS rather than via the */
1754/* standard vfs entry points */
1755#define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000
1756#define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004
1757#define FSCTL_REQUEST_BATCH_OPLOCK 0x00090008
1758#define FSCTL_LOCK_VOLUME 0x00090018
1759#define FSCTL_UNLOCK_VOLUME 0x0009001C
1760#define FSCTL_GET_COMPRESSION 0x0009003C
1761#define FSCTL_SET_COMPRESSION 0x0009C040
1762#define FSCTL_REQUEST_FILTER_OPLOCK 0x0009008C
1763#define FSCTL_FILESYS_GET_STATISTICS 0x00090090
1764#define FSCTL_SET_REPARSE_POINT 0x000900A4
1765#define FSCTL_GET_REPARSE_POINT 0x000900A8
1766#define FSCTL_DELETE_REPARSE_POINT 0x000900AC
1767#define FSCTL_SET_SPARSE 0x000900C4
1768#define FSCTL_SET_ZERO_DATA 0x000900C8
1769#define FSCTL_SET_ENCRYPTION 0x000900D7
1770#define FSCTL_ENCRYPTION_FSCTL_IO 0x000900DB
1771#define FSCTL_WRITE_RAW_ENCRYPTED 0x000900DF
1772#define FSCTL_READ_RAW_ENCRYPTED 0x000900E3
1773#define FSCTL_SIS_COPYFILE 0x00090100
1774#define FSCTL_SIS_LINK_FILES 0x0009C104
1775
1776#define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003
1777#define IO_REPARSE_TAG_HSM 0xC0000004
1778#define IO_REPARSE_TAG_SIS 0x80000007
1779
1780/*
1781 ************************************************************************
1782 * All structs for everything above the SMB PDUs themselves
1783 * (such as the T2 level specific data) go here
1784 ************************************************************************
1785 */
1786
1787/*
1788 * Information on a server
1789 */
1790
1791struct serverInfo {
1792 char name[16];
1793 unsigned char versionMajor;
1794 unsigned char versionMinor;
1795 unsigned long type;
1796 unsigned int commentOffset;
0753ca7b 1797} __attribute__((packed));
1da177e4
LT
1798
1799/*
1800 * The following structure is the format of the data returned on a NetShareEnum
1801 * with level "90" (x5A)
1802 */
1803
1804struct shareInfo {
1805 char shareName[13];
1806 char pad;
1807 unsigned short type;
1808 unsigned int commentOffset;
0753ca7b 1809} __attribute__((packed));
1da177e4
LT
1810
1811struct aliasInfo {
1812 char aliasName[9];
1813 char pad;
1814 unsigned int commentOffset;
1815 unsigned char type[2];
0753ca7b 1816} __attribute__((packed));
1da177e4
LT
1817
1818struct aliasInfo92 {
1819 int aliasNameOffset;
1820 int serverNameOffset;
1821 int shareNameOffset;
0753ca7b 1822} __attribute__((packed));
1da177e4
LT
1823
1824typedef struct {
1825 __le64 TotalAllocationUnits;
1826 __le64 FreeAllocationUnits;
1827 __le32 SectorsPerAllocationUnit;
1828 __le32 BytesPerSector;
0753ca7b 1829} __attribute__((packed)) FILE_SYSTEM_INFO; /* size info, level 0x103 */
1da177e4 1830
20962438
SF
1831typedef struct {
1832 __le32 fsid;
1833 __le32 SectorsPerAllocationUnit;
1834 __le32 TotalAllocationUnits;
1835 __le32 FreeAllocationUnits;
1836 __le16 BytesPerSector;
0753ca7b 1837} __attribute__((packed)) FILE_SYSTEM_ALLOC_INFO;
20962438 1838
1da177e4
LT
1839typedef struct {
1840 __le16 MajorVersionNumber;
1841 __le16 MinorVersionNumber;
1842 __le64 Capability;
0753ca7b 1843} __attribute__((packed)) FILE_SYSTEM_UNIX_INFO; /* Unix extensions info, level 0x200 */
ac67055e
JA
1844
1845/* Version numbers for CIFS UNIX major and minor. */
1846#define CIFS_UNIX_MAJOR_VERSION 1
1847#define CIFS_UNIX_MINOR_VERSION 0
1848
1da177e4
LT
1849/* Linux/Unix extensions capability flags */
1850#define CIFS_UNIX_FCNTL_CAP 0x00000001 /* support for fcntl locks */
f654bac2
SF
1851#define CIFS_UNIX_POSIX_ACL_CAP 0x00000002 /* support getfacl/setfacl */
1852#define CIFS_UNIX_XATTR_CAP 0x00000004 /* support new namespace */
1853#define CIFS_UNIX_EXTATTR_CAP 0x00000008 /* support chattr/chflag */
82940a46
SF
1854#define CIFS_UNIX_POSIX_PATHNAMES_CAP 0x00000010 /* Allow POSIX path chars */
1855#ifdef CONFIG_CIFS_POSIX
1856#define CIFS_UNIX_CAP_MASK 0x0000001b
1857#else
1858#define CIFS_UNIX_CAP_MASK 0x00000013
1859#endif /* CONFIG_CIFS_POSIX */
1860
ac67055e 1861
f28ac91b 1862#define CIFS_POSIX_EXTENSIONS 0x00000010 /* support for new QFSInfo */
ac67055e 1863
1da177e4
LT
1864typedef struct {
1865 /* For undefined recommended transfer size return -1 in that field */
1866 __le32 OptimalTransferSize; /* bsize on some os, iosize on other os */
1867 __le32 BlockSize;
1868 /* The next three fields are in terms of the block size.
1869 (above). If block size is unknown, 4096 would be a
1870 reasonable block size for a server to report.
1871 Note that returning the blocks/blocksavail removes need
1872 to make a second call (to QFSInfo level 0x103 to get this info.
1873 UserBlockAvail is typically less than or equal to BlocksAvail,
1874 if no distinction is made return the same value in each */
1875 __le64 TotalBlocks;
1876 __le64 BlocksAvail; /* bfree */
1877 __le64 UserBlocksAvail; /* bavail */
1878 /* For undefined Node fields or FSID return -1 */
1879 __le64 TotalFileNodes;
1880 __le64 FreeFileNodes;
1881 __le64 FileSysIdentifier; /* fsid */
1882 /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
1883 /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */
0753ca7b 1884} __attribute__((packed)) FILE_SYSTEM_POSIX_INFO;
1da177e4
LT
1885
1886/* DeviceType Flags */
1887#define FILE_DEVICE_CD_ROM 0x00000002
1888#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
1889#define FILE_DEVICE_DFS 0x00000006
1890#define FILE_DEVICE_DISK 0x00000007
1891#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
1892#define FILE_DEVICE_FILE_SYSTEM 0x00000009
1893#define FILE_DEVICE_NAMED_PIPE 0x00000011
1894#define FILE_DEVICE_NETWORK 0x00000012
1895#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
1896#define FILE_DEVICE_NULL 0x00000015
1897#define FILE_DEVICE_PARALLEL_PORT 0x00000016
1898#define FILE_DEVICE_PRINTER 0x00000018
1899#define FILE_DEVICE_SERIAL_PORT 0x0000001b
1900#define FILE_DEVICE_STREAMS 0x0000001e
1901#define FILE_DEVICE_TAPE 0x0000001f
1902#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
1903#define FILE_DEVICE_VIRTUAL_DISK 0x00000024
1904#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
1905
1906typedef struct {
1907 __le32 DeviceType;
1908 __le32 DeviceCharacteristics;
3979877e 1909} __attribute__((packed)) FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */
1da177e4
LT
1910
1911typedef struct {
1912 __le32 Attributes;
1913 __le32 MaxPathNameComponentLength;
1914 __le32 FileSystemNameLen;
3979877e 1915 char FileSystemName[52]; /* do not have to save this - get subset? */
0753ca7b 1916} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
1da177e4
LT
1917
1918/******************************************************************************/
1919/* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
1920/******************************************************************************/
1921typedef struct { /* data block encoding of response to level 263 QPathInfo */
1922 __le64 CreationTime;
1923 __le64 LastAccessTime;
1924 __le64 LastWriteTime;
1925 __le64 ChangeTime;
1926 __le32 Attributes;
1927 __u32 Pad1;
1928 __le64 AllocationSize;
1929 __le64 EndOfFile; /* size ie offset to first free byte in file */
1930 __le32 NumberOfLinks; /* hard links */
1931 __u8 DeletePending;
1932 __u8 Directory;
1933 __u16 Pad2;
1934 __u64 IndexNumber;
1935 __le32 EASize;
1936 __le32 AccessFlags;
1937 __u64 IndexNumber1;
1938 __le64 CurrentByteOffset;
1939 __le32 Mode;
1940 __le32 AlignmentRequirement;
1941 __le32 FileNameLength;
1942 char FileName[1];
0753ca7b 1943} __attribute__((packed)) FILE_ALL_INFO; /* level 0x107 QPathInfo */
1da177e4
LT
1944
1945/* defines for enumerating possible values of the Unix type field below */
1946#define UNIX_FILE 0
1947#define UNIX_DIR 1
1948#define UNIX_SYMLINK 2
1949#define UNIX_CHARDEV 3
1950#define UNIX_BLOCKDEV 4
1951#define UNIX_FIFO 5
1952#define UNIX_SOCKET 6
1953typedef struct {
1954 __le64 EndOfFile;
1955 __le64 NumOfBytes;
1956 __le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */
1957 __le64 LastAccessTime;
1958 __le64 LastModificationTime;
1959 __le64 Uid;
1960 __le64 Gid;
1961 __le32 Type;
1962 __le64 DevMajor;
1963 __le64 DevMinor;
1964 __u64 UniqueId;
1965 __le64 Permissions;
1966 __le64 Nlinks;
0753ca7b 1967} __attribute__((packed)) FILE_UNIX_BASIC_INFO; /* level 0x200 QPathInfo */
1da177e4
LT
1968
1969typedef struct {
1970 char LinkDest[1];
0753ca7b 1971} __attribute__((packed)) FILE_UNIX_LINK_INFO; /* level 0x201 QPathInfo */
1da177e4
LT
1972
1973/* The following three structures are needed only for
1974 setting time to NT4 and some older servers via
1975 the primitive DOS time format */
1976typedef struct {
1977 __u16 Day:5;
1978 __u16 Month:4;
1979 __u16 Year:7;
0753ca7b 1980} __attribute__((packed)) SMB_DATE;
1da177e4
LT
1981
1982typedef struct {
1983 __u16 TwoSeconds:5;
1984 __u16 Minutes:6;
1985 __u16 Hours:5;
0753ca7b 1986} __attribute__((packed)) SMB_TIME;
1da177e4
LT
1987
1988typedef struct {
1989 __le16 CreationDate; /* SMB Date see above */
1990 __le16 CreationTime; /* SMB Time */
1991 __le16 LastAccessDate;
1992 __le16 LastAccessTime;
1993 __le16 LastWriteDate;
1994 __le16 LastWriteTime;
1995 __le32 DataSize; /* File Size (EOF) */
1996 __le32 AllocationSize;
1997 __le16 Attributes; /* verify not u32 */
1998 __le32 EASize;
0753ca7b 1999} __attribute__((packed)) FILE_INFO_STANDARD; /* level 1 SetPath/FileInfo */
1da177e4
LT
2000
2001typedef struct {
2002 __le64 CreationTime;
2003 __le64 LastAccessTime;
2004 __le64 LastWriteTime;
2005 __le64 ChangeTime;
2006 __le32 Attributes;
2007 __u32 Pad;
0753ca7b 2008} __attribute__((packed)) FILE_BASIC_INFO; /* size info, level 0x101 */
1da177e4
LT
2009
2010struct file_allocation_info {
2011 __le64 AllocationSize; /* Note old Samba srvr rounds this up too much */
5bafd765
SF
2012} __attribute__((packed)); /* size used on disk, for level 0x103 for set,
2013 0x105 for query */
1da177e4
LT
2014
2015struct file_end_of_file_info {
2016 __le64 FileSize; /* offset to end of file */
0753ca7b 2017} __attribute__((packed)); /* size info, level 0x104 for set, 0x106 for query */
1da177e4
LT
2018
2019struct file_alt_name_info {
2020 __u8 alt_name[1];
0753ca7b 2021} __attribute__((packed)); /* level 0x0108 */
1da177e4
LT
2022
2023struct file_stream_info {
2024 __le32 number_of_streams; /* BB check sizes and verify location */
2025 /* followed by info on streams themselves
2026 u64 size;
2027 u64 allocation_size
2028 stream info */
2029}; /* level 0x109 */
2030
2031struct file_compression_info {
2032 __le64 compressed_size;
2033 __le16 format;
2034 __u8 unit_shift;
2035 __u8 ch_shift;
2036 __u8 cl_shift;
2037 __u8 pad[3];
0753ca7b 2038} __attribute__((packed)); /* level 0x10b */
1da177e4
LT
2039
2040/* POSIX ACL set/query path info structures */
2041#define CIFS_ACL_VERSION 1
2042struct cifs_posix_ace { /* access control entry (ACE) */
2043 __u8 cifs_e_tag;
2044 __u8 cifs_e_perm;
2045 __le64 cifs_uid; /* or gid */
0753ca7b 2046} __attribute__((packed));
1da177e4
LT
2047
2048struct cifs_posix_acl { /* access conrol list (ACL) */
2049 __le16 version;
2050 __le16 access_entry_count; /* access ACL - count of entries */
2051 __le16 default_entry_count; /* default ACL - count of entries */
2052 struct cifs_posix_ace ace_array[0];
2053 /* followed by
2054 struct cifs_posix_ace default_ace_arraay[] */
0753ca7b 2055} __attribute__((packed)); /* level 0x204 */
1da177e4
LT
2056
2057/* types of access control entries already defined in posix_acl.h */
2058/* #define CIFS_POSIX_ACL_USER_OBJ 0x01
2059#define CIFS_POSIX_ACL_USER 0x02
2060#define CIFS_POSIX_ACL_GROUP_OBJ 0x04
2061#define CIFS_POSIX_ACL_GROUP 0x08
2062#define CIFS_POSIX_ACL_MASK 0x10
2063#define CIFS_POSIX_ACL_OTHER 0x20 */
2064
2065/* types of perms */
2066/* #define CIFS_POSIX_ACL_EXECUTE 0x01
2067#define CIFS_POSIX_ACL_WRITE 0x02
2068#define CIFS_POSIX_ACL_READ 0x04 */
2069
2070/* end of POSIX ACL definitions */
2071
2072struct file_internal_info {
2073 __u64 UniqueId; /* inode number */
0753ca7b 2074} __attribute__((packed)); /* level 0x3ee */
1da177e4
LT
2075struct file_mode_info {
2076 __le32 Mode;
0753ca7b 2077} __attribute__((packed)); /* level 0x3f8 */
1da177e4
LT
2078
2079struct file_attrib_tag {
2080 __le32 Attribute;
2081 __le32 ReparseTag;
0753ca7b 2082} __attribute__((packed)); /* level 0x40b */
1da177e4
LT
2083
2084
2085/********************************************************/
2086/* FindFirst/FindNext transact2 data buffer formats */
2087/********************************************************/
2088
2089typedef struct {
2090 __le32 NextEntryOffset;
2091 __u32 ResumeKey; /* as with FileIndex - no need to convert */
2092 __le64 EndOfFile;
2093 __le64 NumOfBytes;
2094 __le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */
2095 __le64 LastAccessTime;
2096 __le64 LastModificationTime;
2097 __le64 Uid;
2098 __le64 Gid;
2099 __le32 Type;
2100 __le64 DevMajor;
2101 __le64 DevMinor;
2102 __u64 UniqueId;
2103 __le64 Permissions;
2104 __le64 Nlinks;
2105 char FileName[1];
0753ca7b 2106} __attribute__((packed)) FILE_UNIX_INFO; /* level 0x202 */
1da177e4
LT
2107
2108typedef struct {
2109 __le32 NextEntryOffset;
2110 __u32 FileIndex;
2111 __le64 CreationTime;
2112 __le64 LastAccessTime;
2113 __le64 LastWriteTime;
2114 __le64 ChangeTime;
2115 __le64 EndOfFile;
2116 __le64 AllocationSize;
2117 __le32 ExtFileAttributes;
2118 __le32 FileNameLength;
2119 char FileName[1];
5bafd765 2120} __attribute__((packed)) FILE_DIRECTORY_INFO; /* level 0x101 FF resp data */
1da177e4
LT
2121
2122typedef struct {
2123 __le32 NextEntryOffset;
2124 __u32 FileIndex;
2125 __le64 CreationTime;
2126 __le64 LastAccessTime;
2127 __le64 LastWriteTime;
2128 __le64 ChangeTime;
2129 __le64 EndOfFile;
2130 __le64 AllocationSize;
2131 __le32 ExtFileAttributes;
2132 __le32 FileNameLength;
2133 __le32 EaSize; /* length of the xattrs */
2134 char FileName[1];
5bafd765 2135} __attribute__((packed)) FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */
1da177e4
LT
2136
2137typedef struct {
2138 __le32 NextEntryOffset;
2139 __u32 FileIndex;
2140 __le64 CreationTime;
2141 __le64 LastAccessTime;
2142 __le64 LastWriteTime;
2143 __le64 ChangeTime;
2144 __le64 EndOfFile;
2145 __le64 AllocationSize;
2146 __le32 ExtFileAttributes;
2147 __le32 FileNameLength;
2148 __le32 EaSize; /* EA size */
2149 __le32 Reserved;
2150 __u64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
2151 char FileName[1];
5bafd765 2152} __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */
1da177e4
LT
2153
2154typedef struct {
2155 __le32 NextEntryOffset;
2156 __u32 FileIndex;
2157 __le64 CreationTime;
2158 __le64 LastAccessTime;
2159 __le64 LastWriteTime;
2160 __le64 ChangeTime;
2161 __le64 EndOfFile;
2162 __le64 AllocationSize;
2163 __le32 ExtFileAttributes;
2164 __le32 FileNameLength;
2165 __le32 EaSize; /* length of the xattrs */
2166 __u8 ShortNameLength;
2167 __u8 Reserved;
2168 __u8 ShortName[12];
2169 char FileName[1];
5bafd765
SF
2170} __attribute__((packed)) FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FFrsp data */
2171
2172typedef struct {
2173 __u32 ResumeKey;
2174 __le16 CreationDate; /* SMB Date */
2175 __le16 CreationTime; /* SMB Time */
2176 __le16 LastAccessDate;
2177 __le16 LastAccessTime;
2178 __le16 LastWriteDate;
2179 __le16 LastWriteTime;
2180 __le32 DataSize; /* File Size (EOF) */
2181 __le32 AllocationSize;
2182 __le16 Attributes; /* verify not u32 */
2183 __u8 FileNameLength;
2184 char FileName[1];
2185} __attribute__((packed)) FIND_FILE_STANDARD_INFO; /* level 0x1 FF resp data */
1da177e4
LT
2186
2187
86c96b4b
SF
2188struct win_dev {
2189 unsigned char type[8]; /* IntxCHR or IntxBLK */
2190 __le64 major;
2191 __le64 minor;
2192} __attribute__((packed));
2193
1da177e4
LT
2194struct gea {
2195 unsigned char name_len;
2196 char name[1];
0753ca7b 2197} __attribute__((packed));
1da177e4
LT
2198
2199struct gealist {
2200 unsigned long list_len;
2201 struct gea list[1];
0753ca7b 2202} __attribute__((packed));
1da177e4
LT
2203
2204struct fea {
2205 unsigned char EA_flags;
2206 __u8 name_len;
2207 __le16 value_len;
2208 char name[1];
2209 /* optionally followed by value */
0753ca7b 2210} __attribute__((packed));
1da177e4
LT
2211/* flags for _FEA.fEA */
2212#define FEA_NEEDEA 0x80 /* need EA bit */
2213
2214struct fealist {
2215 __le32 list_len;
2216 struct fea list[1];
0753ca7b 2217} __attribute__((packed));
1da177e4
LT
2218
2219/* used to hold an arbitrary blob of data */
2220struct data_blob {
2221 __u8 *data;
2222 size_t length;
2223 void (*free) (struct data_blob * data_blob);
0753ca7b 2224} __attribute__((packed));
1da177e4
LT
2225
2226
2227#ifdef CONFIG_CIFS_POSIX
2228/*
2229 For better POSIX semantics from Linux client, (even better
2230 than the existing CIFS Unix Extensions) we need updated PDUs for:
2231
2232 1) PosixCreateX - to set and return the mode, inode#, device info and
2233 perhaps add a CreateDevice - to create Pipes and other special .inodes
2234 Also note POSIX open flags
2235 2) Close - to return the last write time to do cache across close more safely
1982c344
SF
2236 3) FindFirst return unique inode number - what about resume key, two
2237 forms short (matches readdir) and full (enough info to cache inodes)
2238 4) Mkdir - set mode
1da177e4
LT
2239
2240 And under consideration:
1982c344
SF
2241 5) FindClose2 (return nanosecond timestamp ??)
2242 6) Use nanosecond timestamps throughout all time fields if
1da177e4 2243 corresponding attribute flag is set
1982c344
SF
2244 7) sendfile - handle based copy
2245 8) Direct i/o
2246 9) Misc fcntls?
1da177e4
LT
2247
2248 what about fixing 64 bit alignment
2249
2250 There are also various legacy SMB/CIFS requests used as is
2251
2252 From existing Lanman and NTLM dialects:
2253 --------------------------------------
2254 NEGOTIATE
2255 SESSION_SETUP_ANDX (BB which?)
2256 TREE_CONNECT_ANDX (BB which wct?)
2257 TREE_DISCONNECT (BB add volume timestamp on response)
2258 LOGOFF_ANDX
2259 DELETE (note delete open file behavior)
2260 DELETE_DIRECTORY
2261 READ_AND_X
2262 WRITE_AND_X
2263 LOCKING_AND_X (note posix lock semantics)
2264 RENAME (note rename across dirs and open file rename posix behaviors)
2265 NT_RENAME (for hardlinks) Is this good enough for all features?
2266 FIND_CLOSE2
2267 TRANSACTION2 (18 cases)
2268 SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2
2269 (BB verify that never need to set allocation size)
2270 SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via Unix ext?)
2271
2272 COPY (note support for copy across directories) - FUTURE, OPTIONAL
2273 setting/getting OS/2 EAs - FUTURE (BB can this handle
2274 setting Linux xattrs perfectly) - OPTIONAL
2275 dnotify - FUTURE, OPTIONAL
2276 quota - FUTURE, OPTIONAL
2277
2278 Note that various requests implemented for NT interop such as
2279 NT_TRANSACT (IOCTL) QueryReparseInfo
2280 are unneeded to servers compliant with the CIFS POSIX extensions
2281
2282 From CIFS Unix Extensions:
2283 -------------------------
2284 T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks
2285 T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2)
2286 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK)
2287 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC) - BB check for missing inode fields
2288 Actually need QUERY_FILE_UNIX_INFO since has inode num
2289 BB what about a) blksize/blkbits/blocks
2290 b) i_version
2291 c) i_rdev
2292 d) notify mask?
2293 e) generation
2294 f) size_seqcount
2295 T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX
2296 TRANS2_GET_DFS_REFERRAL - OPTIONAL but recommended
2297 T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL
2298
2299
2300 */
2301
1982c344 2302/* xsymlink is a symlink format (used by MacOS) that can be used
1da177e4
LT
2303 to save symlink info in a regular file when
2304 mounted to operating systems that do not
2305 support the cifs Unix extensions or EAs (for xattr
2306 based symlinks). For such a file to be recognized
2307 as containing symlink data:
2308
2309 1) file size must be 1067,
2310 2) signature must begin file data,
2311 3) length field must be set to ASCII representation
2312 of a number which is less than or equal to 1024,
2313 4) md5 must match that of the path data */
2314
2315struct xsymlink {
2316 /* 1067 bytes */
2317 char signature[4]; /* XSym */ /* not null terminated */
2318 char cr0; /* \n */
2319/* ASCII representation of length (4 bytes decimal) terminated by \n not null */
2320 char length[4];
2321 char cr1; /* \n */
2322/* md5 of valid subset of path ie path[0] through path[length-1] */
2323 __u8 md5[32];
2324 char cr2; /* \n */
2325/* if room left, then end with \n then 0x20s by convention but not required */
2326 char path[1024];
0753ca7b 2327} __attribute__((packed));
1da177e4 2328
f654bac2 2329typedef struct file_xattr_info {
1da177e4
LT
2330 /* BB do we need another field for flags? BB */
2331 __u32 xattr_name_len;
2332 __u32 xattr_value_len;
2333 char xattr_name[0];
2334 /* followed by xattr_value[xattr_value_len], no pad */
0753ca7b 2335} __attribute__((packed)) FILE_XATTR_INFO; /* extended attribute, info level 0x205 */
f654bac2
SF
2336
2337
2338/* flags for chattr command */
2339#define EXT_SECURE_DELETE 0x00000001 /* EXT3_SECRM_FL */
2340#define EXT_ENABLE_UNDELETE 0x00000002 /* EXT3_UNRM_FL */
2341/* Reserved for compress file 0x4 */
2342#define EXT_SYNCHRONOUS 0x00000008 /* EXT3_SYNC_FL */
2343#define EXT_IMMUTABLE_FL 0x00000010 /* EXT3_IMMUTABLE_FL */
2344#define EXT_OPEN_APPEND_ONLY 0x00000020 /* EXT3_APPEND_FL */
2345#define EXT_DO_NOT_BACKUP 0x00000040 /* EXT3_NODUMP_FL */
2346#define EXT_NO_UPDATE_ATIME 0x00000080 /* EXT3_NOATIME_FL */
2347/* 0x100 through 0x800 reserved for compression flags and are GET-ONLY */
2348#define EXT_HASH_TREE_INDEXED_DIR 0x00001000 /* GET-ONLY EXT3_INDEX_FL */
2349/* 0x2000 reserved for IMAGIC_FL */
2350#define EXT_JOURNAL_THIS_FILE 0x00004000 /* GET-ONLY EXT3_JOURNAL_DATA_FL */
2351/* 0x8000 reserved for EXT3_NOTAIL_FL */
2352#define EXT_SYNCHRONOUS_DIR 0x00010000 /* EXT3_DIRSYNC_FL */
2353#define EXT_TOPDIR 0x00020000 /* EXT3_TOPDIR_FL */
2354
2355#define EXT_SET_MASK 0x000300FF
2356#define EXT_GET_MASK 0x0003DFFF
2357
2358typedef struct file_chattr_info {
2359 __le64 mask; /* list of all possible attribute bits */
2360 __le64 mode; /* list of actual attribute bits on this inode */
0753ca7b 2361} __attribute__((packed)) FILE_CHATTR_INFO; /* ext attributes (chattr, chflags) level 0x206 */
1da177e4
LT
2362
2363#endif
2364
1da177e4 2365#endif /* _CIFSPDU_H */