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)
240 #define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \
241 | READ_CONTROL | SYNCHRONIZE)
245 * Invalid readdir handle
247 #define CIFS_NO_HANDLE 0xFFFF
249 #define NO_CHANGE_64 cpu_to_le64(0xFFFFFFFFFFFFFFFFULL)
250 #define NO_CHANGE_32 0xFFFFFFFFUL
253 #define CIFS_IPC_RESOURCE "\x49\x50\x43\x24"
255 /* IPC$ in Unicode */
256 #define CIFS_IPC_UNICODE_RESOURCE "\x00\x49\x00\x50\x00\x43\x00\x24\x00\x00"
258 /* Unicode Null terminate 2 bytes of 0 */
259 #define UNICODE_NULL "\x00\x00"
260 #define ASCII_NULL 0x00
263 * Server type values (returned on EnumServer API
265 #define CIFS_SV_TYPE_DC 0x00000008
266 #define CIFS_SV_TYPE_BACKDC 0x00000010
269 * Alias type flags (From EnumAlias API call
271 #define CIFS_ALIAS_TYPE_FILE 0x0001
272 #define CIFS_SHARE_TYPE_FILE 0x0000
275 * File Attribute flags
277 #define ATTR_READONLY 0x0001
278 #define ATTR_HIDDEN 0x0002
279 #define ATTR_SYSTEM 0x0004
280 #define ATTR_VOLUME 0x0008
281 #define ATTR_DIRECTORY 0x0010
282 #define ATTR_ARCHIVE 0x0020
283 #define ATTR_DEVICE 0x0040
284 #define ATTR_NORMAL 0x0080
285 #define ATTR_TEMPORARY 0x0100
286 #define ATTR_SPARSE 0x0200
287 #define ATTR_REPARSE 0x0400
288 #define ATTR_COMPRESSED 0x0800
289 #define ATTR_OFFLINE 0x1000 /* ie file not immediately available -
290 on offline storage */
291 #define ATTR_NOT_CONTENT_INDEXED 0x2000
292 #define ATTR_ENCRYPTED 0x4000
293 #define ATTR_POSIX_SEMANTICS 0x01000000
294 #define ATTR_BACKUP_SEMANTICS 0x02000000
295 #define ATTR_DELETE_ON_CLOSE 0x04000000
296 #define ATTR_SEQUENTIAL_SCAN 0x08000000
297 #define ATTR_RANDOM_ACCESS 0x10000000
298 #define ATTR_NO_BUFFERING 0x20000000
299 #define ATTR_WRITE_THROUGH 0x80000000
301 /* ShareAccess flags */
302 #define FILE_NO_SHARE 0x00000000
303 #define FILE_SHARE_READ 0x00000001
304 #define FILE_SHARE_WRITE 0x00000002
305 #define FILE_SHARE_DELETE 0x00000004
306 #define FILE_SHARE_ALL 0x00000007
308 /* CreateDisposition flags */
309 #define FILE_SUPERSEDE 0x00000000
310 #define FILE_OPEN 0x00000001
311 #define FILE_CREATE 0x00000002
312 #define FILE_OPEN_IF 0x00000003
313 #define FILE_OVERWRITE 0x00000004
314 #define FILE_OVERWRITE_IF 0x00000005
317 #define CREATE_NOT_FILE 0x00000001 /* if set must not be file */
318 #define CREATE_WRITE_THROUGH 0x00000002
319 #define CREATE_SEQUENTIAL 0x00000004
320 #define CREATE_SYNC_ALERT 0x00000010
321 #define CREATE_ASYNC_ALERT 0x00000020
322 #define CREATE_NOT_DIR 0x00000040 /* if set must not be directory */
323 #define CREATE_NO_EA_KNOWLEDGE 0x00000200
324 #define CREATE_EIGHT_DOT_THREE 0x00000400
325 #define CREATE_RANDOM_ACCESS 0x00000800
326 #define CREATE_DELETE_ON_CLOSE 0x00001000
327 #define CREATE_OPEN_BY_ID 0x00002000
328 #define OPEN_REPARSE_POINT 0x00200000
329 #define CREATE_OPTIONS_MASK 0x007FFFFF
330 #define CREATE_OPTION_SPECIAL 0x20000000 /* system. NB not sent over wire */
332 /* ImpersonationLevel flags */
333 #define SECURITY_ANONYMOUS 0
334 #define SECURITY_IDENTIFICATION 1
335 #define SECURITY_IMPERSONATION 2
336 #define SECURITY_DELEGATION 3
339 #define SECURITY_CONTEXT_TRACKING 0x01
340 #define SECURITY_EFFECTIVE_ONLY 0x02
343 * Default PID value, used in all SMBs where the PID is not important
345 #define CIFS_DFT_PID 0x1234
348 * We use the same routine for Copy and Move SMBs. This flag is used to
351 #define CIFS_COPY_OP 1
352 #define CIFS_RENAME_OP 2
354 #define GETU16(var) (*((__u16 *)var)) /* BB check for endian issues */
355 #define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */
358 __u32 smb_buf_length
; /* big endian on wire *//* BB length is only two
359 or three bytes - with one or two byte type preceding it that are
360 zero - we could mask the type byte off just in case BB */
368 } __attribute__((packed
)) DosError
;
370 } __attribute__((packed
)) Status
;
372 __le16 Flags2
; /* note: le */
376 __le32 SequenceNumber
; /* le */
377 __u32 Reserved
; /* zero */
378 } __attribute__((packed
)) Sequence
;
379 __u8 SecuritySignature
[8]; /* le */
380 } __attribute__((packed
)) Signature
;
387 } __attribute__((packed
));
388 /* given a pointer to an smb_hdr retrieve the value of byte count */
389 #define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount)))
390 #define BCC_LE(smb_var) ( *(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount)))
391 /* given a pointer to an smb_hdr retrieve the pointer to the byte area */
392 #define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount) + 2)
395 * Computer Name Length (since Netbios name was length 16 with last byte 0x20)
396 * No longer as important, now that TCP names are more commonly used to
402 * Share Name Length (SNLEN)
403 * Note: This length was limited by the SMB used to get
404 * the Share info. NetShareEnum only returned 13
405 * chars, including the null termination.
406 * This was removed because it no longer is limiting.
412 #define MAXCOMMENTLEN 40
415 * The OS/2 maximum path name
417 #define MAX_PATHCONF 256
420 * SMB frame definitions (following must be packed structs)
421 * See the SNIA CIFS Specification for details.
423 * The Naming convention is the lower case version of the
424 * smb command code name for the struct and this is typedef to the
425 * uppercase version of the same name with the prefix SMB_ removed
426 * for brevity. Although typedefs are not commonly used for
427 * structure definitions in the Linux kernel, their use in the
428 * CIFS standards document, which this code is based on, may
429 * make this one of the cases where typedefs for structures make
430 * sense to improve readability for readers of the standards doc.
431 * Typedefs can always be removed later if they are too distracting
432 * and they are only used for the CIFSs PDUs themselves, not
433 * internal cifs vfs structures
437 typedef struct negotiate_req
{
438 struct smb_hdr hdr
; /* wct = 0 */
440 unsigned char DialectsArray
[1];
441 } __attribute__((packed
)) NEGOTIATE_REQ
;
443 /* Dialect index is 13 for LANMAN */
445 #define MIN_TZ_ADJ (15 * 60) /* minimum grid for timezones in seconds */
447 typedef struct lanman_neg_rsp
{
448 struct smb_hdr hdr
; /* wct = 13 */
459 } __attribute__((packed
)) SrvTime
;
460 __le16 ServerTimeZone
;
461 __le16 EncryptionKeyLength
;
464 unsigned char EncryptionKey
[1];
465 } __attribute__((packed
)) LANMAN_NEG_RSP
;
467 #define READ_RAW_ENABLE 1
468 #define WRITE_RAW_ENABLE 2
469 #define RAW_ENABLE (READ_RAW_ENABLE | WRITE_RAW_ENABLE)
471 typedef struct negotiate_rsp
{
472 struct smb_hdr hdr
; /* wct = 17 */
477 __le32 MaxBufferSize
;
480 __le32 Capabilities
; /* see below */
481 __le32 SystemTimeLow
;
482 __le32 SystemTimeHigh
;
483 __le16 ServerTimeZone
;
484 __u8 EncryptionKeyLength
;
487 unsigned char EncryptionKey
[1]; /* cap extended security off */
488 /* followed by Domain name - if extended security is off */
489 /* followed by 16 bytes of server GUID */
490 /* then security blob if cap_extended_security negotiated */
492 unsigned char GUID
[16];
493 unsigned char SecurityBlob
[1];
494 } __attribute__((packed
)) extended_response
;
495 } __attribute__((packed
)) u
;
496 } __attribute__((packed
)) NEGOTIATE_RSP
;
498 /* SecurityMode bits */
499 #define SECMODE_USER 0x01 /* off indicates share level security */
500 #define SECMODE_PW_ENCRYPT 0x02
501 #define SECMODE_SIGN_ENABLED 0x04 /* SMB security signatures enabled */
502 #define SECMODE_SIGN_REQUIRED 0x08 /* SMB security signatures required */
504 /* Negotiate response Capabilities */
505 #define CAP_RAW_MODE 0x00000001
506 #define CAP_MPX_MODE 0x00000002
507 #define CAP_UNICODE 0x00000004
508 #define CAP_LARGE_FILES 0x00000008
509 #define CAP_NT_SMBS 0x00000010 /* implies CAP_NT_FIND */
510 #define CAP_RPC_REMOTE_APIS 0x00000020
511 #define CAP_STATUS32 0x00000040
512 #define CAP_LEVEL_II_OPLOCKS 0x00000080
513 #define CAP_LOCK_AND_READ 0x00000100
514 #define CAP_NT_FIND 0x00000200
515 #define CAP_DFS 0x00001000
516 #define CAP_INFOLEVEL_PASSTHRU 0x00002000
517 #define CAP_LARGE_READ_X 0x00004000
518 #define CAP_LARGE_WRITE_X 0x00008000
519 #define CAP_UNIX 0x00800000
520 #define CAP_RESERVED 0x02000000
521 #define CAP_BULK_TRANSFER 0x20000000
522 #define CAP_COMPRESSED_DATA 0x40000000
523 #define CAP_EXTENDED_SECURITY 0x80000000
525 typedef union smb_com_session_setup_andx
{
526 struct { /* request format */
527 struct smb_hdr hdr
; /* wct = 12 */
531 __le16 MaxBufferSize
;
535 __le16 SecurityBlobLength
;
537 __le32 Capabilities
; /* see below */
539 unsigned char SecurityBlob
[1]; /* followed by */
540 /* STRING NativeOS */
541 /* STRING NativeLanMan */
542 } __attribute__((packed
)) req
; /* NTLM request format (with
545 struct { /* request format */
546 struct smb_hdr hdr
; /* wct = 13 */
550 __le16 MaxBufferSize
;
554 __le16 CaseInsensitivePasswordLength
; /* ASCII password len */
555 __le16 CaseSensitivePasswordLength
; /* Unicode password length*/
556 __u32 Reserved
; /* see below */
559 unsigned char CaseInsensitivePassword
[1]; /* followed by: */
560 /* unsigned char * CaseSensitivePassword; */
561 /* STRING AccountName */
562 /* STRING PrimaryDomain */
563 /* STRING NativeOS */
564 /* STRING NativeLanMan */
565 } __attribute__((packed
)) req_no_secext
; /* NTLM request format (without
568 struct { /* default (NTLM) response format */
569 struct smb_hdr hdr
; /* wct = 4 */
573 __le16 Action
; /* see below */
574 __le16 SecurityBlobLength
;
576 unsigned char SecurityBlob
[1]; /* followed by */
577 /* unsigned char * NativeOS; */
578 /* unsigned char * NativeLanMan; */
579 /* unsigned char * PrimaryDomain; */
580 } __attribute__((packed
)) resp
; /* NTLM response
581 (with or without extended sec) */
583 struct { /* request format */
584 struct smb_hdr hdr
; /* wct = 10 */
588 __le16 MaxBufferSize
;
592 __le16 PasswordLength
;
593 __u32 Reserved
; /* encrypt key len and offset */
595 unsigned char AccountPassword
[1]; /* followed by */
596 /* STRING AccountName */
597 /* STRING PrimaryDomain */
598 /* STRING NativeOS */
599 /* STRING NativeLanMan */
600 } __attribute__((packed
)) old_req
; /* pre-NTLM (LANMAN2.1) req format */
602 struct { /* default (NTLM) response format */
603 struct smb_hdr hdr
; /* wct = 3 */
607 __le16 Action
; /* see below */
609 unsigned char NativeOS
[1]; /* followed by */
610 /* unsigned char * NativeLanMan; */
611 /* unsigned char * PrimaryDomain; */
612 } __attribute__((packed
)) old_resp
; /* pre-NTLM (LANMAN2.1) response */
613 } __attribute__((packed
)) SESSION_SETUP_ANDX
;
615 /* format of NLTMv2 Response ie "case sensitive password" hash when NTLMv2 */
617 #define NTLMSSP_SERVER_TYPE 1
618 #define NTLMSSP_DOMAIN_TYPE 2
619 #define NTLMSSP_FQ_DOMAIN_TYPE 3
620 #define NTLMSSP_DNS_DOMAIN_TYPE 4
621 #define NTLMSSP_DNS_PARENT_TYPE 5
623 struct ntlmssp2_name
{
626 /* char name[length]; */
627 } __attribute__((packed
));
630 char ntlmv2_hash
[CIFS_ENCPWD_SIZE
];
631 __le32 blob_signature
;
634 __u64 client_chal
; /* random */
636 struct ntlmssp2_name names
[2];
637 /* array of name entries could follow ending in minimum 4 byte struct */
638 } __attribute__((packed
));
641 #define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux"
643 /* Capabilities bits (for NTLM SessSetup request) */
644 #define CAP_UNICODE 0x00000004
645 #define CAP_LARGE_FILES 0x00000008
646 #define CAP_NT_SMBS 0x00000010
647 #define CAP_STATUS32 0x00000040
648 #define CAP_LEVEL_II_OPLOCKS 0x00000080
649 #define CAP_NT_FIND 0x00000200 /* reserved should be zero
650 (because NT_SMBs implies the same thing?) */
651 #define CAP_BULK_TRANSFER 0x20000000
652 #define CAP_EXTENDED_SECURITY 0x80000000
655 #define GUEST_LOGIN 1
657 typedef struct smb_com_tconx_req
{
658 struct smb_hdr hdr
; /* wct = 4 */
662 __le16 Flags
; /* see below */
663 __le16 PasswordLength
;
665 unsigned char Password
[1]; /* followed by */
666 /* STRING Path *//* \\server\share name */
668 } __attribute__((packed
)) TCONX_REQ
;
670 typedef struct smb_com_tconx_rsp
{
671 struct smb_hdr hdr
; /* wct = 3 note that Win2000 has sent wct = 7
672 in some cases on responses. Four unspecified
673 words followed OptionalSupport */
677 __le16 OptionalSupport
; /* see below */
679 unsigned char Service
[1]; /* always ASCII, not Unicode */
680 /* STRING NativeFileSystem */
681 } __attribute__((packed
)) TCONX_RSP
;
683 /* tree connect Flags */
684 #define DISCONNECT_TID 0x0001
685 #define TCON_EXTENDED_SECINFO 0x0008
686 /* OptionalSupport bits */
687 #define SMB_SUPPORT_SEARCH_BITS 0x0001 /* "must have" directory search bits
688 (exclusive searches supported) */
689 #define SMB_SHARE_IS_IN_DFS 0x0002
691 typedef struct smb_com_logoff_andx_req
{
692 struct smb_hdr hdr
; /* wct = 2 */
697 } __attribute__((packed
)) LOGOFF_ANDX_REQ
;
699 typedef struct smb_com_logoff_andx_rsp
{
700 struct smb_hdr hdr
; /* wct = 2 */
705 } __attribute__((packed
)) LOGOFF_ANDX_RSP
;
707 typedef union smb_com_tree_disconnect
{ /* as an altetnative can use flag on
708 tree_connect PDU to effect disconnect */
709 /* tdis is probably simplest SMB PDU */
711 struct smb_hdr hdr
; /* wct = 0 */
712 __u16 ByteCount
; /* bcc = 0 */
713 } __attribute__((packed
)) req
;
715 struct smb_hdr hdr
; /* wct = 0 */
716 __u16 ByteCount
; /* bcc = 0 */
717 } __attribute__((packed
)) resp
;
718 } __attribute__((packed
)) TREE_DISCONNECT
;
720 typedef struct smb_com_close_req
{
721 struct smb_hdr hdr
; /* wct = 3 */
723 __u32 LastWriteTime
; /* should be zero or -1 */
724 __u16 ByteCount
; /* 0 */
725 } __attribute__((packed
)) CLOSE_REQ
;
727 typedef struct smb_com_close_rsp
{
728 struct smb_hdr hdr
; /* wct = 0 */
729 __u16 ByteCount
; /* bct = 0 */
730 } __attribute__((packed
)) CLOSE_RSP
;
732 typedef struct smb_com_findclose_req
{
733 struct smb_hdr hdr
; /* wct = 1 */
735 __u16 ByteCount
; /* 0 */
736 } __attribute__((packed
)) FINDCLOSE_REQ
;
739 #define REQ_MORE_INFO 0x00000001 /* legacy (OPEN_AND_X) only */
740 #define REQ_OPLOCK 0x00000002
741 #define REQ_BATCHOPLOCK 0x00000004
742 #define REQ_OPENDIRONLY 0x00000008
743 #define REQ_EXTENDED_INFO 0x00000010
746 #define DISK_TYPE 0x0000
747 #define BYTE_PIPE_TYPE 0x0001
748 #define MESSAGE_PIPE_TYPE 0x0002
749 #define PRINTER_TYPE 0x0003
750 #define COMM_DEV_TYPE 0x0004
751 #define UNKNOWN_TYPE 0xFFFF
753 typedef struct smb_com_open_req
{ /* also handles create */
754 struct smb_hdr hdr
; /* wct = 24 */
758 __u8 Reserved
; /* Must Be Zero */
761 __le32 RootDirectoryFid
;
762 __le32 DesiredAccess
;
763 __le64 AllocationSize
;
764 __le32 FileAttributes
;
766 __le32 CreateDisposition
;
767 __le32 CreateOptions
;
768 __le32 ImpersonationLevel
;
772 } __attribute__((packed
)) OPEN_REQ
;
774 /* open response: oplock levels */
775 #define OPLOCK_NONE 0
776 #define OPLOCK_EXCLUSIVE 1
777 #define OPLOCK_BATCH 2
778 #define OPLOCK_READ 3 /* level 2 oplock */
780 /* open response for CreateAction shifted left */
781 #define CIFS_CREATE_ACTION 0x20000 /* file created */
783 typedef struct smb_com_open_rsp
{
784 struct smb_hdr hdr
; /* wct = 34 BB */
792 __le64 LastAccessTime
;
793 __le64 LastWriteTime
;
795 __le32 FileAttributes
;
796 __le64 AllocationSize
;
801 __u16 ByteCount
; /* bct = 0 */
802 } __attribute__((packed
)) OPEN_RSP
;
804 /* format of legacy open request */
805 typedef struct smb_com_openx_req
{
806 struct smb_hdr hdr
; /* wct = 15 */
812 __le16 Sattr
; /* search attributes */
813 __le16 FileAttributes
; /* dos attrs */
814 __le32 CreateTime
; /* os2 format */
819 __le16 ByteCount
; /* file name follows */
821 } __attribute__((packed
)) OPENX_REQ
;
823 typedef struct smb_com_openx_rsp
{
824 struct smb_hdr hdr
; /* wct = 15 */
829 __le16 FileAttributes
;
830 __le32 LastWriteTime
; /* os2 format */
839 } __attribute__((packed
)) OPENX_RSP
;
841 /* For encoding of POSIX Open Request - see trans2 function 0x209 data struct */
843 /* Legacy write request for older servers */
844 typedef struct smb_com_writex_req
{
845 struct smb_hdr hdr
; /* wct = 12 */
851 __u32 Reserved
; /* Timeout */
852 __le16 WriteMode
; /* 1 = write through */
855 __le16 DataLengthLow
;
858 __u8 Pad
; /* BB check for whether padded to DWORD
859 boundary and optimum performance here */
861 } __attribute__((packed
)) WRITEX_REQ
;
863 typedef struct smb_com_write_req
{
864 struct smb_hdr hdr
; /* wct = 14 */
873 __le16 DataLengthHigh
;
874 __le16 DataLengthLow
;
878 __u8 Pad
; /* BB check for whether padded to DWORD
879 boundary and optimum performance here */
881 } __attribute__((packed
)) WRITE_REQ
;
883 typedef struct smb_com_write_rsp
{
884 struct smb_hdr hdr
; /* wct = 6 */
893 } __attribute__((packed
)) WRITE_RSP
;
895 /* legacy read request for older servers */
896 typedef struct smb_com_readx_req
{
897 struct smb_hdr hdr
; /* wct = 10 */
904 __le16 MinCount
; /* obsolete */
908 } __attribute__((packed
)) READX_REQ
;
910 typedef struct smb_com_read_req
{
911 struct smb_hdr hdr
; /* wct = 12 */
918 __le16 MinCount
; /* obsolete */
923 } __attribute__((packed
)) READ_REQ
;
925 typedef struct smb_com_read_rsp
{
926 struct smb_hdr hdr
; /* wct = 12 */
931 __le16 DataCompactionMode
;
935 __le16 DataLengthHigh
;
938 __u8 Pad
; /* BB check for whether padded to DWORD
939 boundary and optimum performance here */
941 } __attribute__((packed
)) READ_RSP
;
943 typedef struct locking_andx_range
{
950 } __attribute__((packed
)) LOCKING_ANDX_RANGE
;
952 #define LOCKING_ANDX_SHARED_LOCK 0x01
953 #define LOCKING_ANDX_OPLOCK_RELEASE 0x02
954 #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
955 #define LOCKING_ANDX_CANCEL_LOCK 0x08
956 #define LOCKING_ANDX_LARGE_FILES 0x10 /* always on for us */
958 typedef struct smb_com_lock_req
{
959 struct smb_hdr hdr
; /* wct = 8 */
967 __le16 NumberOfUnlocks
;
968 __le16 NumberOfLocks
;
970 LOCKING_ANDX_RANGE Locks
[1];
971 } __attribute__((packed
)) LOCK_REQ
;
977 typedef struct cifs_posix_lock
{
978 __le16 lock_type
; /* 0 = Read, 1 = Write, 2 = Unlock */
979 __le16 lock_flags
; /* 1 = Wait (only valid for setlock) */
983 /* BB what about additional owner info to identify network client */
984 } __attribute__((packed
)) CIFS_POSIX_LOCK
;
986 typedef struct smb_com_lock_rsp
{
987 struct smb_hdr hdr
; /* wct = 2 */
992 } __attribute__((packed
)) LOCK_RSP
;
994 typedef struct smb_com_rename_req
{
995 struct smb_hdr hdr
; /* wct = 1 */
996 __le16 SearchAttributes
; /* target file attributes */
998 __u8 BufferFormat
; /* 4 = ASCII or Unicode */
999 unsigned char OldFileName
[1];
1000 /* followed by __u8 BufferFormat2 */
1001 /* followed by NewFileName */
1002 } __attribute__((packed
)) RENAME_REQ
;
1004 /* copy request flags */
1005 #define COPY_MUST_BE_FILE 0x0001
1006 #define COPY_MUST_BE_DIR 0x0002
1007 #define COPY_TARGET_MODE_ASCII 0x0004 /* if not set, binary */
1008 #define COPY_SOURCE_MODE_ASCII 0x0008 /* if not set, binary */
1009 #define COPY_VERIFY_WRITES 0x0010
1010 #define COPY_TREE 0x0020
1012 typedef struct smb_com_copy_req
{
1013 struct smb_hdr hdr
; /* wct = 3 */
1015 __le16 OpenFunction
;
1018 __u8 BufferFormat
; /* 4 = ASCII or Unicode */
1019 unsigned char OldFileName
[1];
1020 /* followed by __u8 BufferFormat2 */
1021 /* followed by NewFileName string */
1022 } __attribute__((packed
)) COPY_REQ
;
1024 typedef struct smb_com_copy_rsp
{
1025 struct smb_hdr hdr
; /* wct = 1 */
1026 __le16 CopyCount
; /* number of files copied */
1027 __u16 ByteCount
; /* may be zero */
1028 __u8 BufferFormat
; /* 0x04 - only present if errored file follows */
1029 unsigned char ErrorFileName
[1]; /* only present if error in copy */
1030 } __attribute__((packed
)) COPY_RSP
;
1032 #define CREATE_HARD_LINK 0x103
1033 #define MOVEFILE_COPY_ALLOWED 0x0002
1034 #define MOVEFILE_REPLACE_EXISTING 0x0001
1036 typedef struct smb_com_nt_rename_req
{ /* A5 - also used for create hardlink */
1037 struct smb_hdr hdr
; /* wct = 4 */
1038 __le16 SearchAttributes
; /* target file attributes */
1039 __le16 Flags
; /* spec says Information Level */
1040 __le32 ClusterCount
;
1042 __u8 BufferFormat
; /* 4 = ASCII or Unicode */
1043 unsigned char OldFileName
[1];
1044 /* followed by __u8 BufferFormat2 */
1045 /* followed by NewFileName */
1046 } __attribute__((packed
)) NT_RENAME_REQ
;
1048 typedef struct smb_com_rename_rsp
{
1049 struct smb_hdr hdr
; /* wct = 0 */
1050 __u16 ByteCount
; /* bct = 0 */
1051 } __attribute__((packed
)) RENAME_RSP
;
1053 typedef struct smb_com_delete_file_req
{
1054 struct smb_hdr hdr
; /* wct = 1 */
1055 __le16 SearchAttributes
;
1057 __u8 BufferFormat
; /* 4 = ASCII */
1058 unsigned char fileName
[1];
1059 } __attribute__((packed
)) DELETE_FILE_REQ
;
1061 typedef struct smb_com_delete_file_rsp
{
1062 struct smb_hdr hdr
; /* wct = 0 */
1063 __u16 ByteCount
; /* bct = 0 */
1064 } __attribute__((packed
)) DELETE_FILE_RSP
;
1066 typedef struct smb_com_delete_directory_req
{
1067 struct smb_hdr hdr
; /* wct = 0 */
1069 __u8 BufferFormat
; /* 4 = ASCII */
1070 unsigned char DirName
[1];
1071 } __attribute__((packed
)) DELETE_DIRECTORY_REQ
;
1073 typedef struct smb_com_delete_directory_rsp
{
1074 struct smb_hdr hdr
; /* wct = 0 */
1075 __u16 ByteCount
; /* bct = 0 */
1076 } __attribute__((packed
)) DELETE_DIRECTORY_RSP
;
1078 typedef struct smb_com_create_directory_req
{
1079 struct smb_hdr hdr
; /* wct = 0 */
1081 __u8 BufferFormat
; /* 4 = ASCII */
1082 unsigned char DirName
[1];
1083 } __attribute__((packed
)) CREATE_DIRECTORY_REQ
;
1085 typedef struct smb_com_create_directory_rsp
{
1086 struct smb_hdr hdr
; /* wct = 0 */
1087 __u16 ByteCount
; /* bct = 0 */
1088 } __attribute__((packed
)) CREATE_DIRECTORY_RSP
;
1090 typedef struct smb_com_query_information_req
{
1091 struct smb_hdr hdr
; /* wct = 0 */
1092 __le16 ByteCount
; /* 1 + namelen + 1 */
1093 __u8 BufferFormat
; /* 4 = ASCII */
1094 unsigned char FileName
[1];
1095 } __attribute__((packed
)) QUERY_INFORMATION_REQ
;
1097 typedef struct smb_com_query_information_rsp
{
1098 struct smb_hdr hdr
; /* wct = 10 */
1100 __le32 last_write_time
;
1103 __le16 ByteCount
; /* bcc = 0 */
1104 } __attribute__((packed
)) QUERY_INFORMATION_RSP
;
1106 typedef struct smb_com_setattr_req
{
1107 struct smb_hdr hdr
; /* wct = 8 */
1111 __le16 reserved
[5]; /* must be zero */
1113 __u8 BufferFormat
; /* 4 = ASCII */
1114 unsigned char fileName
[1];
1115 } __attribute__((packed
)) SETATTR_REQ
;
1117 typedef struct smb_com_setattr_rsp
{
1118 struct smb_hdr hdr
; /* wct = 0 */
1119 __u16 ByteCount
; /* bct = 0 */
1120 } __attribute__((packed
)) SETATTR_RSP
;
1122 /* empty wct response to setattr */
1124 /*******************************************************/
1125 /* NT Transact structure defintions follow */
1126 /* Currently only ioctl, acl (get security descriptor) */
1127 /* and notify are implemented */
1128 /*******************************************************/
1129 typedef struct smb_com_ntransact_req
{
1130 struct smb_hdr hdr
; /* wct >= 19 */
1133 __le32 TotalParameterCount
;
1134 __le32 TotalDataCount
;
1135 __le32 MaxParameterCount
;
1136 __le32 MaxDataCount
;
1137 __le32 ParameterCount
;
1138 __le32 ParameterOffset
;
1141 __u8 SetupCount
; /* four setup words follow subcommand */
1142 /* SNIA spec incorrectly included spurious pad here */
1143 __le16 SubCommand
; /* 2 = IOCTL/FSCTL */
1144 /* SetupCount words follow then */
1148 } __attribute__((packed
)) NTRANSACT_REQ
;
1150 typedef struct smb_com_ntransact_rsp
{
1151 struct smb_hdr hdr
; /* wct = 18 */
1153 __le32 TotalParameterCount
;
1154 __le32 TotalDataCount
;
1155 __le32 ParameterCount
;
1156 __le32 ParameterOffset
;
1157 __le32 ParameterDisplacement
;
1160 __le32 DataDisplacement
;
1161 __u8 SetupCount
; /* 0 */
1164 /* parms and data follow */
1165 } __attribute__((packed
)) NTRANSACT_RSP
;
1167 typedef struct smb_com_transaction_ioctl_req
{
1168 struct smb_hdr hdr
; /* wct = 23 */
1171 __le32 TotalParameterCount
;
1172 __le32 TotalDataCount
;
1173 __le32 MaxParameterCount
;
1174 __le32 MaxDataCount
;
1175 __le32 ParameterCount
;
1176 __le32 ParameterOffset
;
1179 __u8 SetupCount
; /* four setup words follow subcommand */
1180 /* SNIA spec incorrectly included spurious pad here */
1181 __le16 SubCommand
; /* 2 = IOCTL/FSCTL */
1182 __le32 FunctionCode
;
1184 __u8 IsFsctl
; /* 1 = File System Control 0 = device control (IOCTL) */
1185 __u8 IsRootFlag
; /* 1 = apply command to root of share (must be DFS) */
1189 } __attribute__((packed
)) TRANSACT_IOCTL_REQ
;
1191 typedef struct smb_com_transaction_ioctl_rsp
{
1192 struct smb_hdr hdr
; /* wct = 19 */
1194 __le32 TotalParameterCount
;
1195 __le32 TotalDataCount
;
1196 __le32 ParameterCount
;
1197 __le32 ParameterOffset
;
1198 __le32 ParameterDisplacement
;
1201 __le32 DataDisplacement
;
1202 __u8 SetupCount
; /* 1 */
1203 __le16 ReturnedDataLen
;
1205 } __attribute__((packed
)) TRANSACT_IOCTL_RSP
;
1207 #define CIFS_ACL_OWNER 1
1208 #define CIFS_ACL_GROUP 2
1209 #define CIFS_ACL_DACL 4
1210 #define CIFS_ACL_SACL 8
1212 typedef struct smb_com_transaction_qsec_req
{
1213 struct smb_hdr hdr
; /* wct = 19 */
1216 __le32 TotalParameterCount
;
1217 __le32 TotalDataCount
;
1218 __le32 MaxParameterCount
;
1219 __le32 MaxDataCount
;
1220 __le32 ParameterCount
;
1221 __le32 ParameterOffset
;
1224 __u8 SetupCount
; /* no setup words follow subcommand */
1225 /* SNIA spec incorrectly included spurious pad here */
1226 __le16 SubCommand
; /* 6 = QUERY_SECURITY_DESC */
1227 __le16 ByteCount
; /* bcc = 3 + 8 */
1232 } __attribute__((packed
)) QUERY_SEC_DESC_REQ
;
1235 typedef struct smb_com_transaction_ssec_req
{
1236 struct smb_hdr hdr
; /* wct = 19 */
1239 __le32 TotalParameterCount
;
1240 __le32 TotalDataCount
;
1241 __le32 MaxParameterCount
;
1242 __le32 MaxDataCount
;
1243 __le32 ParameterCount
;
1244 __le32 ParameterOffset
;
1247 __u8 SetupCount
; /* no setup words follow subcommand */
1248 /* SNIA spec incorrectly included spurious pad here */
1249 __le16 SubCommand
; /* 3 = SET_SECURITY_DESC */
1250 __le16 ByteCount
; /* bcc = 3 + 8 */
1255 } __attribute__((packed
)) SET_SEC_DESC_REQ
;
1257 typedef struct smb_com_transaction_change_notify_req
{
1258 struct smb_hdr hdr
; /* wct = 23 */
1261 __le32 TotalParameterCount
;
1262 __le32 TotalDataCount
;
1263 __le32 MaxParameterCount
;
1264 __le32 MaxDataCount
;
1265 __le32 ParameterCount
;
1266 __le32 ParameterOffset
;
1269 __u8 SetupCount
; /* four setup words follow subcommand */
1270 /* SNIA spec incorrectly included spurious pad here */
1271 __le16 SubCommand
;/* 4 = Change Notify */
1272 __le32 CompletionFilter
; /* operation to monitor */
1274 __u8 WatchTree
; /* 1 = Monitor subdirectories */
1279 } __attribute__((packed
)) TRANSACT_CHANGE_NOTIFY_REQ
;
1281 /* BB eventually change to use generic ntransact rsp struct
1282 and validation routine */
1283 typedef struct smb_com_transaction_change_notify_rsp
{
1284 struct smb_hdr hdr
; /* wct = 18 */
1286 __le32 TotalParameterCount
;
1287 __le32 TotalDataCount
;
1288 __le32 ParameterCount
;
1289 __le32 ParameterOffset
;
1290 __le32 ParameterDisplacement
;
1293 __le32 DataDisplacement
;
1294 __u8 SetupCount
; /* 0 */
1297 } __attribute__((packed
)) TRANSACT_CHANGE_NOTIFY_RSP
;
1298 /* Completion Filter flags for Notify */
1299 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
1300 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
1301 #define FILE_NOTIFY_CHANGE_NAME 0x00000003
1302 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
1303 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
1304 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
1305 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
1306 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
1307 #define FILE_NOTIFY_CHANGE_EA 0x00000080
1308 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
1309 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
1310 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
1311 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1313 #define FILE_ACTION_ADDED 0x00000001
1314 #define FILE_ACTION_REMOVED 0x00000002
1315 #define FILE_ACTION_MODIFIED 0x00000003
1316 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
1317 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
1318 #define FILE_ACTION_ADDED_STREAM 0x00000006
1319 #define FILE_ACTION_REMOVED_STREAM 0x00000007
1320 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
1322 /* response contains array of the following structures */
1323 struct file_notify_information
{
1324 __le32 NextEntryOffset
;
1326 __le32 FileNameLength
;
1328 } __attribute__((packed
));
1330 struct reparse_data
{
1332 __u16 ReparseDataLength
;
1334 __u16 AltNameOffset
;
1336 __u16 TargetNameOffset
;
1337 __u16 TargetNameLen
;
1338 char LinkNamesBuf
[1];
1339 } __attribute__((packed
));
1341 struct cifs_quota_data
{
1342 __u32 rsrvd1
; /* 0 */
1344 __u64 rsrvd2
; /* 0 */
1348 char sid
[1]; /* variable size? */
1349 } __attribute__((packed
));
1351 /* quota sub commands */
1352 #define QUOTA_LIST_CONTINUE 0
1353 #define QUOTA_LIST_START 0x100
1354 #define QUOTA_FOR_SID 0x101
1357 /* struct smb_hdr hdr precedes. Set wct = 14+ */
1358 __le16 TotalParameterCount
;
1359 __le16 TotalDataCount
;
1360 __le16 MaxParameterCount
;
1361 __le16 MaxDataCount
;
1367 __le16 ParameterCount
;
1368 __le16 ParameterOffset
;
1373 __le16 SubCommand
; /* 1st setup word - SetupCount words follow */
1375 } __attribute__((packed
));
1379 struct trans2_req t2_req
;
1380 } __attribute__((packed
));
1382 struct trans2_resp
{
1383 /* struct smb_hdr hdr precedes. Note wct = 10 + setup count */
1384 __le16 TotalParameterCount
;
1385 __le16 TotalDataCount
;
1387 __le16 ParameterCount
;
1388 __le16 ParameterOffset
;
1389 __le16 ParameterDisplacement
;
1392 __le16 DataDisplacement
;
1395 /* SetupWords[SetupCount];
1398 /* data area follows */
1399 } __attribute__((packed
));
1403 struct trans2_resp t2_rsp
;
1404 } __attribute__((packed
));
1406 /* PathInfo/FileInfo infolevels */
1407 #define SMB_INFO_STANDARD 1
1408 #define SMB_SET_FILE_EA 2
1409 #define SMB_QUERY_FILE_EA_SIZE 2
1410 #define SMB_INFO_QUERY_EAS_FROM_LIST 3
1411 #define SMB_INFO_QUERY_ALL_EAS 4
1412 #define SMB_INFO_IS_NAME_VALID 6
1413 #define SMB_QUERY_FILE_BASIC_INFO 0x101
1414 #define SMB_QUERY_FILE_STANDARD_INFO 0x102
1415 #define SMB_QUERY_FILE_EA_INFO 0x103
1416 #define SMB_QUERY_FILE_NAME_INFO 0x104
1417 #define SMB_QUERY_FILE_ALLOCATION_INFO 0x105
1418 #define SMB_QUERY_FILE_END_OF_FILEINFO 0x106
1419 #define SMB_QUERY_FILE_ALL_INFO 0x107
1420 #define SMB_QUERY_ALT_NAME_INFO 0x108
1421 #define SMB_QUERY_FILE_STREAM_INFO 0x109
1422 #define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
1423 #define SMB_QUERY_FILE_UNIX_BASIC 0x200
1424 #define SMB_QUERY_FILE_UNIX_LINK 0x201
1425 #define SMB_QUERY_POSIX_ACL 0x204
1426 #define SMB_QUERY_XATTR 0x205 /* e.g. system EA name space */
1427 #define SMB_QUERY_ATTR_FLAGS 0x206 /* append,immutable etc. */
1428 #define SMB_QUERY_POSIX_PERMISSION 0x207
1429 #define SMB_QUERY_POSIX_LOCK 0x208
1430 /* #define SMB_POSIX_OPEN 0x209 */
1431 /* #define SMB_POSIX_UNLINK 0x20a */
1432 #define SMB_QUERY_FILE__UNIX_INFO2 0x20b
1433 #define SMB_QUERY_FILE_INTERNAL_INFO 0x3ee
1434 #define SMB_QUERY_FILE_ACCESS_INFO 0x3f0
1435 #define SMB_QUERY_FILE_NAME_INFO2 0x3f1 /* 0x30 bytes */
1436 #define SMB_QUERY_FILE_POSITION_INFO 0x3f6
1437 #define SMB_QUERY_FILE_MODE_INFO 0x3f8
1438 #define SMB_QUERY_FILE_ALGN_INFO 0x3f9
1441 #define SMB_SET_FILE_BASIC_INFO 0x101
1442 #define SMB_SET_FILE_DISPOSITION_INFO 0x102
1443 #define SMB_SET_FILE_ALLOCATION_INFO 0x103
1444 #define SMB_SET_FILE_END_OF_FILE_INFO 0x104
1445 #define SMB_SET_FILE_UNIX_BASIC 0x200
1446 #define SMB_SET_FILE_UNIX_LINK 0x201
1447 #define SMB_SET_FILE_UNIX_HLINK 0x203
1448 #define SMB_SET_POSIX_ACL 0x204
1449 #define SMB_SET_XATTR 0x205
1450 #define SMB_SET_ATTR_FLAGS 0x206 /* append, immutable etc. */
1451 #define SMB_SET_POSIX_LOCK 0x208
1452 #define SMB_POSIX_OPEN 0x209
1453 #define SMB_POSIX_UNLINK 0x20a
1454 #define SMB_SET_FILE_UNIX_INFO2 0x20b
1455 #define SMB_SET_FILE_BASIC_INFO2 0x3ec
1456 #define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo too */
1457 #define SMB_FILE_ALL_INFO2 0x3fa
1458 #define SMB_SET_FILE_ALLOCATION_INFO2 0x3fb
1459 #define SMB_SET_FILE_END_OF_FILE_INFO2 0x3fc
1460 #define SMB_FILE_MOVE_CLUSTER_INFO 0x407
1461 #define SMB_FILE_QUOTA_INFO 0x408
1462 #define SMB_FILE_REPARSEPOINT_INFO 0x409
1463 #define SMB_FILE_MAXIMUM_INFO 0x40d
1465 /* Find File infolevels */
1466 #define SMB_FIND_FILE_INFO_STANDARD 0x001
1467 #define SMB_FIND_FILE_QUERY_EA_SIZE 0x002
1468 #define SMB_FIND_FILE_QUERY_EAS_FROM_LIST 0x003
1469 #define SMB_FIND_FILE_DIRECTORY_INFO 0x101
1470 #define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
1471 #define SMB_FIND_FILE_NAMES_INFO 0x103
1472 #define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
1473 #define SMB_FIND_FILE_ID_FULL_DIR_INFO 0x105
1474 #define SMB_FIND_FILE_ID_BOTH_DIR_INFO 0x106
1475 #define SMB_FIND_FILE_UNIX 0x202
1477 typedef struct smb_com_transaction2_qpi_req
{
1478 struct smb_hdr hdr
; /* wct = 14+ */
1479 __le16 TotalParameterCount
;
1480 __le16 TotalDataCount
;
1481 __le16 MaxParameterCount
;
1482 __le16 MaxDataCount
;
1488 __le16 ParameterCount
;
1489 __le16 ParameterOffset
;
1494 __le16 SubCommand
; /* one setup word */
1497 __le16 InformationLevel
;
1500 } __attribute__((packed
)) TRANSACTION2_QPI_REQ
;
1502 typedef struct smb_com_transaction2_qpi_rsp
{
1503 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1504 struct trans2_resp t2
;
1506 __u16 Reserved2
; /* parameter word is present for infolevels > 100 */
1507 } __attribute__((packed
)) TRANSACTION2_QPI_RSP
;
1509 typedef struct smb_com_transaction2_spi_req
{
1510 struct smb_hdr hdr
; /* wct = 15 */
1511 __le16 TotalParameterCount
;
1512 __le16 TotalDataCount
;
1513 __le16 MaxParameterCount
;
1514 __le16 MaxDataCount
;
1520 __le16 ParameterCount
;
1521 __le16 ParameterOffset
;
1526 __le16 SubCommand
; /* one setup word */
1530 __le16 InformationLevel
;
1533 } __attribute__((packed
)) TRANSACTION2_SPI_REQ
;
1535 typedef struct smb_com_transaction2_spi_rsp
{
1536 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1537 struct trans2_resp t2
;
1539 __u16 Reserved2
; /* parameter word is present for infolevels > 100 */
1540 } __attribute__((packed
)) TRANSACTION2_SPI_RSP
;
1542 struct set_file_rename
{
1543 __le32 overwrite
; /* 1 = overwrite dest */
1544 __u32 root_fid
; /* zero */
1545 __le32 target_name_len
;
1546 char target_name
[0]; /* Must be unicode */
1547 } __attribute__((packed
));
1549 struct smb_com_transaction2_sfi_req
{
1550 struct smb_hdr hdr
; /* wct = 15 */
1551 __le16 TotalParameterCount
;
1552 __le16 TotalDataCount
;
1553 __le16 MaxParameterCount
;
1554 __le16 MaxDataCount
;
1560 __le16 ParameterCount
;
1561 __le16 ParameterOffset
;
1566 __le16 SubCommand
; /* one setup word */
1571 __le16 InformationLevel
;
1573 } __attribute__((packed
));
1575 struct smb_com_transaction2_sfi_rsp
{
1576 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1577 struct trans2_resp t2
;
1579 __u16 Reserved2
; /* parameter word reserved -
1580 present for infolevels > 100 */
1581 } __attribute__((packed
));
1583 struct smb_t2_qfi_req
{
1585 struct trans2_req t2
;
1588 __le16 InformationLevel
;
1589 } __attribute__((packed
));
1591 struct smb_t2_qfi_rsp
{
1592 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1593 struct trans2_resp t2
;
1595 __u16 Reserved2
; /* parameter word reserved -
1596 present for infolevels > 100 */
1597 } __attribute__((packed
));
1600 * Flags on T2 FINDFIRST and FINDNEXT
1602 #define CIFS_SEARCH_CLOSE_ALWAYS 0x0001
1603 #define CIFS_SEARCH_CLOSE_AT_END 0x0002
1604 #define CIFS_SEARCH_RETURN_RESUME 0x0004
1605 #define CIFS_SEARCH_CONTINUE_FROM_LAST 0x0008
1606 #define CIFS_SEARCH_BACKUP_SEARCH 0x0010
1609 * Size of the resume key on FINDFIRST and FINDNEXT calls
1611 #define CIFS_SMB_RESUME_KEY_SIZE 4
1613 typedef struct smb_com_transaction2_ffirst_req
{
1614 struct smb_hdr hdr
; /* wct = 15 */
1615 __le16 TotalParameterCount
;
1616 __le16 TotalDataCount
;
1617 __le16 MaxParameterCount
;
1618 __le16 MaxDataCount
;
1624 __le16 ParameterCount
;
1625 __le16 ParameterOffset
;
1628 __u8 SetupCount
; /* one */
1630 __le16 SubCommand
; /* TRANS2_FIND_FIRST */
1633 __le16 SearchAttributes
;
1636 __le16 InformationLevel
;
1637 __le32 SearchStorageType
;
1639 } __attribute__((packed
)) TRANSACTION2_FFIRST_REQ
;
1641 typedef struct smb_com_transaction2_ffirst_rsp
{
1642 struct smb_hdr hdr
; /* wct = 10 */
1643 struct trans2_resp t2
;
1645 } __attribute__((packed
)) TRANSACTION2_FFIRST_RSP
;
1647 typedef struct smb_com_transaction2_ffirst_rsp_parms
{
1651 __le16 EAErrorOffset
;
1652 __le16 LastNameOffset
;
1653 } __attribute__((packed
)) T2_FFIRST_RSP_PARMS
;
1655 typedef struct smb_com_transaction2_fnext_req
{
1656 struct smb_hdr hdr
; /* wct = 15 */
1657 __le16 TotalParameterCount
;
1658 __le16 TotalDataCount
;
1659 __le16 MaxParameterCount
;
1660 __le16 MaxDataCount
;
1666 __le16 ParameterCount
;
1667 __le16 ParameterOffset
;
1670 __u8 SetupCount
; /* one */
1672 __le16 SubCommand
; /* TRANS2_FIND_NEXT */
1677 __le16 InformationLevel
;
1680 char ResumeFileName
[1];
1681 } __attribute__((packed
)) TRANSACTION2_FNEXT_REQ
;
1683 typedef struct smb_com_transaction2_fnext_rsp
{
1684 struct smb_hdr hdr
; /* wct = 10 */
1685 struct trans2_resp t2
;
1687 } __attribute__((packed
)) TRANSACTION2_FNEXT_RSP
;
1689 typedef struct smb_com_transaction2_fnext_rsp_parms
{
1692 __le16 EAErrorOffset
;
1693 __le16 LastNameOffset
;
1694 } __attribute__((packed
)) T2_FNEXT_RSP_PARMS
;
1696 /* QFSInfo Levels */
1697 #define SMB_INFO_ALLOCATION 1
1698 #define SMB_INFO_VOLUME 2
1699 #define SMB_QUERY_FS_VOLUME_INFO 0x102
1700 #define SMB_QUERY_FS_SIZE_INFO 0x103
1701 #define SMB_QUERY_FS_DEVICE_INFO 0x104
1702 #define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
1703 #define SMB_QUERY_CIFS_UNIX_INFO 0x200
1704 #define SMB_QUERY_POSIX_FS_INFO 0x201
1705 #define SMB_QUERY_POSIX_WHO_AM_I 0x202
1706 #define SMB_QUERY_LABEL_INFO 0x3ea
1707 #define SMB_QUERY_FS_QUOTA_INFO 0x3ee
1708 #define SMB_QUERY_FS_FULL_SIZE_INFO 0x3ef
1709 #define SMB_QUERY_OBJECTID_INFO 0x3f0
1711 typedef struct smb_com_transaction2_qfsi_req
{
1712 struct smb_hdr hdr
; /* wct = 14+ */
1713 __le16 TotalParameterCount
;
1714 __le16 TotalDataCount
;
1715 __le16 MaxParameterCount
;
1716 __le16 MaxDataCount
;
1722 __le16 ParameterCount
;
1723 __le16 ParameterOffset
;
1728 __le16 SubCommand
; /* one setup word */
1731 __le16 InformationLevel
;
1732 } __attribute__((packed
)) TRANSACTION2_QFSI_REQ
;
1734 typedef struct smb_com_transaction_qfsi_rsp
{
1735 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1736 struct trans2_resp t2
;
1738 __u8 Pad
; /* may be three bytes? *//* followed by data area */
1739 } __attribute__((packed
)) TRANSACTION2_QFSI_RSP
;
1741 typedef struct whoami_rsp_data
{ /* Query level 0x202 */
1742 __u32 flags
; /* 0 = Authenticated user 1 = GUEST */
1743 __u32 mask
; /* which flags bits server understands ie 0x0001 */
1745 __u64 unix_user_gid
;
1746 __u32 number_of_supplementary_gids
; /* may be zero */
1747 __u32 number_of_sids
; /* may be zero */
1748 __u32 length_of_sid_array
; /* in bytes - may be zero */
1749 __u32 pad
; /* reserved - MBZ */
1750 /* __u64 gid_array[0]; */ /* may be empty */
1751 /* __u8 * psid_list */ /* may be empty */
1752 } __attribute__((packed
)) WHOAMI_RSP_DATA
;
1754 /* SETFSInfo Levels */
1755 #define SMB_SET_CIFS_UNIX_INFO 0x200
1756 typedef struct smb_com_transaction2_setfsi_req
{
1757 struct smb_hdr hdr
; /* wct = 15 */
1758 __le16 TotalParameterCount
;
1759 __le16 TotalDataCount
;
1760 __le16 MaxParameterCount
;
1761 __le16 MaxDataCount
;
1767 __le16 ParameterCount
; /* 4 */
1768 __le16 ParameterOffset
;
1769 __le16 DataCount
; /* 12 */
1771 __u8 SetupCount
; /* one */
1773 __le16 SubCommand
; /* TRANS2_SET_FS_INFORMATION */
1776 __u16 FileNum
; /* Parameters start. */
1777 __le16 InformationLevel
;/* Parameters end. */
1778 __le16 ClientUnixMajor
; /* Data start. */
1779 __le16 ClientUnixMinor
;
1780 __le64 ClientUnixCap
; /* Data end */
1781 } __attribute__((packed
)) TRANSACTION2_SETFSI_REQ
;
1783 typedef struct smb_com_transaction2_setfsi_rsp
{
1784 struct smb_hdr hdr
; /* wct = 10 */
1785 struct trans2_resp t2
;
1787 } __attribute__((packed
)) TRANSACTION2_SETFSI_RSP
;
1790 typedef struct smb_com_transaction2_get_dfs_refer_req
{
1791 struct smb_hdr hdr
; /* wct = 15 */
1792 __le16 TotalParameterCount
;
1793 __le16 TotalDataCount
;
1794 __le16 MaxParameterCount
;
1795 __le16 MaxDataCount
;
1801 __le16 ParameterCount
;
1802 __le16 ParameterOffset
;
1807 __le16 SubCommand
; /* one setup word */
1809 __u8 Pad
[3]; /* Win2K has sent 0x0F01 (max response length
1810 perhaps?) followed by one byte pad - doesn't
1811 seem to matter though */
1812 __le16 MaxReferralLevel
;
1813 char RequestFileName
[1];
1814 } __attribute__((packed
)) TRANSACTION2_GET_DFS_REFER_REQ
;
1816 typedef struct dfs_referral_level_3
{
1817 __le16 VersionNumber
;
1818 __le16 ReferralSize
;
1819 __le16 ServerType
; /* 0x0001 = CIFS server */
1820 __le16 ReferralFlags
; /* or proximity - not clear which since it is
1821 always set to zero - SNIA spec says 0x01
1822 means strip off PathConsumed chars before
1823 submitting RequestFileName to remote node */
1826 __le16 DfsPathOffset
;
1827 __le16 DfsAlternatePathOffset
;
1828 __le16 NetworkAddressOffset
;
1829 } __attribute__((packed
)) REFERRAL3
;
1831 typedef struct smb_com_transaction_get_dfs_refer_rsp
{
1832 struct smb_hdr hdr
; /* wct = 10 */
1833 struct trans2_resp t2
;
1836 __le16 PathConsumed
;
1837 __le16 NumberOfReferrals
;
1840 REFERRAL3 referrals
[1]; /* array of level 3 dfs_referral structures */
1841 /* followed by the strings pointed to by the referral structures */
1842 } __attribute__((packed
)) TRANSACTION2_GET_DFS_REFER_RSP
;
1845 #define DFSREF_REFERRAL_SERVER 0x0001
1846 #define DFSREF_STORAGE_SERVER 0x0002
1848 /* IOCTL information */
1850 * List of ioctl function codes that look to be of interest to remote clients
1851 * like this one. Need to do some experimentation to make sure they all work
1852 * remotely. Some of the following, such as the encryption/compression ones
1853 * would be invoked from tools via a specialized hook into the VFS rather
1854 * than via the standard vfs entry points
1856 #define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000
1857 #define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004
1858 #define FSCTL_REQUEST_BATCH_OPLOCK 0x00090008
1859 #define FSCTL_LOCK_VOLUME 0x00090018
1860 #define FSCTL_UNLOCK_VOLUME 0x0009001C
1861 #define FSCTL_GET_COMPRESSION 0x0009003C
1862 #define FSCTL_SET_COMPRESSION 0x0009C040
1863 #define FSCTL_REQUEST_FILTER_OPLOCK 0x0009008C
1864 #define FSCTL_FILESYS_GET_STATISTICS 0x00090090
1865 #define FSCTL_SET_REPARSE_POINT 0x000900A4
1866 #define FSCTL_GET_REPARSE_POINT 0x000900A8
1867 #define FSCTL_DELETE_REPARSE_POINT 0x000900AC
1868 #define FSCTL_SET_SPARSE 0x000900C4
1869 #define FSCTL_SET_ZERO_DATA 0x000900C8
1870 #define FSCTL_SET_ENCRYPTION 0x000900D7
1871 #define FSCTL_ENCRYPTION_FSCTL_IO 0x000900DB
1872 #define FSCTL_WRITE_RAW_ENCRYPTED 0x000900DF
1873 #define FSCTL_READ_RAW_ENCRYPTED 0x000900E3
1874 #define FSCTL_SIS_COPYFILE 0x00090100
1875 #define FSCTL_SIS_LINK_FILES 0x0009C104
1877 #define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003
1878 #define IO_REPARSE_TAG_HSM 0xC0000004
1879 #define IO_REPARSE_TAG_SIS 0x80000007
1882 ************************************************************************
1883 * All structs for everything above the SMB PDUs themselves
1884 * (such as the T2 level specific data) go here
1885 ************************************************************************
1889 * Information on a server
1894 unsigned char versionMajor
;
1895 unsigned char versionMinor
;
1897 unsigned int commentOffset
;
1898 } __attribute__((packed
));
1901 * The following structure is the format of the data returned on a NetShareEnum
1902 * with level "90" (x5A)
1908 unsigned short type
;
1909 unsigned int commentOffset
;
1910 } __attribute__((packed
));
1915 unsigned int commentOffset
;
1916 unsigned char type
[2];
1917 } __attribute__((packed
));
1919 struct aliasInfo92
{
1920 int aliasNameOffset
;
1921 int serverNameOffset
;
1922 int shareNameOffset
;
1923 } __attribute__((packed
));
1926 __le64 TotalAllocationUnits
;
1927 __le64 FreeAllocationUnits
;
1928 __le32 SectorsPerAllocationUnit
;
1929 __le32 BytesPerSector
;
1930 } __attribute__((packed
)) FILE_SYSTEM_INFO
; /* size info, level 0x103 */
1934 __le32 SectorsPerAllocationUnit
;
1935 __le32 TotalAllocationUnits
;
1936 __le32 FreeAllocationUnits
;
1937 __le16 BytesPerSector
;
1938 } __attribute__((packed
)) FILE_SYSTEM_ALLOC_INFO
;
1941 __le16 MajorVersionNumber
;
1942 __le16 MinorVersionNumber
;
1944 } __attribute__((packed
)) FILE_SYSTEM_UNIX_INFO
; /* Unix extension level 0x200*/
1946 /* Version numbers for CIFS UNIX major and minor. */
1947 #define CIFS_UNIX_MAJOR_VERSION 1
1948 #define CIFS_UNIX_MINOR_VERSION 0
1950 /* Linux/Unix extensions capability flags */
1951 #define CIFS_UNIX_FCNTL_CAP 0x00000001 /* support for fcntl locks */
1952 #define CIFS_UNIX_POSIX_ACL_CAP 0x00000002 /* support getfacl/setfacl */
1953 #define CIFS_UNIX_XATTR_CAP 0x00000004 /* support new namespace */
1954 #define CIFS_UNIX_EXTATTR_CAP 0x00000008 /* support chattr/chflag */
1955 #define CIFS_UNIX_POSIX_PATHNAMES_CAP 0x00000010 /* Allow POSIX path chars */
1956 #define CIFS_UNIX_POSIX_PATH_OPS_CAP 0x00000020 /* Allow new POSIX path based
1957 calls including posix open
1959 #define CIFS_UNIX_LARGE_READ_CAP 0x00000040 /* support reads >128K (up
1961 #define CIFS_UNIX_LARGE_WRITE_CAP 0x00000080
1963 #ifdef CONFIG_CIFS_POSIX
1964 /* Can not set pathnames cap yet until we send new posix create SMB since
1965 otherwise server can treat such handles opened with older ntcreatex
1966 (by a new client which knows how to send posix path ops)
1967 as non-posix handles (can affect write behavior with byte range locks.
1968 We can add back in POSIX_PATH_OPS cap when Posix Create/Mkdir finished */
1969 /* #define CIFS_UNIX_CAP_MASK 0x000000fb */
1970 #define CIFS_UNIX_CAP_MASK 0x000000db
1972 #define CIFS_UNIX_CAP_MASK 0x00000013
1973 #endif /* CONFIG_CIFS_POSIX */
1976 #define CIFS_POSIX_EXTENSIONS 0x00000010 /* support for new QFSInfo */
1979 /* For undefined recommended transfer size return -1 in that field */
1980 __le32 OptimalTransferSize
; /* bsize on some os, iosize on other os */
1982 /* The next three fields are in terms of the block size.
1983 (above). If block size is unknown, 4096 would be a
1984 reasonable block size for a server to report.
1985 Note that returning the blocks/blocksavail removes need
1986 to make a second call (to QFSInfo level 0x103 to get this info.
1987 UserBlockAvail is typically less than or equal to BlocksAvail,
1988 if no distinction is made return the same value in each */
1990 __le64 BlocksAvail
; /* bfree */
1991 __le64 UserBlocksAvail
; /* bavail */
1992 /* For undefined Node fields or FSID return -1 */
1993 __le64 TotalFileNodes
;
1994 __le64 FreeFileNodes
;
1995 __le64 FileSysIdentifier
; /* fsid */
1996 /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
1997 /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */
1998 } __attribute__((packed
)) FILE_SYSTEM_POSIX_INFO
;
2000 /* DeviceType Flags */
2001 #define FILE_DEVICE_CD_ROM 0x00000002
2002 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
2003 #define FILE_DEVICE_DFS 0x00000006
2004 #define FILE_DEVICE_DISK 0x00000007
2005 #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
2006 #define FILE_DEVICE_FILE_SYSTEM 0x00000009
2007 #define FILE_DEVICE_NAMED_PIPE 0x00000011
2008 #define FILE_DEVICE_NETWORK 0x00000012
2009 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
2010 #define FILE_DEVICE_NULL 0x00000015
2011 #define FILE_DEVICE_PARALLEL_PORT 0x00000016
2012 #define FILE_DEVICE_PRINTER 0x00000018
2013 #define FILE_DEVICE_SERIAL_PORT 0x0000001b
2014 #define FILE_DEVICE_STREAMS 0x0000001e
2015 #define FILE_DEVICE_TAPE 0x0000001f
2016 #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
2017 #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
2018 #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
2022 __le32 DeviceCharacteristics
;
2023 } __attribute__((packed
)) FILE_SYSTEM_DEVICE_INFO
; /* device info level 0x104 */
2027 __le32 MaxPathNameComponentLength
;
2028 __le32 FileSystemNameLen
;
2029 char FileSystemName
[52]; /* do not have to save this - get subset? */
2030 } __attribute__((packed
)) FILE_SYSTEM_ATTRIBUTE_INFO
;
2032 /******************************************************************************/
2033 /* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
2034 /******************************************************************************/
2035 typedef struct { /* data block encoding of response to level 263 QPathInfo */
2036 __le64 CreationTime
;
2037 __le64 LastAccessTime
;
2038 __le64 LastWriteTime
;
2042 __le64 AllocationSize
;
2043 __le64 EndOfFile
; /* size ie offset to first free byte in file */
2044 __le32 NumberOfLinks
; /* hard links */
2052 __le64 CurrentByteOffset
;
2054 __le32 AlignmentRequirement
;
2055 __le32 FileNameLength
;
2057 } __attribute__((packed
)) FILE_ALL_INFO
; /* level 0x107 QPathInfo */
2059 /* defines for enumerating possible values of the Unix type field below */
2062 #define UNIX_SYMLINK 2
2063 #define UNIX_CHARDEV 3
2064 #define UNIX_BLOCKDEV 4
2066 #define UNIX_SOCKET 6
2070 __le64 LastStatusChange
; /*SNIA specs DCE time for the 3 time fields */
2071 __le64 LastAccessTime
;
2072 __le64 LastModificationTime
;
2081 } __attribute__((packed
)) FILE_UNIX_BASIC_INFO
; /* level 0x200 QPathInfo */
2085 } __attribute__((packed
)) FILE_UNIX_LINK_INFO
; /* level 0x201 QPathInfo */
2087 /* The following three structures are needed only for
2088 setting time to NT4 and some older servers via
2089 the primitive DOS time format */
2094 } __attribute__((packed
)) SMB_DATE
;
2100 } __attribute__((packed
)) SMB_TIME
;
2103 __le16 CreationDate
; /* SMB Date see above */
2104 __le16 CreationTime
; /* SMB Time */
2105 __le16 LastAccessDate
;
2106 __le16 LastAccessTime
;
2107 __le16 LastWriteDate
;
2108 __le16 LastWriteTime
;
2109 __le32 DataSize
; /* File Size (EOF) */
2110 __le32 AllocationSize
;
2111 __le16 Attributes
; /* verify not u32 */
2113 } __attribute__((packed
)) FILE_INFO_STANDARD
; /* level 1 SetPath/FileInfo */
2116 __le64 CreationTime
;
2117 __le64 LastAccessTime
;
2118 __le64 LastWriteTime
;
2122 } __attribute__((packed
)) FILE_BASIC_INFO
; /* size info, level 0x101 */
2124 struct file_allocation_info
{
2125 __le64 AllocationSize
; /* Note old Samba srvr rounds this up too much */
2126 } __attribute__((packed
)); /* size used on disk, for level 0x103 for set,
2129 struct file_end_of_file_info
{
2130 __le64 FileSize
; /* offset to end of file */
2131 } __attribute__((packed
)); /* size info, level 0x104 for set, 0x106 for query */
2133 struct file_alt_name_info
{
2135 } __attribute__((packed
)); /* level 0x0108 */
2137 struct file_stream_info
{
2138 __le32 number_of_streams
; /* BB check sizes and verify location */
2139 /* followed by info on streams themselves
2143 }; /* level 0x109 */
2145 struct file_compression_info
{
2146 __le64 compressed_size
;
2152 } __attribute__((packed
)); /* level 0x10b */
2154 /* POSIX ACL set/query path info structures */
2155 #define CIFS_ACL_VERSION 1
2156 struct cifs_posix_ace
{ /* access control entry (ACE) */
2159 __le64 cifs_uid
; /* or gid */
2160 } __attribute__((packed
));
2162 struct cifs_posix_acl
{ /* access conrol list (ACL) */
2164 __le16 access_entry_count
; /* access ACL - count of entries */
2165 __le16 default_entry_count
; /* default ACL - count of entries */
2166 struct cifs_posix_ace ace_array
[0];
2168 struct cifs_posix_ace default_ace_arraay[] */
2169 } __attribute__((packed
)); /* level 0x204 */
2171 /* types of access control entries already defined in posix_acl.h */
2172 /* #define CIFS_POSIX_ACL_USER_OBJ 0x01
2173 #define CIFS_POSIX_ACL_USER 0x02
2174 #define CIFS_POSIX_ACL_GROUP_OBJ 0x04
2175 #define CIFS_POSIX_ACL_GROUP 0x08
2176 #define CIFS_POSIX_ACL_MASK 0x10
2177 #define CIFS_POSIX_ACL_OTHER 0x20 */
2179 /* types of perms */
2180 /* #define CIFS_POSIX_ACL_EXECUTE 0x01
2181 #define CIFS_POSIX_ACL_WRITE 0x02
2182 #define CIFS_POSIX_ACL_READ 0x04 */
2184 /* end of POSIX ACL definitions */
2186 /* POSIX Open Flags */
2187 #define SMB_O_RDONLY 0x1
2188 #define SMB_O_WRONLY 0x2
2189 #define SMB_O_RDWR 0x4
2190 #define SMB_O_CREAT 0x10
2191 #define SMB_O_EXCL 0x20
2192 #define SMB_O_TRUNC 0x40
2193 #define SMB_O_APPEND 0x80
2194 #define SMB_O_SYNC 0x100
2195 #define SMB_O_DIRECTORY 0x200
2196 #define SMB_O_NOFOLLOW 0x400
2197 #define SMB_O_DIRECT 0x800
2200 __le32 OpenFlags
; /* same as NT CreateX */
2201 __le32 PosixOpenFlags
;
2203 __le16 Level
; /* reply level requested (see QPathInfo levels) */
2204 } __attribute__((packed
)) OPEN_PSX_REQ
; /* level 0x209 SetPathInfo data */
2209 __le32 CreateAction
;
2210 __le16 ReturnedLevel
;
2212 /* struct following varies based on requested level */
2213 } __attribute__((packed
)) OPEN_PSX_RSP
; /* level 0x209 SetPathInfo data */
2215 #define SMB_POSIX_UNLINK_FILE_TARGET 0
2216 #define SMB_POSIX_UNLINK_DIRECTORY_TARGET 1
2218 struct unlink_psx_rq
{ /* level 0x20a SetPathInfo */
2220 } __attribute__((packed
));
2222 struct file_internal_info
{
2223 __u64 UniqueId
; /* inode number */
2224 } __attribute__((packed
)); /* level 0x3ee */
2226 struct file_mode_info
{
2228 } __attribute__((packed
)); /* level 0x3f8 */
2230 struct file_attrib_tag
{
2233 } __attribute__((packed
)); /* level 0x40b */
2236 /********************************************************/
2237 /* FindFirst/FindNext transact2 data buffer formats */
2238 /********************************************************/
2241 __le32 NextEntryOffset
;
2242 __u32 ResumeKey
; /* as with FileIndex - no need to convert */
2245 __le64 LastStatusChange
; /*SNIA specs DCE time for the 3 time fields */
2246 __le64 LastAccessTime
;
2247 __le64 LastModificationTime
;
2257 } __attribute__((packed
)) FILE_UNIX_INFO
; /* level 0x202 */
2260 __le32 NextEntryOffset
;
2262 __le64 CreationTime
;
2263 __le64 LastAccessTime
;
2264 __le64 LastWriteTime
;
2267 __le64 AllocationSize
;
2268 __le32 ExtFileAttributes
;
2269 __le32 FileNameLength
;
2271 } __attribute__((packed
)) FILE_DIRECTORY_INFO
; /* level 0x101 FF resp data */
2274 __le32 NextEntryOffset
;
2276 __le64 CreationTime
;
2277 __le64 LastAccessTime
;
2278 __le64 LastWriteTime
;
2281 __le64 AllocationSize
;
2282 __le32 ExtFileAttributes
;
2283 __le32 FileNameLength
;
2284 __le32 EaSize
; /* length of the xattrs */
2286 } __attribute__((packed
)) FILE_FULL_DIRECTORY_INFO
; /* level 0x102 rsp data */
2289 __le32 NextEntryOffset
;
2291 __le64 CreationTime
;
2292 __le64 LastAccessTime
;
2293 __le64 LastWriteTime
;
2296 __le64 AllocationSize
;
2297 __le32 ExtFileAttributes
;
2298 __le32 FileNameLength
;
2299 __le32 EaSize
; /* EA size */
2301 __u64 UniqueId
; /* inode num - le since Samba puts ino in low 32 bit*/
2303 } __attribute__((packed
)) SEARCH_ID_FULL_DIR_INFO
; /* level 0x105 FF rsp data */
2306 __le32 NextEntryOffset
;
2308 __le64 CreationTime
;
2309 __le64 LastAccessTime
;
2310 __le64 LastWriteTime
;
2313 __le64 AllocationSize
;
2314 __le32 ExtFileAttributes
;
2315 __le32 FileNameLength
;
2316 __le32 EaSize
; /* length of the xattrs */
2317 __u8 ShortNameLength
;
2321 } __attribute__((packed
)) FILE_BOTH_DIRECTORY_INFO
; /* level 0x104 FFrsp data */
2325 __le16 CreationDate
; /* SMB Date */
2326 __le16 CreationTime
; /* SMB Time */
2327 __le16 LastAccessDate
;
2328 __le16 LastAccessTime
;
2329 __le16 LastWriteDate
;
2330 __le16 LastWriteTime
;
2331 __le32 DataSize
; /* File Size (EOF) */
2332 __le32 AllocationSize
;
2333 __le16 Attributes
; /* verify not u32 */
2334 __u8 FileNameLength
;
2336 } __attribute__((packed
)) FIND_FILE_STANDARD_INFO
; /* level 0x1 FF resp data */
2340 unsigned char type
[8]; /* IntxCHR or IntxBLK */
2343 } __attribute__((packed
));
2346 unsigned char name_len
;
2348 } __attribute__((packed
));
2351 unsigned long list_len
;
2353 } __attribute__((packed
));
2356 unsigned char EA_flags
;
2360 /* optionally followed by value */
2361 } __attribute__((packed
));
2362 /* flags for _FEA.fEA */
2363 #define FEA_NEEDEA 0x80 /* need EA bit */
2368 } __attribute__((packed
));
2370 /* used to hold an arbitrary blob of data */
2374 void (*free
) (struct data_blob
*data_blob
);
2375 } __attribute__((packed
));
2378 #ifdef CONFIG_CIFS_POSIX
2380 For better POSIX semantics from Linux client, (even better
2381 than the existing CIFS Unix Extensions) we need updated PDUs for:
2383 1) PosixCreateX - to set and return the mode, inode#, device info and
2384 perhaps add a CreateDevice - to create Pipes and other special .inodes
2385 Also note POSIX open flags
2386 2) Close - to return the last write time to do cache across close
2388 3) FindFirst return unique inode number - what about resume key, two
2389 forms short (matches readdir) and full (enough info to cache inodes)
2392 And under consideration:
2393 5) FindClose2 (return nanosecond timestamp ??)
2394 6) Use nanosecond timestamps throughout all time fields if
2395 corresponding attribute flag is set
2396 7) sendfile - handle based copy
2400 what about fixing 64 bit alignment
2402 There are also various legacy SMB/CIFS requests used as is
2404 From existing Lanman and NTLM dialects:
2405 --------------------------------------
2407 SESSION_SETUP_ANDX (BB which?)
2408 TREE_CONNECT_ANDX (BB which wct?)
2409 TREE_DISCONNECT (BB add volume timestamp on response)
2411 DELETE (note delete open file behavior)
2415 LOCKING_AND_X (note posix lock semantics)
2416 RENAME (note rename across dirs and open file rename posix behaviors)
2417 NT_RENAME (for hardlinks) Is this good enough for all features?
2419 TRANSACTION2 (18 cases)
2420 SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2
2421 (BB verify that never need to set allocation size)
2422 SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via
2425 COPY (note support for copy across directories) - FUTURE, OPTIONAL
2426 setting/getting OS/2 EAs - FUTURE (BB can this handle
2427 setting Linux xattrs perfectly) - OPTIONAL
2428 dnotify - FUTURE, OPTIONAL
2429 quota - FUTURE, OPTIONAL
2431 Note that various requests implemented for NT interop such as
2432 NT_TRANSACT (IOCTL) QueryReparseInfo
2433 are unneeded to servers compliant with the CIFS POSIX extensions
2435 From CIFS Unix Extensions:
2436 -------------------------
2437 T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks
2438 T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2)
2439 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK)
2440 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC) BB check for missing
2442 Actually a need QUERY_FILE_UNIX_INFO
2444 BB what about a) blksize/blkbits/blocks
2450 T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX
2451 TRANS2_GET_DFS_REFERRAL - OPTIONAL but recommended
2452 T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL
2455 /* xsymlink is a symlink format (used by MacOS) that can be used
2456 to save symlink info in a regular file when
2457 mounted to operating systems that do not
2458 support the cifs Unix extensions or EAs (for xattr
2459 based symlinks). For such a file to be recognized
2460 as containing symlink data:
2462 1) file size must be 1067,
2463 2) signature must begin file data,
2464 3) length field must be set to ASCII representation
2465 of a number which is less than or equal to 1024,
2466 4) md5 must match that of the path data */
2470 char signature
[4]; /* XSym */ /* not null terminated */
2472 /* ASCII representation of length (4 bytes decimal) terminated by \n not null */
2475 /* md5 of valid subset of path ie path[0] through path[length-1] */
2478 /* if room left, then end with \n then 0x20s by convention but not required */
2480 } __attribute__((packed
));
2482 typedef struct file_xattr_info
{
2483 /* BB do we need another field for flags? BB */
2484 __u32 xattr_name_len
;
2485 __u32 xattr_value_len
;
2487 /* followed by xattr_value[xattr_value_len], no pad */
2488 } __attribute__((packed
)) FILE_XATTR_INFO
; /* extended attribute info
2492 /* flags for chattr command */
2493 #define EXT_SECURE_DELETE 0x00000001 /* EXT3_SECRM_FL */
2494 #define EXT_ENABLE_UNDELETE 0x00000002 /* EXT3_UNRM_FL */
2495 /* Reserved for compress file 0x4 */
2496 #define EXT_SYNCHRONOUS 0x00000008 /* EXT3_SYNC_FL */
2497 #define EXT_IMMUTABLE_FL 0x00000010 /* EXT3_IMMUTABLE_FL */
2498 #define EXT_OPEN_APPEND_ONLY 0x00000020 /* EXT3_APPEND_FL */
2499 #define EXT_DO_NOT_BACKUP 0x00000040 /* EXT3_NODUMP_FL */
2500 #define EXT_NO_UPDATE_ATIME 0x00000080 /* EXT3_NOATIME_FL */
2501 /* 0x100 through 0x800 reserved for compression flags and are GET-ONLY */
2502 #define EXT_HASH_TREE_INDEXED_DIR 0x00001000 /* GET-ONLY EXT3_INDEX_FL */
2503 /* 0x2000 reserved for IMAGIC_FL */
2504 #define EXT_JOURNAL_THIS_FILE 0x00004000 /* GET-ONLY EXT3_JOURNAL_DATA_FL */
2505 /* 0x8000 reserved for EXT3_NOTAIL_FL */
2506 #define EXT_SYNCHRONOUS_DIR 0x00010000 /* EXT3_DIRSYNC_FL */
2507 #define EXT_TOPDIR 0x00020000 /* EXT3_TOPDIR_FL */
2509 #define EXT_SET_MASK 0x000300FF
2510 #define EXT_GET_MASK 0x0003DFFF
2512 typedef struct file_chattr_info
{
2513 __le64 mask
; /* list of all possible attribute bits */
2514 __le64 mode
; /* list of actual attribute bits on this inode */
2515 } __attribute__((packed
)) FILE_CHATTR_INFO
; /* ext attributes
2516 (chattr, chflags) level 0x206 */
2520 #endif /* _CIFSPDU_H */