4 * Copyright (c) International Business Machines Corp., 2002
5 * Author(s): Steve French (sfrench@us.ibm.com)
7 * This library is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15 * the GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #define BAD_PROT CIFS_PROT+1
30 /* SMB command codes */
31 #define SMB_COM_CREATE_DIRECTORY 0x00
32 #define SMB_COM_DELETE_DIRECTORY 0x01
33 #define SMB_COM_CLOSE 0x04
34 #define SMB_COM_DELETE 0x06
35 #define SMB_COM_RENAME 0x07
36 #define SMB_COM_LOCKING_ANDX 0x24
37 #define SMB_COM_COPY 0x29
38 #define SMB_COM_READ_ANDX 0x2E
39 #define SMB_COM_WRITE_ANDX 0x2F
40 #define SMB_COM_TRANSACTION2 0x32
41 #define SMB_COM_TRANSACTION2_SECONDARY 0x33
42 #define SMB_COM_FIND_CLOSE2 0x34
43 #define SMB_COM_TREE_DISCONNECT 0x71
44 #define SMB_COM_NEGOTIATE 0x72
45 #define SMB_COM_SESSION_SETUP_ANDX 0x73
46 #define SMB_COM_LOGOFF_ANDX 0x74
47 #define SMB_COM_TREE_CONNECT_ANDX 0x75
48 #define SMB_COM_NT_TRANSACT 0xA0
49 #define SMB_COM_NT_TRANSACT_SECONDARY 0xA1
50 #define SMB_COM_NT_CREATE_ANDX 0xA2
51 #define SMB_COM_NT_RENAME 0xA5
53 /* Transact2 subcommand codes */
54 #define TRANS2_OPEN 0x00
55 #define TRANS2_FIND_FIRST 0x01
56 #define TRANS2_FIND_NEXT 0x02
57 #define TRANS2_QUERY_FS_INFORMATION 0x03
58 #define TRANS2_QUERY_PATH_INFORMATION 0x05
59 #define TRANS2_SET_PATH_INFORMATION 0x06
60 #define TRANS2_QUERY_FILE_INFORMATION 0x07
61 #define TRANS2_SET_FILE_INFORMATION 0x08
62 #define TRANS2_GET_DFS_REFERRAL 0x10
63 #define TRANS2_REPORT_DFS_INCOSISTENCY 0x11
65 /* NT Transact subcommand codes */
66 #define NT_TRANSACT_CREATE 0x01
67 #define NT_TRANSACT_IOCTL 0x02
68 #define NT_TRANSACT_SET_SECURITY_DESC 0x03
69 #define NT_TRANSACT_NOTIFY_CHANGE 0x04
70 #define NT_TRANSACT_RENAME 0x05
71 #define NT_TRANSACT_QUERY_SECURITY_DESC 0x06
72 #define NT_TRANSACT_GET_USER_QUOTA 0x07
73 #define NT_TRANSACT_SET_USER_QUOTA 0x08
75 #define MAX_CIFS_HDR_SIZE 256 /* chained NTCreateXReadX will probably be biggest */
77 /* internal cifs vfs structures */
78 /*****************************************************************
79 * All constants go here
80 *****************************************************************
84 * Starting value for maximum SMB size negotiation
86 #define CIFS_MAX_MSGSIZE (4*4096)
89 * Size of encrypted user password in bytes
91 #define CIFS_ENCPWD_SIZE (16)
94 * Size of the crypto key returned on the negotiate SMB in bytes
96 #define CIFS_CRYPTO_KEY_SIZE (8)
99 * Size of the session key (crypto key encrypted with the password
101 #define CIFS_SESSION_KEY_SIZE (24)
104 * Maximum user name length
106 #define CIFS_UNLEN (20)
111 #define SMBOPEN_WRITE_THROUGH 0x4000
112 #define SMBOPEN_DENY_ALL 0x0010
113 #define SMBOPEN_DENY_WRITE 0x0020
114 #define SMBOPEN_DENY_READ 0x0030
115 #define SMBOPEN_DENY_NONE 0x0040
116 #define SMBOPEN_READ 0x0000
117 #define SMBOPEN_WRITE 0x0001
118 #define SMBOPEN_READWRITE 0x0002
119 #define SMBOPEN_EXECUTE 0x0003
121 #define SMBOPEN_OCREATE 0x0010
122 #define SMBOPEN_OTRUNC 0x0002
123 #define SMBOPEN_OAPPEND 0x0001
126 * SMB flag definitions
128 #define SMBFLG_EXTD_LOCK 0x01 /* server supports lock-read write-unlock primitives */
129 #define SMBFLG_RCV_POSTED 0x02 /* obsolete */
130 #define SMBFLG_RSVD 0x04
131 #define SMBFLG_CASELESS 0x08 /* all pathnames treated as caseless (off implies case sensitive file handling requested) */
132 #define SMBFLG_CANONICAL_PATH_FORMAT 0x10 /* obsolete */
133 #define SMBFLG_OLD_OPLOCK 0x20 /* obsolete */
134 #define SMBFLG_OLD_OPLOCK_NOTIFY 0x40 /* obsolete */
135 #define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */
138 * SMB flag2 definitions
140 #define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1) /* can send long (non-8.3) path names in response */
141 #define SMBFLG2_KNOWS_EAS cpu_to_le16(2)
142 #define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4)
143 #define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40)
144 #define SMBFLG2_EXT_SEC cpu_to_le16(0x80)
145 #define SMBFLG2_DFS cpu_to_le16(0x1000)
146 #define SMBFLG2_PAGING_IO cpu_to_le16(0x2000)
147 #define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)
148 #define SMBFLG2_UNICODE cpu_to_le16(0x8000)
151 * These are the file access permission bits defined in CIFS for the
152 * NTCreateAndX as well as the level 0x107
153 * TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO
154 * responds with the AccessFlags.
155 * The AccessFlags specifies the access permissions a caller has to the
156 * file and can have any suitable combination of the following values:
159 #define FILE_READ_DATA 0x00000001 /* Data can be read from the file */
160 #define FILE_WRITE_DATA 0x00000002 /* Data can be written to the file */
161 #define FILE_APPEND_DATA 0x00000004 /* Data can be appended to the file */
162 #define FILE_READ_EA 0x00000008 /* Extended attributes associated */
163 /* with the file can be read */
164 #define FILE_WRITE_EA 0x00000010 /* Extended attributes associated */
165 /* with the file can be written */
166 #define FILE_EXECUTE 0x00000020 /*Data can be read into memory from */
167 /* the file using system paging I/O */
168 #define FILE_DELETE_CHILD 0x00000040
169 #define FILE_READ_ATTRIBUTES 0x00000080 /* Attributes associated with the */
170 /* file can be read */
171 #define FILE_WRITE_ATTRIBUTES 0x00000100 /* Attributes associated with the */
172 /* file can be written */
173 #define DELETE 0x00010000 /* The file can be deleted */
174 #define READ_CONTROL 0x00020000 /* The access control list and */
175 /* ownership associated with the */
176 /* file can be read */
177 #define WRITE_DAC 0x00040000 /* The access control list and */
178 /* ownership associated with the */
179 /* file can be written. */
180 #define WRITE_OWNER 0x00080000 /* Ownership information associated */
181 /* with the file can be written */
182 #define SYNCHRONIZE 0x00100000 /* The file handle can waited on to */
183 /* synchronize with the completion */
184 /* of an input/output request */
185 #define GENERIC_ALL 0x10000000
186 #define GENERIC_EXECUTE 0x20000000
187 #define GENERIC_WRITE 0x40000000
188 #define GENERIC_READ 0x80000000
189 /* In summary - Relevant file */
190 /* access flags from CIFS are */
191 /* file_read_data, file_write_data */
192 /* file_execute, file_read_attributes */
193 /* write_dac, and delete. */
196 * Invalid readdir handle
198 #define CIFS_NO_HANDLE 0xFFFF
201 #define CIFS_IPC_RESOURCE "\x49\x50\x43\x24"
203 /* IPC$ in Unicode */
204 #define CIFS_IPC_UNICODE_RESOURCE "\x00\x49\x00\x50\x00\x43\x00\x24\x00\x00"
206 /* Unicode Null terminate 2 bytes of 0 */
207 #define UNICODE_NULL "\x00\x00"
208 #define ASCII_NULL 0x00
211 * Server type values (returned on EnumServer API
213 #define CIFS_SV_TYPE_DC 0x00000008
214 #define CIFS_SV_TYPE_BACKDC 0x00000010
217 * Alias type flags (From EnumAlias API call
219 #define CIFS_ALIAS_TYPE_FILE 0x0001
220 #define CIFS_SHARE_TYPE_FILE 0x0000
223 * File Attribute flags
225 #define ATTR_READONLY 0x0001
226 #define ATTR_HIDDEN 0x0002
227 #define ATTR_SYSTEM 0x0004
228 #define ATTR_VOLUME 0x0008
229 #define ATTR_DIRECTORY 0x0010
230 #define ATTR_ARCHIVE 0x0020
231 #define ATTR_DEVICE 0x0040
232 #define ATTR_NORMAL 0x0080
233 #define ATTR_TEMPORARY 0x0100
234 #define ATTR_SPARSE 0x0200
235 #define ATTR_REPARSE 0x0400
236 #define ATTR_COMPRESSED 0x0800
237 #define ATTR_OFFLINE 0x1000 /* ie file not immediately available - offline storage */
238 #define ATTR_NOT_CONTENT_INDEXED 0x2000
239 #define ATTR_ENCRYPTED 0x4000
240 #define ATTR_POSIX_SEMANTICS 0x01000000
241 #define ATTR_BACKUP_SEMANTICS 0x02000000
242 #define ATTR_DELETE_ON_CLOSE 0x04000000
243 #define ATTR_SEQUENTIAL_SCAN 0x08000000
244 #define ATTR_RANDOM_ACCESS 0x10000000
245 #define ATTR_NO_BUFFERING 0x20000000
246 #define ATTR_WRITE_THROUGH 0x80000000
248 /* ShareAccess flags */
249 #define FILE_NO_SHARE 0x00000000
250 #define FILE_SHARE_READ 0x00000001
251 #define FILE_SHARE_WRITE 0x00000002
252 #define FILE_SHARE_DELETE 0x00000004
253 #define FILE_SHARE_ALL 0x00000007
255 /* CreateDisposition flags */
256 #define FILE_SUPERSEDE 0x00000000
257 #define FILE_OPEN 0x00000001
258 #define FILE_CREATE 0x00000002
259 #define FILE_OPEN_IF 0x00000003
260 #define FILE_OVERWRITE 0x00000004
261 #define FILE_OVERWRITE_IF 0x00000005
264 #define CREATE_NOT_FILE 0x00000001 /* if set must not be file */
265 #define CREATE_WRITE_THROUGH 0x00000002
266 #define CREATE_NOT_DIR 0x00000040 /* if set must not be directory */
267 #define CREATE_RANDOM_ACCESS 0x00000800
268 #define CREATE_DELETE_ON_CLOSE 0x00001000
269 #define OPEN_REPARSE_POINT 0x00200000
271 /* ImpersonationLevel flags */
272 #define SECURITY_ANONYMOUS 0
273 #define SECURITY_IDENTIFICATION 1
274 #define SECURITY_IMPERSONATION 2
275 #define SECURITY_DELEGATION 3
278 #define SECURITY_CONTEXT_TRACKING 0x01
279 #define SECURITY_EFFECTIVE_ONLY 0x02
282 * Default PID value, used in all SMBs where the PID is not important
284 #define CIFS_DFT_PID 0x1234
287 * We use the same routine for Copy and Move SMBs. This flag is used to
290 #define CIFS_COPY_OP 1
291 #define CIFS_RENAME_OP 2
293 #define GETU16(var) (*((__u16 *)var)) /* BB check for endian issues */
294 #define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */
299 __u32 smb_buf_length
; /* big endian on wire *//* BB length is only two or three bytes - with one or two byte type preceding it but that is always zero - we could mask the type byte off just in case BB */
311 __le16 Flags2
; /* note: le */
315 __le32 SequenceNumber
; /* le */
316 __u32 Reserved
; /* zero */
318 __u8 SecuritySignature
[8]; /* le */
327 /* given a pointer to an smb_hdr retrieve the value of byte count */
328 #define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) ) )
330 /* given a pointer to an smb_hdr retrieve the pointer to the byte area */
331 #define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2* smb_var->WordCount) + 2 )
334 * Computer Name Length
339 * Share Name Length @S8A
340 * Note: This length is limited by the SMB used to get @S8A
341 * the Share info. NetShareEnum only returns 13 @S8A
342 * chars, including the null termination. @S8A
344 #define SNLEN 12 /*@S8A */
349 #define MAXCOMMENTLEN 40
352 * The OS/2 maximum path name
354 #define MAX_PATHCONF 256
357 * SMB frame definitions (following must be packed structs)
358 * See the SNIA CIFS Specification for details.
360 * The Naming convention is the lower case version of the
361 * smb command code name for the struct and this is typedef to the
362 * uppercase version of the same name with the prefix SMB_ removed
363 * for brevity. Although typedefs are not commonly used for
364 * structure definitions in the Linux kernel, their use in the
365 * CIFS standards document, which this code is based on, may
366 * make this one of the cases where typedefs for structures make
367 * sense to improve readability for readers of the standards doc.
368 * Typedefs can always be removed later if they are too distracting
369 * and they are only used for the CIFSs PDUs themselves, not
370 * internal cifs vfs structures
374 typedef struct negotiate_req
{
375 struct smb_hdr hdr
; /* wct = 0 */
377 unsigned char DialectsArray
[1];
380 typedef struct negotiate_rsp
{
381 struct smb_hdr hdr
; /* wct = 17 */
386 __le32 MaxBufferSize
;
389 __le32 Capabilities
; /* see below */
390 __le32 SystemTimeLow
;
391 __le32 SystemTimeHigh
;
392 __le16 ServerTimeZone
;
393 __u8 EncryptionKeyLength
;
396 unsigned char EncryptionKey
[1]; /* if cap extended security is off */
397 /* followed by Domain name - if extended security is off */
398 /* followed by 16 bytes of server GUID */
399 /* followed by security blob if cap_extended_security negotiated */
401 unsigned char GUID
[16];
402 unsigned char SecurityBlob
[1];
407 /* SecurityMode bits */
408 #define SECMODE_USER 0x01 /* off indicates share level security */
409 #define SECMODE_PW_ENCRYPT 0x02
410 #define SECMODE_SIGN_ENABLED 0x04 /* SMB security signatures enabled */
411 #define SECMODE_SIGN_REQUIRED 0x08 /* SMB security signatures required */
413 /* Negotiate response Capabilities */
414 #define CAP_RAW_MODE 0x00000001
415 #define CAP_MPX_MODE 0x00000002
416 #define CAP_UNICODE 0x00000004
417 #define CAP_LARGE_FILES 0x00000008
418 #define CAP_NT_SMBS 0x00000010 /* implies CAP_NT_FIND */
419 #define CAP_RPC_REMOTE_APIS 0x00000020
420 #define CAP_STATUS32 0x00000040
421 #define CAP_LEVEL_II_OPLOCKS 0x00000080
422 #define CAP_LOCK_AND_READ 0x00000100
423 #define CAP_NT_FIND 0x00000200
424 #define CAP_DFS 0x00001000
425 #define CAP_INFOLEVEL_PASSTHRU 0x00002000
426 #define CAP_LARGE_READ_X 0x00004000
427 #define CAP_LARGE_WRITE_X 0x00008000
428 #define CAP_UNIX 0x00800000
429 #define CAP_RESERVED 0x02000000
430 #define CAP_BULK_TRANSFER 0x20000000
431 #define CAP_COMPRESSED_DATA 0x40000000
432 #define CAP_EXTENDED_SECURITY 0x80000000
434 typedef union smb_com_session_setup_andx
{
435 struct { /* request format */
436 struct smb_hdr hdr
; /* wct = 12 */
440 __le16 MaxBufferSize
;
444 __le16 SecurityBlobLength
;
446 __le32 Capabilities
; /* see below */
448 unsigned char SecurityBlob
[1]; /* followed by */
449 /* STRING NativeOS */
450 /* STRING NativeLanMan */
451 } req
; /* NTLM request format (with extended security */
453 struct { /* request format */
454 struct smb_hdr hdr
; /* wct = 13 */
458 __le16 MaxBufferSize
;
462 __le16 CaseInsensitivePasswordLength
; /* ASCII password length */
463 __le16 CaseSensitivePasswordLength
; /* Unicode password length */
464 __u32 Reserved
; /* see below */
467 unsigned char CaseInsensitivePassword
[1]; /* followed by: */
468 /* unsigned char * CaseSensitivePassword; */
469 /* STRING AccountName */
470 /* STRING PrimaryDomain */
471 /* STRING NativeOS */
472 /* STRING NativeLanMan */
473 } req_no_secext
; /* NTLM request format (without extended security */
475 struct { /* default (NTLM) response format */
476 struct smb_hdr hdr
; /* wct = 4 */
480 __le16 Action
; /* see below */
481 __le16 SecurityBlobLength
;
483 unsigned char SecurityBlob
[1]; /* followed by */
484 /* unsigned char * NativeOS; */
485 /* unsigned char * NativeLanMan; */
486 /* unsigned char * PrimaryDomain; */
487 } resp
; /* NTLM response format (with or without extended security */
489 struct { /* request format */
490 struct smb_hdr hdr
; /* wct = 10 */
494 __le16 MaxBufferSize
;
498 __le16 PassswordLength
;
501 unsigned char AccountPassword
[1]; /* followed by */
502 /* STRING AccountName */
503 /* STRING PrimaryDomain */
504 /* STRING NativeOS */
505 /* STRING NativeLanMan */
506 } old_req
; /* pre-NTLM (LANMAN2.1) request format */
508 struct { /* default (NTLM) response format */
509 struct smb_hdr hdr
; /* wct = 3 */
513 __le16 Action
; /* see below */
515 unsigned char NativeOS
[1]; /* followed by */
516 /* unsigned char * NativeLanMan; */
517 /* unsigned char * PrimaryDomain; */
518 } old_resp
; /* pre-NTLM (LANMAN2.1) response format */
519 } SESSION_SETUP_ANDX
;
521 #define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux"
523 /* Capabilities bits (for NTLM SessSetup request) */
524 #define CAP_UNICODE 0x00000004
525 #define CAP_LARGE_FILES 0x00000008
526 #define CAP_NT_SMBS 0x00000010
527 #define CAP_STATUS32 0x00000040
528 #define CAP_LEVEL_II_OPLOCKS 0x00000080
529 #define CAP_NT_FIND 0x00000200 /* reserved should be zero (presumably because NT_SMBs implies the same thing) */
530 #define CAP_BULK_TRANSFER 0x20000000
531 #define CAP_EXTENDED_SECURITY 0x80000000
534 #define GUEST_LOGIN 1
536 typedef struct smb_com_tconx_req
{
537 struct smb_hdr hdr
; /* wct = 4 */
541 __le16 Flags
; /* see below */
542 __le16 PasswordLength
;
544 unsigned char Password
[1]; /* followed by */
545 /* STRING Path *//* \\server\share name */
549 typedef struct smb_com_tconx_rsp
{
550 struct smb_hdr hdr
; /* wct = 3 *//* note that Win2000 has sent wct=7 in some cases on responses. Four unspecified words followed OptionalSupport */
554 __le16 OptionalSupport
; /* see below */
556 unsigned char Service
[1]; /* always ASCII, not Unicode */
557 /* STRING NativeFileSystem */
560 /* tree connect Flags */
561 #define DISCONNECT_TID 0x0001
562 #define TCON_EXTENDED_SECINFO 0x0008
563 /* OptionalSupport bits */
564 #define SMB_SUPPORT_SEARCH_BITS 0x0001 /* must have bits (exclusive searches suppt. */
565 #define SMB_SHARE_IS_IN_DFS 0x0002
567 typedef struct smb_com_logoff_andx_req
{
569 struct smb_hdr hdr
; /* wct = 2 */
576 typedef struct smb_com_logoff_andx_rsp
{
577 struct smb_hdr hdr
; /* wct = 2 */
584 typedef union smb_com_tree_disconnect
{ /* as an altetnative can use flag on tree_connect PDU to effect disconnect *//* probably the simplest SMB PDU */
586 struct smb_hdr hdr
; /* wct = 0 */
587 __u16 ByteCount
; /* bcc = 0 */
590 struct smb_hdr hdr
; /* wct = 0 */
591 __u16 ByteCount
; /* bcc = 0 */
595 typedef struct smb_com_close_req
{
596 struct smb_hdr hdr
; /* wct = 3 */
598 __u32 LastWriteTime
; /* should be zero */
599 __u16 ByteCount
; /* 0 */
602 typedef struct smb_com_close_rsp
{
603 struct smb_hdr hdr
; /* wct = 0 */
604 __u16 ByteCount
; /* bct = 0 */
607 typedef struct smb_com_findclose_req
{
608 struct smb_hdr hdr
; /* wct = 1 */
610 __u16 ByteCount
; /* 0 */
614 #define REQ_OPLOCK 0x00000002
615 #define REQ_BATCHOPLOCK 0x00000004
616 #define REQ_OPENDIRONLY 0x00000008
618 typedef struct smb_com_open_req
{ /* also handles create */
619 struct smb_hdr hdr
; /* wct = 24 */
623 __u8 Reserved
; /* Must Be Zero */
626 __le32 RootDirectoryFid
;
627 __le32 DesiredAccess
;
628 __le64 AllocationSize
;
629 __le32 FileAttributes
;
631 __le32 CreateDisposition
;
632 __le32 CreateOptions
;
633 __le32 ImpersonationLevel
;
639 /* open response: oplock levels */
640 #define OPLOCK_NONE 0
641 #define OPLOCK_EXCLUSIVE 1
642 #define OPLOCK_BATCH 2
643 #define OPLOCK_READ 3 /* level 2 oplock */
645 /* open response for CreateAction shifted left */
646 #define CIFS_CREATE_ACTION 0x20000 /* file created */
648 typedef struct smb_com_open_rsp
{
649 struct smb_hdr hdr
; /* wct = 34 BB */
657 __le64 LastAccessTime
;
658 __le64 LastWriteTime
;
660 __le32 FileAttributes
;
661 __le64 AllocationSize
;
666 __u16 ByteCount
; /* bct = 0 */
669 typedef struct smb_com_write_req
{
670 struct smb_hdr hdr
; /* wct = 14 */
679 __le16 DataLengthHigh
;
680 __le16 DataLengthLow
;
684 __u8 Pad
; /* BB check for whether padded to DWORD boundary and optimum performance here */
688 typedef struct smb_com_write_rsp
{
689 struct smb_hdr hdr
; /* wct = 6 */
699 typedef struct smb_com_read_req
{
700 struct smb_hdr hdr
; /* wct = 12 */
707 __le16 MinCount
; /* obsolete */
714 typedef struct smb_com_read_rsp
{
715 struct smb_hdr hdr
; /* wct = 12 */
720 __le16 DataCompactionMode
;
724 __le16 DataLengthHigh
;
727 __u8 Pad
; /* BB check for whether padded to DWORD boundary and optimum performance here */
731 typedef struct locking_andx_range
{
738 } LOCKING_ANDX_RANGE
;
740 #define LOCKING_ANDX_SHARED_LOCK 0x01
741 #define LOCKING_ANDX_OPLOCK_RELEASE 0x02
742 #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
743 #define LOCKING_ANDX_CANCEL_LOCK 0x08
744 #define LOCKING_ANDX_LARGE_FILES 0x10 /* always on for us */
746 typedef struct smb_com_lock_req
{
747 struct smb_hdr hdr
; /* wct = 8 */
755 __le16 NumberOfUnlocks
;
756 __le16 NumberOfLocks
;
758 LOCKING_ANDX_RANGE Locks
[1];
761 typedef struct smb_com_lock_rsp
{
762 struct smb_hdr hdr
; /* wct = 2 */
769 typedef struct smb_com_rename_req
{
770 struct smb_hdr hdr
; /* wct = 1 */
771 __le16 SearchAttributes
; /* target file attributes */
773 __u8 BufferFormat
; /* 4 = ASCII or Unicode */
774 unsigned char OldFileName
[1];
775 /* followed by __u8 BufferFormat2 */
776 /* followed by NewFileName */
779 /* copy request flags */
780 #define COPY_MUST_BE_FILE 0x0001
781 #define COPY_MUST_BE_DIR 0x0002
782 #define COPY_TARGET_MODE_ASCII 0x0004 /* if not set, binary */
783 #define COPY_SOURCE_MODE_ASCII 0x0008 /* if not set, binary */
784 #define COPY_VERIFY_WRITES 0x0010
785 #define COPY_TREE 0x0020
787 typedef struct smb_com_copy_req
{
788 struct smb_hdr hdr
; /* wct = 3 */
793 __u8 BufferFormat
; /* 4 = ASCII or Unicode */
794 unsigned char OldFileName
[1];
795 /* followed by __u8 BufferFormat2 */
796 /* followed by NewFileName string */
799 typedef struct smb_com_copy_rsp
{
800 struct smb_hdr hdr
; /* wct = 1 */
801 __le16 CopyCount
; /* number of files copied */
802 __u16 ByteCount
; /* may be zero */
803 __u8 BufferFormat
; /* 0x04 - only present if errored file follows */
804 unsigned char ErrorFileName
[1]; /* only present if error in copy */
807 #define CREATE_HARD_LINK 0x103
808 #define MOVEFILE_COPY_ALLOWED 0x0002
809 #define MOVEFILE_REPLACE_EXISTING 0x0001
811 typedef struct smb_com_nt_rename_req
{ /* A5 - also used for create hardlink */
812 struct smb_hdr hdr
; /* wct = 4 */
813 __le16 SearchAttributes
; /* target file attributes */
814 __le16 Flags
; /* spec says Information Level */
817 __u8 BufferFormat
; /* 4 = ASCII or Unicode */
818 unsigned char OldFileName
[1];
819 /* followed by __u8 BufferFormat2 */
820 /* followed by NewFileName */
823 typedef struct smb_com_rename_rsp
{
824 struct smb_hdr hdr
; /* wct = 0 */
825 __u16 ByteCount
; /* bct = 0 */
828 typedef struct smb_com_delete_file_req
{
829 struct smb_hdr hdr
; /* wct = 1 */
830 __le16 SearchAttributes
;
832 __u8 BufferFormat
; /* 4 = ASCII */
833 unsigned char fileName
[1];
836 typedef struct smb_com_delete_file_rsp
{
837 struct smb_hdr hdr
; /* wct = 0 */
838 __u16 ByteCount
; /* bct = 0 */
841 typedef struct smb_com_delete_directory_req
{
842 struct smb_hdr hdr
; /* wct = 0 */
844 __u8 BufferFormat
; /* 4 = ASCII */
845 unsigned char DirName
[1];
846 } DELETE_DIRECTORY_REQ
;
848 typedef struct smb_com_delete_directory_rsp
{
849 struct smb_hdr hdr
; /* wct = 0 */
850 __u16 ByteCount
; /* bct = 0 */
851 } DELETE_DIRECTORY_RSP
;
853 typedef struct smb_com_create_directory_req
{
854 struct smb_hdr hdr
; /* wct = 0 */
856 __u8 BufferFormat
; /* 4 = ASCII */
857 unsigned char DirName
[1];
858 } CREATE_DIRECTORY_REQ
;
860 typedef struct smb_com_create_directory_rsp
{
861 struct smb_hdr hdr
; /* wct = 0 */
862 __u16 ByteCount
; /* bct = 0 */
863 } CREATE_DIRECTORY_RSP
;
865 /***************************************************/
866 /* NT Transact structure defintions follow */
867 /* Currently only ioctl and notify are implemented */
868 /***************************************************/
869 typedef struct smb_com_transaction_ioctl_req
{
870 struct smb_hdr hdr
; /* wct = 23 */
873 __le32 TotalParameterCount
;
874 __le32 TotalDataCount
;
875 __le32 MaxParameterCount
;
877 __le32 ParameterCount
;
878 __le32 ParameterOffset
;
881 __u8 SetupCount
; /* four setup words follow subcommand */
882 /* SNIA spec incorrectly included spurious pad here */
883 __le16 SubCommand
;/* 2 = IOCTL/FSCTL */
886 __u8 IsFsctl
; /* 1 = File System Control, 0 = device control (IOCTL)*/
887 __u8 IsRootFlag
; /* 1 = apply command to root of share (must be DFS share)*/
891 } TRANSACT_IOCTL_REQ
;
893 typedef struct smb_com_transaction_ioctl_rsp
{
894 struct smb_hdr hdr
; /* wct = 19 */
896 __le32 TotalParameterCount
;
897 __le32 TotalDataCount
;
898 __le32 ParameterCount
;
899 __le32 ParameterOffset
;
900 __le32 ParameterDisplacement
;
903 __le32 DataDisplacement
;
904 __u8 SetupCount
; /* 1 */
905 __le16 ReturnedDataLen
;
908 } TRANSACT_IOCTL_RSP
;
910 typedef struct smb_com_transaction_change_notify_req
{
911 struct smb_hdr hdr
; /* wct = 23 */
914 __le32 TotalParameterCount
;
915 __le32 TotalDataCount
;
916 __le32 MaxParameterCount
;
918 __le32 ParameterCount
;
919 __le32 ParameterOffset
;
922 __u8 SetupCount
; /* four setup words follow subcommand */
923 /* SNIA spec incorrectly included spurious pad here */
924 __le16 SubCommand
;/* 4 = Change Notify */
925 __le32 CompletionFilter
; /* operation to monitor */
927 __u8 WatchTree
; /* 1 = Monitor subdirectories */
932 } TRANSACT_CHANGE_NOTIFY_REQ
;
934 typedef struct smb_com_transaction_change_notify_rsp
{
935 struct smb_hdr hdr
; /* wct = 18 */
937 __le32 TotalParameterCount
;
938 __le32 TotalDataCount
;
939 __le32 ParameterCount
;
940 __le32 ParameterOffset
;
941 __le32 ParameterDisplacement
;
944 __le32 DataDisplacement
;
945 __u8 SetupCount
; /* 0 */
948 } TRANSACT_CHANGE_NOTIFY_RSP
;
949 /* Completion Filter flags for Notify */
950 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
951 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
952 #define FILE_NOTIFY_CHANGE_NAME 0x00000003
953 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
954 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
955 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
956 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
957 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
958 #define FILE_NOTIFY_CHANGE_EA 0x00000080
959 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
960 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
961 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
962 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
964 #define FILE_ACTION_ADDED 0x00000001
965 #define FILE_ACTION_REMOVED 0x00000002
966 #define FILE_ACTION_MODIFIED 0x00000003
967 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
968 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
969 #define FILE_ACTION_ADDED_STREAM 0x00000006
970 #define FILE_ACTION_REMOVED_STREAM 0x00000007
971 #define FILE_ACTION_MODIFIED_STREAM 0x00000008
973 /* response contains array of the following structures */
974 struct file_notify_information
{
975 __u32 NextEntryOffset
;
977 __u32 FileNameLength
;
981 struct reparse_data
{
983 __u16 ReparseDataLength
;
987 __u16 TargetNameOffset
;
989 char LinkNamesBuf
[1];
992 struct cifs_quota_data
{
993 __u32 rsrvd1
; /* 0 */
995 __u64 rsrvd2
; /* 0 */
999 char sid
[1]; /* variable size? */
1002 /* quota sub commands */
1003 #define QUOTA_LIST_CONTINUE 0
1004 #define QUOTA_LIST_START 0x100
1005 #define QUOTA_FOR_SID 0x101
1007 typedef union smb_com_transaction2
{
1009 struct smb_hdr hdr
; /* wct = 14+ */
1010 __u16 TotalParameterCount
;
1011 __u16 TotalDataCount
;
1012 __u16 MaxParameterCount
;
1019 __u16 ParameterCount
;
1020 __u16 ParameterOffset
;
1025 __u16 SubCommand
; /* 1st setup word - can be followed by SetupCount words */
1026 __u16 ByteCount
; /* careful - setupcount is not always one */
1029 struct smb_hdr hdr
; /* wct = 0 */
1030 __u16 TotalParameterCount
;
1031 __u16 TotalDataCount
;
1033 __u16 ParameterCount
;
1034 __u16 ParamterOffset
;
1035 __u16 ParameterDisplacement
;
1038 __u16 DataDisplacement
;
1040 __u8 Reserved1
; /* should be zero setup words following */
1042 __u16 Reserved2
; /* parameter word reserved - present for infolevels > 100 */
1043 /* data area follows */
1047 /* PathInfo/FileInfo infolevels */
1048 #define SMB_INFO_STANDARD 1
1049 #define SMB_SET_FILE_EA 2
1050 #define SMB_QUERY_FILE_EA_SIZE 2
1051 #define SMB_INFO_QUERY_EAS_FROM_LIST 3
1052 #define SMB_INFO_QUERY_ALL_EAS 4
1053 #define SMB_INFO_IS_NAME_VALID 6
1054 #define SMB_QUERY_FILE_BASIC_INFO 0x101
1055 #define SMB_QUERY_FILE_STANDARD_INFO 0x102
1056 #define SMB_QUERY_FILE_EA_INFO 0x103
1057 #define SMB_QUERY_FILE_NAME_INFO 0x104
1058 #define SMB_QUERY_FILE_ALLOCATION_INFO 0x105
1059 #define SMB_QUERY_FILE_END_OF_FILEINFO 0x106
1060 #define SMB_QUERY_FILE_ALL_INFO 0x107
1061 #define SMB_QUERY_ALT_NAME_INFO 0x108
1062 #define SMB_QUERY_FILE_STREAM_INFO 0x109
1063 #define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
1064 #define SMB_QUERY_FILE_UNIX_BASIC 0x200
1065 #define SMB_QUERY_FILE_UNIX_LINK 0x201
1067 #define SMB_SET_FILE_BASIC_INFO 0x101
1068 #define SMB_SET_FILE_DISPOSITION_INFO 0x102
1069 #define SMB_SET_FILE_ALLOCATION_INFO 0x103
1070 #define SMB_SET_FILE_END_OF_FILE_INFO 0x104
1071 #define SMB_SET_FILE_UNIX_BASIC 0x200
1072 #define SMB_SET_FILE_UNIX_LINK 0x201
1073 #define SMB_SET_FILE_UNIX_HLINK 0x203
1074 #define SMB_SET_FILE_BASIC_INFO2 0x3ec
1075 #define SMB_SET_FILE_RENAME_INFORMATION 0x3f2
1076 #define SMB_FILE_ALL_INFO2 0x3fa
1077 #define SMB_SET_FILE_ALLOCATION_INFO2 0x3fb
1078 #define SMB_SET_FILE_END_OF_FILE_INFO2 0x3fc
1079 #define SMB_FILE_MOVE_CLUSTER_INFO 0x407
1080 #define SMB_FILE_QUOTA_INFO 0x408
1081 #define SMB_FILE_REPARSEPOINT_INFO 0x409
1082 #define SMB_FILE_MAXIMUM_INFO 0x40d
1084 /* Find File infolevels */
1085 #define SMB_FIND_FILE_DIRECTORY_INFO 0x101
1086 #define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
1087 #define SMB_FIND_FILE_NAMES_INFO 0x103
1088 #define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
1089 #define SMB_FIND_FILE_UNIX 0x202
1091 typedef struct smb_com_transaction2_qpi_req
{
1092 struct smb_hdr hdr
; /* wct = 14+ */
1093 __le16 TotalParameterCount
;
1094 __le16 TotalDataCount
;
1095 __le16 MaxParameterCount
;
1096 __le16 MaxDataCount
;
1102 __le16 ParameterCount
;
1103 __le16 ParameterOffset
;
1108 __le16 SubCommand
; /* one setup word */
1111 __le16 InformationLevel
;
1114 } TRANSACTION2_QPI_REQ
;
1116 typedef struct smb_com_transaction2_qpi_rsp
{
1117 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1118 __le16 TotalParameterCount
;
1119 __le16 TotalDataCount
;
1121 __le16 ParameterCount
;
1122 __le16 ParameterOffset
;
1123 __le16 ParameterDisplacement
;
1126 __le16 DataDisplacement
;
1128 __u8 Reserved1
; /* should be zero setup words following */
1130 __u16 Reserved2
; /* parameter word reserved - present for infolevels > 100 */
1131 } TRANSACTION2_QPI_RSP
;
1133 typedef struct smb_com_transaction2_spi_req
{
1134 struct smb_hdr hdr
; /* wct = 15 */
1135 __le16 TotalParameterCount
;
1136 __le16 TotalDataCount
;
1137 __le16 MaxParameterCount
;
1138 __le16 MaxDataCount
;
1144 __le16 ParameterCount
;
1145 __le16 ParameterOffset
;
1150 __le16 SubCommand
; /* one setup word */
1154 __le16 InformationLevel
;
1157 } TRANSACTION2_SPI_REQ
;
1159 typedef struct smb_com_transaction2_spi_rsp
{
1160 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1161 __le16 TotalParameterCount
;
1162 __le16 TotalDataCount
;
1164 __le16 ParameterCount
;
1165 __le16 ParameterOffset
;
1166 __le16 ParameterDisplacement
;
1169 __le16 DataDisplacement
;
1171 __u8 Reserved1
; /* should be zero setup words following */
1173 __u16 Reserved2
; /* parameter word reserved - present for infolevels > 100 */
1174 } TRANSACTION2_SPI_RSP
;
1176 struct set_file_rename
{
1177 __le32 overwrite
; /* 1 = overwrite dest */
1178 __u32 root_fid
; /* zero */
1179 __le32 target_name_len
;
1180 char target_name
[0]; /* Must be unicode */
1183 struct smb_com_transaction2_sfi_req
{
1184 struct smb_hdr hdr
; /* wct = 15 */
1185 __le16 TotalParameterCount
;
1186 __le16 TotalDataCount
;
1187 __le16 MaxParameterCount
;
1188 __le16 MaxDataCount
;
1194 __le16 ParameterCount
;
1195 __le16 ParameterOffset
;
1200 __le16 SubCommand
; /* one setup word */
1205 __le16 InformationLevel
;
1209 struct smb_com_transaction2_sfi_rsp
{
1210 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1211 __le16 TotalParameterCount
;
1212 __le16 TotalDataCount
;
1214 __le16 ParameterCount
;
1215 __le16 ParameterOffset
;
1216 __le16 ParameterDisplacement
;
1219 __le16 DataDisplacement
;
1221 __u8 Reserved1
; /* should be zero setup words following */
1223 __u16 Reserved2
; /* parameter word reserved - present for infolevels > 100 */
1228 * Flags on T2 FINDFIRST and FINDNEXT
1230 #define CIFS_SEARCH_CLOSE_ALWAYS 0x0001
1231 #define CIFS_SEARCH_CLOSE_AT_END 0x0002
1232 #define CIFS_SEARCH_RETURN_RESUME 0x0004
1233 #define CIFS_SEARCH_CONTINUE_FROM_LAST 0x0008
1234 #define CIFS_SEARCH_BACKUP_SEARCH 0x0010
1237 * Size of the resume key on FINDFIRST and FINDNEXT calls
1239 #define CIFS_SMB_RESUME_KEY_SIZE 4
1241 typedef struct smb_com_transaction2_ffirst_req
{
1242 struct smb_hdr hdr
; /* wct = 15 */
1243 __le16 TotalParameterCount
;
1244 __le16 TotalDataCount
;
1245 __le16 MaxParameterCount
;
1246 __le16 MaxDataCount
;
1252 __le16 ParameterCount
;
1253 __le16 ParameterOffset
;
1256 __u8 SetupCount
; /* one */
1258 __le16 SubCommand
; /* TRANS2_FIND_FIRST */
1261 __le16 SearchAttributes
;
1264 __le16 InformationLevel
;
1265 __le32 SearchStorageType
;
1267 } TRANSACTION2_FFIRST_REQ
;
1269 typedef struct smb_com_transaction2_ffirst_rsp
{
1270 struct smb_hdr hdr
; /* wct = 10 */
1271 __le16 TotalParameterCount
;
1272 __le16 TotalDataCount
;
1274 __le16 ParameterCount
;
1275 __le16 ParameterOffset
;
1276 __le16 ParameterDisplacement
;
1279 __le16 DataDisplacement
;
1281 __u8 Reserved1
; /* should be zero setup words following */
1283 } TRANSACTION2_FFIRST_RSP
;
1285 typedef struct smb_com_transaction2_ffirst_rsp_parms
{
1289 __le16 EAErrorOffset
;
1290 __le16 LastNameOffset
;
1291 } T2_FFIRST_RSP_PARMS
;
1293 typedef struct smb_com_transaction2_fnext_req
{
1294 struct smb_hdr hdr
; /* wct = 15 */
1295 __le16 TotalParameterCount
;
1296 __le16 TotalDataCount
;
1297 __le16 MaxParameterCount
;
1298 __le16 MaxDataCount
;
1304 __le16 ParameterCount
;
1305 __le16 ParameterOffset
;
1308 __u8 SetupCount
; /* one */
1310 __le16 SubCommand
; /* TRANS2_FIND_NEXT */
1315 __le16 InformationLevel
;
1318 char ResumeFileName
[1];
1319 } TRANSACTION2_FNEXT_REQ
;
1321 typedef struct smb_com_transaction2_fnext_rsp
{
1322 struct smb_hdr hdr
; /* wct = 10 */
1323 __le16 TotalParameterCount
;
1324 __le16 TotalDataCount
;
1326 __le16 ParameterCount
;
1327 __le16 ParameterOffset
;
1328 __le16 ParameterDisplacement
;
1331 __le16 DataDisplacement
;
1333 __u8 Reserved1
; /* should be zero setup words following */
1335 } TRANSACTION2_FNEXT_RSP
;
1337 typedef struct smb_com_transaction2_fnext_rsp_parms
{
1340 __le16 EAErrorOffset
;
1341 __le16 LastNameOffset
;
1342 } T2_FNEXT_RSP_PARMS
;
1344 /* QFSInfo Levels */
1345 #define SMB_INFO_ALLOCATION 1
1346 #define SMB_INFO_VOLUME 2
1347 #define SMB_QUERY_FS_VOLUME_INFO 0x102
1348 #define SMB_QUERY_FS_SIZE_INFO 0x103
1349 #define SMB_QUERY_FS_DEVICE_INFO 0x104
1350 #define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
1351 #define SMB_QUERY_CIFS_UNIX_INFO 0x200
1352 #define SMB_QUERY_LABEL_INFO 0x3ea
1353 #define SMB_QUERY_FS_QUOTA_INFO 0x3ee
1355 typedef struct smb_com_transaction2_qfsi_req
{
1356 struct smb_hdr hdr
; /* wct = 14+ */
1357 __le16 TotalParameterCount
;
1358 __le16 TotalDataCount
;
1359 __le16 MaxParameterCount
;
1360 __le16 MaxDataCount
;
1366 __le16 ParameterCount
;
1367 __le16 ParameterOffset
;
1372 __le16 SubCommand
; /* one setup word */
1375 __le16 InformationLevel
;
1376 } TRANSACTION2_QFSI_REQ
;
1378 typedef struct smb_com_transaction_qfsi_rsp
{
1379 struct smb_hdr hdr
; /* wct = 10 + SetupCount */
1380 __le16 TotalParameterCount
;
1381 __le16 TotalDataCount
;
1383 __le16 ParameterCount
;
1384 __le16 ParameterOffset
;
1385 __le16 ParameterDisplacement
;
1388 __le16 DataDisplacement
;
1390 __u8 Reserved1
; /* should be zero setup words following */
1392 __u8 Pad
; /* may be three bytes *//* followed by data area */
1393 } TRANSACTION2_QFSI_RSP
;
1395 typedef struct smb_com_transaction2_get_dfs_refer_req
{
1396 struct smb_hdr hdr
; /* wct = 15 */
1397 __le16 TotalParameterCount
;
1398 __le16 TotalDataCount
;
1399 __le16 MaxParameterCount
;
1400 __le16 MaxDataCount
;
1406 __le16 ParameterCount
;
1407 __le16 ParameterOffset
;
1412 __le16 SubCommand
; /* one setup word */
1414 __u8 Pad
[3]; /* Win2K has sent 0x0F01 (max resp length perhaps?) followed by one byte pad - doesn't seem to matter though */
1415 __le16 MaxReferralLevel
;
1416 char RequestFileName
[1];
1417 } TRANSACTION2_GET_DFS_REFER_REQ
;
1419 typedef struct dfs_referral_level_3
{
1420 __le16 VersionNumber
;
1421 __le16 ReferralSize
;
1422 __le16 ServerType
; /* 0x0001 = CIFS server */
1423 __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 */
1426 __le16 DfsPathOffset
;
1427 __le16 DfsAlternatePathOffset
;
1428 __le16 NetworkAddressOffset
;
1431 typedef struct smb_com_transaction_get_dfs_refer_rsp
{
1432 struct smb_hdr hdr
; /* wct = 10 */
1433 __le16 TotalParameterCount
;
1434 __le16 TotalDataCount
;
1436 __le16 ParameterCount
;
1437 __le16 ParameterOffset
;
1438 __le16 ParameterDisplacement
;
1441 __le16 DataDisplacement
;
1443 __u8 Reserved1
; /* zero setup words following */
1446 __le16 PathConsumed
;
1447 __le16 NumberOfReferrals
;
1450 REFERRAL3 referrals
[1]; /* array of level 3 dfs_referral structures */
1451 /* followed by the strings pointed to by the referral structures */
1452 } TRANSACTION2_GET_DFS_REFER_RSP
;
1455 #define DFSREF_REFERRAL_SERVER 0x0001
1456 #define DFSREF_STORAGE_SERVER 0x0002
1458 /* IOCTL information */
1459 /* List of ioctl function codes that look to be of interest to remote clients like this. */
1460 /* Need to do some experimentation to make sure they all work remotely. */
1461 /* Some of the following such as the encryption/compression ones would be */
1462 /* invoked from tools via a specialized hook into the VFS rather than via the */
1463 /* standard vfs entry points */
1464 #define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000
1465 #define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004
1466 #define FSCTL_REQUEST_BATCH_OPLOCK 0x00090008
1467 #define FSCTL_LOCK_VOLUME 0x00090018
1468 #define FSCTL_UNLOCK_VOLUME 0x0009001C
1469 #define FSCTL_GET_COMPRESSION 0x0009003C
1470 #define FSCTL_SET_COMPRESSION 0x0009C040
1471 #define FSCTL_REQUEST_FILTER_OPLOCK 0x0009008C
1472 #define FSCTL_FILESYS_GET_STATISTICS 0x00090090
1473 #define FSCTL_SET_REPARSE_POINT 0x000900A4
1474 #define FSCTL_GET_REPARSE_POINT 0x000900A8
1475 #define FSCTL_DELETE_REPARSE_POINT 0x000900AC
1476 #define FSCTL_SET_SPARSE 0x000900C4
1477 #define FSCTL_SET_ZERO_DATA 0x000900C8
1478 #define FSCTL_SET_ENCRYPTION 0x000900D7
1479 #define FSCTL_ENCRYPTION_FSCTL_IO 0x000900DB
1480 #define FSCTL_WRITE_RAW_ENCRYPTED 0x000900DF
1481 #define FSCTL_READ_RAW_ENCRYPTED 0x000900E3
1482 #define FSCTL_SIS_COPYFILE 0x00090100
1483 #define FSCTL_SIS_LINK_FILES 0x0009C104
1485 #define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003
1486 #define IO_REPARSE_TAG_HSM 0xC0000004
1487 #define IO_REPARSE_TAG_SIS 0x80000007
1490 ************************************************************************
1491 * All structs for everything above the SMB PDUs themselves
1492 * (such as the T2 level specific data) go here
1493 ************************************************************************
1497 * Information on a server
1502 unsigned char versionMajor
;
1503 unsigned char versionMinor
;
1505 unsigned int commentOffset
;
1509 * The following structure is the format of the data returned on a NetShareEnum
1510 * with level "90" (x5A)
1516 unsigned short type
;
1517 unsigned int commentOffset
;
1523 unsigned int commentOffset
;
1524 unsigned char type
[2];
1527 struct aliasInfo92
{
1528 int aliasNameOffset
;
1529 int serverNameOffset
;
1530 int shareNameOffset
;
1534 __le64 TotalAllocationUnits
;
1535 __le64 FreeAllocationUnits
;
1536 __le32 SectorsPerAllocationUnit
;
1537 __le32 BytesPerSector
;
1538 } FILE_SYSTEM_INFO
; /* size info, level 0x103 */
1541 __le16 MajorVersionNumber
;
1542 __le16 MinorVersionNumber
;
1544 } FILE_SYSTEM_UNIX_INFO
; /* Unix extensions info, level 0x200 */
1545 /* Linux/Unix extensions capability flags */
1546 #define CIFS_UNIX_FCNTL_CAP 0x00000001 /* support for fcntl locks */
1547 #define CIFS_UNIX_POSIX_ACL_CAP 0x00000002
1549 /* DeviceType Flags */
1550 #define FILE_DEVICE_CD_ROM 0x00000002
1551 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
1552 #define FILE_DEVICE_DFS 0x00000006
1553 #define FILE_DEVICE_DISK 0x00000007
1554 #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
1555 #define FILE_DEVICE_FILE_SYSTEM 0x00000009
1556 #define FILE_DEVICE_NAMED_PIPE 0x00000011
1557 #define FILE_DEVICE_NETWORK 0x00000012
1558 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
1559 #define FILE_DEVICE_NULL 0x00000015
1560 #define FILE_DEVICE_PARALLEL_PORT 0x00000016
1561 #define FILE_DEVICE_PRINTER 0x00000018
1562 #define FILE_DEVICE_SERIAL_PORT 0x0000001b
1563 #define FILE_DEVICE_STREAMS 0x0000001e
1564 #define FILE_DEVICE_TAPE 0x0000001f
1565 #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
1566 #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
1567 #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
1571 __le32 DeviceCharacteristics
;
1572 } FILE_SYSTEM_DEVICE_INFO
; /* device info, level 0x104 */
1576 __le32 MaxPathNameComponentLength
;
1577 __le32 FileSystemNameLen
;
1578 char FileSystemName
[52]; /* do not really need to save this - so potentially get only subset of name */
1579 } FILE_SYSTEM_ATTRIBUTE_INFO
;
1581 typedef struct { /* data block encoding of response to level 263 QPathInfo */
1582 __le64 CreationTime
;
1583 __le64 LastAccessTime
;
1584 __le64 LastWriteTime
;
1588 __le64 AllocationSize
;
1589 __le64 EndOfFile
; /* size ie offset to first free byte in file */
1590 __le32 NumberOfLinks
; /* hard links */
1598 __le64 CurrentByteOffset
;
1600 __le32 AlignmentRequirement
;
1601 __le32 FileNameLength
;
1603 } FILE_ALL_INFO
; /* level 263 QPathInfo */
1608 __le64 LastStatusChange
; /*SNIA spec says DCE time for the three time fields */
1609 __le64 LastAccessTime
;
1610 __le64 LastModificationTime
;
1619 } FILE_UNIX_BASIC_INFO
; /* level 512 QPathInfo */
1623 } FILE_UNIX_LINK_INFO
; /* level 513 QPathInfo */
1628 __u16 LastAccessDate
;
1629 __u16 LastAccessTime
;
1630 __u16 LastWriteDate
;
1631 __u16 LastWriteTime
;
1632 __u32 DataSize
; /* File Size (EOF) */
1633 __u32 AllocationSize
;
1634 __u16 Attributes
; /* verify not u32 */
1636 } FILE_INFO_STANDARD
; /* level 1 SetPath/FileInfo */
1638 /* defines for enumerating possible values of the Unix type field below */
1641 #define UNIX_SYMLINK 2
1642 #define UNIX_CHARDEV 3
1643 #define UNIX_BLOCKDEV 4
1645 #define UNIX_SOCKET 6
1648 __le32 NextEntryOffset
;
1652 __le64 LastStatusChange
; /*SNIA spec says DCE time for the three time fields */
1653 __le64 LastAccessTime
;
1654 __le64 LastModificationTime
;
1667 __le64 CreationTime
;
1668 __le64 LastAccessTime
;
1669 __le64 LastWriteTime
;
1673 } FILE_BASIC_INFO
; /* size info, level 0x101 */
1675 struct file_allocation_info
{
1676 __le64 AllocationSize
;
1677 }; /* size info, level 0x103 */
1679 struct file_end_of_file_info
{
1680 __le64 FileSize
; /* offset to end of file */
1681 }; /* size info, level 0x104 */
1684 __le32 NextEntryOffset
;
1686 __le64 CreationTime
;
1687 __le64 LastAccessTime
;
1688 __le64 LastWriteTime
;
1691 __le64 AllocationSize
;
1692 __le32 ExtFileAttributes
;
1693 __le32 FileNameLength
;
1695 } FILE_DIRECTORY_INFO
; /* level 257 FF response data area */
1698 unsigned char name_len
;
1703 unsigned long list_len
;
1708 unsigned char EA_flags
;
1712 /* optionally followed by value */
1714 /* flags for _FEA.fEA */
1715 #define FEA_NEEDEA 0x80 /* need EA bit */
1722 /* used to hold an arbitrary blob of data */
1726 void (*free
) (struct data_blob
* data_blob
);
1730 #ifdef CONFIG_CIFS_POSIX
1732 For better POSIX semantics from Linux client, (even better
1733 than the existing CIFS Unix Extensions) we need updated PDUs for:
1735 1) PosixCreateX - to set and return the mode, inode#, device info and
1736 perhaps add a CreateDevice - to create Pipes and other special .inodes
1737 Also note POSIX open flags
1738 2) Close - to return the last write time to do cache across close more safely
1739 3) PosixQFSInfo - to return statfs info
1740 4) FindFirst return unique inode number - what about resume key, two forms short (matches readdir) and full (enough info to cache inodes)
1743 And under consideration:
1744 6) FindClose2 (return nanosecond timestamp ??)
1745 7) Use nanosecond timestamps throughout all time fields if
1746 corresponding attribute flag is set
1747 8) sendfile - handle based copy
1749 10) "POSIX ACL" support
1752 what about fixing 64 bit alignment
1754 There are also various legacy SMB/CIFS requests used as is
1756 From existing Lanman and NTLM dialects:
1757 --------------------------------------
1759 SESSION_SETUP_ANDX (BB which?)
1760 TREE_CONNECT_ANDX (BB which wct?)
1761 TREE_DISCONNECT (BB add volume timestamp on response)
1763 DELETE (note delete open file behavior)
1767 LOCKING_AND_X (note posix lock semantics)
1768 RENAME (note rename across dirs and open file rename posix behaviors)
1769 NT_RENAME (for hardlinks) Is this good enough for all features?
1771 TRANSACTION2 (18 cases)
1772 SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2
1773 (BB verify that never need to set allocation size)
1774 SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via Unix ext?)
1776 COPY (note support for copy across directories) - FUTURE, OPTIONAL
1777 setting/getting OS/2 EAs - FUTURE (BB can this handle
1778 setting Linux xattrs perfectly) - OPTIONAL
1779 dnotify - FUTURE, OPTIONAL
1780 quota - FUTURE, OPTIONAL
1782 Note that various requests implemented for NT interop such as
1783 NT_TRANSACT (IOCTL) QueryReparseInfo
1784 are unneeded to servers compliant with the CIFS POSIX extensions
1786 From CIFS Unix Extensions:
1787 -------------------------
1788 T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks
1789 T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2)
1790 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK)
1791 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC) - BB check for missing inode fields
1792 Actually need QUERY_FILE_UNIX_INFO since has inode num
1793 BB what about a) blksize/blkbits/blocks
1799 T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX
1800 TRANS2_GET_DFS_REFERRAL - OPTIONAL but recommended
1801 T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL
1806 /* xsymlink is a symlink format that can be used
1807 to save symlink info in a regular file when
1808 mounted to operating systems that do not
1809 support the cifs Unix extensions or EAs (for xattr
1810 based symlinks). For such a file to be recognized
1811 as containing symlink data:
1813 1) file size must be 1067,
1814 2) signature must begin file data,
1815 3) length field must be set to ASCII representation
1816 of a number which is less than or equal to 1024,
1817 4) md5 must match that of the path data */
1821 char signature
[4]; /* XSym */ /* not null terminated */
1823 /* ASCII representation of length (4 bytes decimal) terminated by \n not null */
1826 /* md5 of valid subset of path ie path[0] through path[length-1] */
1829 /* if room left, then end with \n then 0x20s by convention but not required */
1835 #pragma pack() /* resume default structure packing */
1837 #endif /* _CIFSPDU_H */