4 * Copyright (c) International Business Machines Corp., 2002,2007
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
27 #ifdef CONFIG_CIFS_WEAK_PW_HASH
29 #define LANMAN2_PROT 1
34 #define POSIX_PROT CIFS_PROT+1
35 #define BAD_PROT 0xFFFF
37 /* SMB command codes */
39 * 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 * Knowing this helps 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_DELETE 0x06 /* trivial response */
47 #define SMB_COM_RENAME 0x07 /* trivial response */
48 #define SMB_COM_QUERY_INFORMATION 0x08 /* aka getattr */
49 #define SMB_COM_SETATTR 0x09 /* trivial response */
50 #define SMB_COM_LOCKING_ANDX 0x24 /* trivial response */
51 #define SMB_COM_COPY 0x29 /* trivial rsp, fail filename ignrd*/
52 #define SMB_COM_OPEN_ANDX 0x2D /* Legacy open for old servers */
53 #define SMB_COM_READ_ANDX 0x2E
54 #define SMB_COM_WRITE_ANDX 0x2F
55 #define SMB_COM_TRANSACTION2 0x32
56 #define SMB_COM_TRANSACTION2_SECONDARY 0x33
57 #define SMB_COM_FIND_CLOSE2 0x34 /* trivial response */
58 #define SMB_COM_TREE_DISCONNECT 0x71 /* trivial response */
59 #define SMB_COM_NEGOTIATE 0x72
60 #define SMB_COM_SESSION_SETUP_ANDX 0x73
61 #define SMB_COM_LOGOFF_ANDX 0x74 /* trivial response */
62 #define SMB_COM_TREE_CONNECT_ANDX 0x75
63 #define SMB_COM_NT_TRANSACT 0xA0
64 #define SMB_COM_NT_TRANSACT_SECONDARY 0xA1
65 #define SMB_COM_NT_CREATE_ANDX 0xA2
66 #define SMB_COM_NT_CANCEL 0xA4 /* no response */
67 #define SMB_COM_NT_RENAME 0xA5 /* trivial response */
69 /* Transact2 subcommand codes */
70 #define TRANS2_OPEN 0x00
71 #define TRANS2_FIND_FIRST 0x01
72 #define TRANS2_FIND_NEXT 0x02
73 #define TRANS2_QUERY_FS_INFORMATION 0x03
74 #define TRANS2_SET_FS_INFORMATION 0x04
75 #define TRANS2_QUERY_PATH_INFORMATION 0x05
76 #define TRANS2_SET_PATH_INFORMATION 0x06
77 #define TRANS2_QUERY_FILE_INFORMATION 0x07
78 #define TRANS2_SET_FILE_INFORMATION 0x08
79 #define TRANS2_GET_DFS_REFERRAL 0x10
80 #define TRANS2_REPORT_DFS_INCOSISTENCY 0x11
82 /* NT Transact subcommand codes */
83 #define NT_TRANSACT_CREATE 0x01
84 #define NT_TRANSACT_IOCTL 0x02
85 #define NT_TRANSACT_SET_SECURITY_DESC 0x03
86 #define NT_TRANSACT_NOTIFY_CHANGE 0x04
87 #define NT_TRANSACT_RENAME 0x05
88 #define NT_TRANSACT_QUERY_SECURITY_DESC 0x06
89 #define NT_TRANSACT_GET_USER_QUOTA 0x07
90 #define NT_TRANSACT_SET_USER_QUOTA 0x08
92 #define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */
93 /* future chained NTCreateXReadX bigger, but for time being NTCreateX biggest */
94 /* among the requests (NTCreateX response is bigger with wct of 34) */
95 #define MAX_CIFS_HDR_SIZE 0x58 /* 4 len + 32 hdr + (2*24 wct) + 2 bct + 2 pad */
96 #define CIFS_SMALL_PATH 120 /* allows for (448-88)/3 */
98 /* internal cifs vfs structures */
99 /*****************************************************************
100 * All constants go here
101 *****************************************************************
105 * Starting value for maximum SMB size negotiation
107 #define CIFS_MAX_MSGSIZE (4*4096)
110 * Size of encrypted user password in bytes
112 #define CIFS_ENCPWD_SIZE (16)
115 * Size of the crypto key returned on the negotiate SMB in bytes
117 #define CIFS_CRYPTO_KEY_SIZE (8)
120 * Size of the session key (crypto key encrypted with the password
122 #define CIFS_SESS_KEY_SIZE (24)
125 * Maximum user name length
127 #define CIFS_UNLEN (20)
132 #define SMBOPEN_WRITE_THROUGH 0x4000
133 #define SMBOPEN_DENY_ALL 0x0010
134 #define SMBOPEN_DENY_WRITE 0x0020
135 #define SMBOPEN_DENY_READ 0x0030
136 #define SMBOPEN_DENY_NONE 0x0040
137 #define SMBOPEN_READ 0x0000
138 #define SMBOPEN_WRITE 0x0001
139 #define SMBOPEN_READWRITE 0x0002
140 #define SMBOPEN_EXECUTE 0x0003
142 #define SMBOPEN_OCREATE 0x0010
143 #define SMBOPEN_OTRUNC 0x0002
144 #define SMBOPEN_OAPPEND 0x0001
147 * SMB flag definitions
149 #define SMBFLG_EXTD_LOCK 0x01 /* server supports lock-read write-unlock smb */
150 #define SMBFLG_RCV_POSTED 0x02 /* obsolete */
151 #define SMBFLG_RSVD 0x04
152 #define SMBFLG_CASELESS 0x08 /* all pathnames treated as caseless (off
153 implies case sensitive file handling request) */
154 #define SMBFLG_CANONICAL_PATH_FORMAT 0x10 /* obsolete */
155 #define SMBFLG_OLD_OPLOCK 0x20 /* obsolete */
156 #define SMBFLG_OLD_OPLOCK_NOTIFY 0x40 /* obsolete */
157 #define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */
160 * SMB flag2 definitions
162 #define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1) /* can send long (non-8.3)
163 path names in response */
164 #define SMBFLG2_KNOWS_EAS cpu_to_le16(2)
165 #define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4)
166 #define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40)
167 #define SMBFLG2_EXT_SEC cpu_to_le16(0x800)
168 #define SMBFLG2_DFS cpu_to_le16(0x1000)
169 #define SMBFLG2_PAGING_IO cpu_to_le16(0x2000)
170 #define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)
171 #define SMBFLG2_UNICODE cpu_to_le16(0x8000)
174 * These are the file access permission bits defined in CIFS for the
175 * NTCreateAndX as well as the level 0x107
176 * TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO
177 * responds with the AccessFlags.
178 * The AccessFlags specifies the access permissions a caller has to the
179 * file and can have any suitable combination of the following values:
182 #define FILE_READ_DATA 0x00000001 /* Data can be read from the file */
183 #define FILE_WRITE_DATA 0x00000002 /* Data can be written to the file */
184 #define FILE_APPEND_DATA 0x00000004 /* Data can be appended to the file */
185 #define FILE_READ_EA 0x00000008 /* Extended attributes associated */
186 /* with the file can be read */
187 #define FILE_WRITE_EA 0x00000010 /* Extended attributes associated */
188 /* with the file can be written */
189 #define FILE_EXECUTE 0x00000020 /*Data can be read into memory from */
190 /* the file using system paging I/O */
191 #define FILE_DELETE_CHILD 0x00000040
192 #define FILE_READ_ATTRIBUTES 0x00000080 /* Attributes associated with the */
193 /* file can be read */
194 #define FILE_WRITE_ATTRIBUTES 0x00000100 /* Attributes associated with the */
195 /* file can be written */
196 #define DELETE 0x00010000 /* The file can be deleted */
197 #define READ_CONTROL 0x00020000 /* The access control list and */
198 /* ownership associated with the */
199 /* file can be read */
200 #define WRITE_DAC 0x00040000 /* The access control list and */
201 /* ownership associated with the */
202 /* file can be written. */
203 #define WRITE_OWNER 0x00080000 /* Ownership information associated */
204 /* with the file can be written */
205 #define SYNCHRONIZE 0x00100000 /* The file handle can waited on to */
206 /* synchronize with the completion */
207 /* of an input/output request */
208 #define GENERIC_ALL 0x10000000
209 #define GENERIC_EXECUTE 0x20000000
210 #define GENERIC_WRITE 0x40000000
211 #define GENERIC_READ 0x80000000
212 /* In summary - Relevant file */
213 /* access flags from CIFS are */
214 /* file_read_data, file_write_data */
215 /* file_execute, file_read_attributes*/
216 /* write_dac, and delete. */
218 #define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES)
219 #define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
220 | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES)
221 #define FILE_EXEC_RIGHTS (FILE_EXECUTE)
223 #define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_WRITE_EA \
224 | FILE_READ_ATTRIBUTES \
225 | FILE_WRITE_ATTRIBUTES \
226 | DELETE | READ_CONTROL | WRITE_DAC \
227 | WRITE_OWNER | SYNCHRONIZE)
228 #define SET_FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
229 | FILE_READ_EA | FILE_WRITE_EA \
230 | FILE_DELETE_CHILD | FILE_READ_ATTRIBUTES \
231 | FILE_WRITE_ATTRIBUTES \
232 | DELETE | READ_CONTROL | WRITE_DAC \
233 | WRITE_OWNER | SYNCHRONIZE)
234 #define SET_FILE_EXEC_RIGHTS (FILE_READ_EA | FILE_WRITE_EA | FILE_EXECUTE \
235 | FILE_READ_ATTRIBUTES \
236 | FILE_WRITE_ATTRIBUTES \
237 | DELETE | READ_CONTROL | WRITE_DAC \
238 | WRITE_OWNER | SYNCHRONIZE)
242 * Invalid readdir handle
244 #define CIFS_NO_HANDLE 0xFFFF
246 #define NO_CHANGE_64 cpu_to_le64(0xFFFFFFFFFFFFFFFFULL)
247 #define NO_CHANGE_32 0xFFFFFFFFUL
250 #define CIFS_IPC_RESOURCE "\x49\x50\x43\x24"
252 /* IPC$ in Unicode */
253 #define CIFS_IPC_UNICODE_RESOURCE "\x00\x49\x00\x50\x00\x43\x00\x24\x00\x00"
255 /* Unicode Null terminate 2 bytes of 0 */
256 #define UNICODE_NULL "\x00\x00"
257 #define ASCII_NULL 0x00
260 * Server type values (returned on EnumServer API
262 #define CIFS_SV_TYPE_DC 0x00000008
263 #define CIFS_SV_TYPE_BACKDC 0x00000010
266 * Alias type flags (From EnumAlias API call
268 #define CIFS_ALIAS_TYPE_FILE 0x0001
269 #define CIFS_SHARE_TYPE_FILE 0x0000
272 * File Attribute flags
274 #define ATTR_READONLY 0x0001
275 #define ATTR_HIDDEN 0x0002
276 #define ATTR_SYSTEM 0x0004
277 #define ATTR_VOLUME 0x0008
278 #define ATTR_DIRECTORY 0x0010
279 #define ATTR_ARCHIVE 0x0020
280 #define ATTR_DEVICE 0x0040
281 #define ATTR_NORMAL 0x0080
282 #define ATTR_TEMPORARY 0x0100
283 #define ATTR_SPARSE 0x0200
284 #define ATTR_REPARSE 0x0400
285 #define ATTR_COMPRESSED 0x0800
286 #define ATTR_OFFLINE 0x1000 /* ie file not immediately available -
287 on offline storage */
288 #define ATTR_NOT_CONTENT_INDEXED 0x2000
289 #define ATTR_ENCRYPTED 0x4000
290 #define ATTR_POSIX_SEMANTICS 0x01000000
291 #define ATTR_BACKUP_SEMANTICS 0x02000000
292 #define ATTR_DELETE_ON_CLOSE 0x04000000
293 #define ATTR_SEQUENTIAL_SCAN 0x08000000
294 #define ATTR_RANDOM_ACCESS 0x10000000
295 #define ATTR_NO_BUFFERING 0x20000000
296 #define ATTR_WRITE_THROUGH 0x80000000
298 /* ShareAccess flags */
299 #define FILE_NO_SHARE 0x00000000
300 #define FILE_SHARE_READ 0x00000001
301 #define FILE_SHARE_WRITE 0x00000002
302 #define FILE_SHARE_DELETE 0x00000004
303 #define FILE_SHARE_ALL 0x00000007
305 /* CreateDisposition flags */
306 #define FILE_SUPERSEDE 0x00000000
307 #define FILE_OPEN 0x00000001
308 #define FILE_CREATE 0x00000002
309 #define FILE_OPEN_IF 0x00000003
310 #define FILE_OVERWRITE 0x00000004
311 #define FILE_OVERWRITE_IF 0x00000005
314 #define CREATE_NOT_FILE 0x00000001 /* if set must not be file */
315 #define CREATE_WRITE_THROUGH 0x00000002
316 #define CREATE_SEQUENTIAL 0x00000004
317 #define CREATE_SYNC_ALERT 0x00000010
318 #define CREATE_ASYNC_ALERT 0x00000020
319 #define CREATE_NOT_DIR 0x00000040 /* if set must not be directory */
320 #define CREATE_NO_EA_KNOWLEDGE 0x00000200
321 #define CREATE_EIGHT_DOT_THREE 0x00000400
322 #define CREATE_RANDOM_ACCESS 0x00000800
323 #define CREATE_DELETE_ON_CLOSE 0x00001000
324 #define CREATE_OPEN_BY_ID 0x00002000
325 #define OPEN_REPARSE_POINT 0x00200000
326 #define CREATE_OPTIONS_MASK 0x007FFFFF
327 #define CREATE_OPTION_SPECIAL 0x20000000 /* system. NB not sent over wire */
329 /* ImpersonationLevel flags */
330 #define SECURITY_ANONYMOUS 0
331 #define SECURITY_IDENTIFICATION 1
332 #define SECURITY_IMPERSONATION 2
333 #define SECURITY_DELEGATION 3
336 #define SECURITY_CONTEXT_TRACKING 0x01
337 #define SECURITY_EFFECTIVE_ONLY 0x02
340 * Default PID value, used in all SMBs where the PID is not important
342 #define CIFS_DFT_PID 0x1234
345 * We use the same routine for Copy and Move SMBs. This flag is used to
348 #define CIFS_COPY_OP 1
349 #define CIFS_RENAME_OP 2
351 #define GETU16(var) (*((__u16 *)var)) /* BB check for endian issues */
352 #define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */
355 __u32 smb_buf_length
; /* big endian on wire *//* BB length is only two
356 or three bytes - with one or two byte type preceding it that are
357 zero - we could mask the type byte off just in case BB */
365 } __attribute__((packed
)) DosError
;
367 } __attribute__((packed
)) Status
;
369 __le16 Flags2
; /* note: le */
373 __le32 SequenceNumber
; /* le */
374 __u32 Reserved
; /* zero */
375 } __attribute__((packed
)) Sequence
;
376 __u8 SecuritySignature
[8]; /* le */
377 } __attribute__((packed
)) Signature
;
384 } __attribute__((packed
));
385 /* given a pointer to an smb_hdr retrieve the value of byte count */
386 #define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount)))
387 #define BCC_LE(smb_var) ( *(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount)))
388 /* given a pointer to an smb_hdr retrieve the pointer to the byte area */
389 #define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount) + 2)
392 * Computer Name Length (since Netbios name was length 16 with last byte 0x20)
393 * No longer as important, now that TCP names are more commonly used to
399 * Share Name Length (SNLEN)
400 * Note: This length was limited by the SMB used to get
401 * the Share info. NetShareEnum only returned 13
402 * chars, including the null termination.
403 * This was removed because it no longer is limiting.
409 #define MAXCOMMENTLEN 40
412 * The OS/2 maximum path name
414 #define MAX_PATHCONF 256
417 * SMB frame definitions (following must be packed structs)
418 * See the SNIA CIFS Specification for details.
420 * The Naming convention is the lower case version of the
421 * smb command code name for the struct and this is typedef to the
422 * uppercase version of the same name with the prefix SMB_ removed
423 * for brevity. Although typedefs are not commonly used for
424 * structure definitions in the Linux kernel, their use in the
425 * CIFS standards document, which this code is based on, may
426 * make this one of the cases where typedefs for structures make
427 * sense to improve readability for readers of the standards doc.
428 * Typedefs can always be removed later if they are too distracting
429 * and they are only used for the CIFSs PDUs themselves, not
430 * internal cifs vfs structures
434 typedef struct negotiate_req
{
435 struct smb_hdr hdr
; /* wct = 0 */
437 unsigned char DialectsArray
[1];
438 } __attribute__((packed
)) NEGOTIATE_REQ
;
440 /* Dialect index is 13 for LANMAN */
442 #define MIN_TZ_ADJ (15 * 60) /* minimum grid for timezones in seconds */
444 typedef struct lanman_neg_rsp
{
445 struct smb_hdr hdr
; /* wct = 13 */
456 } __attribute__((packed
)) SrvTime
;
457 __le16 ServerTimeZone
;
458 __le16 EncryptionKeyLength
;
461 unsigned char EncryptionKey
[1];
462 } __attribute__((packed
)) LANMAN_NEG_RSP
;
464 #define READ_RAW_ENABLE 1
465 #define WRITE_RAW_ENABLE 2
466 #define RAW_ENABLE (READ_RAW_ENABLE | WRITE_RAW_ENABLE)
468 typedef struct negotiate_rsp
{
469 struct smb_hdr hdr
; /* wct = 17 */
474 __le32 MaxBufferSize
;
477 __le32 Capabilities
; /* see below */
478 __le32 SystemTimeLow
;
479 __le32 SystemTimeHigh
;
480 __le16 ServerTimeZone
;
481 __u8 EncryptionKeyLength
;
484 unsigned char EncryptionKey
[1]; /* cap extended security off */
485 /* followed by Domain name - if extended security is off */
486 /* followed by 16 bytes of server GUID */
487 /* then security blob if cap_extended_security negotiated */
489 unsigned char GUID
[16];
490 unsigned char SecurityBlob
[1];
491 } __attribute__((packed
)) extended_response
;
492 } __attribute__((packed
)) u
;
493 } __attribute__((packed
)) NEGOTIATE_RSP
;
495 /* SecurityMode bits */
496 #define SECMODE_USER 0x01 /* off indicates share level security */
497 #define SECMODE_PW_ENCRYPT 0x02
498 #define SECMODE_SIGN_ENABLED 0x04 /* SMB security signatures enabled */
499 #define SECMODE_SIGN_REQUIRED 0x08 /* SMB security signatures required */
501 /* Negotiate response Capabilities */
502 #define CAP_RAW_MODE 0x00000001
503 #define CAP_MPX_MODE 0x00000002
504 #define CAP_UNICODE 0x00000004
505 #define CAP_LARGE_FILES 0x00000008
506 #define CAP_NT_SMBS 0x00000010 /* implies CAP_NT_FIND */
507 #define CAP_RPC_REMOTE_APIS 0x00000020
508 #define CAP_STATUS32 0x00000040
509 #define CAP_LEVEL_II_OPLOCKS 0x00000080
510 #define CAP_LOCK_AND_READ 0x00000100
511 #define CAP_NT_FIND 0x00000200
512 #define CAP_DFS 0x00001000
513 #define CAP_INFOLEVEL_PASSTHRU 0x00002000
514 #define CAP_LARGE_READ_X 0x00004000
515 #define CAP_LARGE_WRITE_X 0x00008000
516 #define CAP_UNIX 0x00800000
517 #define CAP_RESERVED 0x02000000
518 #define CAP_BULK_TRANSFER 0x20000000
519 #define CAP_COMPRESSED_DATA 0x40000000
520 #define CAP_EXTENDED_SECURITY 0x80000000
522 typedef union smb_com_session_setup_andx
{
523 struct { /* request format */
524 struct smb_hdr hdr
; /* wct = 12 */
528 __le16 MaxBufferSize
;
532 __le16 SecurityBlobLength
;
534 __le32 Capabilities
; /* see below */
536 unsigned char SecurityBlob
[1]; /* followed by */
537 /* STRING NativeOS */
538 /* STRING NativeLanMan */
539 } __attribute__((packed
)) req
; /* NTLM request format (with
542 struct { /* request format */
543 struct smb_hdr hdr
; /* wct = 13 */
547 __le16 MaxBufferSize
;
551 __le16 CaseInsensitivePasswordLength
; /* ASCII password len */
552 __le16 CaseSensitivePasswordLength
; /* Unicode password length*/
553 __u32 Reserved
; /* see below */
556 unsigned char CaseInsensitivePassword
[1]; /* followed by: */
557 /* unsigned char * CaseSensitivePassword; */
558 /* STRING AccountName */
559 /* STRING PrimaryDomain */
560 /* STRING NativeOS */
561 /* STRING NativeLanMan */
562 } __attribute__((packed
)) req_no_secext
; /* NTLM request format (without
565 struct { /* default (NTLM) response format */
566 struct smb_hdr hdr
; /* wct = 4 */
570 __le16 Action
; /* see below */
571 __le16 SecurityBlobLength
;
573 unsigned char SecurityBlob
[1]; /* followed by */
574 /* unsigned char * NativeOS; */
575 /* unsigned char * NativeLanMan; */
576 /* unsigned char * PrimaryDomain; */
577 } __attribute__((packed
)) resp
; /* NTLM response
578 (with or without extended sec) */
580 struct { /* request format */
581 struct smb_hdr hdr
; /* wct = 10 */
585 __le16 MaxBufferSize
;
589 __le16 PasswordLength
;
590 __u32 Reserved
; /* encrypt key len and offset */
592 unsigned char AccountPassword
[1]; /* followed by */
593 /* STRING AccountName */
594 /* STRING PrimaryDomain */
595 /* STRING NativeOS */
596 /* STRING NativeLanMan */
597 } __attribute__((packed
)) old_req
; /* pre-NTLM (LANMAN2.1) req format */
599 struct { /* default (NTLM) response format */
600 struct smb_hdr hdr
; /* wct = 3 */
604 __le16 Action
; /* see below */
606 unsigned char NativeOS
[1]; /* followed by */
607 /* unsigned char * NativeLanMan; */
608 /* unsigned char * PrimaryDomain; */
609 } __attribute__((packed
)) old_resp
; /* pre-NTLM (LANMAN2.1) response */
610 } __attribute__((packed
)) SESSION_SETUP_ANDX
;
612 /* format of NLTMv2 Response ie "case sensitive password" hash when NTLMv2 */
614 #define NTLMSSP_SERVER_TYPE 1
615 #define NTLMSSP_DOMAIN_TYPE 2
616 #define NTLMSSP_FQ_DOMAIN_TYPE 3
617 #define NTLMSSP_DNS_DOMAIN_TYPE 4
618 #define NTLMSSP_DNS_PARENT_TYPE 5
620 struct ntlmssp2_name
{
623 /* char name[length]; */
624 } __attribute__((packed
));
627 char ntlmv2_hash
[CIFS_ENCPWD_SIZE
];
628 __le32 blob_signature
;
631 __u64 client_chal
; /* random */
633 struct ntlmssp2_name names
[2];
634 /* array of name entries could follow ending in minimum 4 byte struct */
635 } __attribute__((packed
));
638 #define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux"
640 /* Capabilities bits (for NTLM SessSetup request) */
641 #define CAP_UNICODE 0x00000004
642 #define CAP_LARGE_FILES 0x00000008
643 #define CAP_NT_SMBS 0x00000010
644 #define CAP_STATUS32 0x00000040
645 #define CAP_LEVEL_II_OPLOCKS 0x00000080
646 #define CAP_NT_FIND 0x00000200 /* reserved should be zero
647 (because NT_SMBs implies the same thing?) */
648 #define CAP_BULK_TRANSFER 0x20000000
649 #define CAP_EXTENDED_SECURITY 0x80000000
652 #define GUEST_LOGIN 1
654 typedef struct smb_com_tconx_req
{
655 struct smb_hdr hdr
; /* wct = 4 */
659 __le16 Flags
; /* see below */
660 __le16 PasswordLength
;
662 unsigned char Password
[1]; /* followed by */
663 /* STRING Path *//* \\server\share name */
665 } __attribute__((packed
)) TCONX_REQ
;
667 typedef struct smb_com_tconx_rsp
{
668 struct smb_hdr hdr
; /* wct = 3 note that Win2000 has sent wct = 7
669 in some cases on responses. Four unspecified
670 words followed OptionalSupport */
674 __le16 OptionalSupport
; /* see below */
676 unsigned char Service
[1]; /* always ASCII, not Unicode */
677 /* STRING NativeFileSystem */
678 } __attribute__((packed
)) TCONX_RSP
;
680 /* tree connect Flags */
681 #define DISCONNECT_TID 0x0001
682 #define TCON_EXTENDED_SECINFO 0x0008
683 /* OptionalSupport bits */
684 #define SMB_SUPPORT_SEARCH_BITS 0x0001 /* "must have" directory search bits
685 (exclusive searches supported) */
686 #define SMB_SHARE_IS_IN_DFS 0x0002
688 typedef struct smb_com_logoff_andx_req
{
689 struct smb_hdr hdr
; /* wct = 2 */
694 } __attribute__((packed
)) LOGOFF_ANDX_REQ
;
696 typedef struct smb_com_logoff_andx_rsp
{
697 struct smb_hdr hdr
; /* wct = 2 */
702 } __attribute__((packed
)) LOGOFF_ANDX_RSP
;
704 typedef union smb_com_tree_disconnect
{ /* as an altetnative can use flag on
705 tree_connect PDU to effect disconnect */
706 /* tdis is probably simplest SMB PDU */
708 struct smb_hdr hdr
; /* wct = 0 */
709 __u16 ByteCount
; /* bcc = 0 */
710 } __attribute__((packed
)) req
;
712 struct smb_hdr hdr
; /* wct = 0 */
713 __u16 ByteCount
; /* bcc = 0 */
714 } __attribute__((packed
)) resp
;
715 } __attribute__((packed
)) TREE_DISCONNECT
;
717 typedef struct smb_com_close_req
{
718 struct smb_hdr hdr
; /* wct = 3 */
720 __u32 LastWriteTime
; /* should be zero or -1 */
721 __u16 ByteCount
; /* 0 */
722 } __attribute__((packed
)) CLOSE_REQ
;
724 typedef struct smb_com_close_rsp
{
725 struct smb_hdr hdr
; /* wct = 0 */
726 __u16 ByteCount
; /* bct = 0 */
727 } __attribute__((packed
)) CLOSE_RSP
;
729 typedef struct smb_com_findclose_req
{
730 struct smb_hdr hdr
; /* wct = 1 */
732 __u16 ByteCount
; /* 0 */
733 } __attribute__((packed
)) FINDCLOSE_REQ
;
736 #define REQ_MORE_INFO 0x00000001 /* legacy (OPEN_AND_X) only */
737 #define REQ_OPLOCK 0x00000002
738 #define REQ_BATCHOPLOCK 0x00000004
739 #define REQ_OPENDIRONLY 0x00000008
740 #define REQ_EXTENDED_INFO 0x00000010
743 #define DISK_TYPE 0x0000
744 #define BYTE_PIPE_TYPE 0x0001
745 #define MESSAGE_PIPE_TYPE 0x0002
746 #define PRINTER_TYPE 0x0003
747 #define COMM_DEV_TYPE 0x0004
748 #define UNKNOWN_TYPE 0xFFFF
750 typedef struct smb_com_open_req
{ /* also handles create */
751 struct smb_hdr hdr
; /* wct = 24 */
755 __u8 Reserved
; /* Must Be Zero */
758 __le32 RootDirectoryFid
;
759 __le32 DesiredAccess
;
760 __le64 AllocationSize
;
761 __le32 FileAttributes
;
763 __le32 CreateDisposition
;
764 __le32 CreateOptions
;
765 __le32 ImpersonationLevel
;
769 } __attribute__((packed
)) OPEN_REQ
;
771 /* open response: oplock levels */
772 #define OPLOCK_NONE 0
773 #define OPLOCK_EXCLUSIVE 1
774 #define OPLOCK_BATCH 2
775 #define OPLOCK_READ 3 /* level 2 oplock */
777 /* open response for CreateAction shifted left */
778 #define CIFS_CREATE_ACTION 0x20000 /* file created */
780 typedef struct smb_com_open_rsp
{
781 struct smb_hdr hdr
; /* wct = 34 BB */
789 __le64 LastAccessTime
;
790 __le64 LastWriteTime
;
792 __le32 FileAttributes
;
793 __le64 AllocationSize
;
798 __u16 ByteCount
; /* bct = 0 */
799 } __attribute__((packed
)) OPEN_RSP
;
801 /* format of legacy open request */
802 typedef struct smb_com_openx_req
{
803 struct smb_hdr hdr
; /* wct = 15 */
809 __le16 Sattr
; /* search attributes */
810 __le16 FileAttributes
; /* dos attrs */
811 __le32 CreateTime
; /* os2 format */
816 __le16 ByteCount
; /* file name follows */
818 } __attribute__((packed
)) OPENX_REQ
;
820 typedef struct smb_com_openx_rsp
{
821 struct smb_hdr hdr
; /* wct = 15 */
826 __le16 FileAttributes
;
827 __le32 LastWriteTime
; /* os2 format */
836 } __attribute__((packed
)) OPENX_RSP
;
838 /* For encoding of POSIX Open Request - see trans2 function 0x209 data struct */
840 /* Legacy write request for older servers */
841 typedef struct smb_com_writex_req
{
842 struct smb_hdr hdr
; /* wct = 12 */
848 __u32 Reserved
; /* Timeout */
849 __le16 WriteMode
; /* 1 = write through */
852 __le16 DataLengthLow
;
855 __u8 Pad
; /* BB check for whether padded to DWORD
856 boundary and optimum performance here */
858 } __attribute__((packed
)) WRITEX_REQ
;
860 typedef struct smb_com_write_req
{
861 struct smb_hdr hdr
; /* wct = 14 */
870 __le16 DataLengthHigh
;
871 __le16 DataLengthLow
;
875 __u8 Pad
; /* BB check for whether padded to DWORD
876 boundary and optimum performance here */
878 } __attribute__((packed
)) WRITE_REQ
;
880 typedef struct smb_com_write_rsp
{
881 struct smb_hdr hdr
; /* wct = 6 */
890 } __attribute__((packed
)) WRITE_RSP
;
892 /* legacy read request for older servers */
893 typedef struct smb_com_readx_req
{
894 struct smb_hdr hdr
; /* wct = 10 */
901 __le16 MinCount
; /* obsolete */
905 } __attribute__((packed
)) READX_REQ
;
907 typedef struct smb_com_read_req
{
908 struct smb_hdr hdr
; /* wct = 12 */
915 __le16 MinCount
; /* obsolete */
920 } __attribute__((packed
)) READ_REQ
;
922 typedef struct smb_com_read_rsp
{
923 struct smb_hdr hdr
; /* wct = 12 */
928 __le16 DataCompactionMode
;
932 __le16 DataLengthHigh
;
935 __u8 Pad
; /* BB check for whether padded to DWORD
936 boundary and optimum performance here */
938 } __attribute__((packed
)) READ_RSP
;
940 typedef struct locking_andx_range
{
947 } __attribute__((packed
)) LOCKING_ANDX_RANGE
;
949 #define LOCKING_ANDX_SHARED_LOCK 0x01
950 #define LOCKING_ANDX_OPLOCK_RELEASE 0x02
951 #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
952 #define LOCKING_ANDX_CANCEL_LOCK 0x08
953 #define LOCKING_ANDX_LARGE_FILES 0x10 /* always on for us */
955 typedef struct smb_com_lock_req
{
956 struct smb_hdr hdr
; /* wct = 8 */
964 __le16 NumberOfUnlocks
;
965 __le16 NumberOfLocks
;
967 LOCKING_ANDX_RANGE Locks
[1];
968 } __attribute__((packed
)) LOCK_REQ
;
974 typedef struct cifs_posix_lock
{
975 __le16 lock_type
; /* 0 = Read, 1 = Write, 2 = Unlock */
976 __le16 lock_flags
; /* 1 = Wait (only valid for setlock) */
980 /* BB what about additional owner info to identify network client */
981 } __attribute__((packed
)) CIFS_POSIX_LOCK
;
983 typedef struct smb_com_lock_rsp
{
984 struct smb_hdr hdr
; /* wct = 2 */
989 } __attribute__((packed
)) LOCK_RSP
;
991 typedef struct smb_com_rename_req
{
992 struct smb_hdr hdr
; /* wct = 1 */
993 __le16 SearchAttributes
; /* target file attributes */
995 __u8 BufferFormat
; /* 4 = ASCII or Unicode */
996 unsigned char OldFileName
[1];
997 /* followed by __u8 BufferFormat2 */
998 /* followed by NewFileName */
999 } __attribute__((packed
)) RENAME_REQ
;
1001 /* copy request flags */
1002 #define COPY_MUST_BE_FILE 0x0001
1003 #define COPY_MUST_BE_DIR 0x0002
1004 #define COPY_TARGET_MODE_ASCII 0x0004 /* if not set, binary */
1005 #define COPY_SOURCE_MODE_ASCII 0x0008 /* if not set, binary */
1006 #define COPY_VERIFY_WRITES 0x0010
1007 #define COPY_TREE 0x0020
1009 typedef struct smb_com_copy_req
{
1010 struct smb_hdr hdr
; /* wct = 3 */
1012 __le16 OpenFunction
;
1015 __u8 BufferFormat
; /* 4 = ASCII or Unicode */
1016 unsigned char OldFileName
[1];
1017 /* followed by __u8 BufferFormat2 */
1018 /* followed by NewFileName string */
1019 } __attribute__((packed
)) COPY_REQ
;
1021 typedef struct smb_com_copy_rsp
{
1022 struct smb_hdr hdr
; /* wct = 1 */
1023 __le16 CopyCount
; /* number of files copied */
1024 __u16 ByteCount
; /* may be zero */
1025 __u8 BufferFormat
; /* 0x04 - only present if errored file follows */
1026 unsigned char ErrorFileName
[1]; /* only present if error in copy */
1027 } __attribute__((packed
)) COPY_RSP
;
1029 #define CREATE_HARD_LINK 0x103
1030 #define MOVEFILE_COPY_ALLOWED 0x0002
1031 #define MOVEFILE_REPLACE_EXISTING 0x0001
1033 typedef struct smb_com_nt_rename_req
{ /* A5 - also used for create hardlink */
1034 struct smb_hdr hdr
; /* wct = 4 */
1035 __le16 SearchAttributes
; /* target file attributes */
1036 __le16 Flags
; /* spec says Information Level */
1037 __le32 ClusterCount
;
1039 __u8 BufferFormat
; /* 4 = ASCII or Unicode */
1040 unsigned char OldFileName
[1];
1041 /* followed by __u8 BufferFormat2 */
1042 /* followed by NewFileName */
1043 } __attribute__((packed
)) NT_RENAME_REQ
;
1045 typedef struct smb_com_rename_rsp
{
1046 struct smb_hdr hdr
; /* wct = 0 */
1047 __u16 ByteCount
; /* bct = 0 */
1048 } __attribute__((packed
)) RENAME_RSP
;
1050 typedef struct smb_com_delete_file_req
{
1051 struct smb_hdr hdr
; /* wct = 1 */
1052 __le16 SearchAttributes
;
1054 __u8 BufferFormat
; /* 4 = ASCII */
1055 unsigned char fileName
[1];
1056 } __attribute__((packed
)) DELETE_FILE_REQ
;
1058 typedef struct smb_com_delete_file_rsp
{
1059 struct smb_hdr hdr
; /* wct = 0 */
1060 __u16 ByteCount
; /* bct = 0 */
1061 } __attribute__((packed
)) DELETE_FILE_RSP
;
1063 typedef struct smb_com_delete_directory_req
{
1064 struct smb_hdr hdr
; /* wct = 0 */
1066 __u8 BufferFormat
; /* 4 = ASCII */
1067 unsigned char DirName
[1];
1068 } __attribute__((packed
)) DELETE_DIRECTORY_REQ
;
1070 typedef struct smb_com_delete_directory_rsp
{
1071 struct smb_hdr hdr
; /* wct = 0 */
1072 __u16 ByteCount
; /* bct = 0 */
1073 } __attribute__((packed
)) DELETE_DIRECTORY_RSP
;
1075 typedef struct smb_com_create_directory_req
{
1076 struct smb_hdr hdr
; /* wct = 0 */
1078 __u8 BufferFormat
; /* 4 = ASCII */
1079 unsigned char DirName
[1];
1080 } __attribute__((packed
)) CREATE_DIRECTORY_REQ
;
1082 typedef struct smb_com_create_directory_rsp
{
1083 struct smb_hdr hdr
; /* wct = 0 */
1084 __u16 ByteCount
; /* bct = 0 */
1085 } __attribute__((packed
)) CREATE_DIRECTORY_RSP
;
1087 typedef struct smb_com_query_information_req
{
1088 struct smb_hdr hdr
; /* wct = 0 */
1089 __le16 ByteCount
; /* 1 + namelen + 1 */
1090 __u8 BufferFormat
; /* 4 = ASCII */
1091 unsigned char FileName
[1];
1092 } __attribute__((packed
)) QUERY_INFORMATION_REQ
;
1094 typedef struct smb_com_query_information_rsp
{
1095 struct smb_hdr hdr
; /* wct = 10 */
1097 __le32 last_write_time
;
1100 __le16 ByteCount
; /* bcc = 0 */
1101 } __attribute__((packed
)) QUERY_INFORMATION_RSP
;
1103 typedef struct smb_com_setattr_req
{
1104 struct smb_hdr hdr
; /* wct = 8 */
1108 __le16 reserved
[5]; /* must be zero */
1110 __u8 BufferFormat
; /* 4 = ASCII */
1111 unsigned char fileName
[1];
1112 } __attribute__((packed
)) SETATTR_REQ
;
1114 typedef struct smb_com_setattr_rsp
{
1115 struct smb_hdr hdr
; /* wct = 0 */
1116 __u16 ByteCount
; /* bct = 0 */
1117 } __attribute__((packed
)) SETATTR_RSP
;
1119 /* empty wct response to setattr */
1121 /*******************************************************/
1122 /* NT Transact structure defintions follow */
1123 /* Currently only ioctl, acl (get security descriptor) */
1124 /* and notify are implemented */
1125 /*******************************************************/
1126 typedef struct smb_com_ntransact_req
{
1127 struct smb_hdr hdr
; /* wct >= 19 */
1130 __le32 TotalParameterCount
;
1131 __le32 TotalDataCount
;
1132 __le32 MaxParameterCount
;
1133 __le32 MaxDataCount
;
1134 __le32 ParameterCount
;
1135 __le32 ParameterOffset
;
1138 __u8 SetupCount
; /* four setup words follow subcommand */
1139 /* SNIA spec incorrectly included spurious pad here */
1140 __le16 SubCommand
; /* 2 = IOCTL/FSCTL */
1141 /* SetupCount words follow then */
1145 } __attribute__((packed
)) NTRANSACT_REQ
;
1147 typedef struct smb_com_ntransact_rsp
{
1148 struct smb_hdr hdr
; /* wct = 18 */
1150 __le32 TotalParameterCount
;
1151 __le32 TotalDataCount
;
1152 __le32 ParameterCount
;
1153 __le32 ParameterOffset
;
1154 __le32 ParameterDisplacement
;
1157 __le32 DataDisplacement
;
1158 __u8 SetupCount
; /* 0 */
1161 /* parms and data follow */
1162 } __attribute__((packed
)) NTRANSACT_RSP
;
1164 typedef struct smb_com_transaction_ioctl_req
{
1165 struct smb_hdr hdr
; /* wct = 23 */
1168 __le32 TotalParameterCount
;
1169 __le32 TotalDataCount
;
1170 __le32 MaxParameterCount
;
1171 __le32 MaxDataCount
;
1172 __le32 ParameterCount
;
1173 __le32 ParameterOffset
;
1176 __u8 SetupCount
; /* four setup words follow subcommand */
1177 /* SNIA spec incorrectly included spurious pad here */
1178 __le16 SubCommand
; /* 2 = IOCTL/FSCTL */
1179 __le32 FunctionCode
;
1181 __u8 IsFsctl
; /* 1 = File System Control 0 = device control (IOCTL) */
1182 __u8 IsRootFlag
; /* 1 = apply command to root of share (must be DFS) */
1186 } __attribute__((packed
)) TRANSACT_IOCTL_REQ
;
1188 typedef struct smb_com_transaction_ioctl_rsp
{
1189 struct smb_hdr hdr
; /* wct = 19 */
1191 __le32 TotalParameterCount
;
1192 __le32 TotalDataCount
;
1193 __le32 ParameterCount
;
1194 __le32 ParameterOffset
;
1195 __le32 ParameterDisplacement
;
1198 __le32 DataDisplacement
;
1199 __u8 SetupCount
; /* 1 */
1200 __le16 ReturnedDataLen
;
1202 } __attribute__((packed
)) TRANSACT_IOCTL_RSP
;
1204 #define CIFS_ACL_OWNER 1
1205 #define CIFS_ACL_GROUP 2
1206 #define CIFS_ACL_DACL 4
1207 #define CIFS_ACL_SACL 8
1209 typedef struct smb_com_transaction_qsec_req
{
1210 struct smb_hdr hdr
; /* wct = 19 */
1213 __le32 TotalParameterCount
;
1214 __le32 TotalDataCount
;
1215 __le32 MaxParameterCount
;
1216 __le32 MaxDataCount
;
1217 __le32 ParameterCount
;
1218 __le32 ParameterOffset
;
1221 __u8 SetupCount
; /* no setup words follow subcommand */
1222 /* SNIA spec incorrectly included spurious pad here */
1223 __le16 SubCommand
; /* 6 = QUERY_SECURITY_DESC */
1224 __le16 ByteCount
; /* bcc = 3 + 8 */
1229 } __attribute__((packed
)) QUERY_SEC_DESC_REQ
;
1232 typedef struct smb_com_transaction_ssec_req
{
1233 struct smb_hdr hdr
; /* wct = 19 */
1236 __le32 TotalParameterCount
;
1237 __le32 TotalDataCount
;
1238 __le32 MaxParameterCount
;
1239 __le32 MaxDataCount
;
1240 __le32 ParameterCount
;
1241 __le32 ParameterOffset
;
1244 __u8 SetupCount
; /* no setup words follow subcommand */
1245 /* SNIA spec incorrectly included spurious pad here */
1246 __le16 SubCommand
; /* 3 = SET_SECURITY_DESC */
1247 __le16 ByteCount
; /* bcc = 3 + 8 */
1252 } __attribute__((packed
)) SET_SEC_DESC_REQ
;
1254 typedef struct smb_com_transaction_change_notify_req
{
1255 struct smb_hdr hdr
; /* wct = 23 */
1258 __le32 TotalParameterCount
;
1259 __le32 TotalDataCount
;
1260 __le32 MaxParameterCount
;
1261 __le32 MaxDataCount
;
1262 __le32 ParameterCount
;
1263 __le32 ParameterOffset
;
1266 __u8 SetupCount
; /* four setup words follow subcommand */
1267 /* SNIA spec incorrectly included spurious pad here */
1268 __le16 SubCommand
;/* 4 = Change Notify */
1269 __le32 CompletionFilter
; /* operation to monitor */
1271 __u8 WatchTree
; /* 1 = Monitor subdirectories */
1276 } __attribute__((packed
)) TRANSACT_CHANGE_NOTIFY_REQ
;
1278 /* BB eventually change to use generic ntransact rsp struct
1279 and validation routine */
1280 typedef struct smb_com_transaction_change_notify_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 } __attribute__((packed
)) TRANSACT_CHANGE_NOTIFY_RSP
;
1295 /* Completion Filter flags for Notify */
1296 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
1297 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
1298 #define FILE_NOTIFY_CHANGE_NAME 0x00000003
1299 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
1300 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
1301 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
1302 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
1303 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
1304 #define FILE_NOTIFY_CHANGE_EA 0x00000080
1305 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
1306 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
1307 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
1308 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1310 #define FILE_ACTION_ADDED 0x00000001
1311 #define FILE_ACTION_REMOVED 0x00000002
1312 #define FILE_ACTION_MODIFIED 0x00000003
1313 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
1314 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
1315 #define FILE_ACTION_ADDED_STREAM 0x00000006
1316 #define FILE_ACTION_REMOVED_STREAM 0x00000007
1317 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
1319 /* response contains array of the following structures */
1320 struct file_notify_information
{
1321 __le32 NextEntryOffset
;
1323 __le32 FileNameLength
;
1325 } __attribute__((packed
));
1327 struct reparse_data
{
1329 __u16 ReparseDataLength
;
1331 __u16 AltNameOffset
;
1333 __u16 TargetNameOffset
;
1334 __u16 TargetNameLen
;
1335 char LinkNamesBuf
[1];
1336 } __attribute__((packed
));
1338 struct cifs_quota_data
{
1339 __u32 rsrvd1
; /* 0 */
1341 __u64 rsrvd2
; /* 0 */
1345 char sid
[1]; /* variable size? */
1346 } __attribute__((packed
));
1348 /* quota sub commands */
1349 #define QUOTA_LIST_CONTINUE 0
1350 #define QUOTA_LIST_START 0x100
1351 #define QUOTA_FOR_SID 0x101
1354 /* struct smb_hdr hdr precedes. Set wct = 14+ */
1355 __le16 TotalParameterCount
;
1356 __le16 TotalDataCount
;
1357 __le16 MaxParameterCount
;
1358 __le16 MaxDataCount
;
1364 __le16 ParameterCount
;
1365 __le16 ParameterOffset
;
1370 __le16 SubCommand
; /* 1st setup word - SetupCount words follow */
1372 } __attribute__((packed
));
1376 struct trans2_req t2_req
;
1377 } __attribute__((packed
));
1379 struct trans2_resp
{
1380 /* struct smb_hdr hdr precedes. Note wct = 10 + setup count */
1381 __le16 TotalParameterCount
;
1382 __le16 TotalDataCount
;
1384 __le16 ParameterCount
;
1385 __le16 ParameterOffset
;
1386 __le16 ParameterDisplacement
;
1389 __le16 DataDisplacement
;
1392 /* SetupWords[SetupCount];
1395 /* data area follows */
1396 } __attribute__((packed
));
1400 struct trans2_resp t2_rsp
;
1401 } __attribute__((packed
));
1403 /* PathInfo/FileInfo infolevels */
1404 #define SMB_INFO_STANDARD 1
1405 #define SMB_SET_FILE_EA 2
1406 #define SMB_QUERY_FILE_EA_SIZE 2
1407 #define SMB_INFO_QUERY_EAS_FROM_LIST 3
1408 #define SMB_INFO_QUERY_ALL_EAS 4
1409 #define SMB_INFO_IS_NAME_VALID 6
1410 #define SMB_QUERY_FILE_BASIC_INFO 0x101
1411 #define SMB_QUERY_FILE_STANDARD_INFO 0x102
1412 #define SMB_QUERY_FILE_EA_INFO 0x103
1413 #define SMB_QUERY_FILE_NAME_INFO 0x104
1414 #define SMB_QUERY_FILE_ALLOCATION_INFO 0x105
1415 #define SMB_QUERY_FILE_END_OF_FILEINFO 0x106
1416 #define SMB_QUERY_FILE_ALL_INFO 0x107
1417 #define SMB_QUERY_ALT_NAME_INFO 0x108
1418 #define SMB_QUERY_FILE_STREAM_INFO 0x109
1419 #define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
1420 #define SMB_QUERY_FILE_UNIX_BASIC 0x200
1421 #define SMB_QUERY_FILE_UNIX_LINK 0x201
1422 #define SMB_QUERY_POSIX_ACL 0x204
1423 #define SMB_QUERY_XATTR 0x205 /* e.g. system EA name space */
1424 #define SMB_QUERY_ATTR_FLAGS 0x206 /* append,immutable etc. */
1425 #define SMB_QUERY_POSIX_PERMISSION 0x207
1426 #define SMB_QUERY_POSIX_LOCK 0x208
1427 /* #define SMB_POSIX_OPEN 0x209 */
1428 /* #define SMB_POSIX_UNLINK 0x20a */
1429 #define SMB_QUERY_FILE__UNIX_INFO2 0x20b
1430 #define SMB_QUERY_FILE_INTERNAL_INFO 0x3ee
1431 #define SMB_QUERY_FILE_ACCESS_INFO 0x3f0
1432 #define SMB_QUERY_FILE_NAME_INFO2 0x3f1 /* 0x30 bytes */
1433 #define SMB_QUERY_FILE_POSITION_INFO 0x3f6
1434 #define SMB_QUERY_FILE_MODE_INFO 0x3f8
1435 #define SMB_QUERY_FILE_ALGN_INFO 0x3f9
1438 #define SMB_SET_FILE_BASIC_INFO 0x101
1439 #define SMB_SET_FILE_DISPOSITION_INFO 0x102
1440 #define SMB_SET_FILE_ALLOCATION_INFO 0x103
1441 #define SMB_SET_FILE_END_OF_FILE_INFO 0x104
1442 #define SMB_SET_FILE_UNIX_BASIC 0x200
1443 #define SMB_SET_FILE_UNIX_LINK 0x201
1444 #define SMB_SET_FILE_UNIX_HLINK 0x203
1445 #define SMB_SET_POSIX_ACL 0x204
1446 #define SMB_SET_XATTR 0x205
1447 #define SMB_SET_ATTR_FLAGS 0x206 /* append, immutable etc. */
1448 #define SMB_SET_POSIX_LOCK 0x208
1449 #define SMB_POSIX_OPEN 0x209
1450 #define SMB_POSIX_UNLINK 0x20a
1451 #define SMB_SET_FILE_UNIX_INFO2 0x20b
1452 #define SMB_SET_FILE_BASIC_INFO2 0x3ec
1453 #define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo too */
1454 #define SMB_FILE_ALL_INFO2 0x3fa
1455 #define SMB_SET_FILE_ALLOCATION_INFO2 0x3fb
1456 #define SMB_SET_FILE_END_OF_FILE_INFO2 0x3fc
1457 #define SMB_FILE_MOVE_CLUSTER_INFO 0x407
1458 #define SMB_FILE_QUOTA_INFO 0x408
1459 #define SMB_FILE_REPARSEPOINT_INFO 0x409
1460 #define SMB_FILE_MAXIMUM_INFO 0x40d
1462 /* Find File infolevels */
1463 #define SMB_FIND_FILE_INFO_STANDARD 0x001
1464 #define SMB_FIND_FILE_QUERY_EA_SIZE 0x002
1465 #define SMB_FIND_FILE_QUERY_EAS_FROM_LIST 0x003
1466 #define SMB_FIND_FILE_DIRECTORY_INFO 0x101
1467 #define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
1468 #define SMB_FIND_FILE_NAMES_INFO 0x103
1469 #define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
1470 #define SMB_FIND_FILE_ID_FULL_DIR_INFO 0x105
1471 #define SMB_FIND_FILE_ID_BOTH_DIR_INFO 0x106
1472 #define SMB_FIND_FILE_UNIX 0x202
1474 typedef struct smb_com_transaction2_qpi_req
{
1475 struct smb_hdr hdr
; /* wct = 14+ */
1476 __le16 TotalParameterCount
;
1477 __le16 TotalDataCount
;
1478 __le16 MaxParameterCount
;
1479 __le16 MaxDataCount
;
1485 __le16 ParameterCount
;
1486 __le16 ParameterOffset
;
1491 __le16 SubCommand
; /* one setup word */
1494 __le16 InformationLevel
;
1497 } __attribute__((packed
)) TRANSACTION2_QPI_REQ
;
1499 typedef struct smb_com_transaction2_qpi_rsp
{
1500 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1501 struct trans2_resp t2
;
1503 __u16 Reserved2
; /* parameter word is present for infolevels > 100 */
1504 } __attribute__((packed
)) TRANSACTION2_QPI_RSP
;
1506 typedef struct smb_com_transaction2_spi_req
{
1507 struct smb_hdr hdr
; /* wct = 15 */
1508 __le16 TotalParameterCount
;
1509 __le16 TotalDataCount
;
1510 __le16 MaxParameterCount
;
1511 __le16 MaxDataCount
;
1517 __le16 ParameterCount
;
1518 __le16 ParameterOffset
;
1523 __le16 SubCommand
; /* one setup word */
1527 __le16 InformationLevel
;
1530 } __attribute__((packed
)) TRANSACTION2_SPI_REQ
;
1532 typedef struct smb_com_transaction2_spi_rsp
{
1533 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1534 struct trans2_resp t2
;
1536 __u16 Reserved2
; /* parameter word is present for infolevels > 100 */
1537 } __attribute__((packed
)) TRANSACTION2_SPI_RSP
;
1539 struct set_file_rename
{
1540 __le32 overwrite
; /* 1 = overwrite dest */
1541 __u32 root_fid
; /* zero */
1542 __le32 target_name_len
;
1543 char target_name
[0]; /* Must be unicode */
1544 } __attribute__((packed
));
1546 struct smb_com_transaction2_sfi_req
{
1547 struct smb_hdr hdr
; /* wct = 15 */
1548 __le16 TotalParameterCount
;
1549 __le16 TotalDataCount
;
1550 __le16 MaxParameterCount
;
1551 __le16 MaxDataCount
;
1557 __le16 ParameterCount
;
1558 __le16 ParameterOffset
;
1563 __le16 SubCommand
; /* one setup word */
1568 __le16 InformationLevel
;
1570 } __attribute__((packed
));
1572 struct smb_com_transaction2_sfi_rsp
{
1573 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1574 struct trans2_resp t2
;
1576 __u16 Reserved2
; /* parameter word reserved -
1577 present for infolevels > 100 */
1578 } __attribute__((packed
));
1580 struct smb_t2_qfi_req
{
1582 struct trans2_req t2
;
1585 __le16 InformationLevel
;
1586 } __attribute__((packed
));
1588 struct smb_t2_qfi_rsp
{
1589 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1590 struct trans2_resp t2
;
1592 __u16 Reserved2
; /* parameter word reserved -
1593 present for infolevels > 100 */
1594 } __attribute__((packed
));
1597 * Flags on T2 FINDFIRST and FINDNEXT
1599 #define CIFS_SEARCH_CLOSE_ALWAYS 0x0001
1600 #define CIFS_SEARCH_CLOSE_AT_END 0x0002
1601 #define CIFS_SEARCH_RETURN_RESUME 0x0004
1602 #define CIFS_SEARCH_CONTINUE_FROM_LAST 0x0008
1603 #define CIFS_SEARCH_BACKUP_SEARCH 0x0010
1606 * Size of the resume key on FINDFIRST and FINDNEXT calls
1608 #define CIFS_SMB_RESUME_KEY_SIZE 4
1610 typedef struct smb_com_transaction2_ffirst_req
{
1611 struct smb_hdr hdr
; /* wct = 15 */
1612 __le16 TotalParameterCount
;
1613 __le16 TotalDataCount
;
1614 __le16 MaxParameterCount
;
1615 __le16 MaxDataCount
;
1621 __le16 ParameterCount
;
1622 __le16 ParameterOffset
;
1625 __u8 SetupCount
; /* one */
1627 __le16 SubCommand
; /* TRANS2_FIND_FIRST */
1630 __le16 SearchAttributes
;
1633 __le16 InformationLevel
;
1634 __le32 SearchStorageType
;
1636 } __attribute__((packed
)) TRANSACTION2_FFIRST_REQ
;
1638 typedef struct smb_com_transaction2_ffirst_rsp
{
1639 struct smb_hdr hdr
; /* wct = 10 */
1640 struct trans2_resp t2
;
1642 } __attribute__((packed
)) TRANSACTION2_FFIRST_RSP
;
1644 typedef struct smb_com_transaction2_ffirst_rsp_parms
{
1648 __le16 EAErrorOffset
;
1649 __le16 LastNameOffset
;
1650 } __attribute__((packed
)) T2_FFIRST_RSP_PARMS
;
1652 typedef struct smb_com_transaction2_fnext_req
{
1653 struct smb_hdr hdr
; /* wct = 15 */
1654 __le16 TotalParameterCount
;
1655 __le16 TotalDataCount
;
1656 __le16 MaxParameterCount
;
1657 __le16 MaxDataCount
;
1663 __le16 ParameterCount
;
1664 __le16 ParameterOffset
;
1667 __u8 SetupCount
; /* one */
1669 __le16 SubCommand
; /* TRANS2_FIND_NEXT */
1674 __le16 InformationLevel
;
1677 char ResumeFileName
[1];
1678 } __attribute__((packed
)) TRANSACTION2_FNEXT_REQ
;
1680 typedef struct smb_com_transaction2_fnext_rsp
{
1681 struct smb_hdr hdr
; /* wct = 10 */
1682 struct trans2_resp t2
;
1684 } __attribute__((packed
)) TRANSACTION2_FNEXT_RSP
;
1686 typedef struct smb_com_transaction2_fnext_rsp_parms
{
1689 __le16 EAErrorOffset
;
1690 __le16 LastNameOffset
;
1691 } __attribute__((packed
)) T2_FNEXT_RSP_PARMS
;
1693 /* QFSInfo Levels */
1694 #define SMB_INFO_ALLOCATION 1
1695 #define SMB_INFO_VOLUME 2
1696 #define SMB_QUERY_FS_VOLUME_INFO 0x102
1697 #define SMB_QUERY_FS_SIZE_INFO 0x103
1698 #define SMB_QUERY_FS_DEVICE_INFO 0x104
1699 #define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
1700 #define SMB_QUERY_CIFS_UNIX_INFO 0x200
1701 #define SMB_QUERY_POSIX_FS_INFO 0x201
1702 #define SMB_QUERY_POSIX_WHO_AM_I 0x202
1703 #define SMB_QUERY_LABEL_INFO 0x3ea
1704 #define SMB_QUERY_FS_QUOTA_INFO 0x3ee
1705 #define SMB_QUERY_FS_FULL_SIZE_INFO 0x3ef
1706 #define SMB_QUERY_OBJECTID_INFO 0x3f0
1708 typedef struct smb_com_transaction2_qfsi_req
{
1709 struct smb_hdr hdr
; /* wct = 14+ */
1710 __le16 TotalParameterCount
;
1711 __le16 TotalDataCount
;
1712 __le16 MaxParameterCount
;
1713 __le16 MaxDataCount
;
1719 __le16 ParameterCount
;
1720 __le16 ParameterOffset
;
1725 __le16 SubCommand
; /* one setup word */
1728 __le16 InformationLevel
;
1729 } __attribute__((packed
)) TRANSACTION2_QFSI_REQ
;
1731 typedef struct smb_com_transaction_qfsi_rsp
{
1732 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1733 struct trans2_resp t2
;
1735 __u8 Pad
; /* may be three bytes? *//* followed by data area */
1736 } __attribute__((packed
)) TRANSACTION2_QFSI_RSP
;
1738 typedef struct whoami_rsp_data
{ /* Query level 0x202 */
1739 __u32 flags
; /* 0 = Authenticated user 1 = GUEST */
1740 __u32 mask
; /* which flags bits server understands ie 0x0001 */
1742 __u64 unix_user_gid
;
1743 __u32 number_of_supplementary_gids
; /* may be zero */
1744 __u32 number_of_sids
; /* may be zero */
1745 __u32 length_of_sid_array
; /* in bytes - may be zero */
1746 __u32 pad
; /* reserved - MBZ */
1747 /* __u64 gid_array[0]; */ /* may be empty */
1748 /* __u8 * psid_list */ /* may be empty */
1749 } __attribute__((packed
)) WHOAMI_RSP_DATA
;
1751 /* SETFSInfo Levels */
1752 #define SMB_SET_CIFS_UNIX_INFO 0x200
1753 typedef struct smb_com_transaction2_setfsi_req
{
1754 struct smb_hdr hdr
; /* wct = 15 */
1755 __le16 TotalParameterCount
;
1756 __le16 TotalDataCount
;
1757 __le16 MaxParameterCount
;
1758 __le16 MaxDataCount
;
1764 __le16 ParameterCount
; /* 4 */
1765 __le16 ParameterOffset
;
1766 __le16 DataCount
; /* 12 */
1768 __u8 SetupCount
; /* one */
1770 __le16 SubCommand
; /* TRANS2_SET_FS_INFORMATION */
1773 __u16 FileNum
; /* Parameters start. */
1774 __le16 InformationLevel
;/* Parameters end. */
1775 __le16 ClientUnixMajor
; /* Data start. */
1776 __le16 ClientUnixMinor
;
1777 __le64 ClientUnixCap
; /* Data end */
1778 } __attribute__((packed
)) TRANSACTION2_SETFSI_REQ
;
1780 typedef struct smb_com_transaction2_setfsi_rsp
{
1781 struct smb_hdr hdr
; /* wct = 10 */
1782 struct trans2_resp t2
;
1784 } __attribute__((packed
)) TRANSACTION2_SETFSI_RSP
;
1787 typedef struct smb_com_transaction2_get_dfs_refer_req
{
1788 struct smb_hdr hdr
; /* wct = 15 */
1789 __le16 TotalParameterCount
;
1790 __le16 TotalDataCount
;
1791 __le16 MaxParameterCount
;
1792 __le16 MaxDataCount
;
1798 __le16 ParameterCount
;
1799 __le16 ParameterOffset
;
1804 __le16 SubCommand
; /* one setup word */
1806 __u8 Pad
[3]; /* Win2K has sent 0x0F01 (max response length
1807 perhaps?) followed by one byte pad - doesn't
1808 seem to matter though */
1809 __le16 MaxReferralLevel
;
1810 char RequestFileName
[1];
1811 } __attribute__((packed
)) TRANSACTION2_GET_DFS_REFER_REQ
;
1813 typedef struct dfs_referral_level_3
{
1814 __le16 VersionNumber
;
1815 __le16 ReferralSize
;
1816 __le16 ServerType
; /* 0x0001 = CIFS server */
1817 __le16 ReferralFlags
; /* or proximity - not clear which since it is
1818 always set to zero - SNIA spec says 0x01
1819 means strip off PathConsumed chars before
1820 submitting RequestFileName to remote node */
1823 __le16 DfsPathOffset
;
1824 __le16 DfsAlternatePathOffset
;
1825 __le16 NetworkAddressOffset
;
1826 } __attribute__((packed
)) REFERRAL3
;
1828 typedef struct smb_com_transaction_get_dfs_refer_rsp
{
1829 struct smb_hdr hdr
; /* wct = 10 */
1830 struct trans2_resp t2
;
1833 __le16 PathConsumed
;
1834 __le16 NumberOfReferrals
;
1837 REFERRAL3 referrals
[1]; /* array of level 3 dfs_referral structures */
1838 /* followed by the strings pointed to by the referral structures */
1839 } __attribute__((packed
)) TRANSACTION2_GET_DFS_REFER_RSP
;
1842 #define DFSREF_REFERRAL_SERVER 0x0001
1843 #define DFSREF_STORAGE_SERVER 0x0002
1845 /* IOCTL information */
1847 * List of ioctl function codes that look to be of interest to remote clients
1848 * like this one. Need to do some experimentation to make sure they all work
1849 * remotely. Some of the following, such as the encryption/compression ones
1850 * would be invoked from tools via a specialized hook into the VFS rather
1851 * than via the standard vfs entry points
1853 #define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000
1854 #define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004
1855 #define FSCTL_REQUEST_BATCH_OPLOCK 0x00090008
1856 #define FSCTL_LOCK_VOLUME 0x00090018
1857 #define FSCTL_UNLOCK_VOLUME 0x0009001C
1858 #define FSCTL_GET_COMPRESSION 0x0009003C
1859 #define FSCTL_SET_COMPRESSION 0x0009C040
1860 #define FSCTL_REQUEST_FILTER_OPLOCK 0x0009008C
1861 #define FSCTL_FILESYS_GET_STATISTICS 0x00090090
1862 #define FSCTL_SET_REPARSE_POINT 0x000900A4
1863 #define FSCTL_GET_REPARSE_POINT 0x000900A8
1864 #define FSCTL_DELETE_REPARSE_POINT 0x000900AC
1865 #define FSCTL_SET_SPARSE 0x000900C4
1866 #define FSCTL_SET_ZERO_DATA 0x000900C8
1867 #define FSCTL_SET_ENCRYPTION 0x000900D7
1868 #define FSCTL_ENCRYPTION_FSCTL_IO 0x000900DB
1869 #define FSCTL_WRITE_RAW_ENCRYPTED 0x000900DF
1870 #define FSCTL_READ_RAW_ENCRYPTED 0x000900E3
1871 #define FSCTL_SIS_COPYFILE 0x00090100
1872 #define FSCTL_SIS_LINK_FILES 0x0009C104
1874 #define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003
1875 #define IO_REPARSE_TAG_HSM 0xC0000004
1876 #define IO_REPARSE_TAG_SIS 0x80000007
1879 ************************************************************************
1880 * All structs for everything above the SMB PDUs themselves
1881 * (such as the T2 level specific data) go here
1882 ************************************************************************
1886 * Information on a server
1891 unsigned char versionMajor
;
1892 unsigned char versionMinor
;
1894 unsigned int commentOffset
;
1895 } __attribute__((packed
));
1898 * The following structure is the format of the data returned on a NetShareEnum
1899 * with level "90" (x5A)
1905 unsigned short type
;
1906 unsigned int commentOffset
;
1907 } __attribute__((packed
));
1912 unsigned int commentOffset
;
1913 unsigned char type
[2];
1914 } __attribute__((packed
));
1916 struct aliasInfo92
{
1917 int aliasNameOffset
;
1918 int serverNameOffset
;
1919 int shareNameOffset
;
1920 } __attribute__((packed
));
1923 __le64 TotalAllocationUnits
;
1924 __le64 FreeAllocationUnits
;
1925 __le32 SectorsPerAllocationUnit
;
1926 __le32 BytesPerSector
;
1927 } __attribute__((packed
)) FILE_SYSTEM_INFO
; /* size info, level 0x103 */
1931 __le32 SectorsPerAllocationUnit
;
1932 __le32 TotalAllocationUnits
;
1933 __le32 FreeAllocationUnits
;
1934 __le16 BytesPerSector
;
1935 } __attribute__((packed
)) FILE_SYSTEM_ALLOC_INFO
;
1938 __le16 MajorVersionNumber
;
1939 __le16 MinorVersionNumber
;
1941 } __attribute__((packed
)) FILE_SYSTEM_UNIX_INFO
; /* Unix extension level 0x200*/
1943 /* Version numbers for CIFS UNIX major and minor. */
1944 #define CIFS_UNIX_MAJOR_VERSION 1
1945 #define CIFS_UNIX_MINOR_VERSION 0
1947 /* Linux/Unix extensions capability flags */
1948 #define CIFS_UNIX_FCNTL_CAP 0x00000001 /* support for fcntl locks */
1949 #define CIFS_UNIX_POSIX_ACL_CAP 0x00000002 /* support getfacl/setfacl */
1950 #define CIFS_UNIX_XATTR_CAP 0x00000004 /* support new namespace */
1951 #define CIFS_UNIX_EXTATTR_CAP 0x00000008 /* support chattr/chflag */
1952 #define CIFS_UNIX_POSIX_PATHNAMES_CAP 0x00000010 /* Allow POSIX path chars */
1953 #define CIFS_UNIX_POSIX_PATH_OPS_CAP 0x00000020 /* Allow new POSIX path based
1954 calls including posix open
1956 #define CIFS_UNIX_LARGE_READ_CAP 0x00000040 /* support reads >128K (up
1958 #define CIFS_UNIX_LARGE_WRITE_CAP 0x00000080
1960 #ifdef CONFIG_CIFS_POSIX
1961 /* Can not set pathnames cap yet until we send new posix create SMB since
1962 otherwise server can treat such handles opened with older ntcreatex
1963 (by a new client which knows how to send posix path ops)
1964 as non-posix handles (can affect write behavior with byte range locks.
1965 We can add back in POSIX_PATH_OPS cap when Posix Create/Mkdir finished */
1966 /* #define CIFS_UNIX_CAP_MASK 0x000000fb */
1967 #define CIFS_UNIX_CAP_MASK 0x000000db
1969 #define CIFS_UNIX_CAP_MASK 0x00000013
1970 #endif /* CONFIG_CIFS_POSIX */
1973 #define CIFS_POSIX_EXTENSIONS 0x00000010 /* support for new QFSInfo */
1976 /* For undefined recommended transfer size return -1 in that field */
1977 __le32 OptimalTransferSize
; /* bsize on some os, iosize on other os */
1979 /* The next three fields are in terms of the block size.
1980 (above). If block size is unknown, 4096 would be a
1981 reasonable block size for a server to report.
1982 Note that returning the blocks/blocksavail removes need
1983 to make a second call (to QFSInfo level 0x103 to get this info.
1984 UserBlockAvail is typically less than or equal to BlocksAvail,
1985 if no distinction is made return the same value in each */
1987 __le64 BlocksAvail
; /* bfree */
1988 __le64 UserBlocksAvail
; /* bavail */
1989 /* For undefined Node fields or FSID return -1 */
1990 __le64 TotalFileNodes
;
1991 __le64 FreeFileNodes
;
1992 __le64 FileSysIdentifier
; /* fsid */
1993 /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
1994 /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */
1995 } __attribute__((packed
)) FILE_SYSTEM_POSIX_INFO
;
1997 /* DeviceType Flags */
1998 #define FILE_DEVICE_CD_ROM 0x00000002
1999 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
2000 #define FILE_DEVICE_DFS 0x00000006
2001 #define FILE_DEVICE_DISK 0x00000007
2002 #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
2003 #define FILE_DEVICE_FILE_SYSTEM 0x00000009
2004 #define FILE_DEVICE_NAMED_PIPE 0x00000011
2005 #define FILE_DEVICE_NETWORK 0x00000012
2006 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
2007 #define FILE_DEVICE_NULL 0x00000015
2008 #define FILE_DEVICE_PARALLEL_PORT 0x00000016
2009 #define FILE_DEVICE_PRINTER 0x00000018
2010 #define FILE_DEVICE_SERIAL_PORT 0x0000001b
2011 #define FILE_DEVICE_STREAMS 0x0000001e
2012 #define FILE_DEVICE_TAPE 0x0000001f
2013 #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
2014 #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
2015 #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
2019 __le32 DeviceCharacteristics
;
2020 } __attribute__((packed
)) FILE_SYSTEM_DEVICE_INFO
; /* device info level 0x104 */
2024 __le32 MaxPathNameComponentLength
;
2025 __le32 FileSystemNameLen
;
2026 char FileSystemName
[52]; /* do not have to save this - get subset? */
2027 } __attribute__((packed
)) FILE_SYSTEM_ATTRIBUTE_INFO
;
2029 /******************************************************************************/
2030 /* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
2031 /******************************************************************************/
2032 typedef struct { /* data block encoding of response to level 263 QPathInfo */
2033 __le64 CreationTime
;
2034 __le64 LastAccessTime
;
2035 __le64 LastWriteTime
;
2039 __le64 AllocationSize
;
2040 __le64 EndOfFile
; /* size ie offset to first free byte in file */
2041 __le32 NumberOfLinks
; /* hard links */
2049 __le64 CurrentByteOffset
;
2051 __le32 AlignmentRequirement
;
2052 __le32 FileNameLength
;
2054 } __attribute__((packed
)) FILE_ALL_INFO
; /* level 0x107 QPathInfo */
2056 /* defines for enumerating possible values of the Unix type field below */
2059 #define UNIX_SYMLINK 2
2060 #define UNIX_CHARDEV 3
2061 #define UNIX_BLOCKDEV 4
2063 #define UNIX_SOCKET 6
2067 __le64 LastStatusChange
; /*SNIA specs DCE time for the 3 time fields */
2068 __le64 LastAccessTime
;
2069 __le64 LastModificationTime
;
2078 } __attribute__((packed
)) FILE_UNIX_BASIC_INFO
; /* level 0x200 QPathInfo */
2082 } __attribute__((packed
)) FILE_UNIX_LINK_INFO
; /* level 0x201 QPathInfo */
2084 /* The following three structures are needed only for
2085 setting time to NT4 and some older servers via
2086 the primitive DOS time format */
2091 } __attribute__((packed
)) SMB_DATE
;
2097 } __attribute__((packed
)) SMB_TIME
;
2100 __le16 CreationDate
; /* SMB Date see above */
2101 __le16 CreationTime
; /* SMB Time */
2102 __le16 LastAccessDate
;
2103 __le16 LastAccessTime
;
2104 __le16 LastWriteDate
;
2105 __le16 LastWriteTime
;
2106 __le32 DataSize
; /* File Size (EOF) */
2107 __le32 AllocationSize
;
2108 __le16 Attributes
; /* verify not u32 */
2110 } __attribute__((packed
)) FILE_INFO_STANDARD
; /* level 1 SetPath/FileInfo */
2113 __le64 CreationTime
;
2114 __le64 LastAccessTime
;
2115 __le64 LastWriteTime
;
2119 } __attribute__((packed
)) FILE_BASIC_INFO
; /* size info, level 0x101 */
2121 struct file_allocation_info
{
2122 __le64 AllocationSize
; /* Note old Samba srvr rounds this up too much */
2123 } __attribute__((packed
)); /* size used on disk, for level 0x103 for set,
2126 struct file_end_of_file_info
{
2127 __le64 FileSize
; /* offset to end of file */
2128 } __attribute__((packed
)); /* size info, level 0x104 for set, 0x106 for query */
2130 struct file_alt_name_info
{
2132 } __attribute__((packed
)); /* level 0x0108 */
2134 struct file_stream_info
{
2135 __le32 number_of_streams
; /* BB check sizes and verify location */
2136 /* followed by info on streams themselves
2140 }; /* level 0x109 */
2142 struct file_compression_info
{
2143 __le64 compressed_size
;
2149 } __attribute__((packed
)); /* level 0x10b */
2151 /* POSIX ACL set/query path info structures */
2152 #define CIFS_ACL_VERSION 1
2153 struct cifs_posix_ace
{ /* access control entry (ACE) */
2156 __le64 cifs_uid
; /* or gid */
2157 } __attribute__((packed
));
2159 struct cifs_posix_acl
{ /* access conrol list (ACL) */
2161 __le16 access_entry_count
; /* access ACL - count of entries */
2162 __le16 default_entry_count
; /* default ACL - count of entries */
2163 struct cifs_posix_ace ace_array
[0];
2165 struct cifs_posix_ace default_ace_arraay[] */
2166 } __attribute__((packed
)); /* level 0x204 */
2168 /* types of access control entries already defined in posix_acl.h */
2169 /* #define CIFS_POSIX_ACL_USER_OBJ 0x01
2170 #define CIFS_POSIX_ACL_USER 0x02
2171 #define CIFS_POSIX_ACL_GROUP_OBJ 0x04
2172 #define CIFS_POSIX_ACL_GROUP 0x08
2173 #define CIFS_POSIX_ACL_MASK 0x10
2174 #define CIFS_POSIX_ACL_OTHER 0x20 */
2176 /* types of perms */
2177 /* #define CIFS_POSIX_ACL_EXECUTE 0x01
2178 #define CIFS_POSIX_ACL_WRITE 0x02
2179 #define CIFS_POSIX_ACL_READ 0x04 */
2181 /* end of POSIX ACL definitions */
2183 /* POSIX Open Flags */
2184 #define SMB_O_RDONLY 0x1
2185 #define SMB_O_WRONLY 0x2
2186 #define SMB_O_RDWR 0x4
2187 #define SMB_O_CREAT 0x10
2188 #define SMB_O_EXCL 0x20
2189 #define SMB_O_TRUNC 0x40
2190 #define SMB_O_APPEND 0x80
2191 #define SMB_O_SYNC 0x100
2192 #define SMB_O_DIRECTORY 0x200
2193 #define SMB_O_NOFOLLOW 0x400
2194 #define SMB_O_DIRECT 0x800
2197 __le32 OpenFlags
; /* same as NT CreateX */
2198 __le32 PosixOpenFlags
;
2200 __le16 Level
; /* reply level requested (see QPathInfo levels) */
2201 } __attribute__((packed
)) OPEN_PSX_REQ
; /* level 0x209 SetPathInfo data */
2206 __le32 CreateAction
;
2207 __le16 ReturnedLevel
;
2209 /* struct following varies based on requested level */
2210 } __attribute__((packed
)) OPEN_PSX_RSP
; /* level 0x209 SetPathInfo data */
2212 #define SMB_POSIX_UNLINK_FILE_TARGET 0
2213 #define SMB_POSIX_UNLINK_DIRECTORY_TARGET 1
2215 struct unlink_psx_rq
{ /* level 0x20a SetPathInfo */
2217 } __attribute__((packed
));
2219 struct file_internal_info
{
2220 __u64 UniqueId
; /* inode number */
2221 } __attribute__((packed
)); /* level 0x3ee */
2223 struct file_mode_info
{
2225 } __attribute__((packed
)); /* level 0x3f8 */
2227 struct file_attrib_tag
{
2230 } __attribute__((packed
)); /* level 0x40b */
2233 /********************************************************/
2234 /* FindFirst/FindNext transact2 data buffer formats */
2235 /********************************************************/
2238 __le32 NextEntryOffset
;
2239 __u32 ResumeKey
; /* as with FileIndex - no need to convert */
2242 __le64 LastStatusChange
; /*SNIA specs DCE time for the 3 time fields */
2243 __le64 LastAccessTime
;
2244 __le64 LastModificationTime
;
2254 } __attribute__((packed
)) FILE_UNIX_INFO
; /* level 0x202 */
2257 __le32 NextEntryOffset
;
2259 __le64 CreationTime
;
2260 __le64 LastAccessTime
;
2261 __le64 LastWriteTime
;
2264 __le64 AllocationSize
;
2265 __le32 ExtFileAttributes
;
2266 __le32 FileNameLength
;
2268 } __attribute__((packed
)) FILE_DIRECTORY_INFO
; /* level 0x101 FF resp data */
2271 __le32 NextEntryOffset
;
2273 __le64 CreationTime
;
2274 __le64 LastAccessTime
;
2275 __le64 LastWriteTime
;
2278 __le64 AllocationSize
;
2279 __le32 ExtFileAttributes
;
2280 __le32 FileNameLength
;
2281 __le32 EaSize
; /* length of the xattrs */
2283 } __attribute__((packed
)) FILE_FULL_DIRECTORY_INFO
; /* level 0x102 rsp data */
2286 __le32 NextEntryOffset
;
2288 __le64 CreationTime
;
2289 __le64 LastAccessTime
;
2290 __le64 LastWriteTime
;
2293 __le64 AllocationSize
;
2294 __le32 ExtFileAttributes
;
2295 __le32 FileNameLength
;
2296 __le32 EaSize
; /* EA size */
2298 __u64 UniqueId
; /* inode num - le since Samba puts ino in low 32 bit*/
2300 } __attribute__((packed
)) SEARCH_ID_FULL_DIR_INFO
; /* level 0x105 FF rsp data */
2303 __le32 NextEntryOffset
;
2305 __le64 CreationTime
;
2306 __le64 LastAccessTime
;
2307 __le64 LastWriteTime
;
2310 __le64 AllocationSize
;
2311 __le32 ExtFileAttributes
;
2312 __le32 FileNameLength
;
2313 __le32 EaSize
; /* length of the xattrs */
2314 __u8 ShortNameLength
;
2318 } __attribute__((packed
)) FILE_BOTH_DIRECTORY_INFO
; /* level 0x104 FFrsp data */
2322 __le16 CreationDate
; /* SMB Date */
2323 __le16 CreationTime
; /* SMB Time */
2324 __le16 LastAccessDate
;
2325 __le16 LastAccessTime
;
2326 __le16 LastWriteDate
;
2327 __le16 LastWriteTime
;
2328 __le32 DataSize
; /* File Size (EOF) */
2329 __le32 AllocationSize
;
2330 __le16 Attributes
; /* verify not u32 */
2331 __u8 FileNameLength
;
2333 } __attribute__((packed
)) FIND_FILE_STANDARD_INFO
; /* level 0x1 FF resp data */
2337 unsigned char type
[8]; /* IntxCHR or IntxBLK */
2340 } __attribute__((packed
));
2343 unsigned char name_len
;
2345 } __attribute__((packed
));
2348 unsigned long list_len
;
2350 } __attribute__((packed
));
2353 unsigned char EA_flags
;
2357 /* optionally followed by value */
2358 } __attribute__((packed
));
2359 /* flags for _FEA.fEA */
2360 #define FEA_NEEDEA 0x80 /* need EA bit */
2365 } __attribute__((packed
));
2367 /* used to hold an arbitrary blob of data */
2371 void (*free
) (struct data_blob
*data_blob
);
2372 } __attribute__((packed
));
2375 #ifdef CONFIG_CIFS_POSIX
2377 For better POSIX semantics from Linux client, (even better
2378 than the existing CIFS Unix Extensions) we need updated PDUs for:
2380 1) PosixCreateX - to set and return the mode, inode#, device info and
2381 perhaps add a CreateDevice - to create Pipes and other special .inodes
2382 Also note POSIX open flags
2383 2) Close - to return the last write time to do cache across close
2385 3) FindFirst return unique inode number - what about resume key, two
2386 forms short (matches readdir) and full (enough info to cache inodes)
2389 And under consideration:
2390 5) FindClose2 (return nanosecond timestamp ??)
2391 6) Use nanosecond timestamps throughout all time fields if
2392 corresponding attribute flag is set
2393 7) sendfile - handle based copy
2397 what about fixing 64 bit alignment
2399 There are also various legacy SMB/CIFS requests used as is
2401 From existing Lanman and NTLM dialects:
2402 --------------------------------------
2404 SESSION_SETUP_ANDX (BB which?)
2405 TREE_CONNECT_ANDX (BB which wct?)
2406 TREE_DISCONNECT (BB add volume timestamp on response)
2408 DELETE (note delete open file behavior)
2412 LOCKING_AND_X (note posix lock semantics)
2413 RENAME (note rename across dirs and open file rename posix behaviors)
2414 NT_RENAME (for hardlinks) Is this good enough for all features?
2416 TRANSACTION2 (18 cases)
2417 SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2
2418 (BB verify that never need to set allocation size)
2419 SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via
2422 COPY (note support for copy across directories) - FUTURE, OPTIONAL
2423 setting/getting OS/2 EAs - FUTURE (BB can this handle
2424 setting Linux xattrs perfectly) - OPTIONAL
2425 dnotify - FUTURE, OPTIONAL
2426 quota - FUTURE, OPTIONAL
2428 Note that various requests implemented for NT interop such as
2429 NT_TRANSACT (IOCTL) QueryReparseInfo
2430 are unneeded to servers compliant with the CIFS POSIX extensions
2432 From CIFS Unix Extensions:
2433 -------------------------
2434 T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks
2435 T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2)
2436 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK)
2437 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC) BB check for missing
2439 Actually a need QUERY_FILE_UNIX_INFO
2441 BB what about a) blksize/blkbits/blocks
2447 T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX
2448 TRANS2_GET_DFS_REFERRAL - OPTIONAL but recommended
2449 T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL
2452 /* xsymlink is a symlink format (used by MacOS) that can be used
2453 to save symlink info in a regular file when
2454 mounted to operating systems that do not
2455 support the cifs Unix extensions or EAs (for xattr
2456 based symlinks). For such a file to be recognized
2457 as containing symlink data:
2459 1) file size must be 1067,
2460 2) signature must begin file data,
2461 3) length field must be set to ASCII representation
2462 of a number which is less than or equal to 1024,
2463 4) md5 must match that of the path data */
2467 char signature
[4]; /* XSym */ /* not null terminated */
2469 /* ASCII representation of length (4 bytes decimal) terminated by \n not null */
2472 /* md5 of valid subset of path ie path[0] through path[length-1] */
2475 /* if room left, then end with \n then 0x20s by convention but not required */
2477 } __attribute__((packed
));
2479 typedef struct file_xattr_info
{
2480 /* BB do we need another field for flags? BB */
2481 __u32 xattr_name_len
;
2482 __u32 xattr_value_len
;
2484 /* followed by xattr_value[xattr_value_len], no pad */
2485 } __attribute__((packed
)) FILE_XATTR_INFO
; /* extended attribute info
2489 /* flags for chattr command */
2490 #define EXT_SECURE_DELETE 0x00000001 /* EXT3_SECRM_FL */
2491 #define EXT_ENABLE_UNDELETE 0x00000002 /* EXT3_UNRM_FL */
2492 /* Reserved for compress file 0x4 */
2493 #define EXT_SYNCHRONOUS 0x00000008 /* EXT3_SYNC_FL */
2494 #define EXT_IMMUTABLE_FL 0x00000010 /* EXT3_IMMUTABLE_FL */
2495 #define EXT_OPEN_APPEND_ONLY 0x00000020 /* EXT3_APPEND_FL */
2496 #define EXT_DO_NOT_BACKUP 0x00000040 /* EXT3_NODUMP_FL */
2497 #define EXT_NO_UPDATE_ATIME 0x00000080 /* EXT3_NOATIME_FL */
2498 /* 0x100 through 0x800 reserved for compression flags and are GET-ONLY */
2499 #define EXT_HASH_TREE_INDEXED_DIR 0x00001000 /* GET-ONLY EXT3_INDEX_FL */
2500 /* 0x2000 reserved for IMAGIC_FL */
2501 #define EXT_JOURNAL_THIS_FILE 0x00004000 /* GET-ONLY EXT3_JOURNAL_DATA_FL */
2502 /* 0x8000 reserved for EXT3_NOTAIL_FL */
2503 #define EXT_SYNCHRONOUS_DIR 0x00010000 /* EXT3_DIRSYNC_FL */
2504 #define EXT_TOPDIR 0x00020000 /* EXT3_TOPDIR_FL */
2506 #define EXT_SET_MASK 0x000300FF
2507 #define EXT_GET_MASK 0x0003DFFF
2509 typedef struct file_chattr_info
{
2510 __le64 mask
; /* list of all possible attribute bits */
2511 __le64 mode
; /* list of actual attribute bits on this inode */
2512 } __attribute__((packed
)) FILE_CHATTR_INFO
; /* ext attributes
2513 (chattr, chflags) level 0x206 */
2517 #endif /* _CIFSPDU_H */