4 * Copyright (c) International Business Machines Corp., 2009, 2013
6 * Author(s): Steve French (sfrench@us.ibm.com)
7 * Pavel Shilovsky (pshilovsky@samba.org) 2012
9 * This library is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published
11 * by the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17 * the GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 * Note that, due to trying to use names similar to the protocol specifications,
31 * there are many mixed case field names in the structures below. Although
32 * this does not match typical Linux kernel style, it is necessary to be
33 * be able to match against the protocol specfication.
36 * Some commands have minimal (wct=0,bcc=0), or uninteresting, responses
37 * (ie no useful data other than the SMB error code itself) and are marked such.
38 * Knowing this helps avoid response buffer allocations and copy in some cases.
41 /* List of commands in host endian */
42 #define SMB2_NEGOTIATE_HE 0x0000
43 #define SMB2_SESSION_SETUP_HE 0x0001
44 #define SMB2_LOGOFF_HE 0x0002 /* trivial request/resp */
45 #define SMB2_TREE_CONNECT_HE 0x0003
46 #define SMB2_TREE_DISCONNECT_HE 0x0004 /* trivial req/resp */
47 #define SMB2_CREATE_HE 0x0005
48 #define SMB2_CLOSE_HE 0x0006
49 #define SMB2_FLUSH_HE 0x0007 /* trivial resp */
50 #define SMB2_READ_HE 0x0008
51 #define SMB2_WRITE_HE 0x0009
52 #define SMB2_LOCK_HE 0x000A
53 #define SMB2_IOCTL_HE 0x000B
54 #define SMB2_CANCEL_HE 0x000C
55 #define SMB2_ECHO_HE 0x000D
56 #define SMB2_QUERY_DIRECTORY_HE 0x000E
57 #define SMB2_CHANGE_NOTIFY_HE 0x000F
58 #define SMB2_QUERY_INFO_HE 0x0010
59 #define SMB2_SET_INFO_HE 0x0011
60 #define SMB2_OPLOCK_BREAK_HE 0x0012
62 /* The same list in little endian */
63 #define SMB2_NEGOTIATE cpu_to_le16(SMB2_NEGOTIATE_HE)
64 #define SMB2_SESSION_SETUP cpu_to_le16(SMB2_SESSION_SETUP_HE)
65 #define SMB2_LOGOFF cpu_to_le16(SMB2_LOGOFF_HE)
66 #define SMB2_TREE_CONNECT cpu_to_le16(SMB2_TREE_CONNECT_HE)
67 #define SMB2_TREE_DISCONNECT cpu_to_le16(SMB2_TREE_DISCONNECT_HE)
68 #define SMB2_CREATE cpu_to_le16(SMB2_CREATE_HE)
69 #define SMB2_CLOSE cpu_to_le16(SMB2_CLOSE_HE)
70 #define SMB2_FLUSH cpu_to_le16(SMB2_FLUSH_HE)
71 #define SMB2_READ cpu_to_le16(SMB2_READ_HE)
72 #define SMB2_WRITE cpu_to_le16(SMB2_WRITE_HE)
73 #define SMB2_LOCK cpu_to_le16(SMB2_LOCK_HE)
74 #define SMB2_IOCTL cpu_to_le16(SMB2_IOCTL_HE)
75 #define SMB2_CANCEL cpu_to_le16(SMB2_CANCEL_HE)
76 #define SMB2_ECHO cpu_to_le16(SMB2_ECHO_HE)
77 #define SMB2_QUERY_DIRECTORY cpu_to_le16(SMB2_QUERY_DIRECTORY_HE)
78 #define SMB2_CHANGE_NOTIFY cpu_to_le16(SMB2_CHANGE_NOTIFY_HE)
79 #define SMB2_QUERY_INFO cpu_to_le16(SMB2_QUERY_INFO_HE)
80 #define SMB2_SET_INFO cpu_to_le16(SMB2_SET_INFO_HE)
81 #define SMB2_OPLOCK_BREAK cpu_to_le16(SMB2_OPLOCK_BREAK_HE)
83 #define SMB2_INTERNAL_CMD cpu_to_le16(0xFFFF)
85 #define NUMBER_OF_SMB2_COMMANDS 0x0013
87 /* 52 transform hdr + 64 hdr + 88 create rsp */
88 #define SMB2_TRANSFORM_HEADER_SIZE 52
89 #define MAX_SMB2_HDR_SIZE 204
91 #define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe)
92 #define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd)
95 * SMB2 Header Definition
97 * "MBZ" : Must be Zero
98 * "BB" : BugBug, Something to check/review/analyze later
99 * "PDU" : "Protocol Data Unit" (ie a network "frame")
103 #define SMB2_HEADER_STRUCTURE_SIZE cpu_to_le16(64)
105 struct smb2_sync_hdr {
106 __le32 ProtocolId; /* 0xFE 'S' 'M' 'B' */
107 __le16 StructureSize; /* 64 */
108 __le16 CreditCharge; /* MBZ */
109 __le32 Status; /* Error from server */
111 __le16 CreditRequest; /* CreditResponse */
116 __u32 TreeId; /* opaque - so do not make little endian */
117 __u64 SessionId; /* opaque - so do not make little endian */
121 struct smb2_sync_pdu {
122 struct smb2_sync_hdr sync_hdr;
123 __le16 StructureSize2; /* size of wct area (varies, request specific) */
126 #define SMB3_AES128CMM_NONCE 11
127 #define SMB3_AES128GCM_NONCE 12
129 struct smb2_transform_hdr {
130 __le32 ProtocolId; /* 0xFD 'S' 'M' 'B' */
133 __le32 OriginalMessageSize;
135 __le16 Flags; /* EncryptionAlgorithm */
140 * SMB2 flag definitions
142 #define SMB2_FLAGS_SERVER_TO_REDIR cpu_to_le32(0x00000001)
143 #define SMB2_FLAGS_ASYNC_COMMAND cpu_to_le32(0x00000002)
144 #define SMB2_FLAGS_RELATED_OPERATIONS cpu_to_le32(0x00000004)
145 #define SMB2_FLAGS_SIGNED cpu_to_le32(0x00000008)
146 #define SMB2_FLAGS_DFS_OPERATIONS cpu_to_le32(0x10000000)
149 * Definitions for SMB2 Protocol Data Units (network frames)
151 * See MS-SMB2.PDF specification for protocol details.
152 * The Naming convention is the lower case version of the SMB2
153 * command code name for the struct. Note that structures must be packed.
157 #define COMPOUND_FID 0xFFFFFFFFFFFFFFFFULL
159 #define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9)
161 struct smb2_err_rsp {
162 struct smb2_sync_hdr sync_hdr;
163 __le16 StructureSize;
164 __le16 Reserved; /* MBZ */
165 __le32 ByteCount; /* even if zero, at least one byte follows */
166 __u8 ErrorData[1]; /* variable length */
169 struct smb2_symlink_err_rsp {
170 __le32 SymLinkLength;
171 __le32 SymLinkErrorTag;
173 __le16 ReparseDataLength;
174 __le16 UnparsedPathLength;
175 __le16 SubstituteNameOffset;
176 __le16 SubstituteNameLength;
177 __le16 PrintNameOffset;
178 __le16 PrintNameLength;
183 /* SMB 3.1.1 and later dialects. See MS-SMB2 section 2.2.2.1 */
184 struct smb2_error_context_rsp {
185 __le32 ErrorDataLength;
187 __u8 ErrorContextData; /* ErrorDataLength long array */
190 /* Defines for Type field below (see MS-SMB2 2.2.2.2.2.1) */
191 #define MOVE_DST_IPADDR_V4 cpu_to_le32(0x00000001)
192 #define MOVE_DST_IPADDR_V6 cpu_to_le32(0x00000002)
194 struct move_dst_ipaddr {
197 __u8 address[16]; /* IPv4 followed by 12 bytes rsvd or IPv6 address */
200 struct share_redirect_error_context_rsp {
201 __le32 StructureSize;
202 __le32 NotificationType;
203 __le32 ResourceNameOffset;
204 __le32 ResourceNameLength;
208 struct move_dst_ipaddr IpAddrMoveList[0];
209 /* __u8 ResourceName[] */ /* Name of share as counted Unicode string */
212 #define SMB2_CLIENT_GUID_SIZE 16
214 struct smb2_negotiate_req {
215 struct smb2_sync_hdr sync_hdr;
216 __le16 StructureSize; /* Must be 36 */
219 __le16 Reserved; /* MBZ */
221 __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE];
222 /* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */
223 __le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */
224 __le16 NegotiateContextCount; /* SMB3.1.1 only. MBZ earlier */
226 __le16 Dialects[1]; /* One dialect (vers=) at a time for now */
230 #define SMB20_PROT_ID 0x0202
231 #define SMB21_PROT_ID 0x0210
232 #define SMB30_PROT_ID 0x0300
233 #define SMB302_PROT_ID 0x0302
234 #define SMB311_PROT_ID 0x0311
235 #define BAD_PROT_ID 0xFFFF
237 /* SecurityMode flags */
238 #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001
239 #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002
240 #define SMB2_SEC_MODE_FLAGS_ALL 0x0003
242 /* Capabilities flags */
243 #define SMB2_GLOBAL_CAP_DFS 0x00000001
244 #define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */
245 #define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */
246 #define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */
247 #define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */
248 #define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */
249 #define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */
251 #define SMB2_NT_FIND 0x00100000
252 #define SMB2_LARGE_FILES 0x00200000
255 /* Negotiate Contexts - ContextTypes. See MS-SMB2 section 2.2.3.1 for details */
256 #define SMB2_PREAUTH_INTEGRITY_CAPABILITIES cpu_to_le16(1)
257 #define SMB2_ENCRYPTION_CAPABILITIES cpu_to_le16(2)
258 #define SMB2_COMPRESSION_CAPABILITIES cpu_to_le16(3)
259 #define SMB2_NETNAME_NEGOTIATE_CONTEXT_ID cpu_to_le16(5)
260 #define SMB2_POSIX_EXTENSIONS_AVAILABLE cpu_to_le16(0x100)
262 struct smb2_neg_context {
266 /* Followed by array of data */
269 #define SMB311_SALT_SIZE 32
270 /* Hash Algorithm Types */
271 #define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001)
272 #define SMB2_PREAUTH_HASH_SIZE 64
274 #define MIN_PREAUTH_CTXT_DATA_LEN (SMB311_SALT_SIZE + 6)
275 struct smb2_preauth_neg_context {
276 __le16 ContextType; /* 1 */
279 __le16 HashAlgorithmCount; /* 1 */
281 __le16 HashAlgorithms; /* HashAlgorithms[0] since only one defined */
282 __u8 Salt[SMB311_SALT_SIZE];
285 /* Encryption Algorithms Ciphers */
286 #define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001)
287 #define SMB2_ENCRYPTION_AES128_GCM cpu_to_le16(0x0002)
289 /* Min encrypt context data is one cipher so 2 bytes + 2 byte count field */
290 #define MIN_ENCRYPT_CTXT_DATA_LEN 4
291 struct smb2_encryption_neg_context {
292 __le16 ContextType; /* 2 */
295 __le16 CipherCount; /* AES-128-GCM and AES-128-CCM */
296 __le16 Ciphers[1]; /* Ciphers[0] since only one used now */
299 /* See MS-SMB2 2.2.3.1.3 */
300 #define SMB3_COMPRESS_NONE cpu_to_le16(0x0000)
301 #define SMB3_COMPRESS_LZNT1 cpu_to_le16(0x0001)
302 #define SMB3_COMPRESS_LZ77 cpu_to_le16(0x0002)
303 #define SMB3_COMPRESS_LZ77_HUFF cpu_to_le16(0x0003)
305 struct smb2_compression_capabilities_context {
306 __le16 ContextType; /* 3 */
309 __le16 CompressionAlgorithmCount;
312 __le16 CompressionAlgorithms[3];
316 * For smb2_netname_negotiate_context_id See MS-SMB2 2.2.3.1.4.
317 * Its struct simply contains NetName, an array of Unicode characters
320 #define POSIX_CTXT_DATA_LEN 16
321 struct smb2_posix_neg_context {
322 __le16 ContextType; /* 0x100 */
325 __u8 Name[16]; /* POSIX ctxt GUID 93AD25509CB411E7B42383DE968BCD7C */
328 struct smb2_negotiate_rsp {
329 struct smb2_sync_hdr sync_hdr;
330 __le16 StructureSize; /* Must be 65 */
332 __le16 DialectRevision;
333 __le16 NegotiateContextCount; /* Prior to SMB3.1.1 was Reserved & MBZ */
336 __le32 MaxTransactSize;
339 __le64 SystemTime; /* MBZ */
340 __le64 ServerStartTime;
341 __le16 SecurityBufferOffset;
342 __le16 SecurityBufferLength;
343 __le32 NegotiateContextOffset; /* Pre:SMB3.1.1 was reserved/ignored */
344 __u8 Buffer[1]; /* variable length GSS security buffer */
348 #define SMB2_SESSION_REQ_FLAG_BINDING 0x01
349 #define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04
351 struct smb2_sess_setup_req {
352 struct smb2_sync_hdr sync_hdr;
353 __le16 StructureSize; /* Must be 25 */
358 __le16 SecurityBufferOffset;
359 __le16 SecurityBufferLength;
360 __u64 PreviousSessionId;
361 __u8 Buffer[1]; /* variable length GSS security buffer */
364 /* Currently defined SessionFlags */
365 #define SMB2_SESSION_FLAG_IS_GUEST 0x0001
366 #define SMB2_SESSION_FLAG_IS_NULL 0x0002
367 #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004
368 struct smb2_sess_setup_rsp {
369 struct smb2_sync_hdr sync_hdr;
370 __le16 StructureSize; /* Must be 9 */
372 __le16 SecurityBufferOffset;
373 __le16 SecurityBufferLength;
374 __u8 Buffer[1]; /* variable length GSS security buffer */
377 struct smb2_logoff_req {
378 struct smb2_sync_hdr sync_hdr;
379 __le16 StructureSize; /* Must be 4 */
383 struct smb2_logoff_rsp {
384 struct smb2_sync_hdr sync_hdr;
385 __le16 StructureSize; /* Must be 4 */
389 /* Flags/Reserved for SMB3.1.1 */
390 #define SMB2_TREE_CONNECT_FLAG_CLUSTER_RECONNECT cpu_to_le16(0x0001)
391 #define SMB2_TREE_CONNECT_FLAG_REDIRECT_TO_OWNER cpu_to_le16(0x0002)
392 #define SMB2_TREE_CONNECT_FLAG_EXTENSION_PRESENT cpu_to_le16(0x0004)
394 struct smb2_tree_connect_req {
395 struct smb2_sync_hdr sync_hdr;
396 __le16 StructureSize; /* Must be 9 */
397 __le16 Reserved; /* Flags in SMB3.1.1 */
400 __u8 Buffer[1]; /* variable length */
403 /* See MS-SMB2 section 2.2.9.2 */
405 #define SMB2_RESERVED_TREE_CONNECT_CONTEXT_ID 0x0000
406 #define SMB2_REMOTED_IDENTITY_TREE_CONNECT_CONTEXT_ID cpu_to_le16(0x0001)
408 struct tree_connect_contexts {
415 /* Remoted identity tree connect context structures - see MS-SMB2 2.2.9.2.1 */
416 struct smb3_blob_data {
421 /* Valid values for Attr */
422 #define SE_GROUP_MANDATORY 0x00000001
423 #define SE_GROUP_ENABLED_BY_DEFAULT 0x00000002
424 #define SE_GROUP_ENABLED 0x00000004
425 #define SE_GROUP_OWNER 0x00000008
426 #define SE_GROUP_USE_FOR_DENY_ONLY 0x00000010
427 #define SE_GROUP_INTEGRITY 0x00000020
428 #define SE_GROUP_INTEGRITY_ENABLED 0x00000040
429 #define SE_GROUP_RESOURCE 0x20000000
430 #define SE_GROUP_LOGON_ID 0xC0000000
432 /* struct sid_attr_data is SidData array in BlobData format then le32 Attr */
434 struct sid_array_data {
436 /* SidAttrList - array of sid_attr_data structs */
439 struct luid_attr_data {
444 * struct privilege_data is the same as BLOB_DATA - see MS-SMB2 2.2.9.2.1.5
445 * but with size of LUID_ATTR_DATA struct and BlobData set to LUID_ATTR DATA
448 struct privilege_array_data {
449 __le16 PrivilegeCount;
450 /* array of privilege_data structs */
453 struct remoted_identity_tcon_context {
454 __le16 TicketType; /* must be 0x0001 */
455 __le16 TicketSize; /* total size of this struct */
456 __le16 User; /* offset to SID_ATTR_DATA struct with user info */
457 __le16 UserName; /* offset to null terminated Unicode username string */
458 __le16 Domain; /* offset to null terminated Unicode domain name */
459 __le16 Groups; /* offset to SID_ARRAY_DATA struct with group info */
460 __le16 RestrictedGroups; /* similar to above */
461 __le16 Privileges; /* offset to PRIVILEGE_ARRAY_DATA struct */
462 __le16 PrimaryGroup; /* offset to SID_ARRAY_DATA struct */
463 __le16 Owner; /* offset to BLOB_DATA struct */
464 __le16 DefaultDacl; /* offset to BLOB_DATA struct */
465 __le16 DeviceGroups; /* offset to SID_ARRAY_DATA struct */
466 __le16 UserClaims; /* offset to BLOB_DATA struct */
467 __le16 DeviceClaims; /* offset to BLOB_DATA struct */
468 __u8 TicketInfo[0]; /* variable length buf - remoted identity data */
471 struct smb2_tree_connect_req_extension {
472 __le32 TreeConnectContextOffset;
473 __le16 TreeConnectContextCount;
475 __u8 PathName[0]; /* variable sized array */
476 /* followed by array of TreeConnectContexts */
479 struct smb2_tree_connect_rsp {
480 struct smb2_sync_hdr sync_hdr;
481 __le16 StructureSize; /* Must be 16 */
482 __u8 ShareType; /* see below */
484 __le32 ShareFlags; /* see below */
485 __le32 Capabilities; /* see below */
486 __le32 MaximalAccess;
489 /* Possible ShareType values */
490 #define SMB2_SHARE_TYPE_DISK 0x01
491 #define SMB2_SHARE_TYPE_PIPE 0x02
492 #define SMB2_SHARE_TYPE_PRINT 0x03
495 * Possible ShareFlags - exactly one and only one of the first 4 caching flags
496 * must be set (any of the remaining, SHI1005, flags may be set individually
499 #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000
500 #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010
501 #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020
502 #define SMB2_SHAREFLAG_NO_CACHING 0x00000030
503 #define SHI1005_FLAGS_DFS 0x00000001
504 #define SHI1005_FLAGS_DFS_ROOT 0x00000002
505 #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100
506 #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200
507 #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400
508 #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800
509 #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000
510 #define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000
511 #define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000
512 #define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000
513 #define SMB2_SHAREFLAG_IDENTITY_REMOTING 0x00040000 /* 3.1.1 */
514 #define SHI1005_FLAGS_ALL 0x0004FF33
516 /* Possible share capabilities */
517 #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */
518 #define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */
519 #define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */
520 #define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */
521 #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */
522 #define SMB2_SHARE_CAP_REDIRECT_TO_OWNER cpu_to_le32(0x00000100) /* 3.1.1 */
524 struct smb2_tree_disconnect_req {
525 struct smb2_sync_hdr sync_hdr;
526 __le16 StructureSize; /* Must be 4 */
530 struct smb2_tree_disconnect_rsp {
531 struct smb2_sync_hdr sync_hdr;
532 __le16 StructureSize; /* Must be 4 */
536 /* File Attrubutes */
537 #define FILE_ATTRIBUTE_READONLY 0x00000001
538 #define FILE_ATTRIBUTE_HIDDEN 0x00000002
539 #define FILE_ATTRIBUTE_SYSTEM 0x00000004
540 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
541 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
542 #define FILE_ATTRIBUTE_NORMAL 0x00000080
543 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
544 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
545 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
546 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800
547 #define FILE_ATTRIBUTE_OFFLINE 0x00001000
548 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
549 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
550 #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
551 #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
554 #define SMB2_OPLOCK_LEVEL_NONE 0x00
555 #define SMB2_OPLOCK_LEVEL_II 0x01
556 #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
557 #define SMB2_OPLOCK_LEVEL_BATCH 0x09
558 #define SMB2_OPLOCK_LEVEL_LEASE 0xFF
559 /* Non-spec internal type */
560 #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
562 /* Desired Access Flags */
563 #define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
564 #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
565 #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
566 #define FILE_READ_EA_LE cpu_to_le32(0x00000008)
567 #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
568 #define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
569 #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
570 #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
571 #define FILE_DELETE_LE cpu_to_le32(0x00010000)
572 #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
573 #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
574 #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
575 #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
576 #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
577 #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
578 #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
579 #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
580 #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
581 #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
583 /* ShareAccess Flags */
584 #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
585 #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
586 #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
587 #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
589 /* CreateDisposition Flags */
590 #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
591 #define FILE_OPEN_LE cpu_to_le32(0x00000001)
592 #define FILE_CREATE_LE cpu_to_le32(0x00000002)
593 #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
594 #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
595 #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
597 /* CreateOptions Flags */
598 #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
599 /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
600 #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
601 #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
602 #define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008)
603 #define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010)
604 #define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020)
605 #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
606 #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
607 #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
608 #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
609 #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
610 #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
611 #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
612 #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
613 #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
614 #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
615 #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
616 #define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000)
618 #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
619 | FILE_READ_ATTRIBUTES_LE)
620 #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
621 | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
622 #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
624 /* Impersonation Levels */
625 #define IL_ANONYMOUS cpu_to_le32(0x00000000)
626 #define IL_IDENTIFICATION cpu_to_le32(0x00000001)
627 #define IL_IMPERSONATION cpu_to_le32(0x00000002)
628 #define IL_DELEGATE cpu_to_le32(0x00000003)
630 /* Create Context Values */
631 #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */
632 #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */
633 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
634 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
635 #define SMB2_CREATE_ALLOCATION_SIZE "AISi"
636 #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
637 #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
638 #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
639 #define SMB2_CREATE_REQUEST_LEASE "RqLs"
640 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q"
641 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C"
642 #define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74
643 #define SVHDX_OPEN_DEVICE_CONTEX 0x9CCBCF9E04C1E643980E158DA1F6EC83
644 #define SMB2_CREATE_TAG_POSIX 0x93AD25509CB411E7B42383DE968BCD7C
646 /* Flag (SMB3 open response) values */
647 #define SMB2_CREATE_FLAG_REPARSEPOINT 0x01
650 * Maximum number of iovs we need for an open/create request.
651 * [0] : struct smb2_create_req
653 * [2] : lease context
654 * [3] : durable context
655 * [4] : posix context
656 * [5] : time warp context
657 * [6] : compound padding
659 #define SMB2_CREATE_IOV_SIZE 7
661 struct smb2_create_req {
662 struct smb2_sync_hdr sync_hdr;
663 __le16 StructureSize; /* Must be 57 */
665 __u8 RequestedOplockLevel;
666 __le32 ImpersonationLevel;
667 __le64 SmbCreateFlags;
669 __le32 DesiredAccess;
670 __le32 FileAttributes;
672 __le32 CreateDisposition;
673 __le32 CreateOptions;
676 __le32 CreateContextsOffset;
677 __le32 CreateContextsLength;
682 * Maximum size of a SMB2_CREATE response is 64 (smb2 header) +
683 * 88 (fixed part of create response) + 520 (path) + 150 (contexts) +
684 * 2 bytes of padding.
686 #define MAX_SMB2_CREATE_RESPONSE_SIZE 824
688 struct smb2_create_rsp {
689 struct smb2_sync_hdr sync_hdr;
690 __le16 StructureSize; /* Must be 89 */
692 __u8 Flag; /* 0x01 if reparse point */
695 __le64 LastAccessTime;
696 __le64 LastWriteTime;
698 __le64 AllocationSize;
700 __le32 FileAttributes;
702 __u64 PersistentFileId; /* opaque endianness */
703 __u64 VolatileFileId; /* opaque endianness */
704 __le32 CreateContextsOffset;
705 __le32 CreateContextsLength;
709 struct create_context {
719 #define SMB2_LEASE_READ_CACHING_HE 0x01
720 #define SMB2_LEASE_HANDLE_CACHING_HE 0x02
721 #define SMB2_LEASE_WRITE_CACHING_HE 0x04
723 #define SMB2_LEASE_NONE cpu_to_le32(0x00)
724 #define SMB2_LEASE_READ_CACHING cpu_to_le32(0x01)
725 #define SMB2_LEASE_HANDLE_CACHING cpu_to_le32(0x02)
726 #define SMB2_LEASE_WRITE_CACHING cpu_to_le32(0x04)
728 #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS cpu_to_le32(0x02)
729 #define SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET cpu_to_le32(0x00000004)
731 #define SMB2_LEASE_KEY_SIZE 16
733 struct lease_context {
734 u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
737 __le64 LeaseDuration;
740 struct lease_context_v2 {
741 u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
744 __le64 LeaseDuration;
745 __le64 ParentLeaseKeyLow;
746 __le64 ParentLeaseKeyHigh;
751 struct create_lease {
752 struct create_context ccontext;
754 struct lease_context lcontext;
757 struct create_lease_v2 {
758 struct create_context ccontext;
760 struct lease_context_v2 lcontext;
764 struct create_durable {
765 struct create_context ccontext;
770 __u64 PersistentFileId;
771 __u64 VolatileFileId;
776 struct create_posix {
777 struct create_context ccontext;
783 /* See MS-SMB2 2.2.13.2.11 */
785 #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
786 struct durable_context_v2 {
793 struct create_durable_v2 {
794 struct create_context ccontext;
796 struct durable_context_v2 dcontext;
799 /* See MS-SMB2 2.2.13.2.12 */
800 struct durable_reconnect_context_v2 {
802 __u64 PersistentFileId;
803 __u64 VolatileFileId;
806 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
809 /* See MS-SMB2 2.2.14.2.12 */
810 struct durable_reconnect_context_v2_rsp {
812 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
815 struct create_durable_handle_reconnect_v2 {
816 struct create_context ccontext;
818 struct durable_reconnect_context_v2 dcontext;
821 /* See MS-SMB2 2.2.13.2.5 */
822 struct crt_twarp_ctxt {
823 struct create_context ccontext;
829 #define COPY_CHUNK_RES_KEY_SIZE 24
830 struct resume_key_req {
831 char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
832 __le32 ContextLength; /* MBZ */
833 char Context[0]; /* ignored, Windows sets to 4 bytes of zero */
836 /* this goes in the ioctl buffer when doing a copychunk request */
837 struct copychunk_ioctl {
838 char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
839 __le32 ChunkCount; /* we are only sending 1 */
841 /* array will only be one chunk long for us */
844 __le32 Length; /* how many bytes to copy */
848 /* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */
849 struct file_zero_data_information {
851 __le64 BeyondFinalZero;
854 struct copychunk_ioctl_rsp {
855 __le32 ChunksWritten;
856 __le32 ChunkBytesWritten;
857 __le32 TotalBytesWritten;
860 struct fsctl_set_integrity_information_req {
861 __le16 ChecksumAlgorithm;
866 struct fsctl_get_integrity_information_rsp {
867 __le16 ChecksumAlgorithm;
870 __le32 ChecksumChunkSizeInBytes;
871 __le32 ClusterSizeInBytes;
874 struct file_allocated_range_buffer {
879 /* Integrity ChecksumAlgorithm choices for above */
880 #define CHECKSUM_TYPE_NONE 0x0000
881 #define CHECKSUM_TYPE_CRC64 0x0002
882 #define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */
884 /* Integrity flags for above */
885 #define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001
887 /* Reparse structures - see MS-FSCC 2.1.2 */
889 /* struct fsctl_reparse_info_req is empty, only response structs (see below) */
891 struct reparse_data_buffer {
893 __le16 ReparseDataLength;
895 __u8 DataBuffer[0]; /* Variable Length */
898 struct reparse_guid_data_buffer {
900 __le16 ReparseDataLength;
902 __u8 ReparseGuid[16];
903 __u8 DataBuffer[0]; /* Variable Length */
906 struct reparse_mount_point_data_buffer {
908 __le16 ReparseDataLength;
910 __le16 SubstituteNameOffset;
911 __le16 SubstituteNameLength;
912 __le16 PrintNameOffset;
913 __le16 PrintNameLength;
914 __u8 PathBuffer[0]; /* Variable Length */
917 #define SYMLINK_FLAG_RELATIVE 0x00000001
919 struct reparse_symlink_data_buffer {
921 __le16 ReparseDataLength;
923 __le16 SubstituteNameOffset;
924 __le16 SubstituteNameLength;
925 __le16 PrintNameOffset;
926 __le16 PrintNameLength;
928 __u8 PathBuffer[0]; /* Variable Length */
931 /* See MS-FSCC 2.1.2.6 and cifspdu.h for struct reparse_posix_data */
934 /* See MS-DFSC 2.2.2 */
935 struct fsctl_get_dfs_referral_req {
936 __le16 MaxReferralLevel;
937 __u8 RequestFileName[];
940 /* DFS response is struct get_dfs_refer_rsp */
942 /* See MS-SMB2 2.2.31.3 */
943 struct network_resiliency_req {
947 /* There is no buffer for the response ie no struct network_resiliency_rsp */
950 struct validate_negotiate_info_req {
952 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
955 __le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */
958 struct validate_negotiate_info_rsp {
960 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
962 __le16 Dialect; /* Dialect in use for the connection */
965 #define RSS_CAPABLE cpu_to_le32(0x00000001)
966 #define RDMA_CAPABLE cpu_to_le32(0x00000002)
968 #define INTERNETWORK cpu_to_le16(0x0002)
969 #define INTERNETWORKV6 cpu_to_le16(0x0017)
971 struct network_interface_info_ioctl_rsp {
972 __le32 Next; /* next interface. zero if this is last one */
974 __le32 Capability; /* RSS or RDMA Capable */
981 struct iface_info_ipv4 {
987 struct iface_info_ipv6 {
990 __u8 IPv6Address[16];
994 #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
996 struct compress_ioctl {
997 __le16 CompressionState; /* See cifspdu.h for possible flag values */
1000 struct duplicate_extents_to_file {
1001 __u64 PersistentFileHandle; /* source file handle, opaque endianness */
1002 __u64 VolatileFileHandle;
1003 __le64 SourceFileOffset;
1004 __le64 TargetFileOffset;
1005 __le64 ByteCount; /* Bytes to be copied */
1009 * Maximum number of iovs we need for an ioctl request.
1010 * [0] : struct smb2_ioctl_req
1013 #define SMB2_IOCTL_IOV_SIZE 2
1015 struct smb2_ioctl_req {
1016 struct smb2_sync_hdr sync_hdr;
1017 __le16 StructureSize; /* Must be 57 */
1020 __u64 PersistentFileId; /* opaque endianness */
1021 __u64 VolatileFileId; /* opaque endianness */
1024 __le32 MaxInputResponse;
1025 __le32 OutputOffset;
1027 __le32 MaxOutputResponse;
1033 struct smb2_ioctl_rsp {
1034 struct smb2_sync_hdr sync_hdr;
1035 __le16 StructureSize; /* Must be 57 */
1038 __u64 PersistentFileId; /* opaque endianness */
1039 __u64 VolatileFileId; /* opaque endianness */
1042 __le32 OutputOffset;
1046 /* char * buffer[] */
1049 /* Currently defined values for close flags */
1050 #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001)
1051 struct smb2_close_req {
1052 struct smb2_sync_hdr sync_hdr;
1053 __le16 StructureSize; /* Must be 24 */
1056 __u64 PersistentFileId; /* opaque endianness */
1057 __u64 VolatileFileId; /* opaque endianness */
1061 * Maximum size of a SMB2_CLOSE response is 64 (smb2 header) + 60 (data)
1063 #define MAX_SMB2_CLOSE_RESPONSE_SIZE 124
1065 struct smb2_close_rsp {
1066 struct smb2_sync_hdr sync_hdr;
1067 __le16 StructureSize; /* 60 */
1070 __le64 CreationTime;
1071 __le64 LastAccessTime;
1072 __le64 LastWriteTime;
1074 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
1079 struct smb2_flush_req {
1080 struct smb2_sync_hdr sync_hdr;
1081 __le16 StructureSize; /* Must be 24 */
1084 __u64 PersistentFileId; /* opaque endianness */
1085 __u64 VolatileFileId; /* opaque endianness */
1088 struct smb2_flush_rsp {
1089 struct smb2_sync_hdr sync_hdr;
1090 __le16 StructureSize;
1094 /* For read request Flags field below, following flag is defined for SMB3.02 */
1095 #define SMB2_READFLAG_READ_UNBUFFERED 0x01
1096 #define SMB2_READFLAG_REQUEST_COMPRESSED 0x02 /* See MS-SMB2 2.2.19 */
1098 /* Channel field for read and write: exactly one of following flags can be set*/
1099 #define SMB2_CHANNEL_NONE cpu_to_le32(0x00000000)
1100 #define SMB2_CHANNEL_RDMA_V1 cpu_to_le32(0x00000001) /* SMB3 or later */
1101 #define SMB2_CHANNEL_RDMA_V1_INVALIDATE cpu_to_le32(0x00000002) /* >= SMB3.02 */
1103 /* SMB2 read request without RFC1001 length at the beginning */
1104 struct smb2_read_plain_req {
1105 struct smb2_sync_hdr sync_hdr;
1106 __le16 StructureSize; /* Must be 49 */
1107 __u8 Padding; /* offset from start of SMB2 header to place read */
1108 __u8 Flags; /* MBZ unless SMB3.02 or later */
1111 __u64 PersistentFileId; /* opaque endianness */
1112 __u64 VolatileFileId; /* opaque endianness */
1113 __le32 MinimumCount;
1114 __le32 Channel; /* MBZ except for SMB3 or later */
1115 __le32 RemainingBytes;
1116 __le16 ReadChannelInfoOffset;
1117 __le16 ReadChannelInfoLength;
1121 struct smb2_read_rsp {
1122 struct smb2_sync_hdr sync_hdr;
1123 __le16 StructureSize; /* Must be 17 */
1127 __le32 DataRemaining;
1132 /* For write request Flags field below the following flags are defined: */
1133 #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */
1134 #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */
1136 struct smb2_write_req {
1137 struct smb2_sync_hdr sync_hdr;
1138 __le16 StructureSize; /* Must be 49 */
1139 __le16 DataOffset; /* offset from start of SMB2 header to write data */
1142 __u64 PersistentFileId; /* opaque endianness */
1143 __u64 VolatileFileId; /* opaque endianness */
1144 __le32 Channel; /* Reserved MBZ */
1145 __le32 RemainingBytes;
1146 __le16 WriteChannelInfoOffset;
1147 __le16 WriteChannelInfoLength;
1152 struct smb2_write_rsp {
1153 struct smb2_sync_hdr sync_hdr;
1154 __le16 StructureSize; /* Must be 17 */
1158 __le32 DataRemaining;
1164 #define SMB2_WATCH_TREE 0x0001
1166 /* notify completion filter flags. See MS-FSCC 2.6 and MS-SMB2 2.2.35 */
1167 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
1168 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
1169 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
1170 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008
1171 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
1172 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
1173 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040
1174 #define FILE_NOTIFY_CHANGE_EA 0x00000080
1175 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
1176 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
1177 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
1178 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1180 struct smb2_change_notify_req {
1181 struct smb2_sync_hdr sync_hdr;
1182 __le16 StructureSize;
1184 __le32 OutputBufferLength;
1185 __u64 PersistentFileId; /* opaque endianness */
1186 __u64 VolatileFileId; /* opaque endianness */
1187 __le32 CompletionFilter;
1191 struct smb2_change_notify_rsp {
1192 struct smb2_sync_hdr sync_hdr;
1193 __le16 StructureSize; /* Must be 9 */
1194 __le16 OutputBufferOffset;
1195 __le32 OutputBufferLength;
1196 __u8 Buffer[1]; /* array of file notify structs */
1199 #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001
1200 #define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002
1201 #define SMB2_LOCKFLAG_UNLOCK 0x0004
1202 #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
1204 struct smb2_lock_element {
1211 struct smb2_lock_req {
1212 struct smb2_sync_hdr sync_hdr;
1213 __le16 StructureSize; /* Must be 48 */
1216 __u64 PersistentFileId; /* opaque endianness */
1217 __u64 VolatileFileId; /* opaque endianness */
1218 /* Followed by at least one */
1219 struct smb2_lock_element locks[1];
1222 struct smb2_lock_rsp {
1223 struct smb2_sync_hdr sync_hdr;
1224 __le16 StructureSize; /* Must be 4 */
1228 struct smb2_echo_req {
1229 struct smb2_sync_hdr sync_hdr;
1230 __le16 StructureSize; /* Must be 4 */
1234 struct smb2_echo_rsp {
1235 struct smb2_sync_hdr sync_hdr;
1236 __le16 StructureSize; /* Must be 4 */
1240 /* search (query_directory) Flags field */
1241 #define SMB2_RESTART_SCANS 0x01
1242 #define SMB2_RETURN_SINGLE_ENTRY 0x02
1243 #define SMB2_INDEX_SPECIFIED 0x04
1244 #define SMB2_REOPEN 0x10
1246 struct smb2_query_directory_req {
1247 struct smb2_sync_hdr sync_hdr;
1248 __le16 StructureSize; /* Must be 33 */
1249 __u8 FileInformationClass;
1252 __u64 PersistentFileId; /* opaque endianness */
1253 __u64 VolatileFileId; /* opaque endianness */
1254 __le16 FileNameOffset;
1255 __le16 FileNameLength;
1256 __le32 OutputBufferLength;
1260 struct smb2_query_directory_rsp {
1261 struct smb2_sync_hdr sync_hdr;
1262 __le16 StructureSize; /* Must be 9 */
1263 __le16 OutputBufferOffset;
1264 __le32 OutputBufferLength;
1268 /* Possible InfoType values */
1269 #define SMB2_O_INFO_FILE 0x01
1270 #define SMB2_O_INFO_FILESYSTEM 0x02
1271 #define SMB2_O_INFO_SECURITY 0x03
1272 #define SMB2_O_INFO_QUOTA 0x04
1274 /* Security info type additionalinfo flags. See MS-SMB2 (2.2.37) or MS-DTYP */
1275 #define OWNER_SECINFO 0x00000001
1276 #define GROUP_SECINFO 0x00000002
1277 #define DACL_SECINFO 0x00000004
1278 #define SACL_SECINFO 0x00000008
1279 #define LABEL_SECINFO 0x00000010
1280 #define ATTRIBUTE_SECINFO 0x00000020
1281 #define SCOPE_SECINFO 0x00000040
1282 #define BACKUP_SECINFO 0x00010000
1283 #define UNPROTECTED_SACL_SECINFO 0x10000000
1284 #define UNPROTECTED_DACL_SECINFO 0x20000000
1285 #define PROTECTED_SACL_SECINFO 0x40000000
1286 #define PROTECTED_DACL_SECINFO 0x80000000
1288 /* Flags used for FileFullEAinfo */
1289 #define SL_RESTART_SCAN 0x00000001
1290 #define SL_RETURN_SINGLE_ENTRY 0x00000002
1291 #define SL_INDEX_SPECIFIED 0x00000004
1293 struct smb2_query_info_req {
1294 struct smb2_sync_hdr sync_hdr;
1295 __le16 StructureSize; /* Must be 41 */
1298 __le32 OutputBufferLength;
1299 __le16 InputBufferOffset;
1301 __le32 InputBufferLength;
1302 __le32 AdditionalInformation;
1304 __u64 PersistentFileId; /* opaque endianness */
1305 __u64 VolatileFileId; /* opaque endianness */
1309 struct smb2_query_info_rsp {
1310 struct smb2_sync_hdr sync_hdr;
1311 __le16 StructureSize; /* Must be 9 */
1312 __le16 OutputBufferOffset;
1313 __le32 OutputBufferLength;
1318 * Maximum number of iovs we need for a set-info request.
1319 * The largest one is rename/hardlink
1320 * [0] : struct smb2_set_info_req + smb2_file_[rename|link]_info
1322 * [2] : compound padding
1324 #define SMB2_SET_INFO_IOV_SIZE 3
1326 struct smb2_set_info_req {
1327 struct smb2_sync_hdr sync_hdr;
1328 __le16 StructureSize; /* Must be 33 */
1331 __le32 BufferLength;
1332 __le16 BufferOffset;
1334 __le32 AdditionalInformation;
1335 __u64 PersistentFileId; /* opaque endianness */
1336 __u64 VolatileFileId; /* opaque endianness */
1340 struct smb2_set_info_rsp {
1341 struct smb2_sync_hdr sync_hdr;
1342 __le16 StructureSize; /* Must be 2 */
1345 struct smb2_oplock_break {
1346 struct smb2_sync_hdr sync_hdr;
1347 __le16 StructureSize; /* Must be 24 */
1351 __u64 PersistentFid;
1355 #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
1357 struct smb2_lease_break {
1358 struct smb2_sync_hdr sync_hdr;
1359 __le16 StructureSize; /* Must be 44 */
1363 __le32 CurrentLeaseState;
1364 __le32 NewLeaseState;
1366 __le32 AccessMaskHint;
1367 __le32 ShareMaskHint;
1370 struct smb2_lease_ack {
1371 struct smb2_sync_hdr sync_hdr;
1372 __le16 StructureSize; /* Must be 36 */
1377 __le64 LeaseDuration;
1381 * PDU infolevel structure definitions
1382 * BB consider moving to a different header
1385 /* File System Information Classes */
1386 #define FS_VOLUME_INFORMATION 1 /* Query */
1387 #define FS_LABEL_INFORMATION 2 /* Local only */
1388 #define FS_SIZE_INFORMATION 3 /* Query */
1389 #define FS_DEVICE_INFORMATION 4 /* Query */
1390 #define FS_ATTRIBUTE_INFORMATION 5 /* Query */
1391 #define FS_CONTROL_INFORMATION 6 /* Query, Set */
1392 #define FS_FULL_SIZE_INFORMATION 7 /* Query */
1393 #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
1394 #define FS_DRIVER_PATH_INFORMATION 9 /* Local only */
1395 #define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */
1396 #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
1397 #define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */
1399 struct smb2_fs_full_size_info {
1400 __le64 TotalAllocationUnits;
1401 __le64 CallerAvailableAllocationUnits;
1402 __le64 ActualAvailableAllocationUnits;
1403 __le32 SectorsPerAllocationUnit;
1404 __le32 BytesPerSector;
1407 #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
1408 #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
1409 #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
1410 #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
1412 /* sector size info struct */
1413 struct smb3_fs_ss_info {
1414 __le32 LogicalBytesPerSector;
1415 __le32 PhysicalBytesPerSectorForAtomicity;
1416 __le32 PhysicalBytesPerSectorForPerf;
1417 __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
1419 __le32 ByteOffsetForSectorAlignment;
1420 __le32 ByteOffsetForPartitionAlignment;
1423 /* volume info struct - see MS-FSCC 2.5.9 */
1424 #define MAX_VOL_LABEL_LEN 32
1425 struct smb3_fs_vol_info {
1426 __le64 VolumeCreationTime;
1427 __u32 VolumeSerialNumber;
1428 __le32 VolumeLabelLength; /* includes trailing null */
1429 __u8 SupportsObjects; /* True if eg like NTFS, supports objects */
1431 __u8 VolumeLabel[0]; /* variable len */
1434 /* partial list of QUERY INFO levels */
1435 #define FILE_DIRECTORY_INFORMATION 1
1436 #define FILE_FULL_DIRECTORY_INFORMATION 2
1437 #define FILE_BOTH_DIRECTORY_INFORMATION 3
1438 #define FILE_BASIC_INFORMATION 4
1439 #define FILE_STANDARD_INFORMATION 5
1440 #define FILE_INTERNAL_INFORMATION 6
1441 #define FILE_EA_INFORMATION 7
1442 #define FILE_ACCESS_INFORMATION 8
1443 #define FILE_NAME_INFORMATION 9
1444 #define FILE_RENAME_INFORMATION 10
1445 #define FILE_LINK_INFORMATION 11
1446 #define FILE_NAMES_INFORMATION 12
1447 #define FILE_DISPOSITION_INFORMATION 13
1448 #define FILE_POSITION_INFORMATION 14
1449 #define FILE_FULL_EA_INFORMATION 15
1450 #define FILE_MODE_INFORMATION 16
1451 #define FILE_ALIGNMENT_INFORMATION 17
1452 #define FILE_ALL_INFORMATION 18
1453 #define FILE_ALLOCATION_INFORMATION 19
1454 #define FILE_END_OF_FILE_INFORMATION 20
1455 #define FILE_ALTERNATE_NAME_INFORMATION 21
1456 #define FILE_STREAM_INFORMATION 22
1457 #define FILE_PIPE_INFORMATION 23
1458 #define FILE_PIPE_LOCAL_INFORMATION 24
1459 #define FILE_PIPE_REMOTE_INFORMATION 25
1460 #define FILE_MAILSLOT_QUERY_INFORMATION 26
1461 #define FILE_MAILSLOT_SET_INFORMATION 27
1462 #define FILE_COMPRESSION_INFORMATION 28
1463 #define FILE_OBJECT_ID_INFORMATION 29
1464 /* Number 30 not defined in documents */
1465 #define FILE_MOVE_CLUSTER_INFORMATION 31
1466 #define FILE_QUOTA_INFORMATION 32
1467 #define FILE_REPARSE_POINT_INFORMATION 33
1468 #define FILE_NETWORK_OPEN_INFORMATION 34
1469 #define FILE_ATTRIBUTE_TAG_INFORMATION 35
1470 #define FILE_TRACKING_INFORMATION 36
1471 #define FILEID_BOTH_DIRECTORY_INFORMATION 37
1472 #define FILEID_FULL_DIRECTORY_INFORMATION 38
1473 #define FILE_VALID_DATA_LENGTH_INFORMATION 39
1474 #define FILE_SHORT_NAME_INFORMATION 40
1475 #define FILE_SFIO_RESERVE_INFORMATION 44
1476 #define FILE_SFIO_VOLUME_INFORMATION 45
1477 #define FILE_HARD_LINK_INFORMATION 46
1478 #define FILE_NORMALIZED_NAME_INFORMATION 48
1479 #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
1480 #define FILE_STANDARD_LINK_INFORMATION 54
1482 struct smb2_file_internal_info {
1484 } __packed; /* level 6 Query */
1486 struct smb2_file_rename_info { /* encoding of request for level 10 */
1487 __u8 ReplaceIfExists; /* 1 = replace existing target with new */
1488 /* 0 = fail if target already exists */
1490 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1491 __le32 FileNameLength;
1492 char FileName[0]; /* New name to be assigned */
1493 } __packed; /* level 10 Set */
1495 struct smb2_file_link_info { /* encoding of request for level 11 */
1496 __u8 ReplaceIfExists; /* 1 = replace existing link with new */
1497 /* 0 = fail if link already exists */
1499 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1500 __le32 FileNameLength;
1501 char FileName[0]; /* Name to be assigned to new link */
1502 } __packed; /* level 11 Set */
1504 struct smb2_file_full_ea_info { /* encoding of response for level 15 */
1505 __le32 next_entry_offset;
1507 __u8 ea_name_length;
1508 __le16 ea_value_length;
1509 char ea_data[0]; /* \0 terminated name plus value */
1510 } __packed; /* level 15 Set */
1513 * This level 18, although with struct with same name is different from cifs
1514 * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
1515 * CurrentByteOffset.
1517 struct smb2_file_all_info { /* data block encoding of response to level 18 */
1518 __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
1519 __le64 LastAccessTime;
1520 __le64 LastWriteTime;
1523 __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
1524 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
1525 __le64 EndOfFile; /* size ie offset to first free byte in file */
1526 __le32 NumberOfLinks; /* hard links */
1529 __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */
1533 __le64 CurrentByteOffset;
1535 __le32 AlignmentRequirement;
1536 __le32 FileNameLength;
1538 } __packed; /* level 18 Query */
1540 struct smb2_file_eof_info { /* encoding of request for level 10 */
1541 __le64 EndOfFile; /* new end of file value */
1542 } __packed; /* level 20 Set */
1544 extern char smb2_padding[7];
1546 #endif /* _SMB2PDU_H */