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
;
1231 typedef struct smb_com_transaction_change_notify_req
{
1232 struct smb_hdr hdr
; /* wct = 23 */
1235 __le32 TotalParameterCount
;
1236 __le32 TotalDataCount
;
1237 __le32 MaxParameterCount
;
1238 __le32 MaxDataCount
;
1239 __le32 ParameterCount
;
1240 __le32 ParameterOffset
;
1243 __u8 SetupCount
; /* four setup words follow subcommand */
1244 /* SNIA spec incorrectly included spurious pad here */
1245 __le16 SubCommand
;/* 4 = Change Notify */
1246 __le32 CompletionFilter
; /* operation to monitor */
1248 __u8 WatchTree
; /* 1 = Monitor subdirectories */
1253 } __attribute__((packed
)) TRANSACT_CHANGE_NOTIFY_REQ
;
1255 /* BB eventually change to use generic ntransact rsp struct
1256 and validation routine */
1257 typedef struct smb_com_transaction_change_notify_rsp
{
1258 struct smb_hdr hdr
; /* wct = 18 */
1260 __le32 TotalParameterCount
;
1261 __le32 TotalDataCount
;
1262 __le32 ParameterCount
;
1263 __le32 ParameterOffset
;
1264 __le32 ParameterDisplacement
;
1267 __le32 DataDisplacement
;
1268 __u8 SetupCount
; /* 0 */
1271 } __attribute__((packed
)) TRANSACT_CHANGE_NOTIFY_RSP
;
1272 /* Completion Filter flags for Notify */
1273 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
1274 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
1275 #define FILE_NOTIFY_CHANGE_NAME 0x00000003
1276 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
1277 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
1278 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
1279 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
1280 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
1281 #define FILE_NOTIFY_CHANGE_EA 0x00000080
1282 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
1283 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
1284 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
1285 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1287 #define FILE_ACTION_ADDED 0x00000001
1288 #define FILE_ACTION_REMOVED 0x00000002
1289 #define FILE_ACTION_MODIFIED 0x00000003
1290 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
1291 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
1292 #define FILE_ACTION_ADDED_STREAM 0x00000006
1293 #define FILE_ACTION_REMOVED_STREAM 0x00000007
1294 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
1296 /* response contains array of the following structures */
1297 struct file_notify_information
{
1298 __le32 NextEntryOffset
;
1300 __le32 FileNameLength
;
1302 } __attribute__((packed
));
1304 struct reparse_data
{
1306 __u16 ReparseDataLength
;
1308 __u16 AltNameOffset
;
1310 __u16 TargetNameOffset
;
1311 __u16 TargetNameLen
;
1312 char LinkNamesBuf
[1];
1313 } __attribute__((packed
));
1315 struct cifs_quota_data
{
1316 __u32 rsrvd1
; /* 0 */
1318 __u64 rsrvd2
; /* 0 */
1322 char sid
[1]; /* variable size? */
1323 } __attribute__((packed
));
1325 /* quota sub commands */
1326 #define QUOTA_LIST_CONTINUE 0
1327 #define QUOTA_LIST_START 0x100
1328 #define QUOTA_FOR_SID 0x101
1331 /* struct smb_hdr hdr precedes. Set wct = 14+ */
1332 __le16 TotalParameterCount
;
1333 __le16 TotalDataCount
;
1334 __le16 MaxParameterCount
;
1335 __le16 MaxDataCount
;
1341 __le16 ParameterCount
;
1342 __le16 ParameterOffset
;
1347 __le16 SubCommand
; /* 1st setup word - SetupCount words follow */
1349 } __attribute__((packed
));
1353 struct trans2_req t2_req
;
1354 } __attribute__((packed
));
1356 struct trans2_resp
{
1357 /* struct smb_hdr hdr precedes. Note wct = 10 + setup count */
1358 __le16 TotalParameterCount
;
1359 __le16 TotalDataCount
;
1361 __le16 ParameterCount
;
1362 __le16 ParameterOffset
;
1363 __le16 ParameterDisplacement
;
1366 __le16 DataDisplacement
;
1369 /* SetupWords[SetupCount];
1372 /* data area follows */
1373 } __attribute__((packed
));
1377 struct trans2_resp t2_rsp
;
1378 } __attribute__((packed
));
1380 /* PathInfo/FileInfo infolevels */
1381 #define SMB_INFO_STANDARD 1
1382 #define SMB_SET_FILE_EA 2
1383 #define SMB_QUERY_FILE_EA_SIZE 2
1384 #define SMB_INFO_QUERY_EAS_FROM_LIST 3
1385 #define SMB_INFO_QUERY_ALL_EAS 4
1386 #define SMB_INFO_IS_NAME_VALID 6
1387 #define SMB_QUERY_FILE_BASIC_INFO 0x101
1388 #define SMB_QUERY_FILE_STANDARD_INFO 0x102
1389 #define SMB_QUERY_FILE_EA_INFO 0x103
1390 #define SMB_QUERY_FILE_NAME_INFO 0x104
1391 #define SMB_QUERY_FILE_ALLOCATION_INFO 0x105
1392 #define SMB_QUERY_FILE_END_OF_FILEINFO 0x106
1393 #define SMB_QUERY_FILE_ALL_INFO 0x107
1394 #define SMB_QUERY_ALT_NAME_INFO 0x108
1395 #define SMB_QUERY_FILE_STREAM_INFO 0x109
1396 #define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
1397 #define SMB_QUERY_FILE_UNIX_BASIC 0x200
1398 #define SMB_QUERY_FILE_UNIX_LINK 0x201
1399 #define SMB_QUERY_POSIX_ACL 0x204
1400 #define SMB_QUERY_XATTR 0x205 /* e.g. system EA name space */
1401 #define SMB_QUERY_ATTR_FLAGS 0x206 /* append,immutable etc. */
1402 #define SMB_QUERY_POSIX_PERMISSION 0x207
1403 #define SMB_QUERY_POSIX_LOCK 0x208
1404 /* #define SMB_POSIX_OPEN 0x209 */
1405 /* #define SMB_POSIX_UNLINK 0x20a */
1406 #define SMB_QUERY_FILE__UNIX_INFO2 0x20b
1407 #define SMB_QUERY_FILE_INTERNAL_INFO 0x3ee
1408 #define SMB_QUERY_FILE_ACCESS_INFO 0x3f0
1409 #define SMB_QUERY_FILE_NAME_INFO2 0x3f1 /* 0x30 bytes */
1410 #define SMB_QUERY_FILE_POSITION_INFO 0x3f6
1411 #define SMB_QUERY_FILE_MODE_INFO 0x3f8
1412 #define SMB_QUERY_FILE_ALGN_INFO 0x3f9
1415 #define SMB_SET_FILE_BASIC_INFO 0x101
1416 #define SMB_SET_FILE_DISPOSITION_INFO 0x102
1417 #define SMB_SET_FILE_ALLOCATION_INFO 0x103
1418 #define SMB_SET_FILE_END_OF_FILE_INFO 0x104
1419 #define SMB_SET_FILE_UNIX_BASIC 0x200
1420 #define SMB_SET_FILE_UNIX_LINK 0x201
1421 #define SMB_SET_FILE_UNIX_HLINK 0x203
1422 #define SMB_SET_POSIX_ACL 0x204
1423 #define SMB_SET_XATTR 0x205
1424 #define SMB_SET_ATTR_FLAGS 0x206 /* append, immutable etc. */
1425 #define SMB_SET_POSIX_LOCK 0x208
1426 #define SMB_POSIX_OPEN 0x209
1427 #define SMB_POSIX_UNLINK 0x20a
1428 #define SMB_SET_FILE_UNIX_INFO2 0x20b
1429 #define SMB_SET_FILE_BASIC_INFO2 0x3ec
1430 #define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo too */
1431 #define SMB_FILE_ALL_INFO2 0x3fa
1432 #define SMB_SET_FILE_ALLOCATION_INFO2 0x3fb
1433 #define SMB_SET_FILE_END_OF_FILE_INFO2 0x3fc
1434 #define SMB_FILE_MOVE_CLUSTER_INFO 0x407
1435 #define SMB_FILE_QUOTA_INFO 0x408
1436 #define SMB_FILE_REPARSEPOINT_INFO 0x409
1437 #define SMB_FILE_MAXIMUM_INFO 0x40d
1439 /* Find File infolevels */
1440 #define SMB_FIND_FILE_INFO_STANDARD 0x001
1441 #define SMB_FIND_FILE_QUERY_EA_SIZE 0x002
1442 #define SMB_FIND_FILE_QUERY_EAS_FROM_LIST 0x003
1443 #define SMB_FIND_FILE_DIRECTORY_INFO 0x101
1444 #define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
1445 #define SMB_FIND_FILE_NAMES_INFO 0x103
1446 #define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
1447 #define SMB_FIND_FILE_ID_FULL_DIR_INFO 0x105
1448 #define SMB_FIND_FILE_ID_BOTH_DIR_INFO 0x106
1449 #define SMB_FIND_FILE_UNIX 0x202
1451 typedef struct smb_com_transaction2_qpi_req
{
1452 struct smb_hdr hdr
; /* wct = 14+ */
1453 __le16 TotalParameterCount
;
1454 __le16 TotalDataCount
;
1455 __le16 MaxParameterCount
;
1456 __le16 MaxDataCount
;
1462 __le16 ParameterCount
;
1463 __le16 ParameterOffset
;
1468 __le16 SubCommand
; /* one setup word */
1471 __le16 InformationLevel
;
1474 } __attribute__((packed
)) TRANSACTION2_QPI_REQ
;
1476 typedef struct smb_com_transaction2_qpi_rsp
{
1477 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1478 struct trans2_resp t2
;
1480 __u16 Reserved2
; /* parameter word is present for infolevels > 100 */
1481 } __attribute__((packed
)) TRANSACTION2_QPI_RSP
;
1483 typedef struct smb_com_transaction2_spi_req
{
1484 struct smb_hdr hdr
; /* wct = 15 */
1485 __le16 TotalParameterCount
;
1486 __le16 TotalDataCount
;
1487 __le16 MaxParameterCount
;
1488 __le16 MaxDataCount
;
1494 __le16 ParameterCount
;
1495 __le16 ParameterOffset
;
1500 __le16 SubCommand
; /* one setup word */
1504 __le16 InformationLevel
;
1507 } __attribute__((packed
)) TRANSACTION2_SPI_REQ
;
1509 typedef struct smb_com_transaction2_spi_rsp
{
1510 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1511 struct trans2_resp t2
;
1513 __u16 Reserved2
; /* parameter word is present for infolevels > 100 */
1514 } __attribute__((packed
)) TRANSACTION2_SPI_RSP
;
1516 struct set_file_rename
{
1517 __le32 overwrite
; /* 1 = overwrite dest */
1518 __u32 root_fid
; /* zero */
1519 __le32 target_name_len
;
1520 char target_name
[0]; /* Must be unicode */
1521 } __attribute__((packed
));
1523 struct smb_com_transaction2_sfi_req
{
1524 struct smb_hdr hdr
; /* wct = 15 */
1525 __le16 TotalParameterCount
;
1526 __le16 TotalDataCount
;
1527 __le16 MaxParameterCount
;
1528 __le16 MaxDataCount
;
1534 __le16 ParameterCount
;
1535 __le16 ParameterOffset
;
1540 __le16 SubCommand
; /* one setup word */
1545 __le16 InformationLevel
;
1547 } __attribute__((packed
));
1549 struct smb_com_transaction2_sfi_rsp
{
1550 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1551 struct trans2_resp t2
;
1553 __u16 Reserved2
; /* parameter word reserved -
1554 present for infolevels > 100 */
1555 } __attribute__((packed
));
1557 struct smb_t2_qfi_req
{
1559 struct trans2_req t2
;
1562 __le16 InformationLevel
;
1563 } __attribute__((packed
));
1565 struct smb_t2_qfi_rsp
{
1566 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1567 struct trans2_resp t2
;
1569 __u16 Reserved2
; /* parameter word reserved -
1570 present for infolevels > 100 */
1571 } __attribute__((packed
));
1574 * Flags on T2 FINDFIRST and FINDNEXT
1576 #define CIFS_SEARCH_CLOSE_ALWAYS 0x0001
1577 #define CIFS_SEARCH_CLOSE_AT_END 0x0002
1578 #define CIFS_SEARCH_RETURN_RESUME 0x0004
1579 #define CIFS_SEARCH_CONTINUE_FROM_LAST 0x0008
1580 #define CIFS_SEARCH_BACKUP_SEARCH 0x0010
1583 * Size of the resume key on FINDFIRST and FINDNEXT calls
1585 #define CIFS_SMB_RESUME_KEY_SIZE 4
1587 typedef struct smb_com_transaction2_ffirst_req
{
1588 struct smb_hdr hdr
; /* wct = 15 */
1589 __le16 TotalParameterCount
;
1590 __le16 TotalDataCount
;
1591 __le16 MaxParameterCount
;
1592 __le16 MaxDataCount
;
1598 __le16 ParameterCount
;
1599 __le16 ParameterOffset
;
1602 __u8 SetupCount
; /* one */
1604 __le16 SubCommand
; /* TRANS2_FIND_FIRST */
1607 __le16 SearchAttributes
;
1610 __le16 InformationLevel
;
1611 __le32 SearchStorageType
;
1613 } __attribute__((packed
)) TRANSACTION2_FFIRST_REQ
;
1615 typedef struct smb_com_transaction2_ffirst_rsp
{
1616 struct smb_hdr hdr
; /* wct = 10 */
1617 struct trans2_resp t2
;
1619 } __attribute__((packed
)) TRANSACTION2_FFIRST_RSP
;
1621 typedef struct smb_com_transaction2_ffirst_rsp_parms
{
1625 __le16 EAErrorOffset
;
1626 __le16 LastNameOffset
;
1627 } __attribute__((packed
)) T2_FFIRST_RSP_PARMS
;
1629 typedef struct smb_com_transaction2_fnext_req
{
1630 struct smb_hdr hdr
; /* wct = 15 */
1631 __le16 TotalParameterCount
;
1632 __le16 TotalDataCount
;
1633 __le16 MaxParameterCount
;
1634 __le16 MaxDataCount
;
1640 __le16 ParameterCount
;
1641 __le16 ParameterOffset
;
1644 __u8 SetupCount
; /* one */
1646 __le16 SubCommand
; /* TRANS2_FIND_NEXT */
1651 __le16 InformationLevel
;
1654 char ResumeFileName
[1];
1655 } __attribute__((packed
)) TRANSACTION2_FNEXT_REQ
;
1657 typedef struct smb_com_transaction2_fnext_rsp
{
1658 struct smb_hdr hdr
; /* wct = 10 */
1659 struct trans2_resp t2
;
1661 } __attribute__((packed
)) TRANSACTION2_FNEXT_RSP
;
1663 typedef struct smb_com_transaction2_fnext_rsp_parms
{
1666 __le16 EAErrorOffset
;
1667 __le16 LastNameOffset
;
1668 } __attribute__((packed
)) T2_FNEXT_RSP_PARMS
;
1670 /* QFSInfo Levels */
1671 #define SMB_INFO_ALLOCATION 1
1672 #define SMB_INFO_VOLUME 2
1673 #define SMB_QUERY_FS_VOLUME_INFO 0x102
1674 #define SMB_QUERY_FS_SIZE_INFO 0x103
1675 #define SMB_QUERY_FS_DEVICE_INFO 0x104
1676 #define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
1677 #define SMB_QUERY_CIFS_UNIX_INFO 0x200
1678 #define SMB_QUERY_POSIX_FS_INFO 0x201
1679 #define SMB_QUERY_POSIX_WHO_AM_I 0x202
1680 #define SMB_QUERY_LABEL_INFO 0x3ea
1681 #define SMB_QUERY_FS_QUOTA_INFO 0x3ee
1682 #define SMB_QUERY_FS_FULL_SIZE_INFO 0x3ef
1683 #define SMB_QUERY_OBJECTID_INFO 0x3f0
1685 typedef struct smb_com_transaction2_qfsi_req
{
1686 struct smb_hdr hdr
; /* wct = 14+ */
1687 __le16 TotalParameterCount
;
1688 __le16 TotalDataCount
;
1689 __le16 MaxParameterCount
;
1690 __le16 MaxDataCount
;
1696 __le16 ParameterCount
;
1697 __le16 ParameterOffset
;
1702 __le16 SubCommand
; /* one setup word */
1705 __le16 InformationLevel
;
1706 } __attribute__((packed
)) TRANSACTION2_QFSI_REQ
;
1708 typedef struct smb_com_transaction_qfsi_rsp
{
1709 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1710 struct trans2_resp t2
;
1712 __u8 Pad
; /* may be three bytes? *//* followed by data area */
1713 } __attribute__((packed
)) TRANSACTION2_QFSI_RSP
;
1715 typedef struct whoami_rsp_data
{ /* Query level 0x202 */
1716 __u32 flags
; /* 0 = Authenticated user 1 = GUEST */
1717 __u32 mask
; /* which flags bits server understands ie 0x0001 */
1719 __u64 unix_user_gid
;
1720 __u32 number_of_supplementary_gids
; /* may be zero */
1721 __u32 number_of_sids
; /* may be zero */
1722 __u32 length_of_sid_array
; /* in bytes - may be zero */
1723 __u32 pad
; /* reserved - MBZ */
1724 /* __u64 gid_array[0]; */ /* may be empty */
1725 /* __u8 * psid_list */ /* may be empty */
1726 } __attribute__((packed
)) WHOAMI_RSP_DATA
;
1728 /* SETFSInfo Levels */
1729 #define SMB_SET_CIFS_UNIX_INFO 0x200
1730 typedef struct smb_com_transaction2_setfsi_req
{
1731 struct smb_hdr hdr
; /* wct = 15 */
1732 __le16 TotalParameterCount
;
1733 __le16 TotalDataCount
;
1734 __le16 MaxParameterCount
;
1735 __le16 MaxDataCount
;
1741 __le16 ParameterCount
; /* 4 */
1742 __le16 ParameterOffset
;
1743 __le16 DataCount
; /* 12 */
1745 __u8 SetupCount
; /* one */
1747 __le16 SubCommand
; /* TRANS2_SET_FS_INFORMATION */
1750 __u16 FileNum
; /* Parameters start. */
1751 __le16 InformationLevel
;/* Parameters end. */
1752 __le16 ClientUnixMajor
; /* Data start. */
1753 __le16 ClientUnixMinor
;
1754 __le64 ClientUnixCap
; /* Data end */
1755 } __attribute__((packed
)) TRANSACTION2_SETFSI_REQ
;
1757 typedef struct smb_com_transaction2_setfsi_rsp
{
1758 struct smb_hdr hdr
; /* wct = 10 */
1759 struct trans2_resp t2
;
1761 } __attribute__((packed
)) TRANSACTION2_SETFSI_RSP
;
1764 typedef struct smb_com_transaction2_get_dfs_refer_req
{
1765 struct smb_hdr hdr
; /* wct = 15 */
1766 __le16 TotalParameterCount
;
1767 __le16 TotalDataCount
;
1768 __le16 MaxParameterCount
;
1769 __le16 MaxDataCount
;
1775 __le16 ParameterCount
;
1776 __le16 ParameterOffset
;
1781 __le16 SubCommand
; /* one setup word */
1783 __u8 Pad
[3]; /* Win2K has sent 0x0F01 (max response length
1784 perhaps?) followed by one byte pad - doesn't
1785 seem to matter though */
1786 __le16 MaxReferralLevel
;
1787 char RequestFileName
[1];
1788 } __attribute__((packed
)) TRANSACTION2_GET_DFS_REFER_REQ
;
1790 typedef struct dfs_referral_level_3
{
1791 __le16 VersionNumber
;
1792 __le16 ReferralSize
;
1793 __le16 ServerType
; /* 0x0001 = CIFS server */
1794 __le16 ReferralFlags
; /* or proximity - not clear which since it is
1795 always set to zero - SNIA spec says 0x01
1796 means strip off PathConsumed chars before
1797 submitting RequestFileName to remote node */
1800 __le16 DfsPathOffset
;
1801 __le16 DfsAlternatePathOffset
;
1802 __le16 NetworkAddressOffset
;
1803 } __attribute__((packed
)) REFERRAL3
;
1805 typedef struct smb_com_transaction_get_dfs_refer_rsp
{
1806 struct smb_hdr hdr
; /* wct = 10 */
1807 struct trans2_resp t2
;
1810 __le16 PathConsumed
;
1811 __le16 NumberOfReferrals
;
1814 REFERRAL3 referrals
[1]; /* array of level 3 dfs_referral structures */
1815 /* followed by the strings pointed to by the referral structures */
1816 } __attribute__((packed
)) TRANSACTION2_GET_DFS_REFER_RSP
;
1819 #define DFSREF_REFERRAL_SERVER 0x0001
1820 #define DFSREF_STORAGE_SERVER 0x0002
1822 /* IOCTL information */
1824 * List of ioctl function codes that look to be of interest to remote clients
1825 * like this one. Need to do some experimentation to make sure they all work
1826 * remotely. Some of the following, such as the encryption/compression ones
1827 * would be invoked from tools via a specialized hook into the VFS rather
1828 * than via the standard vfs entry points
1830 #define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000
1831 #define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004
1832 #define FSCTL_REQUEST_BATCH_OPLOCK 0x00090008
1833 #define FSCTL_LOCK_VOLUME 0x00090018
1834 #define FSCTL_UNLOCK_VOLUME 0x0009001C
1835 #define FSCTL_GET_COMPRESSION 0x0009003C
1836 #define FSCTL_SET_COMPRESSION 0x0009C040
1837 #define FSCTL_REQUEST_FILTER_OPLOCK 0x0009008C
1838 #define FSCTL_FILESYS_GET_STATISTICS 0x00090090
1839 #define FSCTL_SET_REPARSE_POINT 0x000900A4
1840 #define FSCTL_GET_REPARSE_POINT 0x000900A8
1841 #define FSCTL_DELETE_REPARSE_POINT 0x000900AC
1842 #define FSCTL_SET_SPARSE 0x000900C4
1843 #define FSCTL_SET_ZERO_DATA 0x000900C8
1844 #define FSCTL_SET_ENCRYPTION 0x000900D7
1845 #define FSCTL_ENCRYPTION_FSCTL_IO 0x000900DB
1846 #define FSCTL_WRITE_RAW_ENCRYPTED 0x000900DF
1847 #define FSCTL_READ_RAW_ENCRYPTED 0x000900E3
1848 #define FSCTL_SIS_COPYFILE 0x00090100
1849 #define FSCTL_SIS_LINK_FILES 0x0009C104
1851 #define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003
1852 #define IO_REPARSE_TAG_HSM 0xC0000004
1853 #define IO_REPARSE_TAG_SIS 0x80000007
1856 ************************************************************************
1857 * All structs for everything above the SMB PDUs themselves
1858 * (such as the T2 level specific data) go here
1859 ************************************************************************
1863 * Information on a server
1868 unsigned char versionMajor
;
1869 unsigned char versionMinor
;
1871 unsigned int commentOffset
;
1872 } __attribute__((packed
));
1875 * The following structure is the format of the data returned on a NetShareEnum
1876 * with level "90" (x5A)
1882 unsigned short type
;
1883 unsigned int commentOffset
;
1884 } __attribute__((packed
));
1889 unsigned int commentOffset
;
1890 unsigned char type
[2];
1891 } __attribute__((packed
));
1893 struct aliasInfo92
{
1894 int aliasNameOffset
;
1895 int serverNameOffset
;
1896 int shareNameOffset
;
1897 } __attribute__((packed
));
1900 __le64 TotalAllocationUnits
;
1901 __le64 FreeAllocationUnits
;
1902 __le32 SectorsPerAllocationUnit
;
1903 __le32 BytesPerSector
;
1904 } __attribute__((packed
)) FILE_SYSTEM_INFO
; /* size info, level 0x103 */
1908 __le32 SectorsPerAllocationUnit
;
1909 __le32 TotalAllocationUnits
;
1910 __le32 FreeAllocationUnits
;
1911 __le16 BytesPerSector
;
1912 } __attribute__((packed
)) FILE_SYSTEM_ALLOC_INFO
;
1915 __le16 MajorVersionNumber
;
1916 __le16 MinorVersionNumber
;
1918 } __attribute__((packed
)) FILE_SYSTEM_UNIX_INFO
; /* Unix extension level 0x200*/
1920 /* Version numbers for CIFS UNIX major and minor. */
1921 #define CIFS_UNIX_MAJOR_VERSION 1
1922 #define CIFS_UNIX_MINOR_VERSION 0
1924 /* Linux/Unix extensions capability flags */
1925 #define CIFS_UNIX_FCNTL_CAP 0x00000001 /* support for fcntl locks */
1926 #define CIFS_UNIX_POSIX_ACL_CAP 0x00000002 /* support getfacl/setfacl */
1927 #define CIFS_UNIX_XATTR_CAP 0x00000004 /* support new namespace */
1928 #define CIFS_UNIX_EXTATTR_CAP 0x00000008 /* support chattr/chflag */
1929 #define CIFS_UNIX_POSIX_PATHNAMES_CAP 0x00000010 /* Allow POSIX path chars */
1930 #define CIFS_UNIX_POSIX_PATH_OPS_CAP 0x00000020 /* Allow new POSIX path based
1931 calls including posix open
1933 #define CIFS_UNIX_LARGE_READ_CAP 0x00000040 /* support reads >128K (up
1935 #define CIFS_UNIX_LARGE_WRITE_CAP 0x00000080
1937 #ifdef CONFIG_CIFS_POSIX
1938 /* Can not set pathnames cap yet until we send new posix create SMB since
1939 otherwise server can treat such handles opened with older ntcreatex
1940 (by a new client which knows how to send posix path ops)
1941 as non-posix handles (can affect write behavior with byte range locks.
1942 We can add back in POSIX_PATH_OPS cap when Posix Create/Mkdir finished */
1943 /* #define CIFS_UNIX_CAP_MASK 0x000000fb */
1944 #define CIFS_UNIX_CAP_MASK 0x000000db
1946 #define CIFS_UNIX_CAP_MASK 0x00000013
1947 #endif /* CONFIG_CIFS_POSIX */
1950 #define CIFS_POSIX_EXTENSIONS 0x00000010 /* support for new QFSInfo */
1953 /* For undefined recommended transfer size return -1 in that field */
1954 __le32 OptimalTransferSize
; /* bsize on some os, iosize on other os */
1956 /* The next three fields are in terms of the block size.
1957 (above). If block size is unknown, 4096 would be a
1958 reasonable block size for a server to report.
1959 Note that returning the blocks/blocksavail removes need
1960 to make a second call (to QFSInfo level 0x103 to get this info.
1961 UserBlockAvail is typically less than or equal to BlocksAvail,
1962 if no distinction is made return the same value in each */
1964 __le64 BlocksAvail
; /* bfree */
1965 __le64 UserBlocksAvail
; /* bavail */
1966 /* For undefined Node fields or FSID return -1 */
1967 __le64 TotalFileNodes
;
1968 __le64 FreeFileNodes
;
1969 __le64 FileSysIdentifier
; /* fsid */
1970 /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
1971 /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */
1972 } __attribute__((packed
)) FILE_SYSTEM_POSIX_INFO
;
1974 /* DeviceType Flags */
1975 #define FILE_DEVICE_CD_ROM 0x00000002
1976 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
1977 #define FILE_DEVICE_DFS 0x00000006
1978 #define FILE_DEVICE_DISK 0x00000007
1979 #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
1980 #define FILE_DEVICE_FILE_SYSTEM 0x00000009
1981 #define FILE_DEVICE_NAMED_PIPE 0x00000011
1982 #define FILE_DEVICE_NETWORK 0x00000012
1983 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
1984 #define FILE_DEVICE_NULL 0x00000015
1985 #define FILE_DEVICE_PARALLEL_PORT 0x00000016
1986 #define FILE_DEVICE_PRINTER 0x00000018
1987 #define FILE_DEVICE_SERIAL_PORT 0x0000001b
1988 #define FILE_DEVICE_STREAMS 0x0000001e
1989 #define FILE_DEVICE_TAPE 0x0000001f
1990 #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
1991 #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
1992 #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
1996 __le32 DeviceCharacteristics
;
1997 } __attribute__((packed
)) FILE_SYSTEM_DEVICE_INFO
; /* device info level 0x104 */
2001 __le32 MaxPathNameComponentLength
;
2002 __le32 FileSystemNameLen
;
2003 char FileSystemName
[52]; /* do not have to save this - get subset? */
2004 } __attribute__((packed
)) FILE_SYSTEM_ATTRIBUTE_INFO
;
2006 /******************************************************************************/
2007 /* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
2008 /******************************************************************************/
2009 typedef struct { /* data block encoding of response to level 263 QPathInfo */
2010 __le64 CreationTime
;
2011 __le64 LastAccessTime
;
2012 __le64 LastWriteTime
;
2016 __le64 AllocationSize
;
2017 __le64 EndOfFile
; /* size ie offset to first free byte in file */
2018 __le32 NumberOfLinks
; /* hard links */
2026 __le64 CurrentByteOffset
;
2028 __le32 AlignmentRequirement
;
2029 __le32 FileNameLength
;
2031 } __attribute__((packed
)) FILE_ALL_INFO
; /* level 0x107 QPathInfo */
2033 /* defines for enumerating possible values of the Unix type field below */
2036 #define UNIX_SYMLINK 2
2037 #define UNIX_CHARDEV 3
2038 #define UNIX_BLOCKDEV 4
2040 #define UNIX_SOCKET 6
2044 __le64 LastStatusChange
; /*SNIA specs DCE time for the 3 time fields */
2045 __le64 LastAccessTime
;
2046 __le64 LastModificationTime
;
2055 } __attribute__((packed
)) FILE_UNIX_BASIC_INFO
; /* level 0x200 QPathInfo */
2059 } __attribute__((packed
)) FILE_UNIX_LINK_INFO
; /* level 0x201 QPathInfo */
2061 /* The following three structures are needed only for
2062 setting time to NT4 and some older servers via
2063 the primitive DOS time format */
2068 } __attribute__((packed
)) SMB_DATE
;
2074 } __attribute__((packed
)) SMB_TIME
;
2077 __le16 CreationDate
; /* SMB Date see above */
2078 __le16 CreationTime
; /* SMB Time */
2079 __le16 LastAccessDate
;
2080 __le16 LastAccessTime
;
2081 __le16 LastWriteDate
;
2082 __le16 LastWriteTime
;
2083 __le32 DataSize
; /* File Size (EOF) */
2084 __le32 AllocationSize
;
2085 __le16 Attributes
; /* verify not u32 */
2087 } __attribute__((packed
)) FILE_INFO_STANDARD
; /* level 1 SetPath/FileInfo */
2090 __le64 CreationTime
;
2091 __le64 LastAccessTime
;
2092 __le64 LastWriteTime
;
2096 } __attribute__((packed
)) FILE_BASIC_INFO
; /* size info, level 0x101 */
2098 struct file_allocation_info
{
2099 __le64 AllocationSize
; /* Note old Samba srvr rounds this up too much */
2100 } __attribute__((packed
)); /* size used on disk, for level 0x103 for set,
2103 struct file_end_of_file_info
{
2104 __le64 FileSize
; /* offset to end of file */
2105 } __attribute__((packed
)); /* size info, level 0x104 for set, 0x106 for query */
2107 struct file_alt_name_info
{
2109 } __attribute__((packed
)); /* level 0x0108 */
2111 struct file_stream_info
{
2112 __le32 number_of_streams
; /* BB check sizes and verify location */
2113 /* followed by info on streams themselves
2117 }; /* level 0x109 */
2119 struct file_compression_info
{
2120 __le64 compressed_size
;
2126 } __attribute__((packed
)); /* level 0x10b */
2128 /* POSIX ACL set/query path info structures */
2129 #define CIFS_ACL_VERSION 1
2130 struct cifs_posix_ace
{ /* access control entry (ACE) */
2133 __le64 cifs_uid
; /* or gid */
2134 } __attribute__((packed
));
2136 struct cifs_posix_acl
{ /* access conrol list (ACL) */
2138 __le16 access_entry_count
; /* access ACL - count of entries */
2139 __le16 default_entry_count
; /* default ACL - count of entries */
2140 struct cifs_posix_ace ace_array
[0];
2142 struct cifs_posix_ace default_ace_arraay[] */
2143 } __attribute__((packed
)); /* level 0x204 */
2145 /* types of access control entries already defined in posix_acl.h */
2146 /* #define CIFS_POSIX_ACL_USER_OBJ 0x01
2147 #define CIFS_POSIX_ACL_USER 0x02
2148 #define CIFS_POSIX_ACL_GROUP_OBJ 0x04
2149 #define CIFS_POSIX_ACL_GROUP 0x08
2150 #define CIFS_POSIX_ACL_MASK 0x10
2151 #define CIFS_POSIX_ACL_OTHER 0x20 */
2153 /* types of perms */
2154 /* #define CIFS_POSIX_ACL_EXECUTE 0x01
2155 #define CIFS_POSIX_ACL_WRITE 0x02
2156 #define CIFS_POSIX_ACL_READ 0x04 */
2158 /* end of POSIX ACL definitions */
2160 /* POSIX Open Flags */
2161 #define SMB_O_RDONLY 0x1
2162 #define SMB_O_WRONLY 0x2
2163 #define SMB_O_RDWR 0x4
2164 #define SMB_O_CREAT 0x10
2165 #define SMB_O_EXCL 0x20
2166 #define SMB_O_TRUNC 0x40
2167 #define SMB_O_APPEND 0x80
2168 #define SMB_O_SYNC 0x100
2169 #define SMB_O_DIRECTORY 0x200
2170 #define SMB_O_NOFOLLOW 0x400
2171 #define SMB_O_DIRECT 0x800
2174 __le32 OpenFlags
; /* same as NT CreateX */
2175 __le32 PosixOpenFlags
;
2177 __le16 Level
; /* reply level requested (see QPathInfo levels) */
2178 } __attribute__((packed
)) OPEN_PSX_REQ
; /* level 0x209 SetPathInfo data */
2183 __le32 CreateAction
;
2184 __le16 ReturnedLevel
;
2186 /* struct following varies based on requested level */
2187 } __attribute__((packed
)) OPEN_PSX_RSP
; /* level 0x209 SetPathInfo data */
2189 #define SMB_POSIX_UNLINK_FILE_TARGET 0
2190 #define SMB_POSIX_UNLINK_DIRECTORY_TARGET 1
2192 struct unlink_psx_rq
{ /* level 0x20a SetPathInfo */
2194 } __attribute__((packed
));
2196 struct file_internal_info
{
2197 __u64 UniqueId
; /* inode number */
2198 } __attribute__((packed
)); /* level 0x3ee */
2200 struct file_mode_info
{
2202 } __attribute__((packed
)); /* level 0x3f8 */
2204 struct file_attrib_tag
{
2207 } __attribute__((packed
)); /* level 0x40b */
2210 /********************************************************/
2211 /* FindFirst/FindNext transact2 data buffer formats */
2212 /********************************************************/
2215 __le32 NextEntryOffset
;
2216 __u32 ResumeKey
; /* as with FileIndex - no need to convert */
2219 __le64 LastStatusChange
; /*SNIA specs DCE time for the 3 time fields */
2220 __le64 LastAccessTime
;
2221 __le64 LastModificationTime
;
2231 } __attribute__((packed
)) FILE_UNIX_INFO
; /* level 0x202 */
2234 __le32 NextEntryOffset
;
2236 __le64 CreationTime
;
2237 __le64 LastAccessTime
;
2238 __le64 LastWriteTime
;
2241 __le64 AllocationSize
;
2242 __le32 ExtFileAttributes
;
2243 __le32 FileNameLength
;
2245 } __attribute__((packed
)) FILE_DIRECTORY_INFO
; /* level 0x101 FF resp data */
2248 __le32 NextEntryOffset
;
2250 __le64 CreationTime
;
2251 __le64 LastAccessTime
;
2252 __le64 LastWriteTime
;
2255 __le64 AllocationSize
;
2256 __le32 ExtFileAttributes
;
2257 __le32 FileNameLength
;
2258 __le32 EaSize
; /* length of the xattrs */
2260 } __attribute__((packed
)) FILE_FULL_DIRECTORY_INFO
; /* level 0x102 rsp data */
2263 __le32 NextEntryOffset
;
2265 __le64 CreationTime
;
2266 __le64 LastAccessTime
;
2267 __le64 LastWriteTime
;
2270 __le64 AllocationSize
;
2271 __le32 ExtFileAttributes
;
2272 __le32 FileNameLength
;
2273 __le32 EaSize
; /* EA size */
2275 __u64 UniqueId
; /* inode num - le since Samba puts ino in low 32 bit*/
2277 } __attribute__((packed
)) SEARCH_ID_FULL_DIR_INFO
; /* level 0x105 FF rsp data */
2280 __le32 NextEntryOffset
;
2282 __le64 CreationTime
;
2283 __le64 LastAccessTime
;
2284 __le64 LastWriteTime
;
2287 __le64 AllocationSize
;
2288 __le32 ExtFileAttributes
;
2289 __le32 FileNameLength
;
2290 __le32 EaSize
; /* length of the xattrs */
2291 __u8 ShortNameLength
;
2295 } __attribute__((packed
)) FILE_BOTH_DIRECTORY_INFO
; /* level 0x104 FFrsp data */
2299 __le16 CreationDate
; /* SMB Date */
2300 __le16 CreationTime
; /* SMB Time */
2301 __le16 LastAccessDate
;
2302 __le16 LastAccessTime
;
2303 __le16 LastWriteDate
;
2304 __le16 LastWriteTime
;
2305 __le32 DataSize
; /* File Size (EOF) */
2306 __le32 AllocationSize
;
2307 __le16 Attributes
; /* verify not u32 */
2308 __u8 FileNameLength
;
2310 } __attribute__((packed
)) FIND_FILE_STANDARD_INFO
; /* level 0x1 FF resp data */
2314 unsigned char type
[8]; /* IntxCHR or IntxBLK */
2317 } __attribute__((packed
));
2320 unsigned char name_len
;
2322 } __attribute__((packed
));
2325 unsigned long list_len
;
2327 } __attribute__((packed
));
2330 unsigned char EA_flags
;
2334 /* optionally followed by value */
2335 } __attribute__((packed
));
2336 /* flags for _FEA.fEA */
2337 #define FEA_NEEDEA 0x80 /* need EA bit */
2342 } __attribute__((packed
));
2344 /* used to hold an arbitrary blob of data */
2348 void (*free
) (struct data_blob
*data_blob
);
2349 } __attribute__((packed
));
2352 #ifdef CONFIG_CIFS_POSIX
2354 For better POSIX semantics from Linux client, (even better
2355 than the existing CIFS Unix Extensions) we need updated PDUs for:
2357 1) PosixCreateX - to set and return the mode, inode#, device info and
2358 perhaps add a CreateDevice - to create Pipes and other special .inodes
2359 Also note POSIX open flags
2360 2) Close - to return the last write time to do cache across close
2362 3) FindFirst return unique inode number - what about resume key, two
2363 forms short (matches readdir) and full (enough info to cache inodes)
2366 And under consideration:
2367 5) FindClose2 (return nanosecond timestamp ??)
2368 6) Use nanosecond timestamps throughout all time fields if
2369 corresponding attribute flag is set
2370 7) sendfile - handle based copy
2374 what about fixing 64 bit alignment
2376 There are also various legacy SMB/CIFS requests used as is
2378 From existing Lanman and NTLM dialects:
2379 --------------------------------------
2381 SESSION_SETUP_ANDX (BB which?)
2382 TREE_CONNECT_ANDX (BB which wct?)
2383 TREE_DISCONNECT (BB add volume timestamp on response)
2385 DELETE (note delete open file behavior)
2389 LOCKING_AND_X (note posix lock semantics)
2390 RENAME (note rename across dirs and open file rename posix behaviors)
2391 NT_RENAME (for hardlinks) Is this good enough for all features?
2393 TRANSACTION2 (18 cases)
2394 SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2
2395 (BB verify that never need to set allocation size)
2396 SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via
2399 COPY (note support for copy across directories) - FUTURE, OPTIONAL
2400 setting/getting OS/2 EAs - FUTURE (BB can this handle
2401 setting Linux xattrs perfectly) - OPTIONAL
2402 dnotify - FUTURE, OPTIONAL
2403 quota - FUTURE, OPTIONAL
2405 Note that various requests implemented for NT interop such as
2406 NT_TRANSACT (IOCTL) QueryReparseInfo
2407 are unneeded to servers compliant with the CIFS POSIX extensions
2409 From CIFS Unix Extensions:
2410 -------------------------
2411 T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks
2412 T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2)
2413 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK)
2414 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC) BB check for missing
2416 Actually a need QUERY_FILE_UNIX_INFO
2418 BB what about a) blksize/blkbits/blocks
2424 T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX
2425 TRANS2_GET_DFS_REFERRAL - OPTIONAL but recommended
2426 T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL
2429 /* xsymlink is a symlink format (used by MacOS) that can be used
2430 to save symlink info in a regular file when
2431 mounted to operating systems that do not
2432 support the cifs Unix extensions or EAs (for xattr
2433 based symlinks). For such a file to be recognized
2434 as containing symlink data:
2436 1) file size must be 1067,
2437 2) signature must begin file data,
2438 3) length field must be set to ASCII representation
2439 of a number which is less than or equal to 1024,
2440 4) md5 must match that of the path data */
2444 char signature
[4]; /* XSym */ /* not null terminated */
2446 /* ASCII representation of length (4 bytes decimal) terminated by \n not null */
2449 /* md5 of valid subset of path ie path[0] through path[length-1] */
2452 /* if room left, then end with \n then 0x20s by convention but not required */
2454 } __attribute__((packed
));
2456 typedef struct file_xattr_info
{
2457 /* BB do we need another field for flags? BB */
2458 __u32 xattr_name_len
;
2459 __u32 xattr_value_len
;
2461 /* followed by xattr_value[xattr_value_len], no pad */
2462 } __attribute__((packed
)) FILE_XATTR_INFO
; /* extended attribute info
2466 /* flags for chattr command */
2467 #define EXT_SECURE_DELETE 0x00000001 /* EXT3_SECRM_FL */
2468 #define EXT_ENABLE_UNDELETE 0x00000002 /* EXT3_UNRM_FL */
2469 /* Reserved for compress file 0x4 */
2470 #define EXT_SYNCHRONOUS 0x00000008 /* EXT3_SYNC_FL */
2471 #define EXT_IMMUTABLE_FL 0x00000010 /* EXT3_IMMUTABLE_FL */
2472 #define EXT_OPEN_APPEND_ONLY 0x00000020 /* EXT3_APPEND_FL */
2473 #define EXT_DO_NOT_BACKUP 0x00000040 /* EXT3_NODUMP_FL */
2474 #define EXT_NO_UPDATE_ATIME 0x00000080 /* EXT3_NOATIME_FL */
2475 /* 0x100 through 0x800 reserved for compression flags and are GET-ONLY */
2476 #define EXT_HASH_TREE_INDEXED_DIR 0x00001000 /* GET-ONLY EXT3_INDEX_FL */
2477 /* 0x2000 reserved for IMAGIC_FL */
2478 #define EXT_JOURNAL_THIS_FILE 0x00004000 /* GET-ONLY EXT3_JOURNAL_DATA_FL */
2479 /* 0x8000 reserved for EXT3_NOTAIL_FL */
2480 #define EXT_SYNCHRONOUS_DIR 0x00010000 /* EXT3_DIRSYNC_FL */
2481 #define EXT_TOPDIR 0x00020000 /* EXT3_TOPDIR_FL */
2483 #define EXT_SET_MASK 0x000300FF
2484 #define EXT_GET_MASK 0x0003DFFF
2486 typedef struct file_chattr_info
{
2487 __le64 mask
; /* list of all possible attribute bits */
2488 __le64 mode
; /* list of actual attribute bits on this inode */
2489 } __attribute__((packed
)) FILE_CHATTR_INFO
; /* ext attributes
2490 (chattr, chflags) level 0x206 */
2494 #endif /* _CIFSPDU_H */