4 * Copyright (c) International Business Machines Corp., 2002,2009
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 #ifdef CONFIG_CIFS_WEAK_PW_HASH
30 #define LANMAN2_PROT 1
35 #define POSIX_PROT (CIFS_PROT+1)
36 #define BAD_PROT 0xFFFF
39 * Note some commands have minimal (wct=0,bcc=0), or uninteresting, responses
40 * (ie which include no useful data other than the SMB error code itself).
41 * This can allow us to avoid response buffer allocations and copy in some cases
43 #define SMB_COM_CREATE_DIRECTORY 0x00 /* trivial response */
44 #define SMB_COM_DELETE_DIRECTORY 0x01 /* trivial response */
45 #define SMB_COM_CLOSE 0x04 /* triv req/rsp, timestamp ignored */
46 #define SMB_COM_FLUSH 0x05 /* triv req/rsp */
47 #define SMB_COM_DELETE 0x06 /* trivial response */
48 #define SMB_COM_RENAME 0x07 /* trivial response */
49 #define SMB_COM_QUERY_INFORMATION 0x08 /* aka getattr */
50 #define SMB_COM_SETATTR 0x09 /* trivial response */
51 #define SMB_COM_LOCKING_ANDX 0x24 /* trivial response */
52 #define SMB_COM_COPY 0x29 /* trivial rsp, fail filename ignrd*/
53 #define SMB_COM_ECHO 0x2B /* echo request */
54 #define SMB_COM_OPEN_ANDX 0x2D /* Legacy open for old servers */
55 #define SMB_COM_READ_ANDX 0x2E
56 #define SMB_COM_WRITE_ANDX 0x2F
57 #define SMB_COM_TRANSACTION2 0x32
58 #define SMB_COM_TRANSACTION2_SECONDARY 0x33
59 #define SMB_COM_FIND_CLOSE2 0x34 /* trivial response */
60 #define SMB_COM_TREE_DISCONNECT 0x71 /* trivial response */
61 #define SMB_COM_NEGOTIATE 0x72
62 #define SMB_COM_SESSION_SETUP_ANDX 0x73
63 #define SMB_COM_LOGOFF_ANDX 0x74 /* trivial response */
64 #define SMB_COM_TREE_CONNECT_ANDX 0x75
65 #define SMB_COM_NT_TRANSACT 0xA0
66 #define SMB_COM_NT_TRANSACT_SECONDARY 0xA1
67 #define SMB_COM_NT_CREATE_ANDX 0xA2
68 #define SMB_COM_NT_CANCEL 0xA4 /* no response */
69 #define SMB_COM_NT_RENAME 0xA5 /* trivial response */
71 /* Transact2 subcommand codes */
72 #define TRANS2_OPEN 0x00
73 #define TRANS2_FIND_FIRST 0x01
74 #define TRANS2_FIND_NEXT 0x02
75 #define TRANS2_QUERY_FS_INFORMATION 0x03
76 #define TRANS2_SET_FS_INFORMATION 0x04
77 #define TRANS2_QUERY_PATH_INFORMATION 0x05
78 #define TRANS2_SET_PATH_INFORMATION 0x06
79 #define TRANS2_QUERY_FILE_INFORMATION 0x07
80 #define TRANS2_SET_FILE_INFORMATION 0x08
81 #define TRANS2_GET_DFS_REFERRAL 0x10
82 #define TRANS2_REPORT_DFS_INCOSISTENCY 0x11
84 /* SMB Transact (Named Pipe) subcommand codes */
85 #define TRANS_SET_NMPIPE_STATE 0x0001
86 #define TRANS_RAW_READ_NMPIPE 0x0011
87 #define TRANS_QUERY_NMPIPE_STATE 0x0021
88 #define TRANS_QUERY_NMPIPE_INFO 0x0022
89 #define TRANS_PEEK_NMPIPE 0x0023
90 #define TRANS_TRANSACT_NMPIPE 0x0026
91 #define TRANS_RAW_WRITE_NMPIPE 0x0031
92 #define TRANS_READ_NMPIPE 0x0036
93 #define TRANS_WRITE_NMPIPE 0x0037
94 #define TRANS_WAIT_NMPIPE 0x0053
95 #define TRANS_CALL_NMPIPE 0x0054
97 /* NT Transact subcommand codes */
98 #define NT_TRANSACT_CREATE 0x01
99 #define NT_TRANSACT_IOCTL 0x02
100 #define NT_TRANSACT_SET_SECURITY_DESC 0x03
101 #define NT_TRANSACT_NOTIFY_CHANGE 0x04
102 #define NT_TRANSACT_RENAME 0x05
103 #define NT_TRANSACT_QUERY_SECURITY_DESC 0x06
104 #define NT_TRANSACT_GET_USER_QUOTA 0x07
105 #define NT_TRANSACT_SET_USER_QUOTA 0x08
107 #define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */
108 /* future chained NTCreateXReadX bigger, but for time being NTCreateX biggest */
109 /* among the requests (NTCreateX response is bigger with wct of 34) */
110 #define MAX_CIFS_HDR_SIZE 0x58 /* 4 len + 32 hdr + (2*24 wct) + 2 bct + 2 pad */
111 #define CIFS_SMALL_PATH 120 /* allows for (448-88)/3 */
113 /* internal cifs vfs structures */
114 /*****************************************************************
115 * All constants go here
116 *****************************************************************
120 * Starting value for maximum SMB size negotiation
122 #define CIFS_MAX_MSGSIZE (4*4096)
125 * Size of encrypted user password in bytes
127 #define CIFS_ENCPWD_SIZE (16)
130 * Size of the crypto key returned on the negotiate SMB in bytes
132 #define CIFS_CRYPTO_KEY_SIZE (8)
135 * Size of the ntlm client response
137 #define CIFS_AUTH_RESP_SIZE (24)
140 * Size of the session key (crypto key encrypted with the password
142 #define CIFS_SESS_KEY_SIZE (16)
144 #define CIFS_CLIENT_CHALLENGE_SIZE (8)
145 #define CIFS_SERVER_CHALLENGE_SIZE (8)
146 #define CIFS_HMAC_MD5_HASH_SIZE (16)
147 #define CIFS_CPHTXT_SIZE (16)
148 #define CIFS_NTHASH_SIZE (16)
151 * Maximum user name length
153 #define CIFS_UNLEN (20)
158 #define SMBOPEN_WRITE_THROUGH 0x4000
159 #define SMBOPEN_DENY_ALL 0x0010
160 #define SMBOPEN_DENY_WRITE 0x0020
161 #define SMBOPEN_DENY_READ 0x0030
162 #define SMBOPEN_DENY_NONE 0x0040
163 #define SMBOPEN_READ 0x0000
164 #define SMBOPEN_WRITE 0x0001
165 #define SMBOPEN_READWRITE 0x0002
166 #define SMBOPEN_EXECUTE 0x0003
168 #define SMBOPEN_OCREATE 0x0010
169 #define SMBOPEN_OTRUNC 0x0002
170 #define SMBOPEN_OAPPEND 0x0001
173 * SMB flag definitions
175 #define SMBFLG_EXTD_LOCK 0x01 /* server supports lock-read write-unlock smb */
176 #define SMBFLG_RCV_POSTED 0x02 /* obsolete */
177 #define SMBFLG_RSVD 0x04
178 #define SMBFLG_CASELESS 0x08 /* all pathnames treated as caseless (off
179 implies case sensitive file handling request) */
180 #define SMBFLG_CANONICAL_PATH_FORMAT 0x10 /* obsolete */
181 #define SMBFLG_OLD_OPLOCK 0x20 /* obsolete */
182 #define SMBFLG_OLD_OPLOCK_NOTIFY 0x40 /* obsolete */
183 #define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */
186 * SMB flag2 definitions
188 #define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1) /* can send long (non-8.3)
189 path names in response */
190 #define SMBFLG2_KNOWS_EAS cpu_to_le16(2)
191 #define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4)
192 #define SMBFLG2_COMPRESSED (8)
193 #define SMBFLG2_SECURITY_SIGNATURE_REQUIRED (0x10)
194 #define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40)
195 #define SMBFLG2_REPARSE_PATH (0x400)
196 #define SMBFLG2_EXT_SEC cpu_to_le16(0x800)
197 #define SMBFLG2_DFS cpu_to_le16(0x1000)
198 #define SMBFLG2_PAGING_IO cpu_to_le16(0x2000)
199 #define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)
200 #define SMBFLG2_UNICODE cpu_to_le16(0x8000)
203 * These are the file access permission bits defined in CIFS for the
204 * NTCreateAndX as well as the level 0x107
205 * TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO
206 * responds with the AccessFlags.
207 * The AccessFlags specifies the access permissions a caller has to the
208 * file and can have any suitable combination of the following values:
211 #define FILE_READ_DATA 0x00000001 /* Data can be read from the file */
212 #define FILE_WRITE_DATA 0x00000002 /* Data can be written to the file */
213 #define FILE_APPEND_DATA 0x00000004 /* Data can be appended to the file */
214 #define FILE_READ_EA 0x00000008 /* Extended attributes associated */
215 /* with the file can be read */
216 #define FILE_WRITE_EA 0x00000010 /* Extended attributes associated */
217 /* with the file can be written */
218 #define FILE_EXECUTE 0x00000020 /*Data can be read into memory from */
219 /* the file using system paging I/O */
220 #define FILE_DELETE_CHILD 0x00000040
221 #define FILE_READ_ATTRIBUTES 0x00000080 /* Attributes associated with the */
222 /* file can be read */
223 #define FILE_WRITE_ATTRIBUTES 0x00000100 /* Attributes associated with the */
224 /* file can be written */
225 #define DELETE 0x00010000 /* The file can be deleted */
226 #define READ_CONTROL 0x00020000 /* The access control list and */
227 /* ownership associated with the */
228 /* file can be read */
229 #define WRITE_DAC 0x00040000 /* The access control list and */
230 /* ownership associated with the */
231 /* file can be written. */
232 #define WRITE_OWNER 0x00080000 /* Ownership information associated */
233 /* with the file can be written */
234 #define SYNCHRONIZE 0x00100000 /* The file handle can waited on to */
235 /* synchronize with the completion */
236 /* of an input/output request */
237 #define GENERIC_ALL 0x10000000
238 #define GENERIC_EXECUTE 0x20000000
239 #define GENERIC_WRITE 0x40000000
240 #define GENERIC_READ 0x80000000
241 /* In summary - Relevant file */
242 /* access flags from CIFS are */
243 /* file_read_data, file_write_data */
244 /* file_execute, file_read_attributes*/
245 /* write_dac, and delete. */
247 #define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES)
248 #define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
249 | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES)
250 #define FILE_EXEC_RIGHTS (FILE_EXECUTE)
252 #define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_WRITE_EA \
253 | FILE_READ_ATTRIBUTES \
254 | FILE_WRITE_ATTRIBUTES \
255 | DELETE | READ_CONTROL | WRITE_DAC \
256 | WRITE_OWNER | SYNCHRONIZE)
257 #define SET_FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
258 | FILE_READ_EA | FILE_WRITE_EA \
259 | FILE_DELETE_CHILD | FILE_READ_ATTRIBUTES \
260 | FILE_WRITE_ATTRIBUTES \
261 | DELETE | READ_CONTROL | WRITE_DAC \
262 | WRITE_OWNER | SYNCHRONIZE)
263 #define SET_FILE_EXEC_RIGHTS (FILE_READ_EA | FILE_WRITE_EA | FILE_EXECUTE \
264 | FILE_READ_ATTRIBUTES \
265 | FILE_WRITE_ATTRIBUTES \
266 | DELETE | READ_CONTROL | WRITE_DAC \
267 | WRITE_OWNER | SYNCHRONIZE)
269 #define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \
270 | READ_CONTROL | SYNCHRONIZE)
274 * Invalid readdir handle
276 #define CIFS_NO_HANDLE 0xFFFF
278 #define NO_CHANGE_64 0xFFFFFFFFFFFFFFFFULL
279 #define NO_CHANGE_32 0xFFFFFFFFUL
282 #define CIFS_IPC_RESOURCE "\x49\x50\x43\x24"
284 /* IPC$ in Unicode */
285 #define CIFS_IPC_UNICODE_RESOURCE "\x00\x49\x00\x50\x00\x43\x00\x24\x00\x00"
287 /* Unicode Null terminate 2 bytes of 0 */
288 #define UNICODE_NULL "\x00\x00"
289 #define ASCII_NULL 0x00
292 * Server type values (returned on EnumServer API
294 #define CIFS_SV_TYPE_DC 0x00000008
295 #define CIFS_SV_TYPE_BACKDC 0x00000010
298 * Alias type flags (From EnumAlias API call
300 #define CIFS_ALIAS_TYPE_FILE 0x0001
301 #define CIFS_SHARE_TYPE_FILE 0x0000
304 * File Attribute flags
306 #define ATTR_READONLY 0x0001
307 #define ATTR_HIDDEN 0x0002
308 #define ATTR_SYSTEM 0x0004
309 #define ATTR_VOLUME 0x0008
310 #define ATTR_DIRECTORY 0x0010
311 #define ATTR_ARCHIVE 0x0020
312 #define ATTR_DEVICE 0x0040
313 #define ATTR_NORMAL 0x0080
314 #define ATTR_TEMPORARY 0x0100
315 #define ATTR_SPARSE 0x0200
316 #define ATTR_REPARSE 0x0400
317 #define ATTR_COMPRESSED 0x0800
318 #define ATTR_OFFLINE 0x1000 /* ie file not immediately available -
319 on offline storage */
320 #define ATTR_NOT_CONTENT_INDEXED 0x2000
321 #define ATTR_ENCRYPTED 0x4000
322 #define ATTR_POSIX_SEMANTICS 0x01000000
323 #define ATTR_BACKUP_SEMANTICS 0x02000000
324 #define ATTR_DELETE_ON_CLOSE 0x04000000
325 #define ATTR_SEQUENTIAL_SCAN 0x08000000
326 #define ATTR_RANDOM_ACCESS 0x10000000
327 #define ATTR_NO_BUFFERING 0x20000000
328 #define ATTR_WRITE_THROUGH 0x80000000
330 /* ShareAccess flags */
331 #define FILE_NO_SHARE 0x00000000
332 #define FILE_SHARE_READ 0x00000001
333 #define FILE_SHARE_WRITE 0x00000002
334 #define FILE_SHARE_DELETE 0x00000004
335 #define FILE_SHARE_ALL 0x00000007
337 /* CreateDisposition flags, similar to CreateAction as well */
338 #define FILE_SUPERSEDE 0x00000000
339 #define FILE_OPEN 0x00000001
340 #define FILE_CREATE 0x00000002
341 #define FILE_OPEN_IF 0x00000003
342 #define FILE_OVERWRITE 0x00000004
343 #define FILE_OVERWRITE_IF 0x00000005
346 #define CREATE_NOT_FILE 0x00000001 /* if set must not be file */
347 #define CREATE_WRITE_THROUGH 0x00000002
348 #define CREATE_SEQUENTIAL 0x00000004
349 #define CREATE_NO_BUFFER 0x00000008 /* should not buffer on srv */
350 #define CREATE_SYNC_ALERT 0x00000010 /* MBZ */
351 #define CREATE_ASYNC_ALERT 0x00000020 /* MBZ */
352 #define CREATE_NOT_DIR 0x00000040 /* if set must not be directory */
353 #define CREATE_TREE_CONNECTION 0x00000080 /* should be zero */
354 #define CREATE_COMPLETE_IF_OPLK 0x00000100 /* should be zero */
355 #define CREATE_NO_EA_KNOWLEDGE 0x00000200
356 #define CREATE_EIGHT_DOT_THREE 0x00000400 /* doc says this is obsolete
357 "open for recovery" flag should
358 be zero in any case */
359 #define CREATE_OPEN_FOR_RECOVERY 0x00000400
360 #define CREATE_RANDOM_ACCESS 0x00000800
361 #define CREATE_DELETE_ON_CLOSE 0x00001000
362 #define CREATE_OPEN_BY_ID 0x00002000
363 #define CREATE_OPEN_BACKUP_INTENT 0x00004000
364 #define CREATE_NO_COMPRESSION 0x00008000
365 #define CREATE_RESERVE_OPFILTER 0x00100000 /* should be zero */
366 #define OPEN_REPARSE_POINT 0x00200000
367 #define OPEN_NO_RECALL 0x00400000
368 #define OPEN_FREE_SPACE_QUERY 0x00800000 /* should be zero */
369 #define CREATE_OPTIONS_MASK 0x007FFFFF
370 #define CREATE_OPTION_READONLY 0x10000000
371 #define CREATE_OPTION_SPECIAL 0x20000000 /* system. NB not sent over wire */
373 /* ImpersonationLevel flags */
374 #define SECURITY_ANONYMOUS 0
375 #define SECURITY_IDENTIFICATION 1
376 #define SECURITY_IMPERSONATION 2
377 #define SECURITY_DELEGATION 3
380 #define SECURITY_CONTEXT_TRACKING 0x01
381 #define SECURITY_EFFECTIVE_ONLY 0x02
384 * Default PID value, used in all SMBs where the PID is not important
386 #define CIFS_DFT_PID 0x1234
389 * We use the same routine for Copy and Move SMBs. This flag is used to
392 #define CIFS_COPY_OP 1
393 #define CIFS_RENAME_OP 2
395 #define GETU16(var) (*((__u16 *)var)) /* BB check for endian issues */
396 #define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */
399 __u32 smb_buf_length; /* big endian on wire *//* BB length is only two
400 or three bytes - with one or two byte type preceding it that are
401 zero - we could mask the type byte off just in case BB */
409 } __attribute__((packed)) DosError;
411 } __attribute__((packed)) Status;
413 __le16 Flags2; /* note: le */
417 __le32 SequenceNumber; /* le */
418 __u32 Reserved; /* zero */
419 } __attribute__((packed)) Sequence;
420 __u8 SecuritySignature[8]; /* le */
421 } __attribute__((packed)) Signature;
428 } __attribute__((packed));
429 /* given a pointer to an smb_hdr retrieve the value of byte count */
430 #define BCC(smb_var) (*(__u16 *)((char *)(smb_var) + sizeof(struct smb_hdr) + (2 * (smb_var)->WordCount)))
431 #define BCC_LE(smb_var) (*(__le16 *)((char *)(smb_var) + sizeof(struct smb_hdr) + (2 * (smb_var)->WordCount)))
432 /* given a pointer to an smb_hdr retrieve the pointer to the byte area */
433 #define pByteArea(smb_var) ((unsigned char *)(smb_var) + sizeof(struct smb_hdr) + (2 * (smb_var)->WordCount) + 2)
436 * Computer Name Length (since Netbios name was length 16 with last byte 0x20)
437 * No longer as important, now that TCP names are more commonly used to
443 * Share Name Length (SNLEN)
444 * Note: This length was limited by the SMB used to get
445 * the Share info. NetShareEnum only returned 13
446 * chars, including the null termination.
447 * This was removed because it no longer is limiting.
453 #define MAXCOMMENTLEN 40
456 * The OS/2 maximum path name
458 #define MAX_PATHCONF 256
461 * SMB frame definitions (following must be packed structs)
462 * See the SNIA CIFS Specification for details.
464 * The Naming convention is the lower case version of the
465 * smb command code name for the struct and this is typedef to the
466 * uppercase version of the same name with the prefix SMB_ removed
467 * for brevity. Although typedefs are not commonly used for
468 * structure definitions in the Linux kernel, their use in the
469 * CIFS standards document, which this code is based on, may
470 * make this one of the cases where typedefs for structures make
471 * sense to improve readability for readers of the standards doc.
472 * Typedefs can always be removed later if they are too distracting
473 * and they are only used for the CIFSs PDUs themselves, not
474 * internal cifs vfs structures
478 typedef struct negotiate_req {
479 struct smb_hdr hdr; /* wct = 0 */
481 unsigned char DialectsArray[1];
482 } __attribute__((packed)) NEGOTIATE_REQ;
484 /* Dialect index is 13 for LANMAN */
486 #define MIN_TZ_ADJ (15 * 60) /* minimum grid for timezones in seconds */
488 typedef struct lanman_neg_rsp {
489 struct smb_hdr hdr; /* wct = 13 */
500 } __attribute__((packed)) SrvTime;
501 __le16 ServerTimeZone;
502 __le16 EncryptionKeyLength;
505 unsigned char EncryptionKey[1];
506 } __attribute__((packed)) LANMAN_NEG_RSP;
508 #define READ_RAW_ENABLE 1
509 #define WRITE_RAW_ENABLE 2
510 #define RAW_ENABLE (READ_RAW_ENABLE | WRITE_RAW_ENABLE)
512 typedef struct negotiate_rsp {
513 struct smb_hdr hdr; /* wct = 17 */
514 __le16 DialectIndex; /* 0xFFFF = no dialect acceptable */
518 __le32 MaxBufferSize;
521 __le32 Capabilities; /* see below */
522 __le32 SystemTimeLow;
523 __le32 SystemTimeHigh;
524 __le16 ServerTimeZone;
525 __u8 EncryptionKeyLength;
528 unsigned char EncryptionKey[1]; /* cap extended security off */
529 /* followed by Domain name - if extended security is off */
530 /* followed by 16 bytes of server GUID */
531 /* then security blob if cap_extended_security negotiated */
533 unsigned char GUID[16];
534 unsigned char SecurityBlob[1];
535 } __attribute__((packed)) extended_response;
536 } __attribute__((packed)) u;
537 } __attribute__((packed)) NEGOTIATE_RSP;
539 /* SecurityMode bits */
540 #define SECMODE_USER 0x01 /* off indicates share level security */
541 #define SECMODE_PW_ENCRYPT 0x02
542 #define SECMODE_SIGN_ENABLED 0x04 /* SMB security signatures enabled */
543 #define SECMODE_SIGN_REQUIRED 0x08 /* SMB security signatures required */
545 /* Negotiate response Capabilities */
546 #define CAP_RAW_MODE 0x00000001
547 #define CAP_MPX_MODE 0x00000002
548 #define CAP_UNICODE 0x00000004
549 #define CAP_LARGE_FILES 0x00000008
550 #define CAP_NT_SMBS 0x00000010 /* implies CAP_NT_FIND */
551 #define CAP_RPC_REMOTE_APIS 0x00000020
552 #define CAP_STATUS32 0x00000040
553 #define CAP_LEVEL_II_OPLOCKS 0x00000080
554 #define CAP_LOCK_AND_READ 0x00000100
555 #define CAP_NT_FIND 0x00000200
556 #define CAP_DFS 0x00001000
557 #define CAP_INFOLEVEL_PASSTHRU 0x00002000
558 #define CAP_LARGE_READ_X 0x00004000
559 #define CAP_LARGE_WRITE_X 0x00008000
560 #define CAP_LWIO 0x00010000 /* support fctl_srv_req_resume_key */
561 #define CAP_UNIX 0x00800000
562 #define CAP_COMPRESSED_DATA 0x02000000
563 #define CAP_DYNAMIC_REAUTH 0x20000000
564 #define CAP_PERSISTENT_HANDLES 0x40000000
565 #define CAP_EXTENDED_SECURITY 0x80000000
567 typedef union smb_com_session_setup_andx {
568 struct { /* request format */
569 struct smb_hdr hdr; /* wct = 12 */
573 __le16 MaxBufferSize;
577 __le16 SecurityBlobLength;
579 __le32 Capabilities; /* see below */
581 unsigned char SecurityBlob[1]; /* followed by */
582 /* STRING NativeOS */
583 /* STRING NativeLanMan */
584 } __attribute__((packed)) req; /* NTLM request format (with
587 struct { /* request format */
588 struct smb_hdr hdr; /* wct = 13 */
592 __le16 MaxBufferSize;
596 __le16 CaseInsensitivePasswordLength; /* ASCII password len */
597 __le16 CaseSensitivePasswordLength; /* Unicode password length*/
598 __u32 Reserved; /* see below */
601 unsigned char CaseInsensitivePassword[1]; /* followed by: */
602 /* unsigned char * CaseSensitivePassword; */
603 /* STRING AccountName */
604 /* STRING PrimaryDomain */
605 /* STRING NativeOS */
606 /* STRING NativeLanMan */
607 } __attribute__((packed)) req_no_secext; /* NTLM request format (without
610 struct { /* default (NTLM) response format */
611 struct smb_hdr hdr; /* wct = 4 */
615 __le16 Action; /* see below */
616 __le16 SecurityBlobLength;
618 unsigned char SecurityBlob[1]; /* followed by */
619 /* unsigned char * NativeOS; */
620 /* unsigned char * NativeLanMan; */
621 /* unsigned char * PrimaryDomain; */
622 } __attribute__((packed)) resp; /* NTLM response
623 (with or without extended sec) */
625 struct { /* request format */
626 struct smb_hdr hdr; /* wct = 10 */
630 __le16 MaxBufferSize;
634 __le16 PasswordLength;
635 __u32 Reserved; /* encrypt key len and offset */
637 unsigned char AccountPassword[1]; /* followed by */
638 /* STRING AccountName */
639 /* STRING PrimaryDomain */
640 /* STRING NativeOS */
641 /* STRING NativeLanMan */
642 } __attribute__((packed)) old_req; /* pre-NTLM (LANMAN2.1) req format */
644 struct { /* default (NTLM) response format */
645 struct smb_hdr hdr; /* wct = 3 */
649 __le16 Action; /* see below */
651 unsigned char NativeOS[1]; /* followed by */
652 /* unsigned char * NativeLanMan; */
653 /* unsigned char * PrimaryDomain; */
654 } __attribute__((packed)) old_resp; /* pre-NTLM (LANMAN2.1) response */
655 } __attribute__((packed)) SESSION_SETUP_ANDX;
657 /* format of NLTMv2 Response ie "case sensitive password" hash when NTLMv2 */
659 #define NTLMSSP_SERVER_TYPE 1
660 #define NTLMSSP_DOMAIN_TYPE 2
661 #define NTLMSSP_FQ_DOMAIN_TYPE 3
662 #define NTLMSSP_DNS_DOMAIN_TYPE 4
663 #define NTLMSSP_DNS_PARENT_TYPE 5
665 struct ntlmssp2_name {
668 /* char name[length]; */
669 } __attribute__((packed));
672 char ntlmv2_hash[CIFS_ENCPWD_SIZE];
673 __le32 blob_signature;
676 __u64 client_chal; /* random */
678 /* array of name entries could follow ending in minimum 4 byte struct */
679 } __attribute__((packed));
682 #define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux"
684 /* Capabilities bits (for NTLM SessSetup request) */
685 #define CAP_UNICODE 0x00000004
686 #define CAP_LARGE_FILES 0x00000008
687 #define CAP_NT_SMBS 0x00000010
688 #define CAP_STATUS32 0x00000040
689 #define CAP_LEVEL_II_OPLOCKS 0x00000080
690 #define CAP_NT_FIND 0x00000200 /* reserved should be zero
691 (because NT_SMBs implies the same thing?) */
692 #define CAP_BULK_TRANSFER 0x20000000
693 #define CAP_EXTENDED_SECURITY 0x80000000
696 #define GUEST_LOGIN 1
698 typedef struct smb_com_tconx_req {
699 struct smb_hdr hdr; /* wct = 4 */
703 __le16 Flags; /* see below */
704 __le16 PasswordLength;
706 unsigned char Password[1]; /* followed by */
707 /* STRING Path *//* \\server\share name */
709 } __attribute__((packed)) TCONX_REQ;
711 typedef struct smb_com_tconx_rsp {
712 struct smb_hdr hdr; /* wct = 3 , not extended response */
716 __le16 OptionalSupport; /* see below */
718 unsigned char Service[1]; /* always ASCII, not Unicode */
719 /* STRING NativeFileSystem */
720 } __attribute__((packed)) TCONX_RSP;
722 typedef struct smb_com_tconx_rsp_ext {
723 struct smb_hdr hdr; /* wct = 7, extended response */
727 __le16 OptionalSupport; /* see below */
728 __le32 MaximalShareAccessRights;
729 __le32 GuestMaximalShareAccessRights;
731 unsigned char Service[1]; /* always ASCII, not Unicode */
732 /* STRING NativeFileSystem */
733 } __attribute__((packed)) TCONX_RSP_EXT;
736 /* tree connect Flags */
737 #define DISCONNECT_TID 0x0001
738 #define TCON_EXTENDED_SIGNATURES 0x0004
739 #define TCON_EXTENDED_SECINFO 0x0008
741 /* OptionalSupport bits */
742 #define SMB_SUPPORT_SEARCH_BITS 0x0001 /* "must have" directory search bits
743 (exclusive searches supported) */
744 #define SMB_SHARE_IS_IN_DFS 0x0002
745 #define SMB_CSC_MASK 0x000C
746 /* CSC flags defined as follows */
747 #define SMB_CSC_CACHE_MANUAL_REINT 0x0000
748 #define SMB_CSC_CACHE_AUTO_REINT 0x0004
749 #define SMB_CSC_CACHE_VDO 0x0008
750 #define SMB_CSC_NO_CACHING 0x000C
751 #define SMB_UNIQUE_FILE_NAME 0x0010
752 #define SMB_EXTENDED_SIGNATURES 0x0020
764 typedef struct smb_com_echo_req {
769 } __attribute__((packed)) ECHO_REQ;
771 typedef struct smb_com_echo_rsp {
773 __le16 SequenceNumber;
776 } __attribute__((packed)) ECHO_RSP;
778 typedef struct smb_com_logoff_andx_req {
779 struct smb_hdr hdr; /* wct = 2 */
784 } __attribute__((packed)) LOGOFF_ANDX_REQ;
786 typedef struct smb_com_logoff_andx_rsp {
787 struct smb_hdr hdr; /* wct = 2 */
792 } __attribute__((packed)) LOGOFF_ANDX_RSP;
794 typedef union smb_com_tree_disconnect { /* as an altetnative can use flag on
795 tree_connect PDU to effect disconnect */
796 /* tdis is probably simplest SMB PDU */
798 struct smb_hdr hdr; /* wct = 0 */
799 __u16 ByteCount; /* bcc = 0 */
800 } __attribute__((packed)) req;
802 struct smb_hdr hdr; /* wct = 0 */
803 __u16 ByteCount; /* bcc = 0 */
804 } __attribute__((packed)) resp;
805 } __attribute__((packed)) TREE_DISCONNECT;
807 typedef struct smb_com_close_req {
808 struct smb_hdr hdr; /* wct = 3 */
810 __u32 LastWriteTime; /* should be zero or -1 */
811 __u16 ByteCount; /* 0 */
812 } __attribute__((packed)) CLOSE_REQ;
814 typedef struct smb_com_close_rsp {
815 struct smb_hdr hdr; /* wct = 0 */
816 __u16 ByteCount; /* bct = 0 */
817 } __attribute__((packed)) CLOSE_RSP;
819 typedef struct smb_com_flush_req {
820 struct smb_hdr hdr; /* wct = 1 */
822 __u16 ByteCount; /* 0 */
823 } __attribute__((packed)) FLUSH_REQ;
825 typedef struct smb_com_findclose_req {
826 struct smb_hdr hdr; /* wct = 1 */
828 __u16 ByteCount; /* 0 */
829 } __attribute__((packed)) FINDCLOSE_REQ;
832 #define REQ_MORE_INFO 0x00000001 /* legacy (OPEN_AND_X) only */
833 #define REQ_OPLOCK 0x00000002
834 #define REQ_BATCHOPLOCK 0x00000004
835 #define REQ_OPENDIRONLY 0x00000008
836 #define REQ_EXTENDED_INFO 0x00000010
839 #define DISK_TYPE 0x0000
840 #define BYTE_PIPE_TYPE 0x0001
841 #define MESSAGE_PIPE_TYPE 0x0002
842 #define PRINTER_TYPE 0x0003
843 #define COMM_DEV_TYPE 0x0004
844 #define UNKNOWN_TYPE 0xFFFF
846 /* Device Type or File Status Flags */
847 #define NO_EAS 0x0001
848 #define NO_SUBSTREAMS 0x0002
849 #define NO_REPARSETAG 0x0004
850 /* following flags can apply if pipe */
851 #define ICOUNT_MASK 0x00FF
852 #define PIPE_READ_MODE 0x0100
853 #define NAMED_PIPE_TYPE 0x0400
854 #define PIPE_END_POINT 0x4000
855 #define BLOCKING_NAMED_PIPE 0x8000
857 typedef struct smb_com_open_req { /* also handles create */
858 struct smb_hdr hdr; /* wct = 24 */
862 __u8 Reserved; /* Must Be Zero */
865 __u32 RootDirectoryFid;
866 __le32 DesiredAccess;
867 __le64 AllocationSize;
868 __le32 FileAttributes;
870 __le32 CreateDisposition;
871 __le32 CreateOptions;
872 __le32 ImpersonationLevel;
876 } __attribute__((packed)) OPEN_REQ;
878 /* open response: oplock levels */
879 #define OPLOCK_NONE 0
880 #define OPLOCK_EXCLUSIVE 1
881 #define OPLOCK_BATCH 2
882 #define OPLOCK_READ 3 /* level 2 oplock */
884 /* open response for CreateAction shifted left */
885 #define CIFS_CREATE_ACTION 0x20000 /* file created */
887 typedef struct smb_com_open_rsp {
888 struct smb_hdr hdr; /* wct = 34 BB */
896 __le64 LastAccessTime;
897 __le64 LastWriteTime;
899 __le32 FileAttributes;
900 __le64 AllocationSize;
905 __u16 ByteCount; /* bct = 0 */
906 } __attribute__((packed)) OPEN_RSP;
908 typedef struct smb_com_open_rsp_ext {
909 struct smb_hdr hdr; /* wct = 42 but meaningless due to MS bug? */
917 __le64 LastAccessTime;
918 __le64 LastWriteTime;
920 __le32 FileAttributes;
921 __le64 AllocationSize;
927 __u64 FileId; /* note no endian conversion - is opaque UniqueID */
928 __le32 MaximalAccessRights;
929 __le32 GuestMaximalAccessRights;
930 __u16 ByteCount; /* bct = 0 */
931 } __attribute__((packed)) OPEN_RSP_EXT;
934 /* format of legacy open request */
935 typedef struct smb_com_openx_req {
936 struct smb_hdr hdr; /* wct = 15 */
942 __le16 Sattr; /* search attributes */
943 __le16 FileAttributes; /* dos attrs */
944 __le32 CreateTime; /* os2 format */
949 __le16 ByteCount; /* file name follows */
951 } __attribute__((packed)) OPENX_REQ;
953 typedef struct smb_com_openx_rsp {
954 struct smb_hdr hdr; /* wct = 15 */
959 __le16 FileAttributes;
960 __le32 LastWriteTime; /* os2 format */
969 } __attribute__((packed)) OPENX_RSP;
971 /* For encoding of POSIX Open Request - see trans2 function 0x209 data struct */
973 /* Legacy write request for older servers */
974 typedef struct smb_com_writex_req {
975 struct smb_hdr hdr; /* wct = 12 */
981 __u32 Reserved; /* Timeout */
982 __le16 WriteMode; /* 1 = write through */
985 __le16 DataLengthLow;
988 __u8 Pad; /* BB check for whether padded to DWORD
989 boundary and optimum performance here */
991 } __attribute__((packed)) WRITEX_REQ;
993 typedef struct smb_com_write_req {
994 struct smb_hdr hdr; /* wct = 14 */
1003 __le16 DataLengthHigh;
1004 __le16 DataLengthLow;
1008 __u8 Pad; /* BB check for whether padded to DWORD
1009 boundary and optimum performance here */
1011 } __attribute__((packed)) WRITE_REQ;
1013 typedef struct smb_com_write_rsp {
1014 struct smb_hdr hdr; /* wct = 6 */
1023 } __attribute__((packed)) WRITE_RSP;
1025 /* legacy read request for older servers */
1026 typedef struct smb_com_readx_req {
1027 struct smb_hdr hdr; /* wct = 10 */
1034 __le16 MinCount; /* obsolete */
1038 } __attribute__((packed)) READX_REQ;
1040 typedef struct smb_com_read_req {
1041 struct smb_hdr hdr; /* wct = 12 */
1048 __le16 MinCount; /* obsolete */
1049 __le32 MaxCountHigh;
1053 } __attribute__((packed)) READ_REQ;
1055 typedef struct smb_com_read_rsp {
1056 struct smb_hdr hdr; /* wct = 12 */
1061 __le16 DataCompactionMode;
1065 __le16 DataLengthHigh;
1068 __u8 Pad; /* BB check for whether padded to DWORD
1069 boundary and optimum performance here */
1071 } __attribute__((packed)) READ_RSP;
1073 typedef struct locking_andx_range {
1080 } __attribute__((packed)) LOCKING_ANDX_RANGE;
1082 #define LOCKING_ANDX_SHARED_LOCK 0x01
1083 #define LOCKING_ANDX_OPLOCK_RELEASE 0x02
1084 #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
1085 #define LOCKING_ANDX_CANCEL_LOCK 0x08
1086 #define LOCKING_ANDX_LARGE_FILES 0x10 /* always on for us */
1088 typedef struct smb_com_lock_req {
1089 struct smb_hdr hdr; /* wct = 8 */
1097 __le16 NumberOfUnlocks;
1098 __le16 NumberOfLocks;
1100 LOCKING_ANDX_RANGE Locks[1];
1101 } __attribute__((packed)) LOCK_REQ;
1104 #define CIFS_RDLCK 0
1105 #define CIFS_WRLCK 1
1106 #define CIFS_UNLCK 2
1107 typedef struct cifs_posix_lock {
1108 __le16 lock_type; /* 0 = Read, 1 = Write, 2 = Unlock */
1109 __le16 lock_flags; /* 1 = Wait (only valid for setlock) */
1113 /* BB what about additional owner info to identify network client */
1114 } __attribute__((packed)) CIFS_POSIX_LOCK;
1116 typedef struct smb_com_lock_rsp {
1117 struct smb_hdr hdr; /* wct = 2 */
1122 } __attribute__((packed)) LOCK_RSP;
1124 typedef struct smb_com_rename_req {
1125 struct smb_hdr hdr; /* wct = 1 */
1126 __le16 SearchAttributes; /* target file attributes */
1128 __u8 BufferFormat; /* 4 = ASCII or Unicode */
1129 unsigned char OldFileName[1];
1130 /* followed by __u8 BufferFormat2 */
1131 /* followed by NewFileName */
1132 } __attribute__((packed)) RENAME_REQ;
1134 /* copy request flags */
1135 #define COPY_MUST_BE_FILE 0x0001
1136 #define COPY_MUST_BE_DIR 0x0002
1137 #define COPY_TARGET_MODE_ASCII 0x0004 /* if not set, binary */
1138 #define COPY_SOURCE_MODE_ASCII 0x0008 /* if not set, binary */
1139 #define COPY_VERIFY_WRITES 0x0010
1140 #define COPY_TREE 0x0020
1142 typedef struct smb_com_copy_req {
1143 struct smb_hdr hdr; /* wct = 3 */
1145 __le16 OpenFunction;
1148 __u8 BufferFormat; /* 4 = ASCII or Unicode */
1149 unsigned char OldFileName[1];
1150 /* followed by __u8 BufferFormat2 */
1151 /* followed by NewFileName string */
1152 } __attribute__((packed)) COPY_REQ;
1154 typedef struct smb_com_copy_rsp {
1155 struct smb_hdr hdr; /* wct = 1 */
1156 __le16 CopyCount; /* number of files copied */
1157 __u16 ByteCount; /* may be zero */
1158 __u8 BufferFormat; /* 0x04 - only present if errored file follows */
1159 unsigned char ErrorFileName[1]; /* only present if error in copy */
1160 } __attribute__((packed)) COPY_RSP;
1162 #define CREATE_HARD_LINK 0x103
1163 #define MOVEFILE_COPY_ALLOWED 0x0002
1164 #define MOVEFILE_REPLACE_EXISTING 0x0001
1166 typedef struct smb_com_nt_rename_req { /* A5 - also used for create hardlink */
1167 struct smb_hdr hdr; /* wct = 4 */
1168 __le16 SearchAttributes; /* target file attributes */
1169 __le16 Flags; /* spec says Information Level */
1170 __le32 ClusterCount;
1172 __u8 BufferFormat; /* 4 = ASCII or Unicode */
1173 unsigned char OldFileName[1];
1174 /* followed by __u8 BufferFormat2 */
1175 /* followed by NewFileName */
1176 } __attribute__((packed)) NT_RENAME_REQ;
1178 typedef struct smb_com_rename_rsp {
1179 struct smb_hdr hdr; /* wct = 0 */
1180 __u16 ByteCount; /* bct = 0 */
1181 } __attribute__((packed)) RENAME_RSP;
1183 typedef struct smb_com_delete_file_req {
1184 struct smb_hdr hdr; /* wct = 1 */
1185 __le16 SearchAttributes;
1187 __u8 BufferFormat; /* 4 = ASCII */
1188 unsigned char fileName[1];
1189 } __attribute__((packed)) DELETE_FILE_REQ;
1191 typedef struct smb_com_delete_file_rsp {
1192 struct smb_hdr hdr; /* wct = 0 */
1193 __u16 ByteCount; /* bct = 0 */
1194 } __attribute__((packed)) DELETE_FILE_RSP;
1196 typedef struct smb_com_delete_directory_req {
1197 struct smb_hdr hdr; /* wct = 0 */
1199 __u8 BufferFormat; /* 4 = ASCII */
1200 unsigned char DirName[1];
1201 } __attribute__((packed)) DELETE_DIRECTORY_REQ;
1203 typedef struct smb_com_delete_directory_rsp {
1204 struct smb_hdr hdr; /* wct = 0 */
1205 __u16 ByteCount; /* bct = 0 */
1206 } __attribute__((packed)) DELETE_DIRECTORY_RSP;
1208 typedef struct smb_com_create_directory_req {
1209 struct smb_hdr hdr; /* wct = 0 */
1211 __u8 BufferFormat; /* 4 = ASCII */
1212 unsigned char DirName[1];
1213 } __attribute__((packed)) CREATE_DIRECTORY_REQ;
1215 typedef struct smb_com_create_directory_rsp {
1216 struct smb_hdr hdr; /* wct = 0 */
1217 __u16 ByteCount; /* bct = 0 */
1218 } __attribute__((packed)) CREATE_DIRECTORY_RSP;
1220 typedef struct smb_com_query_information_req {
1221 struct smb_hdr hdr; /* wct = 0 */
1222 __le16 ByteCount; /* 1 + namelen + 1 */
1223 __u8 BufferFormat; /* 4 = ASCII */
1224 unsigned char FileName[1];
1225 } __attribute__((packed)) QUERY_INFORMATION_REQ;
1227 typedef struct smb_com_query_information_rsp {
1228 struct smb_hdr hdr; /* wct = 10 */
1230 __le32 last_write_time;
1233 __le16 ByteCount; /* bcc = 0 */
1234 } __attribute__((packed)) QUERY_INFORMATION_RSP;
1236 typedef struct smb_com_setattr_req {
1237 struct smb_hdr hdr; /* wct = 8 */
1241 __le16 reserved[5]; /* must be zero */
1243 __u8 BufferFormat; /* 4 = ASCII */
1244 unsigned char fileName[1];
1245 } __attribute__((packed)) SETATTR_REQ;
1247 typedef struct smb_com_setattr_rsp {
1248 struct smb_hdr hdr; /* wct = 0 */
1249 __u16 ByteCount; /* bct = 0 */
1250 } __attribute__((packed)) SETATTR_RSP;
1252 /* empty wct response to setattr */
1254 /*******************************************************/
1255 /* NT Transact structure definitions follow */
1256 /* Currently only ioctl, acl (get security descriptor) */
1257 /* and notify are implemented */
1258 /*******************************************************/
1259 typedef struct smb_com_ntransact_req {
1260 struct smb_hdr hdr; /* wct >= 19 */
1263 __le32 TotalParameterCount;
1264 __le32 TotalDataCount;
1265 __le32 MaxParameterCount;
1266 __le32 MaxDataCount;
1267 __le32 ParameterCount;
1268 __le32 ParameterOffset;
1271 __u8 SetupCount; /* four setup words follow subcommand */
1272 /* SNIA spec incorrectly included spurious pad here */
1273 __le16 SubCommand; /* 2 = IOCTL/FSCTL */
1274 /* SetupCount words follow then */
1278 } __attribute__((packed)) NTRANSACT_REQ;
1280 typedef struct smb_com_ntransact_rsp {
1281 struct smb_hdr hdr; /* wct = 18 */
1283 __le32 TotalParameterCount;
1284 __le32 TotalDataCount;
1285 __le32 ParameterCount;
1286 __le32 ParameterOffset;
1287 __le32 ParameterDisplacement;
1290 __le32 DataDisplacement;
1291 __u8 SetupCount; /* 0 */
1294 /* parms and data follow */
1295 } __attribute__((packed)) NTRANSACT_RSP;
1297 typedef struct smb_com_transaction_ioctl_req {
1298 struct smb_hdr hdr; /* wct = 23 */
1301 __le32 TotalParameterCount;
1302 __le32 TotalDataCount;
1303 __le32 MaxParameterCount;
1304 __le32 MaxDataCount;
1305 __le32 ParameterCount;
1306 __le32 ParameterOffset;
1309 __u8 SetupCount; /* four setup words follow subcommand */
1310 /* SNIA spec incorrectly included spurious pad here */
1311 __le16 SubCommand; /* 2 = IOCTL/FSCTL */
1312 __le32 FunctionCode;
1314 __u8 IsFsctl; /* 1 = File System Control 0 = device control (IOCTL) */
1315 __u8 IsRootFlag; /* 1 = apply command to root of share (must be DFS) */
1319 } __attribute__((packed)) TRANSACT_IOCTL_REQ;
1321 typedef struct smb_com_transaction_ioctl_rsp {
1322 struct smb_hdr hdr; /* wct = 19 */
1324 __le32 TotalParameterCount;
1325 __le32 TotalDataCount;
1326 __le32 ParameterCount;
1327 __le32 ParameterOffset;
1328 __le32 ParameterDisplacement;
1331 __le32 DataDisplacement;
1332 __u8 SetupCount; /* 1 */
1333 __le16 ReturnedDataLen;
1335 } __attribute__((packed)) TRANSACT_IOCTL_RSP;
1337 #define CIFS_ACL_OWNER 1
1338 #define CIFS_ACL_GROUP 2
1339 #define CIFS_ACL_DACL 4
1340 #define CIFS_ACL_SACL 8
1342 typedef struct smb_com_transaction_qsec_req {
1343 struct smb_hdr hdr; /* wct = 19 */
1346 __le32 TotalParameterCount;
1347 __le32 TotalDataCount;
1348 __le32 MaxParameterCount;
1349 __le32 MaxDataCount;
1350 __le32 ParameterCount;
1351 __le32 ParameterOffset;
1354 __u8 SetupCount; /* no setup words follow subcommand */
1355 /* SNIA spec incorrectly included spurious pad here */
1356 __le16 SubCommand; /* 6 = QUERY_SECURITY_DESC */
1357 __le16 ByteCount; /* bcc = 3 + 8 */
1362 } __attribute__((packed)) QUERY_SEC_DESC_REQ;
1365 typedef struct smb_com_transaction_ssec_req {
1366 struct smb_hdr hdr; /* wct = 19 */
1369 __le32 TotalParameterCount;
1370 __le32 TotalDataCount;
1371 __le32 MaxParameterCount;
1372 __le32 MaxDataCount;
1373 __le32 ParameterCount;
1374 __le32 ParameterOffset;
1377 __u8 SetupCount; /* no setup words follow subcommand */
1378 /* SNIA spec incorrectly included spurious pad here */
1379 __le16 SubCommand; /* 3 = SET_SECURITY_DESC */
1380 __le16 ByteCount; /* bcc = 3 + 8 */
1385 } __attribute__((packed)) SET_SEC_DESC_REQ;
1387 typedef struct smb_com_transaction_change_notify_req {
1388 struct smb_hdr hdr; /* wct = 23 */
1391 __le32 TotalParameterCount;
1392 __le32 TotalDataCount;
1393 __le32 MaxParameterCount;
1394 __le32 MaxDataCount;
1395 __le32 ParameterCount;
1396 __le32 ParameterOffset;
1399 __u8 SetupCount; /* four setup words follow subcommand */
1400 /* SNIA spec incorrectly included spurious pad here */
1401 __le16 SubCommand;/* 4 = Change Notify */
1402 __le32 CompletionFilter; /* operation to monitor */
1404 __u8 WatchTree; /* 1 = Monitor subdirectories */
1409 } __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_REQ;
1411 /* BB eventually change to use generic ntransact rsp struct
1412 and validation routine */
1413 typedef struct smb_com_transaction_change_notify_rsp {
1414 struct smb_hdr hdr; /* wct = 18 */
1416 __le32 TotalParameterCount;
1417 __le32 TotalDataCount;
1418 __le32 ParameterCount;
1419 __le32 ParameterOffset;
1420 __le32 ParameterDisplacement;
1423 __le32 DataDisplacement;
1424 __u8 SetupCount; /* 0 */
1427 } __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_RSP;
1428 /* Completion Filter flags for Notify */
1429 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
1430 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
1431 #define FILE_NOTIFY_CHANGE_NAME 0x00000003
1432 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
1433 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
1434 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
1435 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
1436 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
1437 #define FILE_NOTIFY_CHANGE_EA 0x00000080
1438 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
1439 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
1440 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
1441 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1443 #define FILE_ACTION_ADDED 0x00000001
1444 #define FILE_ACTION_REMOVED 0x00000002
1445 #define FILE_ACTION_MODIFIED 0x00000003
1446 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
1447 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
1448 #define FILE_ACTION_ADDED_STREAM 0x00000006
1449 #define FILE_ACTION_REMOVED_STREAM 0x00000007
1450 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
1452 /* response contains array of the following structures */
1453 struct file_notify_information {
1454 __le32 NextEntryOffset;
1456 __le32 FileNameLength;
1458 } __attribute__((packed));
1460 struct reparse_data {
1462 __u16 ReparseDataLength;
1464 __u16 AltNameOffset;
1466 __u16 TargetNameOffset;
1467 __u16 TargetNameLen;
1468 char LinkNamesBuf[1];
1469 } __attribute__((packed));
1471 struct cifs_quota_data {
1472 __u32 rsrvd1; /* 0 */
1474 __u64 rsrvd2; /* 0 */
1478 char sid[1]; /* variable size? */
1479 } __attribute__((packed));
1481 /* quota sub commands */
1482 #define QUOTA_LIST_CONTINUE 0
1483 #define QUOTA_LIST_START 0x100
1484 #define QUOTA_FOR_SID 0x101
1487 /* struct smb_hdr hdr precedes. Set wct = 14+ */
1488 __le16 TotalParameterCount;
1489 __le16 TotalDataCount;
1490 __le16 MaxParameterCount;
1491 __le16 MaxDataCount;
1497 __le16 ParameterCount;
1498 __le16 ParameterOffset;
1503 __le16 SubCommand; /* 1st setup word - SetupCount words follow */
1505 } __attribute__((packed));
1509 struct trans2_req t2_req;
1510 } __attribute__((packed));
1512 struct trans2_resp {
1513 /* struct smb_hdr hdr precedes. Note wct = 10 + setup count */
1514 __le16 TotalParameterCount;
1515 __le16 TotalDataCount;
1517 __le16 ParameterCount;
1518 __le16 ParameterOffset;
1519 __le16 ParameterDisplacement;
1522 __le16 DataDisplacement;
1525 /* SetupWords[SetupCount];
1528 /* data area follows */
1529 } __attribute__((packed));
1533 struct trans2_resp t2_rsp;
1534 } __attribute__((packed));
1536 /* PathInfo/FileInfo infolevels */
1537 #define SMB_INFO_STANDARD 1
1538 #define SMB_SET_FILE_EA 2
1539 #define SMB_QUERY_FILE_EA_SIZE 2
1540 #define SMB_INFO_QUERY_EAS_FROM_LIST 3
1541 #define SMB_INFO_QUERY_ALL_EAS 4
1542 #define SMB_INFO_IS_NAME_VALID 6
1543 #define SMB_QUERY_FILE_BASIC_INFO 0x101
1544 #define SMB_QUERY_FILE_STANDARD_INFO 0x102
1545 #define SMB_QUERY_FILE_EA_INFO 0x103
1546 #define SMB_QUERY_FILE_NAME_INFO 0x104
1547 #define SMB_QUERY_FILE_ALLOCATION_INFO 0x105
1548 #define SMB_QUERY_FILE_END_OF_FILEINFO 0x106
1549 #define SMB_QUERY_FILE_ALL_INFO 0x107
1550 #define SMB_QUERY_ALT_NAME_INFO 0x108
1551 #define SMB_QUERY_FILE_STREAM_INFO 0x109
1552 #define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
1553 #define SMB_QUERY_FILE_UNIX_BASIC 0x200
1554 #define SMB_QUERY_FILE_UNIX_LINK 0x201
1555 #define SMB_QUERY_POSIX_ACL 0x204
1556 #define SMB_QUERY_XATTR 0x205 /* e.g. system EA name space */
1557 #define SMB_QUERY_ATTR_FLAGS 0x206 /* append,immutable etc. */
1558 #define SMB_QUERY_POSIX_PERMISSION 0x207
1559 #define SMB_QUERY_POSIX_LOCK 0x208
1560 /* #define SMB_POSIX_OPEN 0x209 */
1561 /* #define SMB_POSIX_UNLINK 0x20a */
1562 #define SMB_QUERY_FILE__UNIX_INFO2 0x20b
1563 #define SMB_QUERY_FILE_INTERNAL_INFO 0x3ee
1564 #define SMB_QUERY_FILE_ACCESS_INFO 0x3f0
1565 #define SMB_QUERY_FILE_NAME_INFO2 0x3f1 /* 0x30 bytes */
1566 #define SMB_QUERY_FILE_POSITION_INFO 0x3f6
1567 #define SMB_QUERY_FILE_MODE_INFO 0x3f8
1568 #define SMB_QUERY_FILE_ALGN_INFO 0x3f9
1571 #define SMB_SET_FILE_BASIC_INFO 0x101
1572 #define SMB_SET_FILE_DISPOSITION_INFO 0x102
1573 #define SMB_SET_FILE_ALLOCATION_INFO 0x103
1574 #define SMB_SET_FILE_END_OF_FILE_INFO 0x104
1575 #define SMB_SET_FILE_UNIX_BASIC 0x200
1576 #define SMB_SET_FILE_UNIX_LINK 0x201
1577 #define SMB_SET_FILE_UNIX_HLINK 0x203
1578 #define SMB_SET_POSIX_ACL 0x204
1579 #define SMB_SET_XATTR 0x205
1580 #define SMB_SET_ATTR_FLAGS 0x206 /* append, immutable etc. */
1581 #define SMB_SET_POSIX_LOCK 0x208
1582 #define SMB_POSIX_OPEN 0x209
1583 #define SMB_POSIX_UNLINK 0x20a
1584 #define SMB_SET_FILE_UNIX_INFO2 0x20b
1585 #define SMB_SET_FILE_BASIC_INFO2 0x3ec
1586 #define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo too */
1587 #define SMB_FILE_ALL_INFO2 0x3fa
1588 #define SMB_SET_FILE_ALLOCATION_INFO2 0x3fb
1589 #define SMB_SET_FILE_END_OF_FILE_INFO2 0x3fc
1590 #define SMB_FILE_MOVE_CLUSTER_INFO 0x407
1591 #define SMB_FILE_QUOTA_INFO 0x408
1592 #define SMB_FILE_REPARSEPOINT_INFO 0x409
1593 #define SMB_FILE_MAXIMUM_INFO 0x40d
1595 /* Find File infolevels */
1596 #define SMB_FIND_FILE_INFO_STANDARD 0x001
1597 #define SMB_FIND_FILE_QUERY_EA_SIZE 0x002
1598 #define SMB_FIND_FILE_QUERY_EAS_FROM_LIST 0x003
1599 #define SMB_FIND_FILE_DIRECTORY_INFO 0x101
1600 #define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
1601 #define SMB_FIND_FILE_NAMES_INFO 0x103
1602 #define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
1603 #define SMB_FIND_FILE_ID_FULL_DIR_INFO 0x105
1604 #define SMB_FIND_FILE_ID_BOTH_DIR_INFO 0x106
1605 #define SMB_FIND_FILE_UNIX 0x202
1607 typedef struct smb_com_transaction2_qpi_req {
1608 struct smb_hdr hdr; /* wct = 14+ */
1609 __le16 TotalParameterCount;
1610 __le16 TotalDataCount;
1611 __le16 MaxParameterCount;
1612 __le16 MaxDataCount;
1618 __le16 ParameterCount;
1619 __le16 ParameterOffset;
1624 __le16 SubCommand; /* one setup word */
1627 __le16 InformationLevel;
1630 } __attribute__((packed)) TRANSACTION2_QPI_REQ;
1632 typedef struct smb_com_transaction2_qpi_rsp {
1633 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1634 struct trans2_resp t2;
1636 __u16 Reserved2; /* parameter word is present for infolevels > 100 */
1637 } __attribute__((packed)) TRANSACTION2_QPI_RSP;
1639 typedef struct smb_com_transaction2_spi_req {
1640 struct smb_hdr hdr; /* wct = 15 */
1641 __le16 TotalParameterCount;
1642 __le16 TotalDataCount;
1643 __le16 MaxParameterCount;
1644 __le16 MaxDataCount;
1650 __le16 ParameterCount;
1651 __le16 ParameterOffset;
1656 __le16 SubCommand; /* one setup word */
1660 __le16 InformationLevel;
1663 } __attribute__((packed)) TRANSACTION2_SPI_REQ;
1665 typedef struct smb_com_transaction2_spi_rsp {
1666 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1667 struct trans2_resp t2;
1669 __u16 Reserved2; /* parameter word is present for infolevels > 100 */
1670 } __attribute__((packed)) TRANSACTION2_SPI_RSP;
1672 struct set_file_rename {
1673 __le32 overwrite; /* 1 = overwrite dest */
1674 __u32 root_fid; /* zero */
1675 __le32 target_name_len;
1676 char target_name[0]; /* Must be unicode */
1677 } __attribute__((packed));
1679 struct smb_com_transaction2_sfi_req {
1680 struct smb_hdr hdr; /* wct = 15 */
1681 __le16 TotalParameterCount;
1682 __le16 TotalDataCount;
1683 __le16 MaxParameterCount;
1684 __le16 MaxDataCount;
1690 __le16 ParameterCount;
1691 __le16 ParameterOffset;
1696 __le16 SubCommand; /* one setup word */
1701 __le16 InformationLevel;
1703 } __attribute__((packed));
1705 struct smb_com_transaction2_sfi_rsp {
1706 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1707 struct trans2_resp t2;
1709 __u16 Reserved2; /* parameter word reserved -
1710 present for infolevels > 100 */
1711 } __attribute__((packed));
1713 struct smb_t2_qfi_req {
1715 struct trans2_req t2;
1718 __le16 InformationLevel;
1719 } __attribute__((packed));
1721 struct smb_t2_qfi_rsp {
1722 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1723 struct trans2_resp t2;
1725 __u16 Reserved2; /* parameter word reserved -
1726 present for infolevels > 100 */
1727 } __attribute__((packed));
1730 * Flags on T2 FINDFIRST and FINDNEXT
1732 #define CIFS_SEARCH_CLOSE_ALWAYS 0x0001
1733 #define CIFS_SEARCH_CLOSE_AT_END 0x0002
1734 #define CIFS_SEARCH_RETURN_RESUME 0x0004
1735 #define CIFS_SEARCH_CONTINUE_FROM_LAST 0x0008
1736 #define CIFS_SEARCH_BACKUP_SEARCH 0x0010
1739 * Size of the resume key on FINDFIRST and FINDNEXT calls
1741 #define CIFS_SMB_RESUME_KEY_SIZE 4
1743 typedef struct smb_com_transaction2_ffirst_req {
1744 struct smb_hdr hdr; /* wct = 15 */
1745 __le16 TotalParameterCount;
1746 __le16 TotalDataCount;
1747 __le16 MaxParameterCount;
1748 __le16 MaxDataCount;
1754 __le16 ParameterCount;
1755 __le16 ParameterOffset;
1758 __u8 SetupCount; /* one */
1760 __le16 SubCommand; /* TRANS2_FIND_FIRST */
1763 __le16 SearchAttributes;
1766 __le16 InformationLevel;
1767 __le32 SearchStorageType;
1769 } __attribute__((packed)) TRANSACTION2_FFIRST_REQ;
1771 typedef struct smb_com_transaction2_ffirst_rsp {
1772 struct smb_hdr hdr; /* wct = 10 */
1773 struct trans2_resp t2;
1775 } __attribute__((packed)) TRANSACTION2_FFIRST_RSP;
1777 typedef struct smb_com_transaction2_ffirst_rsp_parms {
1781 __le16 EAErrorOffset;
1782 __le16 LastNameOffset;
1783 } __attribute__((packed)) T2_FFIRST_RSP_PARMS;
1785 typedef struct smb_com_transaction2_fnext_req {
1786 struct smb_hdr hdr; /* wct = 15 */
1787 __le16 TotalParameterCount;
1788 __le16 TotalDataCount;
1789 __le16 MaxParameterCount;
1790 __le16 MaxDataCount;
1796 __le16 ParameterCount;
1797 __le16 ParameterOffset;
1800 __u8 SetupCount; /* one */
1802 __le16 SubCommand; /* TRANS2_FIND_NEXT */
1807 __le16 InformationLevel;
1810 char ResumeFileName[1];
1811 } __attribute__((packed)) TRANSACTION2_FNEXT_REQ;
1813 typedef struct smb_com_transaction2_fnext_rsp {
1814 struct smb_hdr hdr; /* wct = 10 */
1815 struct trans2_resp t2;
1817 } __attribute__((packed)) TRANSACTION2_FNEXT_RSP;
1819 typedef struct smb_com_transaction2_fnext_rsp_parms {
1822 __le16 EAErrorOffset;
1823 __le16 LastNameOffset;
1824 } __attribute__((packed)) T2_FNEXT_RSP_PARMS;
1826 /* QFSInfo Levels */
1827 #define SMB_INFO_ALLOCATION 1
1828 #define SMB_INFO_VOLUME 2
1829 #define SMB_QUERY_FS_VOLUME_INFO 0x102
1830 #define SMB_QUERY_FS_SIZE_INFO 0x103
1831 #define SMB_QUERY_FS_DEVICE_INFO 0x104
1832 #define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
1833 #define SMB_QUERY_CIFS_UNIX_INFO 0x200
1834 #define SMB_QUERY_POSIX_FS_INFO 0x201
1835 #define SMB_QUERY_POSIX_WHO_AM_I 0x202
1836 #define SMB_REQUEST_TRANSPORT_ENCRYPTION 0x203
1837 #define SMB_QUERY_FS_PROXY 0x204 /* WAFS enabled. Returns structure
1838 FILE_SYSTEM__UNIX_INFO to tell
1839 whether new NTIOCTL available
1840 (0xACE) for WAN friendly SMB
1841 operations to be carried */
1842 #define SMB_QUERY_LABEL_INFO 0x3ea
1843 #define SMB_QUERY_FS_QUOTA_INFO 0x3ee
1844 #define SMB_QUERY_FS_FULL_SIZE_INFO 0x3ef
1845 #define SMB_QUERY_OBJECTID_INFO 0x3f0
1847 typedef struct smb_com_transaction2_qfsi_req {
1848 struct smb_hdr hdr; /* wct = 14+ */
1849 __le16 TotalParameterCount;
1850 __le16 TotalDataCount;
1851 __le16 MaxParameterCount;
1852 __le16 MaxDataCount;
1858 __le16 ParameterCount;
1859 __le16 ParameterOffset;
1864 __le16 SubCommand; /* one setup word */
1867 __le16 InformationLevel;
1868 } __attribute__((packed)) TRANSACTION2_QFSI_REQ;
1870 typedef struct smb_com_transaction_qfsi_rsp {
1871 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1872 struct trans2_resp t2;
1874 __u8 Pad; /* may be three bytes? *//* followed by data area */
1875 } __attribute__((packed)) TRANSACTION2_QFSI_RSP;
1877 typedef struct whoami_rsp_data { /* Query level 0x202 */
1878 __u32 flags; /* 0 = Authenticated user 1 = GUEST */
1879 __u32 mask; /* which flags bits server understands ie 0x0001 */
1881 __u64 unix_user_gid;
1882 __u32 number_of_supplementary_gids; /* may be zero */
1883 __u32 number_of_sids; /* may be zero */
1884 __u32 length_of_sid_array; /* in bytes - may be zero */
1885 __u32 pad; /* reserved - MBZ */
1886 /* __u64 gid_array[0]; */ /* may be empty */
1887 /* __u8 * psid_list */ /* may be empty */
1888 } __attribute__((packed)) WHOAMI_RSP_DATA;
1890 /* SETFSInfo Levels */
1891 #define SMB_SET_CIFS_UNIX_INFO 0x200
1892 typedef struct smb_com_transaction2_setfsi_req {
1893 struct smb_hdr hdr; /* wct = 15 */
1894 __le16 TotalParameterCount;
1895 __le16 TotalDataCount;
1896 __le16 MaxParameterCount;
1897 __le16 MaxDataCount;
1903 __le16 ParameterCount; /* 4 */
1904 __le16 ParameterOffset;
1905 __le16 DataCount; /* 12 */
1907 __u8 SetupCount; /* one */
1909 __le16 SubCommand; /* TRANS2_SET_FS_INFORMATION */
1912 __u16 FileNum; /* Parameters start. */
1913 __le16 InformationLevel;/* Parameters end. */
1914 __le16 ClientUnixMajor; /* Data start. */
1915 __le16 ClientUnixMinor;
1916 __le64 ClientUnixCap; /* Data end */
1917 } __attribute__((packed)) TRANSACTION2_SETFSI_REQ;
1919 typedef struct smb_com_transaction2_setfsi_rsp {
1920 struct smb_hdr hdr; /* wct = 10 */
1921 struct trans2_resp t2;
1923 } __attribute__((packed)) TRANSACTION2_SETFSI_RSP;
1926 typedef struct smb_com_transaction2_get_dfs_refer_req {
1927 struct smb_hdr hdr; /* wct = 15 */
1928 __le16 TotalParameterCount;
1929 __le16 TotalDataCount;
1930 __le16 MaxParameterCount;
1931 __le16 MaxDataCount;
1937 __le16 ParameterCount;
1938 __le16 ParameterOffset;
1943 __le16 SubCommand; /* one setup word */
1945 __u8 Pad[3]; /* Win2K has sent 0x0F01 (max response length
1946 perhaps?) followed by one byte pad - doesn't
1947 seem to matter though */
1948 __le16 MaxReferralLevel;
1949 char RequestFileName[1];
1950 } __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_REQ;
1952 #define DFS_VERSION cpu_to_le16(0x0003)
1954 /* DFS server target type */
1955 #define DFS_TYPE_LINK 0x0000 /* also for sysvol targets */
1956 #define DFS_TYPE_ROOT 0x0001
1958 /* Referral Entry Flags */
1959 #define DFS_NAME_LIST_REF 0x0200 /* set for domain or DC referral responses */
1960 #define DFS_TARGET_SET_BOUNDARY 0x0400 /* only valid with version 4 dfs req */
1962 typedef struct dfs_referral_level_3 { /* version 4 is same, + one flag bit */
1963 __le16 VersionNumber; /* must be 3 or 4 */
1965 __le16 ServerType; /* 0x0001 = root targets; 0x0000 = link targets */
1966 __le16 ReferralEntryFlags;
1968 __le16 DfsPathOffset;
1969 __le16 DfsAlternatePathOffset;
1970 __le16 NetworkAddressOffset; /* offset of the link target */
1971 __u8 ServiceSiteGuid[16]; /* MBZ, ignored */
1972 } __attribute__((packed)) REFERRAL3;
1974 typedef struct smb_com_transaction_get_dfs_refer_rsp {
1975 struct smb_hdr hdr; /* wct = 10 */
1976 struct trans2_resp t2;
1979 __le16 PathConsumed;
1980 __le16 NumberOfReferrals;
1982 REFERRAL3 referrals[1]; /* array of level 3 dfs_referral structures */
1983 /* followed by the strings pointed to by the referral structures */
1984 } __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_RSP;
1987 #define DFSREF_REFERRAL_SERVER 0x00000001 /* all targets are DFS roots */
1988 #define DFSREF_STORAGE_SERVER 0x00000002 /* no further ref requests needed */
1989 #define DFSREF_TARGET_FAILBACK 0x00000004 /* only for DFS referral version 4 */
1992 ************************************************************************
1993 * All structs for everything above the SMB PDUs themselves
1994 * (such as the T2 level specific data) go here
1995 ************************************************************************
1999 * Information on a server
2004 unsigned char versionMajor;
2005 unsigned char versionMinor;
2007 unsigned int commentOffset;
2008 } __attribute__((packed));
2011 * The following structure is the format of the data returned on a NetShareEnum
2012 * with level "90" (x5A)
2018 unsigned short type;
2019 unsigned int commentOffset;
2020 } __attribute__((packed));
2025 unsigned int commentOffset;
2026 unsigned char type[2];
2027 } __attribute__((packed));
2029 struct aliasInfo92 {
2030 int aliasNameOffset;
2031 int serverNameOffset;
2032 int shareNameOffset;
2033 } __attribute__((packed));
2036 __le64 TotalAllocationUnits;
2037 __le64 FreeAllocationUnits;
2038 __le32 SectorsPerAllocationUnit;
2039 __le32 BytesPerSector;
2040 } __attribute__((packed)) FILE_SYSTEM_INFO; /* size info, level 0x103 */
2044 __le32 SectorsPerAllocationUnit;
2045 __le32 TotalAllocationUnits;
2046 __le32 FreeAllocationUnits;
2047 __le16 BytesPerSector;
2048 } __attribute__((packed)) FILE_SYSTEM_ALLOC_INFO;
2051 __le16 MajorVersionNumber;
2052 __le16 MinorVersionNumber;
2054 } __attribute__((packed)) FILE_SYSTEM_UNIX_INFO; /* Unix extension level 0x200*/
2056 /* Version numbers for CIFS UNIX major and minor. */
2057 #define CIFS_UNIX_MAJOR_VERSION 1
2058 #define CIFS_UNIX_MINOR_VERSION 0
2060 /* Linux/Unix extensions capability flags */
2061 #define CIFS_UNIX_FCNTL_CAP 0x00000001 /* support for fcntl locks */
2062 #define CIFS_UNIX_POSIX_ACL_CAP 0x00000002 /* support getfacl/setfacl */
2063 #define CIFS_UNIX_XATTR_CAP 0x00000004 /* support new namespace */
2064 #define CIFS_UNIX_EXTATTR_CAP 0x00000008 /* support chattr/chflag */
2065 #define CIFS_UNIX_POSIX_PATHNAMES_CAP 0x00000010 /* Allow POSIX path chars */
2066 #define CIFS_UNIX_POSIX_PATH_OPS_CAP 0x00000020 /* Allow new POSIX path based
2067 calls including posix open
2069 #define CIFS_UNIX_LARGE_READ_CAP 0x00000040 /* support reads >128K (up
2071 #define CIFS_UNIX_LARGE_WRITE_CAP 0x00000080
2072 #define CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP 0x00000100 /* can do SPNEGO crypt */
2073 #define CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP 0x00000200 /* must do */
2074 #define CIFS_UNIX_PROXY_CAP 0x00000400 /* Proxy cap: 0xACE ioctl and
2076 #ifdef CONFIG_CIFS_POSIX
2077 /* Can not set pathnames cap yet until we send new posix create SMB since
2078 otherwise server can treat such handles opened with older ntcreatex
2079 (by a new client which knows how to send posix path ops)
2080 as non-posix handles (can affect write behavior with byte range locks.
2081 We can add back in POSIX_PATH_OPS cap when Posix Create/Mkdir finished */
2082 /* #define CIFS_UNIX_CAP_MASK 0x000000fb */
2083 #define CIFS_UNIX_CAP_MASK 0x000000db
2085 #define CIFS_UNIX_CAP_MASK 0x00000013
2086 #endif /* CONFIG_CIFS_POSIX */
2089 #define CIFS_POSIX_EXTENSIONS 0x00000010 /* support for new QFSInfo */
2092 /* For undefined recommended transfer size return -1 in that field */
2093 __le32 OptimalTransferSize; /* bsize on some os, iosize on other os */
2095 /* The next three fields are in terms of the block size.
2096 (above). If block size is unknown, 4096 would be a
2097 reasonable block size for a server to report.
2098 Note that returning the blocks/blocksavail removes need
2099 to make a second call (to QFSInfo level 0x103 to get this info.
2100 UserBlockAvail is typically less than or equal to BlocksAvail,
2101 if no distinction is made return the same value in each */
2103 __le64 BlocksAvail; /* bfree */
2104 __le64 UserBlocksAvail; /* bavail */
2105 /* For undefined Node fields or FSID return -1 */
2106 __le64 TotalFileNodes;
2107 __le64 FreeFileNodes;
2108 __le64 FileSysIdentifier; /* fsid */
2109 /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
2110 /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */
2111 } __attribute__((packed)) FILE_SYSTEM_POSIX_INFO;
2113 /* DeviceType Flags */
2114 #define FILE_DEVICE_CD_ROM 0x00000002
2115 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
2116 #define FILE_DEVICE_DFS 0x00000006
2117 #define FILE_DEVICE_DISK 0x00000007
2118 #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
2119 #define FILE_DEVICE_FILE_SYSTEM 0x00000009
2120 #define FILE_DEVICE_NAMED_PIPE 0x00000011
2121 #define FILE_DEVICE_NETWORK 0x00000012
2122 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
2123 #define FILE_DEVICE_NULL 0x00000015
2124 #define FILE_DEVICE_PARALLEL_PORT 0x00000016
2125 #define FILE_DEVICE_PRINTER 0x00000018
2126 #define FILE_DEVICE_SERIAL_PORT 0x0000001b
2127 #define FILE_DEVICE_STREAMS 0x0000001e
2128 #define FILE_DEVICE_TAPE 0x0000001f
2129 #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
2130 #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
2131 #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
2135 __le32 DeviceCharacteristics;
2136 } __attribute__((packed)) FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */
2140 __le32 MaxPathNameComponentLength;
2141 __le32 FileSystemNameLen;
2142 char FileSystemName[52]; /* do not have to save this - get subset? */
2143 } __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
2145 /******************************************************************************/
2146 /* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
2147 /******************************************************************************/
2148 typedef struct { /* data block encoding of response to level 263 QPathInfo */
2149 __le64 CreationTime;
2150 __le64 LastAccessTime;
2151 __le64 LastWriteTime;
2155 __le64 AllocationSize;
2156 __le64 EndOfFile; /* size ie offset to first free byte in file */
2157 __le32 NumberOfLinks; /* hard links */
2165 __le64 CurrentByteOffset;
2167 __le32 AlignmentRequirement;
2168 __le32 FileNameLength;
2170 } __attribute__((packed)) FILE_ALL_INFO; /* level 0x107 QPathInfo */
2172 /* defines for enumerating possible values of the Unix type field below */
2175 #define UNIX_SYMLINK 2
2176 #define UNIX_CHARDEV 3
2177 #define UNIX_BLOCKDEV 4
2179 #define UNIX_SOCKET 6
2183 __le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */
2184 __le64 LastAccessTime;
2185 __le64 LastModificationTime;
2194 } __attribute__((packed)) FILE_UNIX_BASIC_INFO; /* level 0x200 QPathInfo */
2198 } __attribute__((packed)) FILE_UNIX_LINK_INFO; /* level 0x201 QPathInfo */
2200 /* The following three structures are needed only for
2201 setting time to NT4 and some older servers via
2202 the primitive DOS time format */
2207 } __attribute__((packed)) SMB_DATE;
2213 } __attribute__((packed)) SMB_TIME;
2216 __le16 CreationDate; /* SMB Date see above */
2217 __le16 CreationTime; /* SMB Time */
2218 __le16 LastAccessDate;
2219 __le16 LastAccessTime;
2220 __le16 LastWriteDate;
2221 __le16 LastWriteTime;
2222 __le32 DataSize; /* File Size (EOF) */
2223 __le32 AllocationSize;
2224 __le16 Attributes; /* verify not u32 */
2226 } __attribute__((packed)) FILE_INFO_STANDARD; /* level 1 SetPath/FileInfo */
2229 __le64 CreationTime;
2230 __le64 LastAccessTime;
2231 __le64 LastWriteTime;
2235 } __attribute__((packed)) FILE_BASIC_INFO; /* size info, level 0x101 */
2237 struct file_allocation_info {
2238 __le64 AllocationSize; /* Note old Samba srvr rounds this up too much */
2239 } __attribute__((packed)); /* size used on disk, for level 0x103 for set,
2242 struct file_end_of_file_info {
2243 __le64 FileSize; /* offset to end of file */
2244 } __attribute__((packed)); /* size info, level 0x104 for set, 0x106 for query */
2246 struct file_alt_name_info {
2248 } __attribute__((packed)); /* level 0x0108 */
2250 struct file_stream_info {
2251 __le32 number_of_streams; /* BB check sizes and verify location */
2252 /* followed by info on streams themselves
2256 }; /* level 0x109 */
2258 struct file_compression_info {
2259 __le64 compressed_size;
2265 } __attribute__((packed)); /* level 0x10b */
2267 /* POSIX ACL set/query path info structures */
2268 #define CIFS_ACL_VERSION 1
2269 struct cifs_posix_ace { /* access control entry (ACE) */
2272 __le64 cifs_uid; /* or gid */
2273 } __attribute__((packed));
2275 struct cifs_posix_acl { /* access conrol list (ACL) */
2277 __le16 access_entry_count; /* access ACL - count of entries */
2278 __le16 default_entry_count; /* default ACL - count of entries */
2279 struct cifs_posix_ace ace_array[0];
2281 struct cifs_posix_ace default_ace_arraay[] */
2282 } __attribute__((packed)); /* level 0x204 */
2284 /* types of access control entries already defined in posix_acl.h */
2285 /* #define CIFS_POSIX_ACL_USER_OBJ 0x01
2286 #define CIFS_POSIX_ACL_USER 0x02
2287 #define CIFS_POSIX_ACL_GROUP_OBJ 0x04
2288 #define CIFS_POSIX_ACL_GROUP 0x08
2289 #define CIFS_POSIX_ACL_MASK 0x10
2290 #define CIFS_POSIX_ACL_OTHER 0x20 */
2292 /* types of perms */
2293 /* #define CIFS_POSIX_ACL_EXECUTE 0x01
2294 #define CIFS_POSIX_ACL_WRITE 0x02
2295 #define CIFS_POSIX_ACL_READ 0x04 */
2297 /* end of POSIX ACL definitions */
2299 /* POSIX Open Flags */
2300 #define SMB_O_RDONLY 0x1
2301 #define SMB_O_WRONLY 0x2
2302 #define SMB_O_RDWR 0x4
2303 #define SMB_O_CREAT 0x10
2304 #define SMB_O_EXCL 0x20
2305 #define SMB_O_TRUNC 0x40
2306 #define SMB_O_APPEND 0x80
2307 #define SMB_O_SYNC 0x100
2308 #define SMB_O_DIRECTORY 0x200
2309 #define SMB_O_NOFOLLOW 0x400
2310 #define SMB_O_DIRECT 0x800
2313 __le32 OpenFlags; /* same as NT CreateX */
2314 __le32 PosixOpenFlags;
2316 __le16 Level; /* reply level requested (see QPathInfo levels) */
2317 } __attribute__((packed)) OPEN_PSX_REQ; /* level 0x209 SetPathInfo data */
2322 __le32 CreateAction;
2323 __le16 ReturnedLevel;
2325 /* struct following varies based on requested level */
2326 } __attribute__((packed)) OPEN_PSX_RSP; /* level 0x209 SetPathInfo data */
2328 #define SMB_POSIX_UNLINK_FILE_TARGET 0
2329 #define SMB_POSIX_UNLINK_DIRECTORY_TARGET 1
2331 struct unlink_psx_rq { /* level 0x20a SetPathInfo */
2333 } __attribute__((packed));
2335 struct file_internal_info {
2336 __le64 UniqueId; /* inode number */
2337 } __attribute__((packed)); /* level 0x3ee */
2339 struct file_mode_info {
2341 } __attribute__((packed)); /* level 0x3f8 */
2343 struct file_attrib_tag {
2346 } __attribute__((packed)); /* level 0x40b */
2349 /********************************************************/
2350 /* FindFirst/FindNext transact2 data buffer formats */
2351 /********************************************************/
2354 __le32 NextEntryOffset;
2355 __u32 ResumeKey; /* as with FileIndex - no need to convert */
2356 FILE_UNIX_BASIC_INFO basic;
2358 } __attribute__((packed)) FILE_UNIX_INFO; /* level 0x202 */
2361 __le32 NextEntryOffset;
2363 __le64 CreationTime;
2364 __le64 LastAccessTime;
2365 __le64 LastWriteTime;
2368 __le64 AllocationSize;
2369 __le32 ExtFileAttributes;
2370 __le32 FileNameLength;
2372 } __attribute__((packed)) FILE_DIRECTORY_INFO; /* level 0x101 FF resp data */
2375 __le32 NextEntryOffset;
2377 __le64 CreationTime;
2378 __le64 LastAccessTime;
2379 __le64 LastWriteTime;
2382 __le64 AllocationSize;
2383 __le32 ExtFileAttributes;
2384 __le32 FileNameLength;
2385 __le32 EaSize; /* length of the xattrs */
2387 } __attribute__((packed)) FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */
2390 __le32 NextEntryOffset;
2392 __le64 CreationTime;
2393 __le64 LastAccessTime;
2394 __le64 LastWriteTime;
2397 __le64 AllocationSize;
2398 __le32 ExtFileAttributes;
2399 __le32 FileNameLength;
2400 __le32 EaSize; /* EA size */
2402 __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
2404 } __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */
2407 __le32 NextEntryOffset;
2409 __le64 CreationTime;
2410 __le64 LastAccessTime;
2411 __le64 LastWriteTime;
2414 __le64 AllocationSize;
2415 __le32 ExtFileAttributes;
2416 __le32 FileNameLength;
2417 __le32 EaSize; /* length of the xattrs */
2418 __u8 ShortNameLength;
2422 } __attribute__((packed)) FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FFrsp data */
2426 __le16 CreationDate; /* SMB Date */
2427 __le16 CreationTime; /* SMB Time */
2428 __le16 LastAccessDate;
2429 __le16 LastAccessTime;
2430 __le16 LastWriteDate;
2431 __le16 LastWriteTime;
2432 __le32 DataSize; /* File Size (EOF) */
2433 __le32 AllocationSize;
2434 __le16 Attributes; /* verify not u32 */
2435 __u8 FileNameLength;
2437 } __attribute__((packed)) FIND_FILE_STANDARD_INFO; /* level 0x1 FF resp data */
2441 unsigned char type[8]; /* IntxCHR or IntxBLK */
2444 } __attribute__((packed));
2447 unsigned char name_len;
2449 } __attribute__((packed));
2452 unsigned long list_len;
2454 } __attribute__((packed));
2457 unsigned char EA_flags;
2461 /* optionally followed by value */
2462 } __attribute__((packed));
2463 /* flags for _FEA.fEA */
2464 #define FEA_NEEDEA 0x80 /* need EA bit */
2469 } __attribute__((packed));
2471 /* used to hold an arbitrary blob of data */
2475 void (*free) (struct data_blob *data_blob);
2476 } __attribute__((packed));
2479 #ifdef CONFIG_CIFS_POSIX
2481 For better POSIX semantics from Linux client, (even better
2482 than the existing CIFS Unix Extensions) we need updated PDUs for:
2484 1) PosixCreateX - to set and return the mode, inode#, device info and
2485 perhaps add a CreateDevice - to create Pipes and other special .inodes
2486 Also note POSIX open flags
2487 2) Close - to return the last write time to do cache across close
2489 3) FindFirst return unique inode number - what about resume key, two
2490 forms short (matches readdir) and full (enough info to cache inodes)
2493 And under consideration:
2494 5) FindClose2 (return nanosecond timestamp ??)
2495 6) Use nanosecond timestamps throughout all time fields if
2496 corresponding attribute flag is set
2497 7) sendfile - handle based copy
2499 what about fixing 64 bit alignment
2501 There are also various legacy SMB/CIFS requests used as is
2503 From existing Lanman and NTLM dialects:
2504 --------------------------------------
2506 SESSION_SETUP_ANDX (BB which?)
2507 TREE_CONNECT_ANDX (BB which wct?)
2508 TREE_DISCONNECT (BB add volume timestamp on response)
2510 DELETE (note delete open file behavior)
2514 LOCKING_AND_X (note posix lock semantics)
2515 RENAME (note rename across dirs and open file rename posix behaviors)
2516 NT_RENAME (for hardlinks) Is this good enough for all features?
2518 TRANSACTION2 (18 cases)
2519 SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2
2520 (BB verify that never need to set allocation size)
2521 SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via
2524 COPY (note support for copy across directories) - FUTURE, OPTIONAL
2525 setting/getting OS/2 EAs - FUTURE (BB can this handle
2526 setting Linux xattrs perfectly) - OPTIONAL
2527 dnotify - FUTURE, OPTIONAL
2528 quota - FUTURE, OPTIONAL
2530 Note that various requests implemented for NT interop such as
2531 NT_TRANSACT (IOCTL) QueryReparseInfo
2532 are unneeded to servers compliant with the CIFS POSIX extensions
2534 From CIFS Unix Extensions:
2535 -------------------------
2536 T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks
2537 T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2)
2538 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK)
2539 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC) BB check for missing
2541 Actually a need QUERY_FILE_UNIX_INFO
2543 BB what about a) blksize/blkbits/blocks
2549 T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX
2550 TRANS2_GET_DFS_REFERRAL - OPTIONAL but recommended
2551 T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL
2554 /* xsymlink is a symlink format (used by MacOS) that can be used
2555 to save symlink info in a regular file when
2556 mounted to operating systems that do not
2557 support the cifs Unix extensions or EAs (for xattr
2558 based symlinks). For such a file to be recognized
2559 as containing symlink data:
2561 1) file size must be 1067,
2562 2) signature must begin file data,
2563 3) length field must be set to ASCII representation
2564 of a number which is less than or equal to 1024,
2565 4) md5 must match that of the path data */
2569 char signature[4]; /* XSym */ /* not null terminated */
2571 /* ASCII representation of length (4 bytes decimal) terminated by \n not null */
2574 /* md5 of valid subset of path ie path[0] through path[length-1] */
2577 /* if room left, then end with \n then 0x20s by convention but not required */
2579 } __attribute__((packed));
2581 typedef struct file_xattr_info {
2582 /* BB do we need another field for flags? BB */
2583 __u32 xattr_name_len;
2584 __u32 xattr_value_len;
2586 /* followed by xattr_value[xattr_value_len], no pad */
2587 } __attribute__((packed)) FILE_XATTR_INFO; /* extended attribute info
2591 /* flags for chattr command */
2592 #define EXT_SECURE_DELETE 0x00000001 /* EXT3_SECRM_FL */
2593 #define EXT_ENABLE_UNDELETE 0x00000002 /* EXT3_UNRM_FL */
2594 /* Reserved for compress file 0x4 */
2595 #define EXT_SYNCHRONOUS 0x00000008 /* EXT3_SYNC_FL */
2596 #define EXT_IMMUTABLE_FL 0x00000010 /* EXT3_IMMUTABLE_FL */
2597 #define EXT_OPEN_APPEND_ONLY 0x00000020 /* EXT3_APPEND_FL */
2598 #define EXT_DO_NOT_BACKUP 0x00000040 /* EXT3_NODUMP_FL */
2599 #define EXT_NO_UPDATE_ATIME 0x00000080 /* EXT3_NOATIME_FL */
2600 /* 0x100 through 0x800 reserved for compression flags and are GET-ONLY */
2601 #define EXT_HASH_TREE_INDEXED_DIR 0x00001000 /* GET-ONLY EXT3_INDEX_FL */
2602 /* 0x2000 reserved for IMAGIC_FL */
2603 #define EXT_JOURNAL_THIS_FILE 0x00004000 /* GET-ONLY EXT3_JOURNAL_DATA_FL */
2604 /* 0x8000 reserved for EXT3_NOTAIL_FL */
2605 #define EXT_SYNCHRONOUS_DIR 0x00010000 /* EXT3_DIRSYNC_FL */
2606 #define EXT_TOPDIR 0x00020000 /* EXT3_TOPDIR_FL */
2608 #define EXT_SET_MASK 0x000300FF
2609 #define EXT_GET_MASK 0x0003DFFF
2611 typedef struct file_chattr_info {
2612 __le64 mask; /* list of all possible attribute bits */
2613 __le64 mode; /* list of actual attribute bits on this inode */
2614 } __attribute__((packed)) FILE_CHATTR_INFO; /* ext attributes
2615 (chattr, chflags) level 0x206 */
2617 #endif /* _CIFSPDU_H */