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 */
38 /* Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
39 (ie which include no useful data other than the SMB error code itself).
40 Knowing this helps avoid response buffer allocations and copy in some cases */
41 #define SMB_COM_CREATE_DIRECTORY 0x00 /* trivial response */
42 #define SMB_COM_DELETE_DIRECTORY 0x01 /* trivial response */
43 #define SMB_COM_CLOSE 0x04 /* triv req/rsp, timestamp ignored */
44 #define SMB_COM_DELETE 0x06 /* trivial response */
45 #define SMB_COM_RENAME 0x07 /* trivial response */
46 #define SMB_COM_QUERY_INFORMATION 0x08 /* aka getattr */
47 #define SMB_COM_SETATTR 0x09 /* trivial response */
48 #define SMB_COM_LOCKING_ANDX 0x24 /* trivial response */
49 #define SMB_COM_COPY 0x29 /* trivial rsp, fail filename ignrd*/
50 #define SMB_COM_OPEN_ANDX 0x2D /* Legacy open for old servers */
51 #define SMB_COM_READ_ANDX 0x2E
52 #define SMB_COM_WRITE_ANDX 0x2F
53 #define SMB_COM_TRANSACTION2 0x32
54 #define SMB_COM_TRANSACTION2_SECONDARY 0x33
55 #define SMB_COM_FIND_CLOSE2 0x34 /* trivial response */
56 #define SMB_COM_TREE_DISCONNECT 0x71 /* trivial response */
57 #define SMB_COM_NEGOTIATE 0x72
58 #define SMB_COM_SESSION_SETUP_ANDX 0x73
59 #define SMB_COM_LOGOFF_ANDX 0x74 /* trivial response */
60 #define SMB_COM_TREE_CONNECT_ANDX 0x75
61 #define SMB_COM_NT_TRANSACT 0xA0
62 #define SMB_COM_NT_TRANSACT_SECONDARY 0xA1
63 #define SMB_COM_NT_CREATE_ANDX 0xA2
64 #define SMB_COM_NT_CANCEL 0xA4 /* no response */
65 #define SMB_COM_NT_RENAME 0xA5 /* trivial response */
67 /* Transact2 subcommand codes */
68 #define TRANS2_OPEN 0x00
69 #define TRANS2_FIND_FIRST 0x01
70 #define TRANS2_FIND_NEXT 0x02
71 #define TRANS2_QUERY_FS_INFORMATION 0x03
72 #define TRANS2_SET_FS_INFORMATION 0x04
73 #define TRANS2_QUERY_PATH_INFORMATION 0x05
74 #define TRANS2_SET_PATH_INFORMATION 0x06
75 #define TRANS2_QUERY_FILE_INFORMATION 0x07
76 #define TRANS2_SET_FILE_INFORMATION 0x08
77 #define TRANS2_GET_DFS_REFERRAL 0x10
78 #define TRANS2_REPORT_DFS_INCOSISTENCY 0x11
80 /* NT Transact subcommand codes */
81 #define NT_TRANSACT_CREATE 0x01
82 #define NT_TRANSACT_IOCTL 0x02
83 #define NT_TRANSACT_SET_SECURITY_DESC 0x03
84 #define NT_TRANSACT_NOTIFY_CHANGE 0x04
85 #define NT_TRANSACT_RENAME 0x05
86 #define NT_TRANSACT_QUERY_SECURITY_DESC 0x06
87 #define NT_TRANSACT_GET_USER_QUOTA 0x07
88 #define NT_TRANSACT_SET_USER_QUOTA 0x08
90 #define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */
91 /* future chained NTCreateXReadX bigger, but for time being NTCreateX biggest */
92 /* among the requests (NTCreateX response is bigger with wct of 34) */
93 #define MAX_CIFS_HDR_SIZE 0x58 /* 4 len + 32 hdr + (2*24 wct) + 2 bct + 2 pad */
94 #define CIFS_SMALL_PATH 120 /* allows for (448-88)/3 */
96 /* internal cifs vfs structures */
97 /*****************************************************************
98 * All constants go here
99 *****************************************************************
103 * Starting value for maximum SMB size negotiation
105 #define CIFS_MAX_MSGSIZE (4*4096)
108 * Size of encrypted user password in bytes
110 #define CIFS_ENCPWD_SIZE (16)
113 * Size of the crypto key returned on the negotiate SMB in bytes
115 #define CIFS_CRYPTO_KEY_SIZE (8)
118 * Size of the session key (crypto key encrypted with the password
120 #define CIFS_SESS_KEY_SIZE (24)
123 * Maximum user name length
125 #define CIFS_UNLEN (20)
130 #define SMBOPEN_WRITE_THROUGH 0x4000
131 #define SMBOPEN_DENY_ALL 0x0010
132 #define SMBOPEN_DENY_WRITE 0x0020
133 #define SMBOPEN_DENY_READ 0x0030
134 #define SMBOPEN_DENY_NONE 0x0040
135 #define SMBOPEN_READ 0x0000
136 #define SMBOPEN_WRITE 0x0001
137 #define SMBOPEN_READWRITE 0x0002
138 #define SMBOPEN_EXECUTE 0x0003
140 #define SMBOPEN_OCREATE 0x0010
141 #define SMBOPEN_OTRUNC 0x0002
142 #define SMBOPEN_OAPPEND 0x0001
145 * SMB flag definitions
147 #define SMBFLG_EXTD_LOCK 0x01 /* server supports lock-read write-unlock smb */
148 #define SMBFLG_RCV_POSTED 0x02 /* obsolete */
149 #define SMBFLG_RSVD 0x04
150 #define SMBFLG_CASELESS 0x08 /* all pathnames treated as caseless (off
151 implies case sensitive file handling request) */
152 #define SMBFLG_CANONICAL_PATH_FORMAT 0x10 /* obsolete */
153 #define SMBFLG_OLD_OPLOCK 0x20 /* obsolete */
154 #define SMBFLG_OLD_OPLOCK_NOTIFY 0x40 /* obsolete */
155 #define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */
158 * SMB flag2 definitions
160 #define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1) /* can send long (non-8.3)
161 path names in response */
162 #define SMBFLG2_KNOWS_EAS cpu_to_le16(2)
163 #define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4)
164 #define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40)
165 #define SMBFLG2_EXT_SEC cpu_to_le16(0x800)
166 #define SMBFLG2_DFS cpu_to_le16(0x1000)
167 #define SMBFLG2_PAGING_IO cpu_to_le16(0x2000)
168 #define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)
169 #define SMBFLG2_UNICODE cpu_to_le16(0x8000)
172 * These are the file access permission bits defined in CIFS for the
173 * NTCreateAndX as well as the level 0x107
174 * TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO
175 * responds with the AccessFlags.
176 * The AccessFlags specifies the access permissions a caller has to the
177 * file and can have any suitable combination of the following values:
180 #define FILE_READ_DATA 0x00000001 /* Data can be read from the file */
181 #define FILE_WRITE_DATA 0x00000002 /* Data can be written to the file */
182 #define FILE_APPEND_DATA 0x00000004 /* Data can be appended to the file */
183 #define FILE_READ_EA 0x00000008 /* Extended attributes associated */
184 /* with the file can be read */
185 #define FILE_WRITE_EA 0x00000010 /* Extended attributes associated */
186 /* with the file can be written */
187 #define FILE_EXECUTE 0x00000020 /*Data can be read into memory from */
188 /* the file using system paging I/O */
189 #define FILE_DELETE_CHILD 0x00000040
190 #define FILE_READ_ATTRIBUTES 0x00000080 /* Attributes associated with the */
191 /* file can be read */
192 #define FILE_WRITE_ATTRIBUTES 0x00000100 /* Attributes associated with the */
193 /* file can be written */
194 #define DELETE 0x00010000 /* The file can be deleted */
195 #define READ_CONTROL 0x00020000 /* The access control list and */
196 /* ownership associated with the */
197 /* file can be read */
198 #define WRITE_DAC 0x00040000 /* The access control list and */
199 /* ownership associated with the */
200 /* file can be written. */
201 #define WRITE_OWNER 0x00080000 /* Ownership information associated */
202 /* with the file can be written */
203 #define SYNCHRONIZE 0x00100000 /* The file handle can waited on to */
204 /* synchronize with the completion */
205 /* of an input/output request */
206 #define GENERIC_ALL 0x10000000
207 #define GENERIC_EXECUTE 0x20000000
208 #define GENERIC_WRITE 0x40000000
209 #define GENERIC_READ 0x80000000
210 /* In summary - Relevant file */
211 /* access flags from CIFS are */
212 /* file_read_data, file_write_data */
213 /* file_execute, file_read_attributes*/
214 /* write_dac, and delete. */
217 * Invalid readdir handle
219 #define CIFS_NO_HANDLE 0xFFFF
222 #define CIFS_IPC_RESOURCE "\x49\x50\x43\x24"
224 /* IPC$ in Unicode */
225 #define CIFS_IPC_UNICODE_RESOURCE "\x00\x49\x00\x50\x00\x43\x00\x24\x00\x00"
227 /* Unicode Null terminate 2 bytes of 0 */
228 #define UNICODE_NULL "\x00\x00"
229 #define ASCII_NULL 0x00
232 * Server type values (returned on EnumServer API
234 #define CIFS_SV_TYPE_DC 0x00000008
235 #define CIFS_SV_TYPE_BACKDC 0x00000010
238 * Alias type flags (From EnumAlias API call
240 #define CIFS_ALIAS_TYPE_FILE 0x0001
241 #define CIFS_SHARE_TYPE_FILE 0x0000
244 * File Attribute flags
246 #define ATTR_READONLY 0x0001
247 #define ATTR_HIDDEN 0x0002
248 #define ATTR_SYSTEM 0x0004
249 #define ATTR_VOLUME 0x0008
250 #define ATTR_DIRECTORY 0x0010
251 #define ATTR_ARCHIVE 0x0020
252 #define ATTR_DEVICE 0x0040
253 #define ATTR_NORMAL 0x0080
254 #define ATTR_TEMPORARY 0x0100
255 #define ATTR_SPARSE 0x0200
256 #define ATTR_REPARSE 0x0400
257 #define ATTR_COMPRESSED 0x0800
258 #define ATTR_OFFLINE 0x1000 /* ie file not immediately available -
259 on offline storage */
260 #define ATTR_NOT_CONTENT_INDEXED 0x2000
261 #define ATTR_ENCRYPTED 0x4000
262 #define ATTR_POSIX_SEMANTICS 0x01000000
263 #define ATTR_BACKUP_SEMANTICS 0x02000000
264 #define ATTR_DELETE_ON_CLOSE 0x04000000
265 #define ATTR_SEQUENTIAL_SCAN 0x08000000
266 #define ATTR_RANDOM_ACCESS 0x10000000
267 #define ATTR_NO_BUFFERING 0x20000000
268 #define ATTR_WRITE_THROUGH 0x80000000
270 /* ShareAccess flags */
271 #define FILE_NO_SHARE 0x00000000
272 #define FILE_SHARE_READ 0x00000001
273 #define FILE_SHARE_WRITE 0x00000002
274 #define FILE_SHARE_DELETE 0x00000004
275 #define FILE_SHARE_ALL 0x00000007
277 /* CreateDisposition flags */
278 #define FILE_SUPERSEDE 0x00000000
279 #define FILE_OPEN 0x00000001
280 #define FILE_CREATE 0x00000002
281 #define FILE_OPEN_IF 0x00000003
282 #define FILE_OVERWRITE 0x00000004
283 #define FILE_OVERWRITE_IF 0x00000005
286 #define CREATE_NOT_FILE 0x00000001 /* if set must not be file */
287 #define CREATE_WRITE_THROUGH 0x00000002
288 #define CREATE_SEQUENTIAL 0x00000004
289 #define CREATE_SYNC_ALERT 0x00000010
290 #define CREATE_ASYNC_ALERT 0x00000020
291 #define CREATE_NOT_DIR 0x00000040 /* if set must not be directory */
292 #define CREATE_NO_EA_KNOWLEDGE 0x00000200
293 #define CREATE_EIGHT_DOT_THREE 0x00000400
294 #define CREATE_RANDOM_ACCESS 0x00000800
295 #define CREATE_DELETE_ON_CLOSE 0x00001000
296 #define CREATE_OPEN_BY_ID 0x00002000
297 #define OPEN_REPARSE_POINT 0x00200000
298 #define CREATE_OPTIONS_MASK 0x007FFFFF
299 #define CREATE_OPTION_SPECIAL 0x20000000 /* system. NB not sent over wire */
301 /* ImpersonationLevel flags */
302 #define SECURITY_ANONYMOUS 0
303 #define SECURITY_IDENTIFICATION 1
304 #define SECURITY_IMPERSONATION 2
305 #define SECURITY_DELEGATION 3
308 #define SECURITY_CONTEXT_TRACKING 0x01
309 #define SECURITY_EFFECTIVE_ONLY 0x02
312 * Default PID value, used in all SMBs where the PID is not important
314 #define CIFS_DFT_PID 0x1234
317 * We use the same routine for Copy and Move SMBs. This flag is used to
320 #define CIFS_COPY_OP 1
321 #define CIFS_RENAME_OP 2
323 #define GETU16(var) (*((__u16 *)var)) /* BB check for endian issues */
324 #define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */
327 __u32 smb_buf_length
; /* big endian on wire *//* BB length is only two
328 or three bytes - with one or two byte type preceding it that are
329 zero - we could mask the type byte off just in case BB */
337 } __attribute__((packed
)) DosError
;
339 } __attribute__((packed
)) Status
;
341 __le16 Flags2
; /* note: le */
345 __le32 SequenceNumber
; /* le */
346 __u32 Reserved
; /* zero */
347 } __attribute__((packed
)) Sequence
;
348 __u8 SecuritySignature
[8]; /* le */
349 } __attribute__((packed
)) Signature
;
356 } __attribute__((packed
));
357 /* given a pointer to an smb_hdr retrieve the value of byte count */
358 #define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) ) )
359 #define BCC_LE(smb_var) ( *(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) ) )
360 /* given a pointer to an smb_hdr retrieve the pointer to the byte area */
361 #define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) + 2 )
364 * Computer Name Length
369 * Share Name Length @S8A
370 * Note: This length is limited by the SMB used to get @S8A
371 * the Share info. NetShareEnum only returns 13 @S8A
372 * chars, including the null termination. @S8A
374 #define SNLEN 12 /*@S8A */
379 #define MAXCOMMENTLEN 40
382 * The OS/2 maximum path name
384 #define MAX_PATHCONF 256
387 * SMB frame definitions (following must be packed structs)
388 * See the SNIA CIFS Specification for details.
390 * The Naming convention is the lower case version of the
391 * smb command code name for the struct and this is typedef to the
392 * uppercase version of the same name with the prefix SMB_ removed
393 * for brevity. Although typedefs are not commonly used for
394 * structure definitions in the Linux kernel, their use in the
395 * CIFS standards document, which this code is based on, may
396 * make this one of the cases where typedefs for structures make
397 * sense to improve readability for readers of the standards doc.
398 * Typedefs can always be removed later if they are too distracting
399 * and they are only used for the CIFSs PDUs themselves, not
400 * internal cifs vfs structures
404 typedef struct negotiate_req
{
405 struct smb_hdr hdr
; /* wct = 0 */
407 unsigned char DialectsArray
[1];
408 } __attribute__((packed
)) NEGOTIATE_REQ
;
410 /* Dialect index is 13 for LANMAN */
412 #define MIN_TZ_ADJ (15 * 60) /* minimum grid for timezones in seconds */
414 typedef struct lanman_neg_rsp
{
415 struct smb_hdr hdr
; /* wct = 13 */
426 } __attribute__((packed
)) SrvTime
;
427 __le16 ServerTimeZone
;
428 __le16 EncryptionKeyLength
;
431 unsigned char EncryptionKey
[1];
432 } __attribute__((packed
)) LANMAN_NEG_RSP
;
434 #define READ_RAW_ENABLE 1
435 #define WRITE_RAW_ENABLE 2
436 #define RAW_ENABLE (READ_RAW_ENABLE | WRITE_RAW_ENABLE)
438 typedef struct negotiate_rsp
{
439 struct smb_hdr hdr
; /* wct = 17 */
444 __le32 MaxBufferSize
;
447 __le32 Capabilities
; /* see below */
448 __le32 SystemTimeLow
;
449 __le32 SystemTimeHigh
;
450 __le16 ServerTimeZone
;
451 __u8 EncryptionKeyLength
;
454 unsigned char EncryptionKey
[1]; /* cap extended security off */
455 /* followed by Domain name - if extended security is off */
456 /* followed by 16 bytes of server GUID */
457 /* then security blob if cap_extended_security negotiated */
459 unsigned char GUID
[16];
460 unsigned char SecurityBlob
[1];
461 } __attribute__((packed
)) extended_response
;
462 } __attribute__((packed
)) u
;
463 } __attribute__((packed
)) NEGOTIATE_RSP
;
465 /* SecurityMode bits */
466 #define SECMODE_USER 0x01 /* off indicates share level security */
467 #define SECMODE_PW_ENCRYPT 0x02
468 #define SECMODE_SIGN_ENABLED 0x04 /* SMB security signatures enabled */
469 #define SECMODE_SIGN_REQUIRED 0x08 /* SMB security signatures required */
471 /* Negotiate response Capabilities */
472 #define CAP_RAW_MODE 0x00000001
473 #define CAP_MPX_MODE 0x00000002
474 #define CAP_UNICODE 0x00000004
475 #define CAP_LARGE_FILES 0x00000008
476 #define CAP_NT_SMBS 0x00000010 /* implies CAP_NT_FIND */
477 #define CAP_RPC_REMOTE_APIS 0x00000020
478 #define CAP_STATUS32 0x00000040
479 #define CAP_LEVEL_II_OPLOCKS 0x00000080
480 #define CAP_LOCK_AND_READ 0x00000100
481 #define CAP_NT_FIND 0x00000200
482 #define CAP_DFS 0x00001000
483 #define CAP_INFOLEVEL_PASSTHRU 0x00002000
484 #define CAP_LARGE_READ_X 0x00004000
485 #define CAP_LARGE_WRITE_X 0x00008000
486 #define CAP_UNIX 0x00800000
487 #define CAP_RESERVED 0x02000000
488 #define CAP_BULK_TRANSFER 0x20000000
489 #define CAP_COMPRESSED_DATA 0x40000000
490 #define CAP_EXTENDED_SECURITY 0x80000000
492 typedef union smb_com_session_setup_andx
{
493 struct { /* request format */
494 struct smb_hdr hdr
; /* wct = 12 */
498 __le16 MaxBufferSize
;
502 __le16 SecurityBlobLength
;
504 __le32 Capabilities
; /* see below */
506 unsigned char SecurityBlob
[1]; /* followed by */
507 /* STRING NativeOS */
508 /* STRING NativeLanMan */
509 } __attribute__((packed
)) req
; /* NTLM request format (with
512 struct { /* request format */
513 struct smb_hdr hdr
; /* wct = 13 */
517 __le16 MaxBufferSize
;
521 __le16 CaseInsensitivePasswordLength
; /* ASCII password len */
522 __le16 CaseSensitivePasswordLength
; /* Unicode password length*/
523 __u32 Reserved
; /* see below */
526 unsigned char CaseInsensitivePassword
[1]; /* followed by: */
527 /* unsigned char * CaseSensitivePassword; */
528 /* STRING AccountName */
529 /* STRING PrimaryDomain */
530 /* STRING NativeOS */
531 /* STRING NativeLanMan */
532 } __attribute__((packed
)) req_no_secext
; /* NTLM request format (without
535 struct { /* default (NTLM) response format */
536 struct smb_hdr hdr
; /* wct = 4 */
540 __le16 Action
; /* see below */
541 __le16 SecurityBlobLength
;
543 unsigned char SecurityBlob
[1]; /* followed by */
544 /* unsigned char * NativeOS; */
545 /* unsigned char * NativeLanMan; */
546 /* unsigned char * PrimaryDomain; */
547 } __attribute__((packed
)) resp
; /* NTLM response
548 (with or without extended sec) */
550 struct { /* request format */
551 struct smb_hdr hdr
; /* wct = 10 */
555 __le16 MaxBufferSize
;
559 __le16 PasswordLength
;
560 __u32 Reserved
; /* encrypt key len and offset */
562 unsigned char AccountPassword
[1]; /* followed by */
563 /* STRING AccountName */
564 /* STRING PrimaryDomain */
565 /* STRING NativeOS */
566 /* STRING NativeLanMan */
567 } __attribute__((packed
)) old_req
; /* pre-NTLM (LANMAN2.1) req format */
569 struct { /* default (NTLM) response format */
570 struct smb_hdr hdr
; /* wct = 3 */
574 __le16 Action
; /* see below */
576 unsigned char NativeOS
[1]; /* followed by */
577 /* unsigned char * NativeLanMan; */
578 /* unsigned char * PrimaryDomain; */
579 } __attribute__((packed
)) old_resp
; /* pre-NTLM (LANMAN2.1) response */
580 } __attribute__((packed
)) SESSION_SETUP_ANDX
;
582 /* format of NLTMv2 Response ie "case sensitive password" hash when NTLMv2 */
584 #define NTLMSSP_SERVER_TYPE 1
585 #define NTLMSSP_DOMAIN_TYPE 2
586 #define NTLMSSP_FQ_DOMAIN_TYPE 3
587 #define NTLMSSP_DNS_DOMAIN_TYPE 4
588 #define NTLMSSP_DNS_PARENT_TYPE 5
590 struct ntlmssp2_name
{
593 /* char name[length]; */
594 } __attribute__((packed
));
597 char ntlmv2_hash
[CIFS_ENCPWD_SIZE
];
598 __le32 blob_signature
;
601 __u64 client_chal
; /* random */
603 struct ntlmssp2_name names
[2];
604 /* array of name entries could follow ending in minimum 4 byte struct */
605 } __attribute__((packed
));
608 #define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux"
610 /* Capabilities bits (for NTLM SessSetup request) */
611 #define CAP_UNICODE 0x00000004
612 #define CAP_LARGE_FILES 0x00000008
613 #define CAP_NT_SMBS 0x00000010
614 #define CAP_STATUS32 0x00000040
615 #define CAP_LEVEL_II_OPLOCKS 0x00000080
616 #define CAP_NT_FIND 0x00000200 /* reserved should be zero
617 (because NT_SMBs implies the same thing?) */
618 #define CAP_BULK_TRANSFER 0x20000000
619 #define CAP_EXTENDED_SECURITY 0x80000000
622 #define GUEST_LOGIN 1
624 typedef struct smb_com_tconx_req
{
625 struct smb_hdr hdr
; /* wct = 4 */
629 __le16 Flags
; /* see below */
630 __le16 PasswordLength
;
632 unsigned char Password
[1]; /* followed by */
633 /* STRING Path *//* \\server\share name */
635 } __attribute__((packed
)) TCONX_REQ
;
637 typedef struct smb_com_tconx_rsp
{
638 struct smb_hdr hdr
; /* wct = 3 note that Win2000 has sent wct = 7
639 in some cases on responses. Four unspecified
640 words followed OptionalSupport */
644 __le16 OptionalSupport
; /* see below */
646 unsigned char Service
[1]; /* always ASCII, not Unicode */
647 /* STRING NativeFileSystem */
648 } __attribute__((packed
)) TCONX_RSP
;
650 /* tree connect Flags */
651 #define DISCONNECT_TID 0x0001
652 #define TCON_EXTENDED_SECINFO 0x0008
653 /* OptionalSupport bits */
654 #define SMB_SUPPORT_SEARCH_BITS 0x0001 /* "must have" directory search bits
655 (exclusive searches supported) */
656 #define SMB_SHARE_IS_IN_DFS 0x0002
658 typedef struct smb_com_logoff_andx_req
{
659 struct smb_hdr hdr
; /* wct = 2 */
664 } __attribute__((packed
)) LOGOFF_ANDX_REQ
;
666 typedef struct smb_com_logoff_andx_rsp
{
667 struct smb_hdr hdr
; /* wct = 2 */
672 } __attribute__((packed
)) LOGOFF_ANDX_RSP
;
674 typedef union smb_com_tree_disconnect
{ /* as an altetnative can use flag on
675 tree_connect PDU to effect disconnect */
676 /* tdis is probably simplest SMB PDU */
678 struct smb_hdr hdr
; /* wct = 0 */
679 __u16 ByteCount
; /* bcc = 0 */
680 } __attribute__((packed
)) req
;
682 struct smb_hdr hdr
; /* wct = 0 */
683 __u16 ByteCount
; /* bcc = 0 */
684 } __attribute__((packed
)) resp
;
685 } __attribute__((packed
)) TREE_DISCONNECT
;
687 typedef struct smb_com_close_req
{
688 struct smb_hdr hdr
; /* wct = 3 */
690 __u32 LastWriteTime
; /* should be zero or -1 */
691 __u16 ByteCount
; /* 0 */
692 } __attribute__((packed
)) CLOSE_REQ
;
694 typedef struct smb_com_close_rsp
{
695 struct smb_hdr hdr
; /* wct = 0 */
696 __u16 ByteCount
; /* bct = 0 */
697 } __attribute__((packed
)) CLOSE_RSP
;
699 typedef struct smb_com_findclose_req
{
700 struct smb_hdr hdr
; /* wct = 1 */
702 __u16 ByteCount
; /* 0 */
703 } __attribute__((packed
)) FINDCLOSE_REQ
;
706 #define REQ_MORE_INFO 0x00000001 /* legacy (OPEN_AND_X) only */
707 #define REQ_OPLOCK 0x00000002
708 #define REQ_BATCHOPLOCK 0x00000004
709 #define REQ_OPENDIRONLY 0x00000008
711 typedef struct smb_com_open_req
{ /* also handles create */
712 struct smb_hdr hdr
; /* wct = 24 */
716 __u8 Reserved
; /* Must Be Zero */
719 __le32 RootDirectoryFid
;
720 __le32 DesiredAccess
;
721 __le64 AllocationSize
;
722 __le32 FileAttributes
;
724 __le32 CreateDisposition
;
725 __le32 CreateOptions
;
726 __le32 ImpersonationLevel
;
730 } __attribute__((packed
)) OPEN_REQ
;
732 /* open response: oplock levels */
733 #define OPLOCK_NONE 0
734 #define OPLOCK_EXCLUSIVE 1
735 #define OPLOCK_BATCH 2
736 #define OPLOCK_READ 3 /* level 2 oplock */
738 /* open response for CreateAction shifted left */
739 #define CIFS_CREATE_ACTION 0x20000 /* file created */
741 typedef struct smb_com_open_rsp
{
742 struct smb_hdr hdr
; /* wct = 34 BB */
750 __le64 LastAccessTime
;
751 __le64 LastWriteTime
;
753 __le32 FileAttributes
;
754 __le64 AllocationSize
;
759 __u16 ByteCount
; /* bct = 0 */
760 } __attribute__((packed
)) OPEN_RSP
;
762 /* format of legacy open request */
763 typedef struct smb_com_openx_req
{
764 struct smb_hdr hdr
; /* wct = 15 */
770 __le16 Sattr
; /* search attributes */
771 __le16 FileAttributes
; /* dos attrs */
772 __le32 CreateTime
; /* os2 format */
777 __le16 ByteCount
; /* file name follows */
779 } __attribute__((packed
)) OPENX_REQ
;
781 typedef struct smb_com_openx_rsp
{
782 struct smb_hdr hdr
; /* wct = 15 */
787 __le16 FileAttributes
;
788 __le32 LastWriteTime
; /* os2 format */
797 } __attribute__((packed
)) OPENX_RSP
;
799 /* For encoding of POSIX Open Request - see trans2 function 0x209 data struct */
801 /* Legacy write request for older servers */
802 typedef struct smb_com_writex_req
{
803 struct smb_hdr hdr
; /* wct = 12 */
809 __u32 Reserved
; /* Timeout */
810 __le16 WriteMode
; /* 1 = write through */
813 __le16 DataLengthLow
;
816 __u8 Pad
; /* BB check for whether padded to DWORD boundary and optimum performance here */
818 } __attribute__((packed
)) WRITEX_REQ
;
820 typedef struct smb_com_write_req
{
821 struct smb_hdr hdr
; /* wct = 14 */
830 __le16 DataLengthHigh
;
831 __le16 DataLengthLow
;
835 __u8 Pad
; /* BB check for whether padded to DWORD boundary and optimum performance here */
837 } __attribute__((packed
)) WRITE_REQ
;
839 typedef struct smb_com_write_rsp
{
840 struct smb_hdr hdr
; /* wct = 6 */
849 } __attribute__((packed
)) WRITE_RSP
;
851 /* legacy read request for older servers */
852 typedef struct smb_com_readx_req
{
853 struct smb_hdr hdr
; /* wct = 10 */
860 __le16 MinCount
; /* obsolete */
864 } __attribute__((packed
)) READX_REQ
;
866 typedef struct smb_com_read_req
{
867 struct smb_hdr hdr
; /* wct = 12 */
874 __le16 MinCount
; /* obsolete */
879 } __attribute__((packed
)) READ_REQ
;
881 typedef struct smb_com_read_rsp
{
882 struct smb_hdr hdr
; /* wct = 12 */
887 __le16 DataCompactionMode
;
891 __le16 DataLengthHigh
;
894 __u8 Pad
; /* BB check for whether padded to DWORD boundary and optimum performance here */
896 } __attribute__((packed
)) READ_RSP
;
898 typedef struct locking_andx_range
{
905 } __attribute__((packed
)) LOCKING_ANDX_RANGE
;
907 #define LOCKING_ANDX_SHARED_LOCK 0x01
908 #define LOCKING_ANDX_OPLOCK_RELEASE 0x02
909 #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
910 #define LOCKING_ANDX_CANCEL_LOCK 0x08
911 #define LOCKING_ANDX_LARGE_FILES 0x10 /* always on for us */
913 typedef struct smb_com_lock_req
{
914 struct smb_hdr hdr
; /* wct = 8 */
922 __le16 NumberOfUnlocks
;
923 __le16 NumberOfLocks
;
925 LOCKING_ANDX_RANGE Locks
[1];
926 } __attribute__((packed
)) LOCK_REQ
;
932 typedef struct cifs_posix_lock
{
933 __le16 lock_type
; /* 0 = Read, 1 = Write, 2 = Unlock */
934 __le16 lock_flags
; /* 1 = Wait (only valid for setlock) */
938 /* BB what about additional owner info to identify network client */
939 } __attribute__((packed
)) CIFS_POSIX_LOCK
;
941 typedef struct smb_com_lock_rsp
{
942 struct smb_hdr hdr
; /* wct = 2 */
947 } __attribute__((packed
)) LOCK_RSP
;
949 typedef struct smb_com_rename_req
{
950 struct smb_hdr hdr
; /* wct = 1 */
951 __le16 SearchAttributes
; /* target file attributes */
953 __u8 BufferFormat
; /* 4 = ASCII or Unicode */
954 unsigned char OldFileName
[1];
955 /* followed by __u8 BufferFormat2 */
956 /* followed by NewFileName */
957 } __attribute__((packed
)) RENAME_REQ
;
959 /* copy request flags */
960 #define COPY_MUST_BE_FILE 0x0001
961 #define COPY_MUST_BE_DIR 0x0002
962 #define COPY_TARGET_MODE_ASCII 0x0004 /* if not set, binary */
963 #define COPY_SOURCE_MODE_ASCII 0x0008 /* if not set, binary */
964 #define COPY_VERIFY_WRITES 0x0010
965 #define COPY_TREE 0x0020
967 typedef struct smb_com_copy_req
{
968 struct smb_hdr hdr
; /* wct = 3 */
973 __u8 BufferFormat
; /* 4 = ASCII or Unicode */
974 unsigned char OldFileName
[1];
975 /* followed by __u8 BufferFormat2 */
976 /* followed by NewFileName string */
977 } __attribute__((packed
)) COPY_REQ
;
979 typedef struct smb_com_copy_rsp
{
980 struct smb_hdr hdr
; /* wct = 1 */
981 __le16 CopyCount
; /* number of files copied */
982 __u16 ByteCount
; /* may be zero */
983 __u8 BufferFormat
; /* 0x04 - only present if errored file follows */
984 unsigned char ErrorFileName
[1]; /* only present if error in copy */
985 } __attribute__((packed
)) COPY_RSP
;
987 #define CREATE_HARD_LINK 0x103
988 #define MOVEFILE_COPY_ALLOWED 0x0002
989 #define MOVEFILE_REPLACE_EXISTING 0x0001
991 typedef struct smb_com_nt_rename_req
{ /* A5 - also used for create hardlink */
992 struct smb_hdr hdr
; /* wct = 4 */
993 __le16 SearchAttributes
; /* target file attributes */
994 __le16 Flags
; /* spec says Information Level */
997 __u8 BufferFormat
; /* 4 = ASCII or Unicode */
998 unsigned char OldFileName
[1];
999 /* followed by __u8 BufferFormat2 */
1000 /* followed by NewFileName */
1001 } __attribute__((packed
)) NT_RENAME_REQ
;
1003 typedef struct smb_com_rename_rsp
{
1004 struct smb_hdr hdr
; /* wct = 0 */
1005 __u16 ByteCount
; /* bct = 0 */
1006 } __attribute__((packed
)) RENAME_RSP
;
1008 typedef struct smb_com_delete_file_req
{
1009 struct smb_hdr hdr
; /* wct = 1 */
1010 __le16 SearchAttributes
;
1012 __u8 BufferFormat
; /* 4 = ASCII */
1013 unsigned char fileName
[1];
1014 } __attribute__((packed
)) DELETE_FILE_REQ
;
1016 typedef struct smb_com_delete_file_rsp
{
1017 struct smb_hdr hdr
; /* wct = 0 */
1018 __u16 ByteCount
; /* bct = 0 */
1019 } __attribute__((packed
)) DELETE_FILE_RSP
;
1021 typedef struct smb_com_delete_directory_req
{
1022 struct smb_hdr hdr
; /* wct = 0 */
1024 __u8 BufferFormat
; /* 4 = ASCII */
1025 unsigned char DirName
[1];
1026 } __attribute__((packed
)) DELETE_DIRECTORY_REQ
;
1028 typedef struct smb_com_delete_directory_rsp
{
1029 struct smb_hdr hdr
; /* wct = 0 */
1030 __u16 ByteCount
; /* bct = 0 */
1031 } __attribute__((packed
)) DELETE_DIRECTORY_RSP
;
1033 typedef struct smb_com_create_directory_req
{
1034 struct smb_hdr hdr
; /* wct = 0 */
1036 __u8 BufferFormat
; /* 4 = ASCII */
1037 unsigned char DirName
[1];
1038 } __attribute__((packed
)) CREATE_DIRECTORY_REQ
;
1040 typedef struct smb_com_create_directory_rsp
{
1041 struct smb_hdr hdr
; /* wct = 0 */
1042 __u16 ByteCount
; /* bct = 0 */
1043 } __attribute__((packed
)) CREATE_DIRECTORY_RSP
;
1045 typedef struct smb_com_query_information_req
{
1046 struct smb_hdr hdr
; /* wct = 0 */
1047 __le16 ByteCount
; /* 1 + namelen + 1 */
1048 __u8 BufferFormat
; /* 4 = ASCII */
1049 unsigned char FileName
[1];
1050 } __attribute__((packed
)) QUERY_INFORMATION_REQ
;
1052 typedef struct smb_com_query_information_rsp
{
1053 struct smb_hdr hdr
; /* wct = 10 */
1055 __le32 last_write_time
;
1058 __le16 ByteCount
; /* bcc = 0 */
1059 } __attribute__((packed
)) QUERY_INFORMATION_RSP
;
1061 typedef struct smb_com_setattr_req
{
1062 struct smb_hdr hdr
; /* wct = 8 */
1066 __le16 reserved
[5]; /* must be zero */
1068 __u8 BufferFormat
; /* 4 = ASCII */
1069 unsigned char fileName
[1];
1070 } __attribute__((packed
)) SETATTR_REQ
;
1072 typedef struct smb_com_setattr_rsp
{
1073 struct smb_hdr hdr
; /* wct = 0 */
1074 __u16 ByteCount
; /* bct = 0 */
1075 } __attribute__((packed
)) SETATTR_RSP
;
1077 /* empty wct response to setattr */
1079 /*******************************************************/
1080 /* NT Transact structure defintions follow */
1081 /* Currently only ioctl, acl (get security descriptor) */
1082 /* and notify are implemented */
1083 /*******************************************************/
1084 typedef struct smb_com_ntransact_req
{
1085 struct smb_hdr hdr
; /* wct >= 19 */
1088 __le32 TotalParameterCount
;
1089 __le32 TotalDataCount
;
1090 __le32 MaxParameterCount
;
1091 __le32 MaxDataCount
;
1092 __le32 ParameterCount
;
1093 __le32 ParameterOffset
;
1096 __u8 SetupCount
; /* four setup words follow subcommand */
1097 /* SNIA spec incorrectly included spurious pad here */
1098 __le16 SubCommand
; /* 2 = IOCTL/FSCTL */
1099 /* SetupCount words follow then */
1103 } __attribute__((packed
)) NTRANSACT_REQ
;
1105 typedef struct smb_com_ntransact_rsp
{
1106 struct smb_hdr hdr
; /* wct = 18 */
1108 __le32 TotalParameterCount
;
1109 __le32 TotalDataCount
;
1110 __le32 ParameterCount
;
1111 __le32 ParameterOffset
;
1112 __le32 ParameterDisplacement
;
1115 __le32 DataDisplacement
;
1116 __u8 SetupCount
; /* 0 */
1119 /* parms and data follow */
1120 } __attribute__((packed
)) NTRANSACT_RSP
;
1122 typedef struct smb_com_transaction_ioctl_req
{
1123 struct smb_hdr hdr
; /* wct = 23 */
1126 __le32 TotalParameterCount
;
1127 __le32 TotalDataCount
;
1128 __le32 MaxParameterCount
;
1129 __le32 MaxDataCount
;
1130 __le32 ParameterCount
;
1131 __le32 ParameterOffset
;
1134 __u8 SetupCount
; /* four setup words follow subcommand */
1135 /* SNIA spec incorrectly included spurious pad here */
1136 __le16 SubCommand
; /* 2 = IOCTL/FSCTL */
1137 __le32 FunctionCode
;
1139 __u8 IsFsctl
; /* 1 = File System Control 0 = device control (IOCTL) */
1140 __u8 IsRootFlag
; /* 1 = apply command to root of share (must be DFS) */
1144 } __attribute__((packed
)) TRANSACT_IOCTL_REQ
;
1146 typedef struct smb_com_transaction_ioctl_rsp
{
1147 struct smb_hdr hdr
; /* wct = 19 */
1149 __le32 TotalParameterCount
;
1150 __le32 TotalDataCount
;
1151 __le32 ParameterCount
;
1152 __le32 ParameterOffset
;
1153 __le32 ParameterDisplacement
;
1156 __le32 DataDisplacement
;
1157 __u8 SetupCount
; /* 1 */
1158 __le16 ReturnedDataLen
;
1160 } __attribute__((packed
)) TRANSACT_IOCTL_RSP
;
1162 #define CIFS_ACL_OWNER 1
1163 #define CIFS_ACL_GROUP 2
1164 #define CIFS_ACL_DACL 4
1165 #define CIFS_ACL_SACL 8
1167 typedef struct smb_com_transaction_qsec_req
{
1168 struct smb_hdr hdr
; /* wct = 19 */
1171 __le32 TotalParameterCount
;
1172 __le32 TotalDataCount
;
1173 __le32 MaxParameterCount
;
1174 __le32 MaxDataCount
;
1175 __le32 ParameterCount
;
1176 __le32 ParameterOffset
;
1179 __u8 SetupCount
; /* no setup words follow subcommand */
1180 /* SNIA spec incorrectly included spurious pad here */
1181 __le16 SubCommand
; /* 6 = QUERY_SECURITY_DESC */
1182 __le16 ByteCount
; /* bcc = 3 + 8 */
1187 } __attribute__((packed
)) QUERY_SEC_DESC_REQ
;
1189 typedef struct smb_com_transaction_change_notify_req
{
1190 struct smb_hdr hdr
; /* wct = 23 */
1193 __le32 TotalParameterCount
;
1194 __le32 TotalDataCount
;
1195 __le32 MaxParameterCount
;
1196 __le32 MaxDataCount
;
1197 __le32 ParameterCount
;
1198 __le32 ParameterOffset
;
1201 __u8 SetupCount
; /* four setup words follow subcommand */
1202 /* SNIA spec incorrectly included spurious pad here */
1203 __le16 SubCommand
;/* 4 = Change Notify */
1204 __le32 CompletionFilter
; /* operation to monitor */
1206 __u8 WatchTree
; /* 1 = Monitor subdirectories */
1211 } __attribute__((packed
)) TRANSACT_CHANGE_NOTIFY_REQ
;
1213 /* BB eventually change to use generic ntransact rsp struct
1214 and validation routine */
1215 typedef struct smb_com_transaction_change_notify_rsp
{
1216 struct smb_hdr hdr
; /* wct = 18 */
1218 __le32 TotalParameterCount
;
1219 __le32 TotalDataCount
;
1220 __le32 ParameterCount
;
1221 __le32 ParameterOffset
;
1222 __le32 ParameterDisplacement
;
1225 __le32 DataDisplacement
;
1226 __u8 SetupCount
; /* 0 */
1229 } __attribute__((packed
)) TRANSACT_CHANGE_NOTIFY_RSP
;
1230 /* Completion Filter flags for Notify */
1231 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
1232 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
1233 #define FILE_NOTIFY_CHANGE_NAME 0x00000003
1234 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
1235 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
1236 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
1237 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
1238 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
1239 #define FILE_NOTIFY_CHANGE_EA 0x00000080
1240 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
1241 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
1242 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
1243 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1245 #define FILE_ACTION_ADDED 0x00000001
1246 #define FILE_ACTION_REMOVED 0x00000002
1247 #define FILE_ACTION_MODIFIED 0x00000003
1248 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
1249 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
1250 #define FILE_ACTION_ADDED_STREAM 0x00000006
1251 #define FILE_ACTION_REMOVED_STREAM 0x00000007
1252 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
1254 /* response contains array of the following structures */
1255 struct file_notify_information
{
1256 __le32 NextEntryOffset
;
1258 __le32 FileNameLength
;
1260 } __attribute__((packed
));
1262 struct reparse_data
{
1264 __u16 ReparseDataLength
;
1266 __u16 AltNameOffset
;
1268 __u16 TargetNameOffset
;
1269 __u16 TargetNameLen
;
1270 char LinkNamesBuf
[1];
1271 } __attribute__((packed
));
1273 struct cifs_quota_data
{
1274 __u32 rsrvd1
; /* 0 */
1276 __u64 rsrvd2
; /* 0 */
1280 char sid
[1]; /* variable size? */
1281 } __attribute__((packed
));
1283 /* quota sub commands */
1284 #define QUOTA_LIST_CONTINUE 0
1285 #define QUOTA_LIST_START 0x100
1286 #define QUOTA_FOR_SID 0x101
1289 /* struct smb_hdr hdr precedes. Set wct = 14+ */
1290 __le16 TotalParameterCount
;
1291 __le16 TotalDataCount
;
1292 __le16 MaxParameterCount
;
1293 __le16 MaxDataCount
;
1299 __le16 ParameterCount
;
1300 __le16 ParameterOffset
;
1305 __le16 SubCommand
; /* 1st setup word - SetupCount words follow */
1307 } __attribute__((packed
));
1311 struct trans2_req t2_req
;
1312 } __attribute__((packed
));
1314 struct trans2_resp
{
1315 /* struct smb_hdr hdr precedes. Note wct = 10 + setup count */
1316 __le16 TotalParameterCount
;
1317 __le16 TotalDataCount
;
1319 __le16 ParameterCount
;
1320 __le16 ParameterOffset
;
1321 __le16 ParameterDisplacement
;
1324 __le16 DataDisplacement
;
1327 /* SetupWords[SetupCount];
1330 /* data area follows */
1331 } __attribute__((packed
));
1335 struct trans2_resp t2_rsp
;
1336 } __attribute__((packed
));
1338 /* PathInfo/FileInfo infolevels */
1339 #define SMB_INFO_STANDARD 1
1340 #define SMB_SET_FILE_EA 2
1341 #define SMB_QUERY_FILE_EA_SIZE 2
1342 #define SMB_INFO_QUERY_EAS_FROM_LIST 3
1343 #define SMB_INFO_QUERY_ALL_EAS 4
1344 #define SMB_INFO_IS_NAME_VALID 6
1345 #define SMB_QUERY_FILE_BASIC_INFO 0x101
1346 #define SMB_QUERY_FILE_STANDARD_INFO 0x102
1347 #define SMB_QUERY_FILE_EA_INFO 0x103
1348 #define SMB_QUERY_FILE_NAME_INFO 0x104
1349 #define SMB_QUERY_FILE_ALLOCATION_INFO 0x105
1350 #define SMB_QUERY_FILE_END_OF_FILEINFO 0x106
1351 #define SMB_QUERY_FILE_ALL_INFO 0x107
1352 #define SMB_QUERY_ALT_NAME_INFO 0x108
1353 #define SMB_QUERY_FILE_STREAM_INFO 0x109
1354 #define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
1355 #define SMB_QUERY_FILE_UNIX_BASIC 0x200
1356 #define SMB_QUERY_FILE_UNIX_LINK 0x201
1357 #define SMB_QUERY_POSIX_ACL 0x204
1358 #define SMB_QUERY_XATTR 0x205 /* e.g. system EA name space */
1359 #define SMB_QUERY_ATTR_FLAGS 0x206 /* append,immutable etc. */
1360 #define SMB_QUERY_POSIX_PERMISSION 0x207
1361 #define SMB_QUERY_POSIX_LOCK 0x208
1362 /* #define SMB_POSIX_OPEN 0x209 */
1363 /* #define SMB_POSIX_UNLINK 0x20a */
1364 #define SMB_QUERY_FILE__UNIX_INFO2 0x20b
1365 #define SMB_QUERY_FILE_INTERNAL_INFO 0x3ee
1366 #define SMB_QUERY_FILE_ACCESS_INFO 0x3f0
1367 #define SMB_QUERY_FILE_NAME_INFO2 0x3f1 /* 0x30 bytes */
1368 #define SMB_QUERY_FILE_POSITION_INFO 0x3f6
1369 #define SMB_QUERY_FILE_MODE_INFO 0x3f8
1370 #define SMB_QUERY_FILE_ALGN_INFO 0x3f9
1373 #define SMB_SET_FILE_BASIC_INFO 0x101
1374 #define SMB_SET_FILE_DISPOSITION_INFO 0x102
1375 #define SMB_SET_FILE_ALLOCATION_INFO 0x103
1376 #define SMB_SET_FILE_END_OF_FILE_INFO 0x104
1377 #define SMB_SET_FILE_UNIX_BASIC 0x200
1378 #define SMB_SET_FILE_UNIX_LINK 0x201
1379 #define SMB_SET_FILE_UNIX_HLINK 0x203
1380 #define SMB_SET_POSIX_ACL 0x204
1381 #define SMB_SET_XATTR 0x205
1382 #define SMB_SET_ATTR_FLAGS 0x206 /* append, immutable etc. */
1383 #define SMB_SET_POSIX_LOCK 0x208
1384 #define SMB_POSIX_OPEN 0x209
1385 #define SMB_POSIX_UNLINK 0x20a
1386 #define SMB_SET_FILE_UNIX_INFO2
1387 #define SMB_SET_FILE_BASIC_INFO2 0x3ec
1388 #define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo too */
1389 #define SMB_FILE_ALL_INFO2 0x3fa
1390 #define SMB_SET_FILE_ALLOCATION_INFO2 0x3fb
1391 #define SMB_SET_FILE_END_OF_FILE_INFO2 0x3fc
1392 #define SMB_FILE_MOVE_CLUSTER_INFO 0x407
1393 #define SMB_FILE_QUOTA_INFO 0x408
1394 #define SMB_FILE_REPARSEPOINT_INFO 0x409
1395 #define SMB_FILE_MAXIMUM_INFO 0x40d
1397 /* Find File infolevels */
1398 #define SMB_FIND_FILE_INFO_STANDARD 0x001
1399 #define SMB_FIND_FILE_QUERY_EA_SIZE 0x002
1400 #define SMB_FIND_FILE_QUERY_EAS_FROM_LIST 0x003
1401 #define SMB_FIND_FILE_DIRECTORY_INFO 0x101
1402 #define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
1403 #define SMB_FIND_FILE_NAMES_INFO 0x103
1404 #define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
1405 #define SMB_FIND_FILE_ID_FULL_DIR_INFO 0x105
1406 #define SMB_FIND_FILE_ID_BOTH_DIR_INFO 0x106
1407 #define SMB_FIND_FILE_UNIX 0x202
1409 typedef struct smb_com_transaction2_qpi_req
{
1410 struct smb_hdr hdr
; /* wct = 14+ */
1411 __le16 TotalParameterCount
;
1412 __le16 TotalDataCount
;
1413 __le16 MaxParameterCount
;
1414 __le16 MaxDataCount
;
1420 __le16 ParameterCount
;
1421 __le16 ParameterOffset
;
1426 __le16 SubCommand
; /* one setup word */
1429 __le16 InformationLevel
;
1432 } __attribute__((packed
)) TRANSACTION2_QPI_REQ
;
1434 typedef struct smb_com_transaction2_qpi_rsp
{
1435 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1436 struct trans2_resp t2
;
1438 __u16 Reserved2
; /* parameter word is present for infolevels > 100 */
1439 } __attribute__((packed
)) TRANSACTION2_QPI_RSP
;
1441 typedef struct smb_com_transaction2_spi_req
{
1442 struct smb_hdr hdr
; /* wct = 15 */
1443 __le16 TotalParameterCount
;
1444 __le16 TotalDataCount
;
1445 __le16 MaxParameterCount
;
1446 __le16 MaxDataCount
;
1452 __le16 ParameterCount
;
1453 __le16 ParameterOffset
;
1458 __le16 SubCommand
; /* one setup word */
1462 __le16 InformationLevel
;
1465 } __attribute__((packed
)) TRANSACTION2_SPI_REQ
;
1467 typedef struct smb_com_transaction2_spi_rsp
{
1468 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1469 struct trans2_resp t2
;
1471 __u16 Reserved2
; /* parameter word is present for infolevels > 100 */
1472 } __attribute__((packed
)) TRANSACTION2_SPI_RSP
;
1474 struct set_file_rename
{
1475 __le32 overwrite
; /* 1 = overwrite dest */
1476 __u32 root_fid
; /* zero */
1477 __le32 target_name_len
;
1478 char target_name
[0]; /* Must be unicode */
1479 } __attribute__((packed
));
1481 struct smb_com_transaction2_sfi_req
{
1482 struct smb_hdr hdr
; /* wct = 15 */
1483 __le16 TotalParameterCount
;
1484 __le16 TotalDataCount
;
1485 __le16 MaxParameterCount
;
1486 __le16 MaxDataCount
;
1492 __le16 ParameterCount
;
1493 __le16 ParameterOffset
;
1498 __le16 SubCommand
; /* one setup word */
1503 __le16 InformationLevel
;
1505 } __attribute__((packed
));
1507 struct smb_com_transaction2_sfi_rsp
{
1508 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1509 struct trans2_resp t2
;
1511 __u16 Reserved2
; /* parameter word reserved -
1512 present for infolevels > 100 */
1513 } __attribute__((packed
));
1515 struct smb_t2_qfi_req
{
1517 struct trans2_req t2
;
1520 __le16 InformationLevel
;
1521 } __attribute__((packed
));
1523 struct smb_t2_qfi_rsp
{
1524 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1525 struct trans2_resp t2
;
1527 __u16 Reserved2
; /* parameter word reserved -
1528 present for infolevels > 100 */
1529 } __attribute__((packed
));
1532 * Flags on T2 FINDFIRST and FINDNEXT
1534 #define CIFS_SEARCH_CLOSE_ALWAYS 0x0001
1535 #define CIFS_SEARCH_CLOSE_AT_END 0x0002
1536 #define CIFS_SEARCH_RETURN_RESUME 0x0004
1537 #define CIFS_SEARCH_CONTINUE_FROM_LAST 0x0008
1538 #define CIFS_SEARCH_BACKUP_SEARCH 0x0010
1541 * Size of the resume key on FINDFIRST and FINDNEXT calls
1543 #define CIFS_SMB_RESUME_KEY_SIZE 4
1545 typedef struct smb_com_transaction2_ffirst_req
{
1546 struct smb_hdr hdr
; /* wct = 15 */
1547 __le16 TotalParameterCount
;
1548 __le16 TotalDataCount
;
1549 __le16 MaxParameterCount
;
1550 __le16 MaxDataCount
;
1556 __le16 ParameterCount
;
1557 __le16 ParameterOffset
;
1560 __u8 SetupCount
; /* one */
1562 __le16 SubCommand
; /* TRANS2_FIND_FIRST */
1565 __le16 SearchAttributes
;
1568 __le16 InformationLevel
;
1569 __le32 SearchStorageType
;
1571 } __attribute__((packed
)) TRANSACTION2_FFIRST_REQ
;
1573 typedef struct smb_com_transaction2_ffirst_rsp
{
1574 struct smb_hdr hdr
; /* wct = 10 */
1575 struct trans2_resp t2
;
1577 } __attribute__((packed
)) TRANSACTION2_FFIRST_RSP
;
1579 typedef struct smb_com_transaction2_ffirst_rsp_parms
{
1583 __le16 EAErrorOffset
;
1584 __le16 LastNameOffset
;
1585 } __attribute__((packed
)) T2_FFIRST_RSP_PARMS
;
1587 typedef struct smb_com_transaction2_fnext_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_NEXT */
1609 __le16 InformationLevel
;
1612 char ResumeFileName
[1];
1613 } __attribute__((packed
)) TRANSACTION2_FNEXT_REQ
;
1615 typedef struct smb_com_transaction2_fnext_rsp
{
1616 struct smb_hdr hdr
; /* wct = 10 */
1617 struct trans2_resp t2
;
1619 } __attribute__((packed
)) TRANSACTION2_FNEXT_RSP
;
1621 typedef struct smb_com_transaction2_fnext_rsp_parms
{
1624 __le16 EAErrorOffset
;
1625 __le16 LastNameOffset
;
1626 } __attribute__((packed
)) T2_FNEXT_RSP_PARMS
;
1628 /* QFSInfo Levels */
1629 #define SMB_INFO_ALLOCATION 1
1630 #define SMB_INFO_VOLUME 2
1631 #define SMB_QUERY_FS_VOLUME_INFO 0x102
1632 #define SMB_QUERY_FS_SIZE_INFO 0x103
1633 #define SMB_QUERY_FS_DEVICE_INFO 0x104
1634 #define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
1635 #define SMB_QUERY_CIFS_UNIX_INFO 0x200
1636 #define SMB_QUERY_POSIX_FS_INFO 0x201
1637 #define SMB_QUERY_POSIX_WHO_AM_I 0x202
1638 #define SMB_QUERY_LABEL_INFO 0x3ea
1639 #define SMB_QUERY_FS_QUOTA_INFO 0x3ee
1640 #define SMB_QUERY_FS_FULL_SIZE_INFO 0x3ef
1641 #define SMB_QUERY_OBJECTID_INFO 0x3f0
1643 typedef struct smb_com_transaction2_qfsi_req
{
1644 struct smb_hdr hdr
; /* wct = 14+ */
1645 __le16 TotalParameterCount
;
1646 __le16 TotalDataCount
;
1647 __le16 MaxParameterCount
;
1648 __le16 MaxDataCount
;
1654 __le16 ParameterCount
;
1655 __le16 ParameterOffset
;
1660 __le16 SubCommand
; /* one setup word */
1663 __le16 InformationLevel
;
1664 } __attribute__((packed
)) TRANSACTION2_QFSI_REQ
;
1666 typedef struct smb_com_transaction_qfsi_rsp
{
1667 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1668 struct trans2_resp t2
;
1670 __u8 Pad
; /* may be three bytes? *//* followed by data area */
1671 } __attribute__((packed
)) TRANSACTION2_QFSI_RSP
;
1673 typedef struct whoami_rsp_data
{ /* Query level 0x202 */
1674 __u32 flags
; /* 0 = Authenticated user 1 = GUEST */
1675 __u32 mask
; /* which flags bits server understands ie 0x0001 */
1677 __u64 unix_user_gid
;
1678 __u32 number_of_supplementary_gids
; /* may be zero */
1679 __u32 number_of_sids
; /* may be zero */
1680 __u32 length_of_sid_array
; /* in bytes - may be zero */
1681 __u32 pad
; /* reserved - MBZ */
1682 /* __u64 gid_array[0]; */ /* may be empty */
1683 /* __u8 * psid_list */ /* may be empty */
1684 } __attribute__((packed
)) WHOAMI_RSP_DATA
;
1686 /* SETFSInfo Levels */
1687 #define SMB_SET_CIFS_UNIX_INFO 0x200
1688 typedef struct smb_com_transaction2_setfsi_req
{
1689 struct smb_hdr hdr
; /* wct = 15 */
1690 __le16 TotalParameterCount
;
1691 __le16 TotalDataCount
;
1692 __le16 MaxParameterCount
;
1693 __le16 MaxDataCount
;
1699 __le16 ParameterCount
; /* 4 */
1700 __le16 ParameterOffset
;
1701 __le16 DataCount
; /* 12 */
1703 __u8 SetupCount
; /* one */
1705 __le16 SubCommand
; /* TRANS2_SET_FS_INFORMATION */
1708 __u16 FileNum
; /* Parameters start. */
1709 __le16 InformationLevel
;/* Parameters end. */
1710 __le16 ClientUnixMajor
; /* Data start. */
1711 __le16 ClientUnixMinor
;
1712 __le64 ClientUnixCap
; /* Data end */
1713 } __attribute__((packed
)) TRANSACTION2_SETFSI_REQ
;
1715 typedef struct smb_com_transaction2_setfsi_rsp
{
1716 struct smb_hdr hdr
; /* wct = 10 */
1717 struct trans2_resp t2
;
1719 } __attribute__((packed
)) TRANSACTION2_SETFSI_RSP
;
1722 typedef struct smb_com_transaction2_get_dfs_refer_req
{
1723 struct smb_hdr hdr
; /* wct = 15 */
1724 __le16 TotalParameterCount
;
1725 __le16 TotalDataCount
;
1726 __le16 MaxParameterCount
;
1727 __le16 MaxDataCount
;
1733 __le16 ParameterCount
;
1734 __le16 ParameterOffset
;
1739 __le16 SubCommand
; /* one setup word */
1741 __u8 Pad
[3]; /* Win2K has sent 0x0F01 (max resp length perhaps?) followed by one byte pad - doesn't seem to matter though */
1742 __le16 MaxReferralLevel
;
1743 char RequestFileName
[1];
1744 } __attribute__((packed
)) TRANSACTION2_GET_DFS_REFER_REQ
;
1746 typedef struct dfs_referral_level_3
{
1747 __le16 VersionNumber
;
1748 __le16 ReferralSize
;
1749 __le16 ServerType
; /* 0x0001 = CIFS server */
1750 __le16 ReferralFlags
; /* or proximity - not clear which since always set to zero - SNIA spec says 0x01 means strip off PathConsumed chars before submitting RequestFileName to remote node */
1753 __le16 DfsPathOffset
;
1754 __le16 DfsAlternatePathOffset
;
1755 __le16 NetworkAddressOffset
;
1756 } __attribute__((packed
)) REFERRAL3
;
1758 typedef struct smb_com_transaction_get_dfs_refer_rsp
{
1759 struct smb_hdr hdr
; /* wct = 10 */
1760 struct trans2_resp t2
;
1763 __le16 PathConsumed
;
1764 __le16 NumberOfReferrals
;
1767 REFERRAL3 referrals
[1]; /* array of level 3 dfs_referral structures */
1768 /* followed by the strings pointed to by the referral structures */
1769 } __attribute__((packed
)) TRANSACTION2_GET_DFS_REFER_RSP
;
1772 #define DFSREF_REFERRAL_SERVER 0x0001
1773 #define DFSREF_STORAGE_SERVER 0x0002
1775 /* IOCTL information */
1776 /* List of ioctl function codes that look to be of interest to remote clients like this. */
1777 /* Need to do some experimentation to make sure they all work remotely. */
1778 /* Some of the following such as the encryption/compression ones would be */
1779 /* invoked from tools via a specialized hook into the VFS rather than via the */
1780 /* standard vfs entry points */
1781 #define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000
1782 #define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004
1783 #define FSCTL_REQUEST_BATCH_OPLOCK 0x00090008
1784 #define FSCTL_LOCK_VOLUME 0x00090018
1785 #define FSCTL_UNLOCK_VOLUME 0x0009001C
1786 #define FSCTL_GET_COMPRESSION 0x0009003C
1787 #define FSCTL_SET_COMPRESSION 0x0009C040
1788 #define FSCTL_REQUEST_FILTER_OPLOCK 0x0009008C
1789 #define FSCTL_FILESYS_GET_STATISTICS 0x00090090
1790 #define FSCTL_SET_REPARSE_POINT 0x000900A4
1791 #define FSCTL_GET_REPARSE_POINT 0x000900A8
1792 #define FSCTL_DELETE_REPARSE_POINT 0x000900AC
1793 #define FSCTL_SET_SPARSE 0x000900C4
1794 #define FSCTL_SET_ZERO_DATA 0x000900C8
1795 #define FSCTL_SET_ENCRYPTION 0x000900D7
1796 #define FSCTL_ENCRYPTION_FSCTL_IO 0x000900DB
1797 #define FSCTL_WRITE_RAW_ENCRYPTED 0x000900DF
1798 #define FSCTL_READ_RAW_ENCRYPTED 0x000900E3
1799 #define FSCTL_SIS_COPYFILE 0x00090100
1800 #define FSCTL_SIS_LINK_FILES 0x0009C104
1802 #define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003
1803 #define IO_REPARSE_TAG_HSM 0xC0000004
1804 #define IO_REPARSE_TAG_SIS 0x80000007
1807 ************************************************************************
1808 * All structs for everything above the SMB PDUs themselves
1809 * (such as the T2 level specific data) go here
1810 ************************************************************************
1814 * Information on a server
1819 unsigned char versionMajor
;
1820 unsigned char versionMinor
;
1822 unsigned int commentOffset
;
1823 } __attribute__((packed
));
1826 * The following structure is the format of the data returned on a NetShareEnum
1827 * with level "90" (x5A)
1833 unsigned short type
;
1834 unsigned int commentOffset
;
1835 } __attribute__((packed
));
1840 unsigned int commentOffset
;
1841 unsigned char type
[2];
1842 } __attribute__((packed
));
1844 struct aliasInfo92
{
1845 int aliasNameOffset
;
1846 int serverNameOffset
;
1847 int shareNameOffset
;
1848 } __attribute__((packed
));
1851 __le64 TotalAllocationUnits
;
1852 __le64 FreeAllocationUnits
;
1853 __le32 SectorsPerAllocationUnit
;
1854 __le32 BytesPerSector
;
1855 } __attribute__((packed
)) FILE_SYSTEM_INFO
; /* size info, level 0x103 */
1859 __le32 SectorsPerAllocationUnit
;
1860 __le32 TotalAllocationUnits
;
1861 __le32 FreeAllocationUnits
;
1862 __le16 BytesPerSector
;
1863 } __attribute__((packed
)) FILE_SYSTEM_ALLOC_INFO
;
1866 __le16 MajorVersionNumber
;
1867 __le16 MinorVersionNumber
;
1869 } __attribute__((packed
)) FILE_SYSTEM_UNIX_INFO
; /* Unix extensions info, level 0x200 */
1871 /* Version numbers for CIFS UNIX major and minor. */
1872 #define CIFS_UNIX_MAJOR_VERSION 1
1873 #define CIFS_UNIX_MINOR_VERSION 0
1875 /* Linux/Unix extensions capability flags */
1876 #define CIFS_UNIX_FCNTL_CAP 0x00000001 /* support for fcntl locks */
1877 #define CIFS_UNIX_POSIX_ACL_CAP 0x00000002 /* support getfacl/setfacl */
1878 #define CIFS_UNIX_XATTR_CAP 0x00000004 /* support new namespace */
1879 #define CIFS_UNIX_EXTATTR_CAP 0x00000008 /* support chattr/chflag */
1880 #define CIFS_UNIX_POSIX_PATHNAMES_CAP 0x00000010 /* Allow POSIX path chars */
1881 #define CIFS_UNIX_POSIX_PATH_OPS_CAP 0x00000020 /* Allow new POSIX path based
1882 calls including posix open
1884 #ifdef CONFIG_CIFS_POSIX
1885 #define CIFS_UNIX_CAP_MASK 0x0000003b
1887 #define CIFS_UNIX_CAP_MASK 0x00000013
1888 #endif /* CONFIG_CIFS_POSIX */
1891 #define CIFS_POSIX_EXTENSIONS 0x00000010 /* support for new QFSInfo */
1894 /* For undefined recommended transfer size return -1 in that field */
1895 __le32 OptimalTransferSize
; /* bsize on some os, iosize on other os */
1897 /* The next three fields are in terms of the block size.
1898 (above). If block size is unknown, 4096 would be a
1899 reasonable block size for a server to report.
1900 Note that returning the blocks/blocksavail removes need
1901 to make a second call (to QFSInfo level 0x103 to get this info.
1902 UserBlockAvail is typically less than or equal to BlocksAvail,
1903 if no distinction is made return the same value in each */
1905 __le64 BlocksAvail
; /* bfree */
1906 __le64 UserBlocksAvail
; /* bavail */
1907 /* For undefined Node fields or FSID return -1 */
1908 __le64 TotalFileNodes
;
1909 __le64 FreeFileNodes
;
1910 __le64 FileSysIdentifier
; /* fsid */
1911 /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
1912 /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */
1913 } __attribute__((packed
)) FILE_SYSTEM_POSIX_INFO
;
1915 /* DeviceType Flags */
1916 #define FILE_DEVICE_CD_ROM 0x00000002
1917 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
1918 #define FILE_DEVICE_DFS 0x00000006
1919 #define FILE_DEVICE_DISK 0x00000007
1920 #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
1921 #define FILE_DEVICE_FILE_SYSTEM 0x00000009
1922 #define FILE_DEVICE_NAMED_PIPE 0x00000011
1923 #define FILE_DEVICE_NETWORK 0x00000012
1924 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
1925 #define FILE_DEVICE_NULL 0x00000015
1926 #define FILE_DEVICE_PARALLEL_PORT 0x00000016
1927 #define FILE_DEVICE_PRINTER 0x00000018
1928 #define FILE_DEVICE_SERIAL_PORT 0x0000001b
1929 #define FILE_DEVICE_STREAMS 0x0000001e
1930 #define FILE_DEVICE_TAPE 0x0000001f
1931 #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
1932 #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
1933 #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
1937 __le32 DeviceCharacteristics
;
1938 } __attribute__((packed
)) FILE_SYSTEM_DEVICE_INFO
; /* device info level 0x104 */
1942 __le32 MaxPathNameComponentLength
;
1943 __le32 FileSystemNameLen
;
1944 char FileSystemName
[52]; /* do not have to save this - get subset? */
1945 } __attribute__((packed
)) FILE_SYSTEM_ATTRIBUTE_INFO
;
1947 /******************************************************************************/
1948 /* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
1949 /******************************************************************************/
1950 typedef struct { /* data block encoding of response to level 263 QPathInfo */
1951 __le64 CreationTime
;
1952 __le64 LastAccessTime
;
1953 __le64 LastWriteTime
;
1957 __le64 AllocationSize
;
1958 __le64 EndOfFile
; /* size ie offset to first free byte in file */
1959 __le32 NumberOfLinks
; /* hard links */
1967 __le64 CurrentByteOffset
;
1969 __le32 AlignmentRequirement
;
1970 __le32 FileNameLength
;
1972 } __attribute__((packed
)) FILE_ALL_INFO
; /* level 0x107 QPathInfo */
1974 /* defines for enumerating possible values of the Unix type field below */
1977 #define UNIX_SYMLINK 2
1978 #define UNIX_CHARDEV 3
1979 #define UNIX_BLOCKDEV 4
1981 #define UNIX_SOCKET 6
1985 __le64 LastStatusChange
; /*SNIA specs DCE time for the 3 time fields */
1986 __le64 LastAccessTime
;
1987 __le64 LastModificationTime
;
1996 } __attribute__((packed
)) FILE_UNIX_BASIC_INFO
; /* level 0x200 QPathInfo */
2000 } __attribute__((packed
)) FILE_UNIX_LINK_INFO
; /* level 0x201 QPathInfo */
2002 /* The following three structures are needed only for
2003 setting time to NT4 and some older servers via
2004 the primitive DOS time format */
2009 } __attribute__((packed
)) SMB_DATE
;
2015 } __attribute__((packed
)) SMB_TIME
;
2018 __le16 CreationDate
; /* SMB Date see above */
2019 __le16 CreationTime
; /* SMB Time */
2020 __le16 LastAccessDate
;
2021 __le16 LastAccessTime
;
2022 __le16 LastWriteDate
;
2023 __le16 LastWriteTime
;
2024 __le32 DataSize
; /* File Size (EOF) */
2025 __le32 AllocationSize
;
2026 __le16 Attributes
; /* verify not u32 */
2028 } __attribute__((packed
)) FILE_INFO_STANDARD
; /* level 1 SetPath/FileInfo */
2031 __le64 CreationTime
;
2032 __le64 LastAccessTime
;
2033 __le64 LastWriteTime
;
2037 } __attribute__((packed
)) FILE_BASIC_INFO
; /* size info, level 0x101 */
2039 struct file_allocation_info
{
2040 __le64 AllocationSize
; /* Note old Samba srvr rounds this up too much */
2041 } __attribute__((packed
)); /* size used on disk, for level 0x103 for set,
2044 struct file_end_of_file_info
{
2045 __le64 FileSize
; /* offset to end of file */
2046 } __attribute__((packed
)); /* size info, level 0x104 for set, 0x106 for query */
2048 struct file_alt_name_info
{
2050 } __attribute__((packed
)); /* level 0x0108 */
2052 struct file_stream_info
{
2053 __le32 number_of_streams
; /* BB check sizes and verify location */
2054 /* followed by info on streams themselves
2058 }; /* level 0x109 */
2060 struct file_compression_info
{
2061 __le64 compressed_size
;
2067 } __attribute__((packed
)); /* level 0x10b */
2069 /* POSIX ACL set/query path info structures */
2070 #define CIFS_ACL_VERSION 1
2071 struct cifs_posix_ace
{ /* access control entry (ACE) */
2074 __le64 cifs_uid
; /* or gid */
2075 } __attribute__((packed
));
2077 struct cifs_posix_acl
{ /* access conrol list (ACL) */
2079 __le16 access_entry_count
; /* access ACL - count of entries */
2080 __le16 default_entry_count
; /* default ACL - count of entries */
2081 struct cifs_posix_ace ace_array
[0];
2083 struct cifs_posix_ace default_ace_arraay[] */
2084 } __attribute__((packed
)); /* level 0x204 */
2086 /* types of access control entries already defined in posix_acl.h */
2087 /* #define CIFS_POSIX_ACL_USER_OBJ 0x01
2088 #define CIFS_POSIX_ACL_USER 0x02
2089 #define CIFS_POSIX_ACL_GROUP_OBJ 0x04
2090 #define CIFS_POSIX_ACL_GROUP 0x08
2091 #define CIFS_POSIX_ACL_MASK 0x10
2092 #define CIFS_POSIX_ACL_OTHER 0x20 */
2094 /* types of perms */
2095 /* #define CIFS_POSIX_ACL_EXECUTE 0x01
2096 #define CIFS_POSIX_ACL_WRITE 0x02
2097 #define CIFS_POSIX_ACL_READ 0x04 */
2099 /* end of POSIX ACL definitions */
2102 __u32 OpenFlags
; /* same as NT CreateX */
2103 __u32 PosixOpenFlags
;
2105 __u16 Level
; /* reply level requested (see QPathInfo levels) */
2106 __u16 Pad
; /* reserved - MBZ */
2107 } __attribute__((packed
)) OPEN_PSX_REQ
; /* level 0x209 SetPathInfo data */
2110 /* reply varies based on requested level */
2111 } __attribute__((packed
)) OPEN_PSX_RSP
; /* level 0x209 SetPathInfo data */
2114 struct file_internal_info
{
2115 __u64 UniqueId
; /* inode number */
2116 } __attribute__((packed
)); /* level 0x3ee */
2117 struct file_mode_info
{
2119 } __attribute__((packed
)); /* level 0x3f8 */
2121 struct file_attrib_tag
{
2124 } __attribute__((packed
)); /* level 0x40b */
2127 /********************************************************/
2128 /* FindFirst/FindNext transact2 data buffer formats */
2129 /********************************************************/
2132 __le32 NextEntryOffset
;
2133 __u32 ResumeKey
; /* as with FileIndex - no need to convert */
2136 __le64 LastStatusChange
; /*SNIA specs DCE time for the 3 time fields */
2137 __le64 LastAccessTime
;
2138 __le64 LastModificationTime
;
2148 } __attribute__((packed
)) FILE_UNIX_INFO
; /* level 0x202 */
2151 __le32 NextEntryOffset
;
2153 __le64 CreationTime
;
2154 __le64 LastAccessTime
;
2155 __le64 LastWriteTime
;
2158 __le64 AllocationSize
;
2159 __le32 ExtFileAttributes
;
2160 __le32 FileNameLength
;
2162 } __attribute__((packed
)) FILE_DIRECTORY_INFO
; /* level 0x101 FF resp data */
2165 __le32 NextEntryOffset
;
2167 __le64 CreationTime
;
2168 __le64 LastAccessTime
;
2169 __le64 LastWriteTime
;
2172 __le64 AllocationSize
;
2173 __le32 ExtFileAttributes
;
2174 __le32 FileNameLength
;
2175 __le32 EaSize
; /* length of the xattrs */
2177 } __attribute__((packed
)) FILE_FULL_DIRECTORY_INFO
; /* level 0x102 rsp data */
2180 __le32 NextEntryOffset
;
2182 __le64 CreationTime
;
2183 __le64 LastAccessTime
;
2184 __le64 LastWriteTime
;
2187 __le64 AllocationSize
;
2188 __le32 ExtFileAttributes
;
2189 __le32 FileNameLength
;
2190 __le32 EaSize
; /* EA size */
2192 __u64 UniqueId
; /* inode num - le since Samba puts ino in low 32 bit*/
2194 } __attribute__((packed
)) SEARCH_ID_FULL_DIR_INFO
; /* level 0x105 FF rsp data */
2197 __le32 NextEntryOffset
;
2199 __le64 CreationTime
;
2200 __le64 LastAccessTime
;
2201 __le64 LastWriteTime
;
2204 __le64 AllocationSize
;
2205 __le32 ExtFileAttributes
;
2206 __le32 FileNameLength
;
2207 __le32 EaSize
; /* length of the xattrs */
2208 __u8 ShortNameLength
;
2212 } __attribute__((packed
)) FILE_BOTH_DIRECTORY_INFO
; /* level 0x104 FFrsp data */
2216 __le16 CreationDate
; /* SMB Date */
2217 __le16 CreationTime
; /* SMB Time */
2218 __le16 LastAccessDate
;
2219 __le16 LastAccessTime
;
2220 __le16 LastWriteDate
;
2221 __le16 LastWriteTime
;
2222 __le32 DataSize
; /* File Size (EOF) */
2223 __le32 AllocationSize
;
2224 __le16 Attributes
; /* verify not u32 */
2225 __u8 FileNameLength
;
2227 } __attribute__((packed
)) FIND_FILE_STANDARD_INFO
; /* level 0x1 FF resp data */
2231 unsigned char type
[8]; /* IntxCHR or IntxBLK */
2234 } __attribute__((packed
));
2237 unsigned char name_len
;
2239 } __attribute__((packed
));
2242 unsigned long list_len
;
2244 } __attribute__((packed
));
2247 unsigned char EA_flags
;
2251 /* optionally followed by value */
2252 } __attribute__((packed
));
2253 /* flags for _FEA.fEA */
2254 #define FEA_NEEDEA 0x80 /* need EA bit */
2259 } __attribute__((packed
));
2261 /* used to hold an arbitrary blob of data */
2265 void (*free
) (struct data_blob
* data_blob
);
2266 } __attribute__((packed
));
2269 #ifdef CONFIG_CIFS_POSIX
2271 For better POSIX semantics from Linux client, (even better
2272 than the existing CIFS Unix Extensions) we need updated PDUs for:
2274 1) PosixCreateX - to set and return the mode, inode#, device info and
2275 perhaps add a CreateDevice - to create Pipes and other special .inodes
2276 Also note POSIX open flags
2277 2) Close - to return the last write time to do cache across close
2279 3) FindFirst return unique inode number - what about resume key, two
2280 forms short (matches readdir) and full (enough info to cache inodes)
2283 And under consideration:
2284 5) FindClose2 (return nanosecond timestamp ??)
2285 6) Use nanosecond timestamps throughout all time fields if
2286 corresponding attribute flag is set
2287 7) sendfile - handle based copy
2291 what about fixing 64 bit alignment
2293 There are also various legacy SMB/CIFS requests used as is
2295 From existing Lanman and NTLM dialects:
2296 --------------------------------------
2298 SESSION_SETUP_ANDX (BB which?)
2299 TREE_CONNECT_ANDX (BB which wct?)
2300 TREE_DISCONNECT (BB add volume timestamp on response)
2302 DELETE (note delete open file behavior)
2306 LOCKING_AND_X (note posix lock semantics)
2307 RENAME (note rename across dirs and open file rename posix behaviors)
2308 NT_RENAME (for hardlinks) Is this good enough for all features?
2310 TRANSACTION2 (18 cases)
2311 SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2
2312 (BB verify that never need to set allocation size)
2313 SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via
2316 COPY (note support for copy across directories) - FUTURE, OPTIONAL
2317 setting/getting OS/2 EAs - FUTURE (BB can this handle
2318 setting Linux xattrs perfectly) - OPTIONAL
2319 dnotify - FUTURE, OPTIONAL
2320 quota - FUTURE, OPTIONAL
2322 Note that various requests implemented for NT interop such as
2323 NT_TRANSACT (IOCTL) QueryReparseInfo
2324 are unneeded to servers compliant with the CIFS POSIX extensions
2326 From CIFS Unix Extensions:
2327 -------------------------
2328 T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks
2329 T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2)
2330 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK)
2331 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC) - BB check for missing inode fields
2332 Actually need QUERY_FILE_UNIX_INFO since has inode num
2333 BB what about a) blksize/blkbits/blocks
2339 T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX
2340 TRANS2_GET_DFS_REFERRAL - OPTIONAL but recommended
2341 T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL
2346 /* xsymlink is a symlink format (used by MacOS) that can be used
2347 to save symlink info in a regular file when
2348 mounted to operating systems that do not
2349 support the cifs Unix extensions or EAs (for xattr
2350 based symlinks). For such a file to be recognized
2351 as containing symlink data:
2353 1) file size must be 1067,
2354 2) signature must begin file data,
2355 3) length field must be set to ASCII representation
2356 of a number which is less than or equal to 1024,
2357 4) md5 must match that of the path data */
2361 char signature
[4]; /* XSym */ /* not null terminated */
2363 /* ASCII representation of length (4 bytes decimal) terminated by \n not null */
2366 /* md5 of valid subset of path ie path[0] through path[length-1] */
2369 /* if room left, then end with \n then 0x20s by convention but not required */
2371 } __attribute__((packed
));
2373 typedef struct file_xattr_info
{
2374 /* BB do we need another field for flags? BB */
2375 __u32 xattr_name_len
;
2376 __u32 xattr_value_len
;
2378 /* followed by xattr_value[xattr_value_len], no pad */
2379 } __attribute__((packed
)) FILE_XATTR_INFO
; /* extended attribute, info level 0x205 */
2382 /* flags for chattr command */
2383 #define EXT_SECURE_DELETE 0x00000001 /* EXT3_SECRM_FL */
2384 #define EXT_ENABLE_UNDELETE 0x00000002 /* EXT3_UNRM_FL */
2385 /* Reserved for compress file 0x4 */
2386 #define EXT_SYNCHRONOUS 0x00000008 /* EXT3_SYNC_FL */
2387 #define EXT_IMMUTABLE_FL 0x00000010 /* EXT3_IMMUTABLE_FL */
2388 #define EXT_OPEN_APPEND_ONLY 0x00000020 /* EXT3_APPEND_FL */
2389 #define EXT_DO_NOT_BACKUP 0x00000040 /* EXT3_NODUMP_FL */
2390 #define EXT_NO_UPDATE_ATIME 0x00000080 /* EXT3_NOATIME_FL */
2391 /* 0x100 through 0x800 reserved for compression flags and are GET-ONLY */
2392 #define EXT_HASH_TREE_INDEXED_DIR 0x00001000 /* GET-ONLY EXT3_INDEX_FL */
2393 /* 0x2000 reserved for IMAGIC_FL */
2394 #define EXT_JOURNAL_THIS_FILE 0x00004000 /* GET-ONLY EXT3_JOURNAL_DATA_FL */
2395 /* 0x8000 reserved for EXT3_NOTAIL_FL */
2396 #define EXT_SYNCHRONOUS_DIR 0x00010000 /* EXT3_DIRSYNC_FL */
2397 #define EXT_TOPDIR 0x00020000 /* EXT3_TOPDIR_FL */
2399 #define EXT_SET_MASK 0x000300FF
2400 #define EXT_GET_MASK 0x0003DFFF
2402 typedef struct file_chattr_info
{
2403 __le64 mask
; /* list of all possible attribute bits */
2404 __le64 mode
; /* list of actual attribute bits on this inode */
2405 } __attribute__((packed
)) FILE_CHATTR_INFO
; /* ext attributes (chattr, chflags) level 0x206 */
2409 #endif /* _CIFSPDU_H */