4 * Copyright (c) International Business Machines Corp., 2002
5 * Author(s): Steve French (sfrench@us.ibm.com)
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.
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.
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
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #define BAD_PROT CIFS_PROT+1
30 /* SMB command codes */
31 /* Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
32 (ie which include no useful data other than the SMB error code itself).
33 Knowing this helps avoid response buffer allocations and copy in some cases */
34 #define SMB_COM_CREATE_DIRECTORY 0x00 /* trivial response */
35 #define SMB_COM_DELETE_DIRECTORY 0x01 /* trivial response */
36 #define SMB_COM_CLOSE 0x04 /* triv req/rsp, timestamp ignored */
37 #define SMB_COM_DELETE 0x06 /* trivial response */
38 #define SMB_COM_RENAME 0x07 /* trivial response */
39 #define SMB_COM_SETATTR 0x09 /* trivial response */
40 #define SMB_COM_LOCKING_ANDX 0x24 /* trivial response */
41 #define SMB_COM_COPY 0x29 /* trivial rsp, fail filename ignrd*/
42 #define SMB_COM_READ_ANDX 0x2E
43 #define SMB_COM_WRITE_ANDX 0x2F
44 #define SMB_COM_TRANSACTION2 0x32
45 #define SMB_COM_TRANSACTION2_SECONDARY 0x33
46 #define SMB_COM_FIND_CLOSE2 0x34 /* trivial response */
47 #define SMB_COM_TREE_DISCONNECT 0x71 /* trivial response */
48 #define SMB_COM_NEGOTIATE 0x72
49 #define SMB_COM_SESSION_SETUP_ANDX 0x73
50 #define SMB_COM_LOGOFF_ANDX 0x74 /* trivial response */
51 #define SMB_COM_TREE_CONNECT_ANDX 0x75
52 #define SMB_COM_NT_TRANSACT 0xA0
53 #define SMB_COM_NT_TRANSACT_SECONDARY 0xA1
54 #define SMB_COM_NT_CREATE_ANDX 0xA2
55 #define SMB_COM_NT_RENAME 0xA5 /* trivial response */
57 /* Transact2 subcommand codes */
58 #define TRANS2_OPEN 0x00
59 #define TRANS2_FIND_FIRST 0x01
60 #define TRANS2_FIND_NEXT 0x02
61 #define TRANS2_QUERY_FS_INFORMATION 0x03
62 #define TRANS2_SET_FS_INFORMATION 0x04
63 #define TRANS2_QUERY_PATH_INFORMATION 0x05
64 #define TRANS2_SET_PATH_INFORMATION 0x06
65 #define TRANS2_QUERY_FILE_INFORMATION 0x07
66 #define TRANS2_SET_FILE_INFORMATION 0x08
67 #define TRANS2_GET_DFS_REFERRAL 0x10
68 #define TRANS2_REPORT_DFS_INCOSISTENCY 0x11
70 /* NT Transact subcommand codes */
71 #define NT_TRANSACT_CREATE 0x01
72 #define NT_TRANSACT_IOCTL 0x02
73 #define NT_TRANSACT_SET_SECURITY_DESC 0x03
74 #define NT_TRANSACT_NOTIFY_CHANGE 0x04
75 #define NT_TRANSACT_RENAME 0x05
76 #define NT_TRANSACT_QUERY_SECURITY_DESC 0x06
77 #define NT_TRANSACT_GET_USER_QUOTA 0x07
78 #define NT_TRANSACT_SET_USER_QUOTA 0x08
80 #define MAX_CIFS_HDR_SIZE 256 /* chained NTCreateXReadX will probably be biggest */
82 /* internal cifs vfs structures */
83 /*****************************************************************
84 * All constants go here
85 *****************************************************************
89 * Starting value for maximum SMB size negotiation
91 #define CIFS_MAX_MSGSIZE (4*4096)
94 * Size of encrypted user password in bytes
96 #define CIFS_ENCPWD_SIZE (16)
99 * Size of the crypto key returned on the negotiate SMB in bytes
101 #define CIFS_CRYPTO_KEY_SIZE (8)
104 * Size of the session key (crypto key encrypted with the password
106 #define CIFS_SESSION_KEY_SIZE (24)
109 * Maximum user name length
111 #define CIFS_UNLEN (20)
116 #define SMBOPEN_WRITE_THROUGH 0x4000
117 #define SMBOPEN_DENY_ALL 0x0010
118 #define SMBOPEN_DENY_WRITE 0x0020
119 #define SMBOPEN_DENY_READ 0x0030
120 #define SMBOPEN_DENY_NONE 0x0040
121 #define SMBOPEN_READ 0x0000
122 #define SMBOPEN_WRITE 0x0001
123 #define SMBOPEN_READWRITE 0x0002
124 #define SMBOPEN_EXECUTE 0x0003
126 #define SMBOPEN_OCREATE 0x0010
127 #define SMBOPEN_OTRUNC 0x0002
128 #define SMBOPEN_OAPPEND 0x0001
131 * SMB flag definitions
133 #define SMBFLG_EXTD_LOCK 0x01 /* server supports lock-read write-unlock primitives */
134 #define SMBFLG_RCV_POSTED 0x02 /* obsolete */
135 #define SMBFLG_RSVD 0x04
136 #define SMBFLG_CASELESS 0x08 /* all pathnames treated as caseless (off implies case sensitive file handling requested) */
137 #define SMBFLG_CANONICAL_PATH_FORMAT 0x10 /* obsolete */
138 #define SMBFLG_OLD_OPLOCK 0x20 /* obsolete */
139 #define SMBFLG_OLD_OPLOCK_NOTIFY 0x40 /* obsolete */
140 #define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */
143 * SMB flag2 definitions
145 #define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1) /* can send long (non-8.3) path names in response */
146 #define SMBFLG2_KNOWS_EAS cpu_to_le16(2)
147 #define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4)
148 #define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40)
149 #define SMBFLG2_EXT_SEC cpu_to_le16(0x800)
150 #define SMBFLG2_DFS cpu_to_le16(0x1000)
151 #define SMBFLG2_PAGING_IO cpu_to_le16(0x2000)
152 #define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)
153 #define SMBFLG2_UNICODE cpu_to_le16(0x8000)
156 * These are the file access permission bits defined in CIFS for the
157 * NTCreateAndX as well as the level 0x107
158 * TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO
159 * responds with the AccessFlags.
160 * The AccessFlags specifies the access permissions a caller has to the
161 * file and can have any suitable combination of the following values:
164 #define FILE_READ_DATA 0x00000001 /* Data can be read from the file */
165 #define FILE_WRITE_DATA 0x00000002 /* Data can be written to the file */
166 #define FILE_APPEND_DATA 0x00000004 /* Data can be appended to the file */
167 #define FILE_READ_EA 0x00000008 /* Extended attributes associated */
168 /* with the file can be read */
169 #define FILE_WRITE_EA 0x00000010 /* Extended attributes associated */
170 /* with the file can be written */
171 #define FILE_EXECUTE 0x00000020 /*Data can be read into memory from */
172 /* the file using system paging I/O */
173 #define FILE_DELETE_CHILD 0x00000040
174 #define FILE_READ_ATTRIBUTES 0x00000080 /* Attributes associated with the */
175 /* file can be read */
176 #define FILE_WRITE_ATTRIBUTES 0x00000100 /* Attributes associated with the */
177 /* file can be written */
178 #define DELETE 0x00010000 /* The file can be deleted */
179 #define READ_CONTROL 0x00020000 /* The access control list and */
180 /* ownership associated with the */
181 /* file can be read */
182 #define WRITE_DAC 0x00040000 /* The access control list and */
183 /* ownership associated with the */
184 /* file can be written. */
185 #define WRITE_OWNER 0x00080000 /* Ownership information associated */
186 /* with the file can be written */
187 #define SYNCHRONIZE 0x00100000 /* The file handle can waited on to */
188 /* synchronize with the completion */
189 /* of an input/output request */
190 #define GENERIC_ALL 0x10000000
191 #define GENERIC_EXECUTE 0x20000000
192 #define GENERIC_WRITE 0x40000000
193 #define GENERIC_READ 0x80000000
194 /* In summary - Relevant file */
195 /* access flags from CIFS are */
196 /* file_read_data, file_write_data */
197 /* file_execute, file_read_attributes */
198 /* write_dac, and delete. */
201 * Invalid readdir handle
203 #define CIFS_NO_HANDLE 0xFFFF
206 #define CIFS_IPC_RESOURCE "\x49\x50\x43\x24"
208 /* IPC$ in Unicode */
209 #define CIFS_IPC_UNICODE_RESOURCE "\x00\x49\x00\x50\x00\x43\x00\x24\x00\x00"
211 /* Unicode Null terminate 2 bytes of 0 */
212 #define UNICODE_NULL "\x00\x00"
213 #define ASCII_NULL 0x00
216 * Server type values (returned on EnumServer API
218 #define CIFS_SV_TYPE_DC 0x00000008
219 #define CIFS_SV_TYPE_BACKDC 0x00000010
222 * Alias type flags (From EnumAlias API call
224 #define CIFS_ALIAS_TYPE_FILE 0x0001
225 #define CIFS_SHARE_TYPE_FILE 0x0000
228 * File Attribute flags
230 #define ATTR_READONLY 0x0001
231 #define ATTR_HIDDEN 0x0002
232 #define ATTR_SYSTEM 0x0004
233 #define ATTR_VOLUME 0x0008
234 #define ATTR_DIRECTORY 0x0010
235 #define ATTR_ARCHIVE 0x0020
236 #define ATTR_DEVICE 0x0040
237 #define ATTR_NORMAL 0x0080
238 #define ATTR_TEMPORARY 0x0100
239 #define ATTR_SPARSE 0x0200
240 #define ATTR_REPARSE 0x0400
241 #define ATTR_COMPRESSED 0x0800
242 #define ATTR_OFFLINE 0x1000 /* ie file not immediately available - offline storage */
243 #define ATTR_NOT_CONTENT_INDEXED 0x2000
244 #define ATTR_ENCRYPTED 0x4000
245 #define ATTR_POSIX_SEMANTICS 0x01000000
246 #define ATTR_BACKUP_SEMANTICS 0x02000000
247 #define ATTR_DELETE_ON_CLOSE 0x04000000
248 #define ATTR_SEQUENTIAL_SCAN 0x08000000
249 #define ATTR_RANDOM_ACCESS 0x10000000
250 #define ATTR_NO_BUFFERING 0x20000000
251 #define ATTR_WRITE_THROUGH 0x80000000
253 /* ShareAccess flags */
254 #define FILE_NO_SHARE 0x00000000
255 #define FILE_SHARE_READ 0x00000001
256 #define FILE_SHARE_WRITE 0x00000002
257 #define FILE_SHARE_DELETE 0x00000004
258 #define FILE_SHARE_ALL 0x00000007
260 /* CreateDisposition flags */
261 #define FILE_SUPERSEDE 0x00000000
262 #define FILE_OPEN 0x00000001
263 #define FILE_CREATE 0x00000002
264 #define FILE_OPEN_IF 0x00000003
265 #define FILE_OVERWRITE 0x00000004
266 #define FILE_OVERWRITE_IF 0x00000005
269 #define CREATE_NOT_FILE 0x00000001 /* if set must not be file */
270 #define CREATE_WRITE_THROUGH 0x00000002
271 #define CREATE_SEQUENTIAL 0x00000004
272 #define CREATE_SYNC_ALERT 0x00000010
273 #define CREATE_ASYNC_ALERT 0x00000020
274 #define CREATE_NOT_DIR 0x00000040 /* if set must not be directory */
275 #define CREATE_NO_EA_KNOWLEDGE 0x00000200
276 #define CREATE_EIGHT_DOT_THREE 0x00000400
277 #define CREATE_RANDOM_ACCESS 0x00000800
278 #define CREATE_DELETE_ON_CLOSE 0x00001000
279 #define CREATE_OPEN_BY_ID 0x00002000
280 #define OPEN_REPARSE_POINT 0x00200000
281 #define CREATE_OPTIONS_MASK 0x007FFFFF
282 #define CREATE_OPTION_SPECIAL 0x20000000 /* system. NB not sent over wire */
284 /* ImpersonationLevel flags */
285 #define SECURITY_ANONYMOUS 0
286 #define SECURITY_IDENTIFICATION 1
287 #define SECURITY_IMPERSONATION 2
288 #define SECURITY_DELEGATION 3
291 #define SECURITY_CONTEXT_TRACKING 0x01
292 #define SECURITY_EFFECTIVE_ONLY 0x02
295 * Default PID value, used in all SMBs where the PID is not important
297 #define CIFS_DFT_PID 0x1234
300 * We use the same routine for Copy and Move SMBs. This flag is used to
303 #define CIFS_COPY_OP 1
304 #define CIFS_RENAME_OP 2
306 #define GETU16(var) (*((__u16 *)var)) /* BB check for endian issues */
307 #define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */
312 __u32 smb_buf_length; /* big endian on wire *//* BB length is only two or three bytes - with one or two byte type preceding it but that is always zero - we could mask the type byte off just in case BB */
324 __le16 Flags2; /* note: le */
328 __le32 SequenceNumber; /* le */
329 __u32 Reserved; /* zero */
331 __u8 SecuritySignature[8]; /* le */
340 /* given a pointer to an smb_hdr retrieve the value of byte count */
341 #define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) ) )
342 #define BCC_LE(smb_var) ( *(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) ) )
343 /* given a pointer to an smb_hdr retrieve the pointer to the byte area */
344 #define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) + 2 )
347 * Computer Name Length
352 * Share Name Length @S8A
353 * Note: This length is limited by the SMB used to get @S8A
354 * the Share info. NetShareEnum only returns 13 @S8A
355 * chars, including the null termination. @S8A
357 #define SNLEN 12 /*@S8A */
362 #define MAXCOMMENTLEN 40
365 * The OS/2 maximum path name
367 #define MAX_PATHCONF 256
370 * SMB frame definitions (following must be packed structs)
371 * See the SNIA CIFS Specification for details.
373 * The Naming convention is the lower case version of the
374 * smb command code name for the struct and this is typedef to the
375 * uppercase version of the same name with the prefix SMB_ removed
376 * for brevity. Although typedefs are not commonly used for
377 * structure definitions in the Linux kernel, their use in the
378 * CIFS standards document, which this code is based on, may
379 * make this one of the cases where typedefs for structures make
380 * sense to improve readability for readers of the standards doc.
381 * Typedefs can always be removed later if they are too distracting
382 * and they are only used for the CIFSs PDUs themselves, not
383 * internal cifs vfs structures
387 typedef struct negotiate_req {
388 struct smb_hdr hdr; /* wct = 0 */
390 unsigned char DialectsArray[1];
393 typedef struct negotiate_rsp {
394 struct smb_hdr hdr; /* wct = 17 */
399 __le32 MaxBufferSize;
402 __le32 Capabilities; /* see below */
403 __le32 SystemTimeLow;
404 __le32 SystemTimeHigh;
405 __le16 ServerTimeZone;
406 __u8 EncryptionKeyLength;
409 unsigned char EncryptionKey[1]; /* if cap extended security is off */
410 /* followed by Domain name - if extended security is off */
411 /* followed by 16 bytes of server GUID */
412 /* followed by security blob if cap_extended_security negotiated */
414 unsigned char GUID[16];
415 unsigned char SecurityBlob[1];
420 /* SecurityMode bits */
421 #define SECMODE_USER 0x01 /* off indicates share level security */
422 #define SECMODE_PW_ENCRYPT 0x02
423 #define SECMODE_SIGN_ENABLED 0x04 /* SMB security signatures enabled */
424 #define SECMODE_SIGN_REQUIRED 0x08 /* SMB security signatures required */
426 /* Negotiate response Capabilities */
427 #define CAP_RAW_MODE 0x00000001
428 #define CAP_MPX_MODE 0x00000002
429 #define CAP_UNICODE 0x00000004
430 #define CAP_LARGE_FILES 0x00000008
431 #define CAP_NT_SMBS 0x00000010 /* implies CAP_NT_FIND */
432 #define CAP_RPC_REMOTE_APIS 0x00000020
433 #define CAP_STATUS32 0x00000040
434 #define CAP_LEVEL_II_OPLOCKS 0x00000080
435 #define CAP_LOCK_AND_READ 0x00000100
436 #define CAP_NT_FIND 0x00000200
437 #define CAP_DFS 0x00001000
438 #define CAP_INFOLEVEL_PASSTHRU 0x00002000
439 #define CAP_LARGE_READ_X 0x00004000
440 #define CAP_LARGE_WRITE_X 0x00008000
441 #define CAP_UNIX 0x00800000
442 #define CAP_RESERVED 0x02000000
443 #define CAP_BULK_TRANSFER 0x20000000
444 #define CAP_COMPRESSED_DATA 0x40000000
445 #define CAP_EXTENDED_SECURITY 0x80000000
447 typedef union smb_com_session_setup_andx {
448 struct { /* request format */
449 struct smb_hdr hdr; /* wct = 12 */
453 __le16 MaxBufferSize;
457 __le16 SecurityBlobLength;
459 __le32 Capabilities; /* see below */
461 unsigned char SecurityBlob[1]; /* followed by */
462 /* STRING NativeOS */
463 /* STRING NativeLanMan */
464 } req; /* NTLM request format (with extended security */
466 struct { /* request format */
467 struct smb_hdr hdr; /* wct = 13 */
471 __le16 MaxBufferSize;
475 __le16 CaseInsensitivePasswordLength; /* ASCII password length */
476 __le16 CaseSensitivePasswordLength; /* Unicode password length */
477 __u32 Reserved; /* see below */
480 unsigned char CaseInsensitivePassword[1]; /* followed by: */
481 /* unsigned char * CaseSensitivePassword; */
482 /* STRING AccountName */
483 /* STRING PrimaryDomain */
484 /* STRING NativeOS */
485 /* STRING NativeLanMan */
486 } req_no_secext; /* NTLM request format (without extended security */
488 struct { /* default (NTLM) response format */
489 struct smb_hdr hdr; /* wct = 4 */
493 __le16 Action; /* see below */
494 __le16 SecurityBlobLength;
496 unsigned char SecurityBlob[1]; /* followed by */
497 /* unsigned char * NativeOS; */
498 /* unsigned char * NativeLanMan; */
499 /* unsigned char * PrimaryDomain; */
500 } resp; /* NTLM response format (with or without extended security */
502 struct { /* request format */
503 struct smb_hdr hdr; /* wct = 10 */
507 __le16 MaxBufferSize;
511 __le16 PassswordLength;
514 unsigned char AccountPassword[1]; /* followed by */
515 /* STRING AccountName */
516 /* STRING PrimaryDomain */
517 /* STRING NativeOS */
518 /* STRING NativeLanMan */
519 } old_req; /* pre-NTLM (LANMAN2.1) request format */
521 struct { /* default (NTLM) response format */
522 struct smb_hdr hdr; /* wct = 3 */
526 __le16 Action; /* see below */
528 unsigned char NativeOS[1]; /* followed by */
529 /* unsigned char * NativeLanMan; */
530 /* unsigned char * PrimaryDomain; */
531 } old_resp; /* pre-NTLM (LANMAN2.1) response format */
532 } SESSION_SETUP_ANDX;
534 #define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux"
536 /* Capabilities bits (for NTLM SessSetup request) */
537 #define CAP_UNICODE 0x00000004
538 #define CAP_LARGE_FILES 0x00000008
539 #define CAP_NT_SMBS 0x00000010
540 #define CAP_STATUS32 0x00000040
541 #define CAP_LEVEL_II_OPLOCKS 0x00000080
542 #define CAP_NT_FIND 0x00000200 /* reserved should be zero (presumably because NT_SMBs implies the same thing) */
543 #define CAP_BULK_TRANSFER 0x20000000
544 #define CAP_EXTENDED_SECURITY 0x80000000
547 #define GUEST_LOGIN 1
549 typedef struct smb_com_tconx_req {
550 struct smb_hdr hdr; /* wct = 4 */
554 __le16 Flags; /* see below */
555 __le16 PasswordLength;
557 unsigned char Password[1]; /* followed by */
558 /* STRING Path *//* \\server\share name */
562 typedef struct smb_com_tconx_rsp {
563 struct smb_hdr hdr; /* wct = 3 *//* note that Win2000 has sent wct=7 in some cases on responses. Four unspecified words followed OptionalSupport */
567 __le16 OptionalSupport; /* see below */
569 unsigned char Service[1]; /* always ASCII, not Unicode */
570 /* STRING NativeFileSystem */
573 /* tree connect Flags */
574 #define DISCONNECT_TID 0x0001
575 #define TCON_EXTENDED_SECINFO 0x0008
576 /* OptionalSupport bits */
577 #define SMB_SUPPORT_SEARCH_BITS 0x0001 /* must have bits (exclusive searches suppt. */
578 #define SMB_SHARE_IS_IN_DFS 0x0002
580 typedef struct smb_com_logoff_andx_req {
581 struct smb_hdr hdr; /* wct = 2 */
588 typedef struct smb_com_logoff_andx_rsp {
589 struct smb_hdr hdr; /* wct = 2 */
596 typedef union smb_com_tree_disconnect { /* as an altetnative can use flag on tree_connect PDU to effect disconnect *//* probably the simplest SMB PDU */
598 struct smb_hdr hdr; /* wct = 0 */
599 __u16 ByteCount; /* bcc = 0 */
602 struct smb_hdr hdr; /* wct = 0 */
603 __u16 ByteCount; /* bcc = 0 */
607 typedef struct smb_com_close_req {
608 struct smb_hdr hdr; /* wct = 3 */
610 __u32 LastWriteTime; /* should be zero */
611 __u16 ByteCount; /* 0 */
614 typedef struct smb_com_close_rsp {
615 struct smb_hdr hdr; /* wct = 0 */
616 __u16 ByteCount; /* bct = 0 */
619 typedef struct smb_com_findclose_req {
620 struct smb_hdr hdr; /* wct = 1 */
622 __u16 ByteCount; /* 0 */
626 #define REQ_OPLOCK 0x00000002
627 #define REQ_BATCHOPLOCK 0x00000004
628 #define REQ_OPENDIRONLY 0x00000008
630 typedef struct smb_com_open_req { /* also handles create */
631 struct smb_hdr hdr; /* wct = 24 */
635 __u8 Reserved; /* Must Be Zero */
638 __le32 RootDirectoryFid;
639 __le32 DesiredAccess;
640 __le64 AllocationSize;
641 __le32 FileAttributes;
643 __le32 CreateDisposition;
644 __le32 CreateOptions;
645 __le32 ImpersonationLevel;
651 /* open response: oplock levels */
652 #define OPLOCK_NONE 0
653 #define OPLOCK_EXCLUSIVE 1
654 #define OPLOCK_BATCH 2
655 #define OPLOCK_READ 3 /* level 2 oplock */
657 /* open response for CreateAction shifted left */
658 #define CIFS_CREATE_ACTION 0x20000 /* file created */
660 typedef struct smb_com_open_rsp {
661 struct smb_hdr hdr; /* wct = 34 BB */
669 __le64 LastAccessTime;
670 __le64 LastWriteTime;
672 __le32 FileAttributes;
673 __le64 AllocationSize;
678 __u16 ByteCount; /* bct = 0 */
681 typedef struct smb_com_write_req {
682 struct smb_hdr hdr; /* wct = 14 */
691 __le16 DataLengthHigh;
692 __le16 DataLengthLow;
696 __u8 Pad; /* BB check for whether padded to DWORD boundary and optimum performance here */
700 typedef struct smb_com_write_rsp {
701 struct smb_hdr hdr; /* wct = 6 */
712 typedef struct smb_com_read_req {
713 struct smb_hdr hdr; /* wct = 12 */
720 __le16 MinCount; /* obsolete */
727 typedef struct smb_com_read_rsp {
728 struct smb_hdr hdr; /* wct = 12 */
733 __le16 DataCompactionMode;
737 __le16 DataLengthHigh;
740 __u8 Pad; /* BB check for whether padded to DWORD boundary and optimum performance here */
744 typedef struct locking_andx_range {
751 } LOCKING_ANDX_RANGE;
753 #define LOCKING_ANDX_SHARED_LOCK 0x01
754 #define LOCKING_ANDX_OPLOCK_RELEASE 0x02
755 #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
756 #define LOCKING_ANDX_CANCEL_LOCK 0x08
757 #define LOCKING_ANDX_LARGE_FILES 0x10 /* always on for us */
759 typedef struct smb_com_lock_req {
760 struct smb_hdr hdr; /* wct = 8 */
768 __le16 NumberOfUnlocks;
769 __le16 NumberOfLocks;
771 LOCKING_ANDX_RANGE Locks[1];
775 typedef struct cifs_posix_lock {
776 __le16 lock_type; /* 0 = Read, 1 = Write, 2 = Unlock */
777 __le16 lock_flags; /* 1 = Wait (only valid for setlock) */
781 /* BB what about additional owner info to identify network client */
784 typedef struct smb_com_lock_rsp {
785 struct smb_hdr hdr; /* wct = 2 */
792 typedef struct smb_com_rename_req {
793 struct smb_hdr hdr; /* wct = 1 */
794 __le16 SearchAttributes; /* target file attributes */
796 __u8 BufferFormat; /* 4 = ASCII or Unicode */
797 unsigned char OldFileName[1];
798 /* followed by __u8 BufferFormat2 */
799 /* followed by NewFileName */
802 /* copy request flags */
803 #define COPY_MUST_BE_FILE 0x0001
804 #define COPY_MUST_BE_DIR 0x0002
805 #define COPY_TARGET_MODE_ASCII 0x0004 /* if not set, binary */
806 #define COPY_SOURCE_MODE_ASCII 0x0008 /* if not set, binary */
807 #define COPY_VERIFY_WRITES 0x0010
808 #define COPY_TREE 0x0020
810 typedef struct smb_com_copy_req {
811 struct smb_hdr hdr; /* wct = 3 */
816 __u8 BufferFormat; /* 4 = ASCII or Unicode */
817 unsigned char OldFileName[1];
818 /* followed by __u8 BufferFormat2 */
819 /* followed by NewFileName string */
822 typedef struct smb_com_copy_rsp {
823 struct smb_hdr hdr; /* wct = 1 */
824 __le16 CopyCount; /* number of files copied */
825 __u16 ByteCount; /* may be zero */
826 __u8 BufferFormat; /* 0x04 - only present if errored file follows */
827 unsigned char ErrorFileName[1]; /* only present if error in copy */
830 #define CREATE_HARD_LINK 0x103
831 #define MOVEFILE_COPY_ALLOWED 0x0002
832 #define MOVEFILE_REPLACE_EXISTING 0x0001
834 typedef struct smb_com_nt_rename_req { /* A5 - also used for create hardlink */
835 struct smb_hdr hdr; /* wct = 4 */
836 __le16 SearchAttributes; /* target file attributes */
837 __le16 Flags; /* spec says Information Level */
840 __u8 BufferFormat; /* 4 = ASCII or Unicode */
841 unsigned char OldFileName[1];
842 /* followed by __u8 BufferFormat2 */
843 /* followed by NewFileName */
846 typedef struct smb_com_rename_rsp {
847 struct smb_hdr hdr; /* wct = 0 */
848 __u16 ByteCount; /* bct = 0 */
851 typedef struct smb_com_delete_file_req {
852 struct smb_hdr hdr; /* wct = 1 */
853 __le16 SearchAttributes;
855 __u8 BufferFormat; /* 4 = ASCII */
856 unsigned char fileName[1];
859 typedef struct smb_com_delete_file_rsp {
860 struct smb_hdr hdr; /* wct = 0 */
861 __u16 ByteCount; /* bct = 0 */
864 typedef struct smb_com_delete_directory_req {
865 struct smb_hdr hdr; /* wct = 0 */
867 __u8 BufferFormat; /* 4 = ASCII */
868 unsigned char DirName[1];
869 } DELETE_DIRECTORY_REQ;
871 typedef struct smb_com_delete_directory_rsp {
872 struct smb_hdr hdr; /* wct = 0 */
873 __u16 ByteCount; /* bct = 0 */
874 } DELETE_DIRECTORY_RSP;
876 typedef struct smb_com_create_directory_req {
877 struct smb_hdr hdr; /* wct = 0 */
879 __u8 BufferFormat; /* 4 = ASCII */
880 unsigned char DirName[1];
881 } CREATE_DIRECTORY_REQ;
883 typedef struct smb_com_create_directory_rsp {
884 struct smb_hdr hdr; /* wct = 0 */
885 __u16 ByteCount; /* bct = 0 */
886 } CREATE_DIRECTORY_RSP;
888 typedef struct smb_com_setattr_req {
889 struct smb_hdr hdr; /* wct = 8 */
893 __le16 reserved[5]; /* must be zero */
895 __u8 BufferFormat; /* 4 = ASCII */
896 unsigned char fileName[1];
899 typedef struct smb_com_setattr_rsp {
900 struct smb_hdr hdr; /* wct = 0 */
901 __u16 ByteCount; /* bct = 0 */
904 /* empty wct response to setattr */
906 /***************************************************/
907 /* NT Transact structure defintions follow */
908 /* Currently only ioctl and notify are implemented */
909 /***************************************************/
910 typedef struct smb_com_transaction_ioctl_req {
911 struct smb_hdr hdr; /* wct = 23 */
914 __le32 TotalParameterCount;
915 __le32 TotalDataCount;
916 __le32 MaxParameterCount;
918 __le32 ParameterCount;
919 __le32 ParameterOffset;
922 __u8 SetupCount; /* four setup words follow subcommand */
923 /* SNIA spec incorrectly included spurious pad here */
924 __le16 SubCommand;/* 2 = IOCTL/FSCTL */
927 __u8 IsFsctl; /* 1 = File System Control, 0 = device control (IOCTL)*/
928 __u8 IsRootFlag; /* 1 = apply command to root of share (must be DFS share)*/
932 } TRANSACT_IOCTL_REQ;
934 typedef struct smb_com_transaction_ioctl_rsp {
935 struct smb_hdr hdr; /* wct = 19 */
937 __le32 TotalParameterCount;
938 __le32 TotalDataCount;
939 __le32 ParameterCount;
940 __le32 ParameterOffset;
941 __le32 ParameterDisplacement;
944 __le32 DataDisplacement;
945 __u8 SetupCount; /* 1 */
946 __le16 ReturnedDataLen;
949 } TRANSACT_IOCTL_RSP;
951 typedef struct smb_com_transaction_change_notify_req {
952 struct smb_hdr hdr; /* wct = 23 */
955 __le32 TotalParameterCount;
956 __le32 TotalDataCount;
957 __le32 MaxParameterCount;
959 __le32 ParameterCount;
960 __le32 ParameterOffset;
963 __u8 SetupCount; /* four setup words follow subcommand */
964 /* SNIA spec incorrectly included spurious pad here */
965 __le16 SubCommand;/* 4 = Change Notify */
966 __le32 CompletionFilter; /* operation to monitor */
968 __u8 WatchTree; /* 1 = Monitor subdirectories */
973 } TRANSACT_CHANGE_NOTIFY_REQ;
975 typedef struct smb_com_transaction_change_notify_rsp {
976 struct smb_hdr hdr; /* wct = 18 */
978 __le32 TotalParameterCount;
979 __le32 TotalDataCount;
980 __le32 ParameterCount;
981 __le32 ParameterOffset;
982 __le32 ParameterDisplacement;
985 __le32 DataDisplacement;
986 __u8 SetupCount; /* 0 */
989 } TRANSACT_CHANGE_NOTIFY_RSP;
990 /* Completion Filter flags for Notify */
991 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
992 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
993 #define FILE_NOTIFY_CHANGE_NAME 0x00000003
994 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
995 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
996 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
997 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
998 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
999 #define FILE_NOTIFY_CHANGE_EA 0x00000080
1000 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
1001 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
1002 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
1003 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1005 #define FILE_ACTION_ADDED 0x00000001
1006 #define FILE_ACTION_REMOVED 0x00000002
1007 #define FILE_ACTION_MODIFIED 0x00000003
1008 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
1009 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
1010 #define FILE_ACTION_ADDED_STREAM 0x00000006
1011 #define FILE_ACTION_REMOVED_STREAM 0x00000007
1012 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
1014 /* response contains array of the following structures */
1015 struct file_notify_information {
1016 __le32 NextEntryOffset;
1018 __le32 FileNameLength;
1022 struct reparse_data {
1024 __u16 ReparseDataLength;
1026 __u16 AltNameOffset;
1028 __u16 TargetNameOffset;
1029 __u16 TargetNameLen;
1030 char LinkNamesBuf[1];
1033 struct cifs_quota_data {
1034 __u32 rsrvd1; /* 0 */
1036 __u64 rsrvd2; /* 0 */
1040 char sid[1]; /* variable size? */
1043 /* quota sub commands */
1044 #define QUOTA_LIST_CONTINUE 0
1045 #define QUOTA_LIST_START 0x100
1046 #define QUOTA_FOR_SID 0x101
1049 /* struct smb_hdr hdr precedes. Set wct = 14+ */
1050 __le16 TotalParameterCount;
1051 __le16 TotalDataCount;
1052 __le16 MaxParameterCount;
1053 __le16 MaxDataCount;
1059 __le16 ParameterCount;
1060 __le16 ParameterOffset;
1065 __le16 SubCommand; /* 1st setup word - SetupCount words follow */
1071 struct trans2_req t2_req;
1074 struct trans2_resp {
1075 /* struct smb_hdr hdr precedes. Note wct = 10 + setup count */
1076 __le16 TotalParameterCount;
1077 __le16 TotalDataCount;
1079 __le16 ParameterCount;
1080 __le16 ParameterOffset;
1081 __le16 ParameterDisplacement;
1084 __le16 DataDisplacement;
1087 /* SetupWords[SetupCount];
1090 /* data area follows */
1095 struct trans2_resp t2_rsp;
1098 /* PathInfo/FileInfo infolevels */
1099 #define SMB_INFO_STANDARD 1
1100 #define SMB_SET_FILE_EA 2
1101 #define SMB_QUERY_FILE_EA_SIZE 2
1102 #define SMB_INFO_QUERY_EAS_FROM_LIST 3
1103 #define SMB_INFO_QUERY_ALL_EAS 4
1104 #define SMB_INFO_IS_NAME_VALID 6
1105 #define SMB_QUERY_FILE_BASIC_INFO 0x101
1106 #define SMB_QUERY_FILE_STANDARD_INFO 0x102
1107 #define SMB_QUERY_FILE_EA_INFO 0x103
1108 #define SMB_QUERY_FILE_NAME_INFO 0x104
1109 #define SMB_QUERY_FILE_ALLOCATION_INFO 0x105
1110 #define SMB_QUERY_FILE_END_OF_FILEINFO 0x106
1111 #define SMB_QUERY_FILE_ALL_INFO 0x107
1112 #define SMB_QUERY_ALT_NAME_INFO 0x108
1113 #define SMB_QUERY_FILE_STREAM_INFO 0x109
1114 #define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
1115 #define SMB_QUERY_FILE_UNIX_BASIC 0x200
1116 #define SMB_QUERY_FILE_UNIX_LINK 0x201
1117 #define SMB_QUERY_POSIX_ACL 0x204
1118 #define SMB_QUERY_XATTR 0x205
1119 #define SMB_QUERY_ATTR_FLAGS 0x206 /* append,immutable etc. */
1120 #define SMB_QUERY_POSIX_PERMISSION 0x207
1121 #define SMB_QUERY_POSIX_LOCK 0x208
1122 #define SMB_QUERY_FILE_INTERNAL_INFO 0x3ee
1123 #define SMB_QUERY_FILE_ACCESS_INFO 0x3f0
1124 #define SMB_QUERY_FILE_NAME_INFO2 0x3f1 /* 0x30 bytes */
1125 #define SMB_QUERY_FILE_POSITION_INFO 0x3f6
1126 #define SMB_QUERY_FILE_MODE_INFO 0x3f8
1127 #define SMB_QUERY_FILE_ALGN_INFO 0x3f9
1130 #define SMB_SET_FILE_BASIC_INFO 0x101
1131 #define SMB_SET_FILE_DISPOSITION_INFO 0x102
1132 #define SMB_SET_FILE_ALLOCATION_INFO 0x103
1133 #define SMB_SET_FILE_END_OF_FILE_INFO 0x104
1134 #define SMB_SET_FILE_UNIX_BASIC 0x200
1135 #define SMB_SET_FILE_UNIX_LINK 0x201
1136 #define SMB_SET_FILE_UNIX_HLINK 0x203
1137 #define SMB_SET_POSIX_ACL 0x204
1138 #define SMB_SET_XATTR 0x205
1139 #define SMB_SET_ATTR_FLAGS 0x206 /* append, immutable etc. */
1140 #define SMB_SET_POSIX_LOCK 0x208
1141 #define SMB_SET_FILE_BASIC_INFO2 0x3ec
1142 #define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo level too */
1143 #define SMB_FILE_ALL_INFO2 0x3fa
1144 #define SMB_SET_FILE_ALLOCATION_INFO2 0x3fb
1145 #define SMB_SET_FILE_END_OF_FILE_INFO2 0x3fc
1146 #define SMB_FILE_MOVE_CLUSTER_INFO 0x407
1147 #define SMB_FILE_QUOTA_INFO 0x408
1148 #define SMB_FILE_REPARSEPOINT_INFO 0x409
1149 #define SMB_FILE_MAXIMUM_INFO 0x40d
1151 /* Find File infolevels */
1152 #define SMB_FIND_FILE_DIRECTORY_INFO 0x101
1153 #define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
1154 #define SMB_FIND_FILE_NAMES_INFO 0x103
1155 #define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
1156 #define SMB_FIND_FILE_ID_FULL_DIR_INFO 0x105
1157 #define SMB_FIND_FILE_ID_BOTH_DIR_INFO 0x106
1158 #define SMB_FIND_FILE_UNIX 0x202
1160 typedef struct smb_com_transaction2_qpi_req {
1161 struct smb_hdr hdr; /* wct = 14+ */
1162 __le16 TotalParameterCount;
1163 __le16 TotalDataCount;
1164 __le16 MaxParameterCount;
1165 __le16 MaxDataCount;
1171 __le16 ParameterCount;
1172 __le16 ParameterOffset;
1177 __le16 SubCommand; /* one setup word */
1180 __le16 InformationLevel;
1183 } TRANSACTION2_QPI_REQ;
1185 typedef struct smb_com_transaction2_qpi_rsp {
1186 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1187 struct trans2_resp t2;
1189 __u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */
1190 } TRANSACTION2_QPI_RSP;
1192 typedef struct smb_com_transaction2_spi_req {
1193 struct smb_hdr hdr; /* wct = 15 */
1194 __le16 TotalParameterCount;
1195 __le16 TotalDataCount;
1196 __le16 MaxParameterCount;
1197 __le16 MaxDataCount;
1203 __le16 ParameterCount;
1204 __le16 ParameterOffset;
1209 __le16 SubCommand; /* one setup word */
1213 __le16 InformationLevel;
1216 } TRANSACTION2_SPI_REQ;
1218 typedef struct smb_com_transaction2_spi_rsp {
1219 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1220 struct trans2_resp t2;
1222 __u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */
1223 } TRANSACTION2_SPI_RSP;
1225 struct set_file_rename {
1226 __le32 overwrite; /* 1 = overwrite dest */
1227 __u32 root_fid; /* zero */
1228 __le32 target_name_len;
1229 char target_name[0]; /* Must be unicode */
1232 struct smb_com_transaction2_sfi_req {
1233 struct smb_hdr hdr; /* wct = 15 */
1234 __le16 TotalParameterCount;
1235 __le16 TotalDataCount;
1236 __le16 MaxParameterCount;
1237 __le16 MaxDataCount;
1243 __le16 ParameterCount;
1244 __le16 ParameterOffset;
1249 __le16 SubCommand; /* one setup word */
1254 __le16 InformationLevel;
1258 struct smb_com_transaction2_sfi_rsp {
1259 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1260 struct trans2_resp t2;
1262 __u16 Reserved2; /* parameter word reserved -
1263 present for infolevels > 100 */
1266 struct smb_t2_qfi_req {
1268 struct trans2_req t2;
1271 __le16 InformationLevel;
1274 struct smb_t2_qfi_rsp {
1275 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1276 struct trans2_resp t2;
1278 __u16 Reserved2; /* parameter word reserved -
1279 present for infolevels > 100 */
1283 * Flags on T2 FINDFIRST and FINDNEXT
1285 #define CIFS_SEARCH_CLOSE_ALWAYS 0x0001
1286 #define CIFS_SEARCH_CLOSE_AT_END 0x0002
1287 #define CIFS_SEARCH_RETURN_RESUME 0x0004
1288 #define CIFS_SEARCH_CONTINUE_FROM_LAST 0x0008
1289 #define CIFS_SEARCH_BACKUP_SEARCH 0x0010
1292 * Size of the resume key on FINDFIRST and FINDNEXT calls
1294 #define CIFS_SMB_RESUME_KEY_SIZE 4
1296 typedef struct smb_com_transaction2_ffirst_req {
1297 struct smb_hdr hdr; /* wct = 15 */
1298 __le16 TotalParameterCount;
1299 __le16 TotalDataCount;
1300 __le16 MaxParameterCount;
1301 __le16 MaxDataCount;
1307 __le16 ParameterCount;
1308 __le16 ParameterOffset;
1311 __u8 SetupCount; /* one */
1313 __le16 SubCommand; /* TRANS2_FIND_FIRST */
1316 __le16 SearchAttributes;
1319 __le16 InformationLevel;
1320 __le32 SearchStorageType;
1322 } TRANSACTION2_FFIRST_REQ;
1324 typedef struct smb_com_transaction2_ffirst_rsp {
1325 struct smb_hdr hdr; /* wct = 10 */
1326 struct trans2_resp t2;
1328 } TRANSACTION2_FFIRST_RSP;
1330 typedef struct smb_com_transaction2_ffirst_rsp_parms {
1334 __le16 EAErrorOffset;
1335 __le16 LastNameOffset;
1336 } T2_FFIRST_RSP_PARMS;
1338 typedef struct smb_com_transaction2_fnext_req {
1339 struct smb_hdr hdr; /* wct = 15 */
1340 __le16 TotalParameterCount;
1341 __le16 TotalDataCount;
1342 __le16 MaxParameterCount;
1343 __le16 MaxDataCount;
1349 __le16 ParameterCount;
1350 __le16 ParameterOffset;
1353 __u8 SetupCount; /* one */
1355 __le16 SubCommand; /* TRANS2_FIND_NEXT */
1360 __le16 InformationLevel;
1363 char ResumeFileName[1];
1364 } TRANSACTION2_FNEXT_REQ;
1366 typedef struct smb_com_transaction2_fnext_rsp {
1367 struct smb_hdr hdr; /* wct = 10 */
1368 struct trans2_resp t2;
1370 } TRANSACTION2_FNEXT_RSP;
1372 typedef struct smb_com_transaction2_fnext_rsp_parms {
1375 __le16 EAErrorOffset;
1376 __le16 LastNameOffset;
1377 } T2_FNEXT_RSP_PARMS;
1379 /* QFSInfo Levels */
1380 #define SMB_INFO_ALLOCATION 1
1381 #define SMB_INFO_VOLUME 2
1382 #define SMB_QUERY_FS_VOLUME_INFO 0x102
1383 #define SMB_QUERY_FS_SIZE_INFO 0x103
1384 #define SMB_QUERY_FS_DEVICE_INFO 0x104
1385 #define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
1386 #define SMB_QUERY_CIFS_UNIX_INFO 0x200
1387 #define SMB_QUERY_POSIX_FS_INFO 0x201
1388 #define SMB_QUERY_LABEL_INFO 0x3ea
1389 #define SMB_QUERY_FS_QUOTA_INFO 0x3ee
1390 #define SMB_QUERY_FS_FULL_SIZE_INFO 0x3ef
1391 #define SMB_QUERY_OBJECTID_INFO 0x3f0
1393 typedef struct smb_com_transaction2_qfsi_req {
1394 struct smb_hdr hdr; /* wct = 14+ */
1395 __le16 TotalParameterCount;
1396 __le16 TotalDataCount;
1397 __le16 MaxParameterCount;
1398 __le16 MaxDataCount;
1404 __le16 ParameterCount;
1405 __le16 ParameterOffset;
1410 __le16 SubCommand; /* one setup word */
1413 __le16 InformationLevel;
1414 } TRANSACTION2_QFSI_REQ;
1416 typedef struct smb_com_transaction_qfsi_rsp {
1417 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1418 struct trans2_resp t2;
1420 __u8 Pad; /* may be three bytes *//* followed by data area */
1421 } TRANSACTION2_QFSI_RSP;
1424 /* SETFSInfo Levels */
1425 #define SMB_SET_CIFS_UNIX_INFO 0x200
1426 typedef struct smb_com_transaction2_setfsi_req {
1427 struct smb_hdr hdr; /* wct = 15 */
1428 __le16 TotalParameterCount;
1429 __le16 TotalDataCount;
1430 __le16 MaxParameterCount;
1431 __le16 MaxDataCount;
1437 __le16 ParameterCount; /* 4 */
1438 __le16 ParameterOffset;
1439 __le16 DataCount; /* 12 */
1441 __u8 SetupCount; /* one */
1443 __le16 SubCommand; /* TRANS2_SET_FS_INFORMATION */
1446 __u16 FileNum; /* Parameters start. */
1447 __le16 InformationLevel;/* Parameters end. */
1448 __le16 ClientUnixMajor; /* Data start. */
1449 __le16 ClientUnixMinor;
1450 __le64 ClientUnixCap; /* Data end */
1451 } TRANSACTION2_SETFSI_REQ;
1453 typedef struct smb_com_transaction2_setfsi_rsp {
1454 struct smb_hdr hdr; /* wct = 10 */
1455 struct trans2_resp t2;
1457 } TRANSACTION2_SETFSI_RSP;
1460 typedef struct smb_com_transaction2_get_dfs_refer_req {
1461 struct smb_hdr hdr; /* wct = 15 */
1462 __le16 TotalParameterCount;
1463 __le16 TotalDataCount;
1464 __le16 MaxParameterCount;
1465 __le16 MaxDataCount;
1471 __le16 ParameterCount;
1472 __le16 ParameterOffset;
1477 __le16 SubCommand; /* one setup word */
1479 __u8 Pad[3]; /* Win2K has sent 0x0F01 (max resp length perhaps?) followed by one byte pad - doesn't seem to matter though */
1480 __le16 MaxReferralLevel;
1481 char RequestFileName[1];
1482 } TRANSACTION2_GET_DFS_REFER_REQ;
1484 typedef struct dfs_referral_level_3 {
1485 __le16 VersionNumber;
1486 __le16 ReferralSize;
1487 __le16 ServerType; /* 0x0001 = CIFS server */
1488 __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 */
1491 __le16 DfsPathOffset;
1492 __le16 DfsAlternatePathOffset;
1493 __le16 NetworkAddressOffset;
1496 typedef struct smb_com_transaction_get_dfs_refer_rsp {
1497 struct smb_hdr hdr; /* wct = 10 */
1498 struct trans2_resp t2;
1501 __le16 PathConsumed;
1502 __le16 NumberOfReferrals;
1505 REFERRAL3 referrals[1]; /* array of level 3 dfs_referral structures */
1506 /* followed by the strings pointed to by the referral structures */
1507 } TRANSACTION2_GET_DFS_REFER_RSP;
1510 #define DFSREF_REFERRAL_SERVER 0x0001
1511 #define DFSREF_STORAGE_SERVER 0x0002
1513 /* IOCTL information */
1514 /* List of ioctl function codes that look to be of interest to remote clients like this. */
1515 /* Need to do some experimentation to make sure they all work remotely. */
1516 /* Some of the following such as the encryption/compression ones would be */
1517 /* invoked from tools via a specialized hook into the VFS rather than via the */
1518 /* standard vfs entry points */
1519 #define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000
1520 #define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004
1521 #define FSCTL_REQUEST_BATCH_OPLOCK 0x00090008
1522 #define FSCTL_LOCK_VOLUME 0x00090018
1523 #define FSCTL_UNLOCK_VOLUME 0x0009001C
1524 #define FSCTL_GET_COMPRESSION 0x0009003C
1525 #define FSCTL_SET_COMPRESSION 0x0009C040
1526 #define FSCTL_REQUEST_FILTER_OPLOCK 0x0009008C
1527 #define FSCTL_FILESYS_GET_STATISTICS 0x00090090
1528 #define FSCTL_SET_REPARSE_POINT 0x000900A4
1529 #define FSCTL_GET_REPARSE_POINT 0x000900A8
1530 #define FSCTL_DELETE_REPARSE_POINT 0x000900AC
1531 #define FSCTL_SET_SPARSE 0x000900C4
1532 #define FSCTL_SET_ZERO_DATA 0x000900C8
1533 #define FSCTL_SET_ENCRYPTION 0x000900D7
1534 #define FSCTL_ENCRYPTION_FSCTL_IO 0x000900DB
1535 #define FSCTL_WRITE_RAW_ENCRYPTED 0x000900DF
1536 #define FSCTL_READ_RAW_ENCRYPTED 0x000900E3
1537 #define FSCTL_SIS_COPYFILE 0x00090100
1538 #define FSCTL_SIS_LINK_FILES 0x0009C104
1540 #define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003
1541 #define IO_REPARSE_TAG_HSM 0xC0000004
1542 #define IO_REPARSE_TAG_SIS 0x80000007
1545 ************************************************************************
1546 * All structs for everything above the SMB PDUs themselves
1547 * (such as the T2 level specific data) go here
1548 ************************************************************************
1552 * Information on a server
1557 unsigned char versionMajor;
1558 unsigned char versionMinor;
1560 unsigned int commentOffset;
1564 * The following structure is the format of the data returned on a NetShareEnum
1565 * with level "90" (x5A)
1571 unsigned short type;
1572 unsigned int commentOffset;
1578 unsigned int commentOffset;
1579 unsigned char type[2];
1582 struct aliasInfo92 {
1583 int aliasNameOffset;
1584 int serverNameOffset;
1585 int shareNameOffset;
1589 __le64 TotalAllocationUnits;
1590 __le64 FreeAllocationUnits;
1591 __le32 SectorsPerAllocationUnit;
1592 __le32 BytesPerSector;
1593 } FILE_SYSTEM_INFO; /* size info, level 0x103 */
1596 __le16 MajorVersionNumber;
1597 __le16 MinorVersionNumber;
1599 } FILE_SYSTEM_UNIX_INFO; /* Unix extensions info, level 0x200 */
1601 /* Version numbers for CIFS UNIX major and minor. */
1602 #define CIFS_UNIX_MAJOR_VERSION 1
1603 #define CIFS_UNIX_MINOR_VERSION 0
1605 /* Linux/Unix extensions capability flags */
1606 #define CIFS_UNIX_FCNTL_CAP 0x00000001 /* support for fcntl locks */
1607 #define CIFS_UNIX_POSIX_ACL_CAP 0x00000002 /* support getfacl/setfacl */
1608 #define CIFS_UNIX_XATTR_CAP 0x00000004 /* support new namespace */
1609 #define CIFS_UNIX_EXTATTR_CAP 0x00000008 /* support chattr/chflag */
1610 #define CIFS_UNIX_POSIX_PATHNAMES_CAP 0x00000010 /* Use POSIX pathnames on the wire. */
1612 #define CIFS_POSIX_EXTENSIONS 0x00000010 /* support for new QFSInfo */
1615 /* For undefined recommended transfer size return -1 in that field */
1616 __le32 OptimalTransferSize; /* bsize on some os, iosize on other os */
1618 /* The next three fields are in terms of the block size.
1619 (above). If block size is unknown, 4096 would be a
1620 reasonable block size for a server to report.
1621 Note that returning the blocks/blocksavail removes need
1622 to make a second call (to QFSInfo level 0x103 to get this info.
1623 UserBlockAvail is typically less than or equal to BlocksAvail,
1624 if no distinction is made return the same value in each */
1626 __le64 BlocksAvail; /* bfree */
1627 __le64 UserBlocksAvail; /* bavail */
1628 /* For undefined Node fields or FSID return -1 */
1629 __le64 TotalFileNodes;
1630 __le64 FreeFileNodes;
1631 __le64 FileSysIdentifier; /* fsid */
1632 /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
1633 /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */
1634 } FILE_SYSTEM_POSIX_INFO;
1636 /* DeviceType Flags */
1637 #define FILE_DEVICE_CD_ROM 0x00000002
1638 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
1639 #define FILE_DEVICE_DFS 0x00000006
1640 #define FILE_DEVICE_DISK 0x00000007
1641 #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
1642 #define FILE_DEVICE_FILE_SYSTEM 0x00000009
1643 #define FILE_DEVICE_NAMED_PIPE 0x00000011
1644 #define FILE_DEVICE_NETWORK 0x00000012
1645 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
1646 #define FILE_DEVICE_NULL 0x00000015
1647 #define FILE_DEVICE_PARALLEL_PORT 0x00000016
1648 #define FILE_DEVICE_PRINTER 0x00000018
1649 #define FILE_DEVICE_SERIAL_PORT 0x0000001b
1650 #define FILE_DEVICE_STREAMS 0x0000001e
1651 #define FILE_DEVICE_TAPE 0x0000001f
1652 #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
1653 #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
1654 #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
1658 __le32 DeviceCharacteristics;
1659 } FILE_SYSTEM_DEVICE_INFO; /* device info, level 0x104 */
1663 __le32 MaxPathNameComponentLength;
1664 __le32 FileSystemNameLen;
1665 char FileSystemName[52]; /* do not really need to save this - so potentially get only subset of name */
1666 } FILE_SYSTEM_ATTRIBUTE_INFO;
1668 /******************************************************************************/
1669 /* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
1670 /******************************************************************************/
1671 typedef struct { /* data block encoding of response to level 263 QPathInfo */
1672 __le64 CreationTime;
1673 __le64 LastAccessTime;
1674 __le64 LastWriteTime;
1678 __le64 AllocationSize;
1679 __le64 EndOfFile; /* size ie offset to first free byte in file */
1680 __le32 NumberOfLinks; /* hard links */
1688 __le64 CurrentByteOffset;
1690 __le32 AlignmentRequirement;
1691 __le32 FileNameLength;
1693 } FILE_ALL_INFO; /* level 0x107 QPathInfo */
1695 /* defines for enumerating possible values of the Unix type field below */
1698 #define UNIX_SYMLINK 2
1699 #define UNIX_CHARDEV 3
1700 #define UNIX_BLOCKDEV 4
1702 #define UNIX_SOCKET 6
1706 __le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */
1707 __le64 LastAccessTime;
1708 __le64 LastModificationTime;
1717 } FILE_UNIX_BASIC_INFO; /* level 0x200 QPathInfo */
1721 } FILE_UNIX_LINK_INFO; /* level 0x201 QPathInfo */
1723 /* The following three structures are needed only for
1724 setting time to NT4 and some older servers via
1725 the primitive DOS time format */
1739 __le16 CreationDate; /* SMB Date see above */
1740 __le16 CreationTime; /* SMB Time */
1741 __le16 LastAccessDate;
1742 __le16 LastAccessTime;
1743 __le16 LastWriteDate;
1744 __le16 LastWriteTime;
1745 __le32 DataSize; /* File Size (EOF) */
1746 __le32 AllocationSize;
1747 __le16 Attributes; /* verify not u32 */
1749 } FILE_INFO_STANDARD; /* level 1 SetPath/FileInfo */
1752 __le64 CreationTime;
1753 __le64 LastAccessTime;
1754 __le64 LastWriteTime;
1758 } FILE_BASIC_INFO; /* size info, level 0x101 */
1760 struct file_allocation_info {
1761 __le64 AllocationSize; /* Note old Samba srvr rounds this up too much */
1762 }; /* size used on disk, level 0x103 for set, 0x105 for query */
1764 struct file_end_of_file_info {
1765 __le64 FileSize; /* offset to end of file */
1766 }; /* size info, level 0x104 for set, 0x106 for query */
1768 struct file_alt_name_info {
1770 }; /* level 0x0108 */
1772 struct file_stream_info {
1773 __le32 number_of_streams; /* BB check sizes and verify location */
1774 /* followed by info on streams themselves
1778 }; /* level 0x109 */
1780 struct file_compression_info {
1781 __le64 compressed_size;
1787 }; /* level 0x10b */
1789 /* POSIX ACL set/query path info structures */
1790 #define CIFS_ACL_VERSION 1
1791 struct cifs_posix_ace { /* access control entry (ACE) */
1794 __le64 cifs_uid; /* or gid */
1797 struct cifs_posix_acl { /* access conrol list (ACL) */
1799 __le16 access_entry_count; /* access ACL - count of entries */
1800 __le16 default_entry_count; /* default ACL - count of entries */
1801 struct cifs_posix_ace ace_array[0];
1803 struct cifs_posix_ace default_ace_arraay[] */
1804 }; /* level 0x204 */
1806 /* types of access control entries already defined in posix_acl.h */
1807 /* #define CIFS_POSIX_ACL_USER_OBJ 0x01
1808 #define CIFS_POSIX_ACL_USER 0x02
1809 #define CIFS_POSIX_ACL_GROUP_OBJ 0x04
1810 #define CIFS_POSIX_ACL_GROUP 0x08
1811 #define CIFS_POSIX_ACL_MASK 0x10
1812 #define CIFS_POSIX_ACL_OTHER 0x20 */
1814 /* types of perms */
1815 /* #define CIFS_POSIX_ACL_EXECUTE 0x01
1816 #define CIFS_POSIX_ACL_WRITE 0x02
1817 #define CIFS_POSIX_ACL_READ 0x04 */
1819 /* end of POSIX ACL definitions */
1821 struct file_internal_info {
1822 __u64 UniqueId; /* inode number */
1823 }; /* level 0x3ee */
1824 struct file_mode_info {
1826 }; /* level 0x3f8 */
1828 struct file_attrib_tag {
1831 }; /* level 0x40b */
1834 /********************************************************/
1835 /* FindFirst/FindNext transact2 data buffer formats */
1836 /********************************************************/
1839 __le32 NextEntryOffset;
1840 __u32 ResumeKey; /* as with FileIndex - no need to convert */
1843 __le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */
1844 __le64 LastAccessTime;
1845 __le64 LastModificationTime;
1855 } FILE_UNIX_INFO; /* level 0x202 */
1858 __le32 NextEntryOffset;
1860 __le64 CreationTime;
1861 __le64 LastAccessTime;
1862 __le64 LastWriteTime;
1865 __le64 AllocationSize;
1866 __le32 ExtFileAttributes;
1867 __le32 FileNameLength;
1869 } FILE_DIRECTORY_INFO; /* level 0x101 FF response data area */
1872 __le32 NextEntryOffset;
1874 __le64 CreationTime;
1875 __le64 LastAccessTime;
1876 __le64 LastWriteTime;
1879 __le64 AllocationSize;
1880 __le32 ExtFileAttributes;
1881 __le32 FileNameLength;
1882 __le32 EaSize; /* length of the xattrs */
1884 } FILE_FULL_DIRECTORY_INFO; /* level 0x102 FF response data area */
1887 __le32 NextEntryOffset;
1889 __le64 CreationTime;
1890 __le64 LastAccessTime;
1891 __le64 LastWriteTime;
1894 __le64 AllocationSize;
1895 __le32 ExtFileAttributes;
1896 __le32 FileNameLength;
1897 __le32 EaSize; /* EA size */
1899 __u64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
1901 } SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF response data area */
1904 __le32 NextEntryOffset;
1906 __le64 CreationTime;
1907 __le64 LastAccessTime;
1908 __le64 LastWriteTime;
1911 __le64 AllocationSize;
1912 __le32 ExtFileAttributes;
1913 __le32 FileNameLength;
1914 __le32 EaSize; /* length of the xattrs */
1915 __u8 ShortNameLength;
1919 } FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FF response data area */
1923 unsigned char name_len;
1928 unsigned long list_len;
1933 unsigned char EA_flags;
1937 /* optionally followed by value */
1939 /* flags for _FEA.fEA */
1940 #define FEA_NEEDEA 0x80 /* need EA bit */
1947 /* used to hold an arbitrary blob of data */
1951 void (*free) (struct data_blob * data_blob);
1955 #ifdef CONFIG_CIFS_POSIX
1957 For better POSIX semantics from Linux client, (even better
1958 than the existing CIFS Unix Extensions) we need updated PDUs for:
1960 1) PosixCreateX - to set and return the mode, inode#, device info and
1961 perhaps add a CreateDevice - to create Pipes and other special .inodes
1962 Also note POSIX open flags
1963 2) Close - to return the last write time to do cache across close more safely
1964 3) PosixQFSInfo - to return statfs info
1965 4) FindFirst return unique inode number - what about resume key, two forms short (matches readdir) and full (enough info to cache inodes)
1968 And under consideration:
1969 6) FindClose2 (return nanosecond timestamp ??)
1970 7) Use nanosecond timestamps throughout all time fields if
1971 corresponding attribute flag is set
1972 8) sendfile - handle based copy
1974 10) "POSIX ACL" support
1977 what about fixing 64 bit alignment
1979 There are also various legacy SMB/CIFS requests used as is
1981 From existing Lanman and NTLM dialects:
1982 --------------------------------------
1984 SESSION_SETUP_ANDX (BB which?)
1985 TREE_CONNECT_ANDX (BB which wct?)
1986 TREE_DISCONNECT (BB add volume timestamp on response)
1988 DELETE (note delete open file behavior)
1992 LOCKING_AND_X (note posix lock semantics)
1993 RENAME (note rename across dirs and open file rename posix behaviors)
1994 NT_RENAME (for hardlinks) Is this good enough for all features?
1996 TRANSACTION2 (18 cases)
1997 SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2
1998 (BB verify that never need to set allocation size)
1999 SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via Unix ext?)
2001 COPY (note support for copy across directories) - FUTURE, OPTIONAL
2002 setting/getting OS/2 EAs - FUTURE (BB can this handle
2003 setting Linux xattrs perfectly) - OPTIONAL
2004 dnotify - FUTURE, OPTIONAL
2005 quota - FUTURE, OPTIONAL
2007 Note that various requests implemented for NT interop such as
2008 NT_TRANSACT (IOCTL) QueryReparseInfo
2009 are unneeded to servers compliant with the CIFS POSIX extensions
2011 From CIFS Unix Extensions:
2012 -------------------------
2013 T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks
2014 T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2)
2015 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK)
2016 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC) - BB check for missing inode fields
2017 Actually need QUERY_FILE_UNIX_INFO since has inode num
2018 BB what about a) blksize/blkbits/blocks
2024 T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX
2025 TRANS2_GET_DFS_REFERRAL - OPTIONAL but recommended
2026 T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL
2031 /* xsymlink is a symlink format that can be used
2032 to save symlink info in a regular file when
2033 mounted to operating systems that do not
2034 support the cifs Unix extensions or EAs (for xattr
2035 based symlinks). For such a file to be recognized
2036 as containing symlink data:
2038 1) file size must be 1067,
2039 2) signature must begin file data,
2040 3) length field must be set to ASCII representation
2041 of a number which is less than or equal to 1024,
2042 4) md5 must match that of the path data */
2046 char signature[4]; /* XSym */ /* not null terminated */
2048 /* ASCII representation of length (4 bytes decimal) terminated by \n not null */
2051 /* md5 of valid subset of path ie path[0] through path[length-1] */
2054 /* if room left, then end with \n then 0x20s by convention but not required */
2058 typedef struct file_xattr_info {
2059 /* BB do we need another field for flags? BB */
2060 __u32 xattr_name_len;
2061 __u32 xattr_value_len;
2063 /* followed by xattr_value[xattr_value_len], no pad */
2064 } FILE_XATTR_INFO; /* extended attribute, info level 0x205 */
2067 /* flags for chattr command */
2068 #define EXT_SECURE_DELETE 0x00000001 /* EXT3_SECRM_FL */
2069 #define EXT_ENABLE_UNDELETE 0x00000002 /* EXT3_UNRM_FL */
2070 /* Reserved for compress file 0x4 */
2071 #define EXT_SYNCHRONOUS 0x00000008 /* EXT3_SYNC_FL */
2072 #define EXT_IMMUTABLE_FL 0x00000010 /* EXT3_IMMUTABLE_FL */
2073 #define EXT_OPEN_APPEND_ONLY 0x00000020 /* EXT3_APPEND_FL */
2074 #define EXT_DO_NOT_BACKUP 0x00000040 /* EXT3_NODUMP_FL */
2075 #define EXT_NO_UPDATE_ATIME 0x00000080 /* EXT3_NOATIME_FL */
2076 /* 0x100 through 0x800 reserved for compression flags and are GET-ONLY */
2077 #define EXT_HASH_TREE_INDEXED_DIR 0x00001000 /* GET-ONLY EXT3_INDEX_FL */
2078 /* 0x2000 reserved for IMAGIC_FL */
2079 #define EXT_JOURNAL_THIS_FILE 0x00004000 /* GET-ONLY EXT3_JOURNAL_DATA_FL */
2080 /* 0x8000 reserved for EXT3_NOTAIL_FL */
2081 #define EXT_SYNCHRONOUS_DIR 0x00010000 /* EXT3_DIRSYNC_FL */
2082 #define EXT_TOPDIR 0x00020000 /* EXT3_TOPDIR_FL */
2084 #define EXT_SET_MASK 0x000300FF
2085 #define EXT_GET_MASK 0x0003DFFF
2087 typedef struct file_chattr_info {
2088 __le64 mask; /* list of all possible attribute bits */
2089 __le64 mode; /* list of actual attribute bits on this inode */
2090 } FILE_CHATTR_INFO; /* ext attributes (chattr, chflags) level 0x206 */
2094 #pragma pack() /* resume default structure packing */
2096 #endif /* _CIFSPDU_H */