1 /* 2 * fs/cifs/smb2pdu.h 3 * 4 * Copyright (c) International Business Machines Corp., 2009, 2013 5 * Etersoft, 2012 6 * Author(s): Steve French (sfrench@us.ibm.com) 7 * Pavel Shilovsky (pshilovsky@samba.org) 2012 8 * 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. 13 * 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. 18 * 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 22 */ 23 24 #ifndef _SMB2PDU_H 25 #define _SMB2PDU_H 26 27 #include <net/sock.h> 28 29 /* 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. 34 * 35 * SMB2 commands 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. 39 */ 40 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 61 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) 82 83 #define SMB2_INTERNAL_CMD cpu_to_le16(0xFFFF) 84 85 #define NUMBER_OF_SMB2_COMMANDS 0x0013 86 87 /* 4 len + 52 transform hdr + 64 hdr + 56 create rsp */ 88 #define MAX_SMB2_HDR_SIZE 0x00b0 89 90 #define SMB2_PROTO_NUMBER cpu_to_le32(0x424d53fe) 91 #define SMB2_TRANSFORM_PROTO_NUM cpu_to_le32(0x424d53fd) 92 93 /* 94 * SMB2 Header Definition 95 * 96 * "MBZ" : Must be Zero 97 * "BB" : BugBug, Something to check/review/analyze later 98 * "PDU" : "Protocol Data Unit" (ie a network "frame") 99 * 100 */ 101 102 #define SMB2_HEADER_STRUCTURE_SIZE cpu_to_le16(64) 103 104 struct smb2_hdr { 105 __be32 smb2_buf_length; /* big endian on wire */ 106 /* length is only two or three bytes - with 107 one or two byte type preceding it that MBZ */ 108 __le32 ProtocolId; /* 0xFE 'S' 'M' 'B' */ 109 __le16 StructureSize; /* 64 */ 110 __le16 CreditCharge; /* MBZ */ 111 __le32 Status; /* Error from server */ 112 __le16 Command; 113 __le16 CreditRequest; /* CreditResponse */ 114 __le32 Flags; 115 __le32 NextCommand; 116 __le64 MessageId; 117 __le32 ProcessId; 118 __u32 TreeId; /* opaque - so do not make little endian */ 119 __u64 SessionId; /* opaque - so do not make little endian */ 120 __u8 Signature[16]; 121 } __packed; 122 123 struct smb2_pdu { 124 struct smb2_hdr hdr; 125 __le16 StructureSize2; /* size of wct area (varies, request specific) */ 126 } __packed; 127 128 struct smb2_transform_hdr { 129 __be32 smb2_buf_length; /* big endian on wire */ 130 /* length is only two or three bytes - with 131 one or two byte type preceding it that MBZ */ 132 __u8 ProtocolId[4]; /* 0xFD 'S' 'M' 'B' */ 133 __u8 Signature[16]; 134 __u8 Nonce[16]; 135 __le32 OriginalMessageSize; 136 __u16 Reserved1; 137 __le16 Flags; /* EncryptionAlgorithm */ 138 __u64 SessionId; 139 } __packed; 140 141 /* 142 * SMB2 flag definitions 143 */ 144 #define SMB2_FLAGS_SERVER_TO_REDIR cpu_to_le32(0x00000001) 145 #define SMB2_FLAGS_ASYNC_COMMAND cpu_to_le32(0x00000002) 146 #define SMB2_FLAGS_RELATED_OPERATIONS cpu_to_le32(0x00000004) 147 #define SMB2_FLAGS_SIGNED cpu_to_le32(0x00000008) 148 #define SMB2_FLAGS_DFS_OPERATIONS cpu_to_le32(0x10000000) 149 150 /* 151 * Definitions for SMB2 Protocol Data Units (network frames) 152 * 153 * See MS-SMB2.PDF specification for protocol details. 154 * The Naming convention is the lower case version of the SMB2 155 * command code name for the struct. Note that structures must be packed. 156 * 157 */ 158 159 #define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9) 160 161 struct smb2_err_rsp { 162 struct smb2_hdr 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 */ 167 } __packed; 168 169 struct smb2_symlink_err_rsp { 170 __le32 SymLinkLength; 171 __le32 SymLinkErrorTag; 172 __le32 ReparseTag; 173 __le16 ReparseDataLength; 174 __le16 UnparsedPathLength; 175 __le16 SubstituteNameOffset; 176 __le16 SubstituteNameLength; 177 __le16 PrintNameOffset; 178 __le16 PrintNameLength; 179 __le32 Flags; 180 __u8 PathBuffer[0]; 181 } __packed; 182 183 #define SMB2_CLIENT_GUID_SIZE 16 184 185 struct smb2_negotiate_req { 186 struct smb2_hdr hdr; 187 __le16 StructureSize; /* Must be 36 */ 188 __le16 DialectCount; 189 __le16 SecurityMode; 190 __le16 Reserved; /* MBZ */ 191 __le32 Capabilities; 192 __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE]; 193 /* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */ 194 __le32 NegotiateContextOffset; /* SMB3.1.1 only. MBZ earlier */ 195 __le16 NegotiateContextCount; /* SMB3.1.1 only. MBZ earlier */ 196 __le16 Reserved2; 197 __le16 Dialects[1]; /* One dialect (vers=) at a time for now */ 198 } __packed; 199 200 /* Dialects */ 201 #define SMB20_PROT_ID 0x0202 202 #define SMB21_PROT_ID 0x0210 203 #define SMB30_PROT_ID 0x0300 204 #define SMB302_PROT_ID 0x0302 205 #define SMB311_PROT_ID 0x0311 206 #define BAD_PROT_ID 0xFFFF 207 208 /* SecurityMode flags */ 209 #define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001 210 #define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002 211 /* Capabilities flags */ 212 #define SMB2_GLOBAL_CAP_DFS 0x00000001 213 #define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */ 214 #define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */ 215 #define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */ 216 #define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */ 217 #define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */ 218 #define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */ 219 /* Internal types */ 220 #define SMB2_NT_FIND 0x00100000 221 #define SMB2_LARGE_FILES 0x00200000 222 223 #define SMB311_SALT_SIZE 32 224 /* Hash Algorithm Types */ 225 #define SMB2_PREAUTH_INTEGRITY_SHA512 cpu_to_le16(0x0001) 226 227 struct smb2_preauth_neg_context { 228 __le16 ContextType; /* 1 */ 229 __le16 DataLength; 230 __le32 Reserved; 231 __le16 HashAlgorithmCount; /* 1 */ 232 __le16 SaltLength; 233 __le16 HashAlgorithms; /* HashAlgorithms[0] since only one defined */ 234 __u8 Salt[SMB311_SALT_SIZE]; 235 } __packed; 236 237 /* Encryption Algorithms Ciphers */ 238 #define SMB2_ENCRYPTION_AES128_CCM cpu_to_le16(0x0001) 239 #define SMB2_ENCRYPTION_AES128_GCM cpu_to_le16(0x0002) 240 241 struct smb2_encryption_neg_context { 242 __le16 ContextType; /* 2 */ 243 __le16 DataLength; 244 __le32 Reserved; 245 __le16 CipherCount; /* AES-128-GCM and AES-128-CCM */ 246 __le16 Ciphers[2]; /* Ciphers[0] since only one used now */ 247 } __packed; 248 249 struct smb2_negotiate_rsp { 250 struct smb2_hdr hdr; 251 __le16 StructureSize; /* Must be 65 */ 252 __le16 SecurityMode; 253 __le16 DialectRevision; 254 __le16 NegotiateContextCount; /* Prior to SMB3.1.1 was Reserved & MBZ */ 255 __u8 ServerGUID[16]; 256 __le32 Capabilities; 257 __le32 MaxTransactSize; 258 __le32 MaxReadSize; 259 __le32 MaxWriteSize; 260 __le64 SystemTime; /* MBZ */ 261 __le64 ServerStartTime; 262 __le16 SecurityBufferOffset; 263 __le16 SecurityBufferLength; 264 __le32 NegotiateContextOffset; /* Pre:SMB3.1.1 was reserved/ignored */ 265 __u8 Buffer[1]; /* variable length GSS security buffer */ 266 } __packed; 267 268 /* Flags */ 269 #define SMB2_SESSION_REQ_FLAG_BINDING 0x01 270 #define SMB2_SESSION_REQ_FLAG_ENCRYPT_DATA 0x04 271 272 struct smb2_sess_setup_req { 273 struct smb2_hdr hdr; 274 __le16 StructureSize; /* Must be 25 */ 275 __u8 Flags; 276 __u8 SecurityMode; 277 __le32 Capabilities; 278 __le32 Channel; 279 __le16 SecurityBufferOffset; 280 __le16 SecurityBufferLength; 281 __u64 PreviousSessionId; 282 __u8 Buffer[1]; /* variable length GSS security buffer */ 283 } __packed; 284 285 /* Currently defined SessionFlags */ 286 #define SMB2_SESSION_FLAG_IS_GUEST 0x0001 287 #define SMB2_SESSION_FLAG_IS_NULL 0x0002 288 #define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004 289 struct smb2_sess_setup_rsp { 290 struct smb2_hdr hdr; 291 __le16 StructureSize; /* Must be 9 */ 292 __le16 SessionFlags; 293 __le16 SecurityBufferOffset; 294 __le16 SecurityBufferLength; 295 __u8 Buffer[1]; /* variable length GSS security buffer */ 296 } __packed; 297 298 struct smb2_logoff_req { 299 struct smb2_hdr hdr; 300 __le16 StructureSize; /* Must be 4 */ 301 __le16 Reserved; 302 } __packed; 303 304 struct smb2_logoff_rsp { 305 struct smb2_hdr hdr; 306 __le16 StructureSize; /* Must be 4 */ 307 __le16 Reserved; 308 } __packed; 309 310 /* Flags/Reserved for SMB3.1.1 */ 311 #define SMB2_SHAREFLAG_CLUSTER_RECONNECT 0x0001 312 313 struct smb2_tree_connect_req { 314 struct smb2_hdr hdr; 315 __le16 StructureSize; /* Must be 9 */ 316 __le16 Reserved; /* Flags in SMB3.1.1 */ 317 __le16 PathOffset; 318 __le16 PathLength; 319 __u8 Buffer[1]; /* variable length */ 320 } __packed; 321 322 struct smb2_tree_connect_rsp { 323 struct smb2_hdr hdr; 324 __le16 StructureSize; /* Must be 16 */ 325 __u8 ShareType; /* see below */ 326 __u8 Reserved; 327 __le32 ShareFlags; /* see below */ 328 __le32 Capabilities; /* see below */ 329 __le32 MaximalAccess; 330 } __packed; 331 332 /* Possible ShareType values */ 333 #define SMB2_SHARE_TYPE_DISK 0x01 334 #define SMB2_SHARE_TYPE_PIPE 0x02 335 #define SMB2_SHARE_TYPE_PRINT 0x03 336 337 /* 338 * Possible ShareFlags - exactly one and only one of the first 4 caching flags 339 * must be set (any of the remaining, SHI1005, flags may be set individually 340 * or in combination. 341 */ 342 #define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000 343 #define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010 344 #define SMB2_SHAREFLAG_VDO_CACHING 0x00000020 345 #define SMB2_SHAREFLAG_NO_CACHING 0x00000030 346 #define SHI1005_FLAGS_DFS 0x00000001 347 #define SHI1005_FLAGS_DFS_ROOT 0x00000002 348 #define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100 349 #define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200 350 #define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400 351 #define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800 352 #define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000 353 #define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000 354 #define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000 355 #define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000 356 #define SHI1005_FLAGS_ALL 0x0000FF33 357 358 /* Possible share capabilities */ 359 #define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */ 360 #define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */ 361 #define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */ 362 #define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */ 363 #define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */ 364 365 struct smb2_tree_disconnect_req { 366 struct smb2_hdr hdr; 367 __le16 StructureSize; /* Must be 4 */ 368 __le16 Reserved; 369 } __packed; 370 371 struct smb2_tree_disconnect_rsp { 372 struct smb2_hdr hdr; 373 __le16 StructureSize; /* Must be 4 */ 374 __le16 Reserved; 375 } __packed; 376 377 /* File Attrubutes */ 378 #define FILE_ATTRIBUTE_READONLY 0x00000001 379 #define FILE_ATTRIBUTE_HIDDEN 0x00000002 380 #define FILE_ATTRIBUTE_SYSTEM 0x00000004 381 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010 382 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020 383 #define FILE_ATTRIBUTE_NORMAL 0x00000080 384 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100 385 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 386 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 387 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800 388 #define FILE_ATTRIBUTE_OFFLINE 0x00001000 389 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 390 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 391 #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000 392 #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000 393 394 /* Oplock levels */ 395 #define SMB2_OPLOCK_LEVEL_NONE 0x00 396 #define SMB2_OPLOCK_LEVEL_II 0x01 397 #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08 398 #define SMB2_OPLOCK_LEVEL_BATCH 0x09 399 #define SMB2_OPLOCK_LEVEL_LEASE 0xFF 400 /* Non-spec internal type */ 401 #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99 402 403 /* Desired Access Flags */ 404 #define FILE_READ_DATA_LE cpu_to_le32(0x00000001) 405 #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002) 406 #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004) 407 #define FILE_READ_EA_LE cpu_to_le32(0x00000008) 408 #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010) 409 #define FILE_EXECUTE_LE cpu_to_le32(0x00000020) 410 #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080) 411 #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100) 412 #define FILE_DELETE_LE cpu_to_le32(0x00010000) 413 #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000) 414 #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000) 415 #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000) 416 #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000) 417 #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000) 418 #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000) 419 #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000) 420 #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000) 421 #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000) 422 #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000) 423 424 /* ShareAccess Flags */ 425 #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001) 426 #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002) 427 #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004) 428 #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007) 429 430 /* CreateDisposition Flags */ 431 #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000) 432 #define FILE_OPEN_LE cpu_to_le32(0x00000001) 433 #define FILE_CREATE_LE cpu_to_le32(0x00000002) 434 #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003) 435 #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004) 436 #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005) 437 438 /* CreateOptions Flags */ 439 #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001) 440 /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */ 441 #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002) 442 #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004) 443 #define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008) 444 #define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010) 445 #define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020) 446 #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040) 447 #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100) 448 #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200) 449 #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800) 450 #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000) 451 #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000) 452 #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000) 453 #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000) 454 #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000) 455 #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000) 456 #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000) 457 #define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000) 458 459 #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \ 460 | FILE_READ_ATTRIBUTES_LE) 461 #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \ 462 | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE) 463 #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE) 464 465 /* Impersonation Levels */ 466 #define IL_ANONYMOUS cpu_to_le32(0x00000000) 467 #define IL_IDENTIFICATION cpu_to_le32(0x00000001) 468 #define IL_IMPERSONATION cpu_to_le32(0x00000002) 469 #define IL_DELEGATE cpu_to_le32(0x00000003) 470 471 /* Create Context Values */ 472 #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */ 473 #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */ 474 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ" 475 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC" 476 #define SMB2_CREATE_ALLOCATION_SIZE "AISi" 477 #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc" 478 #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp" 479 #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid" 480 #define SMB2_CREATE_REQUEST_LEASE "RqLs" 481 #define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q" 482 #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C" 483 #define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74 484 #define SVHDX_OPEN_DEVICE_CONTEXT 0x83CE6F1AD851E0986E34401CC9BCFCE9 485 486 struct smb2_create_req { 487 struct smb2_hdr hdr; 488 __le16 StructureSize; /* Must be 57 */ 489 __u8 SecurityFlags; 490 __u8 RequestedOplockLevel; 491 __le32 ImpersonationLevel; 492 __le64 SmbCreateFlags; 493 __le64 Reserved; 494 __le32 DesiredAccess; 495 __le32 FileAttributes; 496 __le32 ShareAccess; 497 __le32 CreateDisposition; 498 __le32 CreateOptions; 499 __le16 NameOffset; 500 __le16 NameLength; 501 __le32 CreateContextsOffset; 502 __le32 CreateContextsLength; 503 __u8 Buffer[0]; 504 } __packed; 505 506 struct smb2_create_rsp { 507 struct smb2_hdr hdr; 508 __le16 StructureSize; /* Must be 89 */ 509 __u8 OplockLevel; 510 __u8 Reserved; 511 __le32 CreateAction; 512 __le64 CreationTime; 513 __le64 LastAccessTime; 514 __le64 LastWriteTime; 515 __le64 ChangeTime; 516 __le64 AllocationSize; 517 __le64 EndofFile; 518 __le32 FileAttributes; 519 __le32 Reserved2; 520 __u64 PersistentFileId; /* opaque endianness */ 521 __u64 VolatileFileId; /* opaque endianness */ 522 __le32 CreateContextsOffset; 523 __le32 CreateContextsLength; 524 __u8 Buffer[1]; 525 } __packed; 526 527 struct create_context { 528 __le32 Next; 529 __le16 NameOffset; 530 __le16 NameLength; 531 __le16 Reserved; 532 __le16 DataOffset; 533 __le32 DataLength; 534 __u8 Buffer[0]; 535 } __packed; 536 537 #define SMB2_LEASE_READ_CACHING_HE 0x01 538 #define SMB2_LEASE_HANDLE_CACHING_HE 0x02 539 #define SMB2_LEASE_WRITE_CACHING_HE 0x04 540 541 #define SMB2_LEASE_NONE cpu_to_le32(0x00) 542 #define SMB2_LEASE_READ_CACHING cpu_to_le32(0x01) 543 #define SMB2_LEASE_HANDLE_CACHING cpu_to_le32(0x02) 544 #define SMB2_LEASE_WRITE_CACHING cpu_to_le32(0x04) 545 546 #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS cpu_to_le32(0x02) 547 548 #define SMB2_LEASE_KEY_SIZE 16 549 550 struct lease_context { 551 __le64 LeaseKeyLow; 552 __le64 LeaseKeyHigh; 553 __le32 LeaseState; 554 __le32 LeaseFlags; 555 __le64 LeaseDuration; 556 } __packed; 557 558 struct lease_context_v2 { 559 __le64 LeaseKeyLow; 560 __le64 LeaseKeyHigh; 561 __le32 LeaseState; 562 __le32 LeaseFlags; 563 __le64 LeaseDuration; 564 __le64 ParentLeaseKeyLow; 565 __le64 ParentLeaseKeyHigh; 566 __le16 Epoch; 567 __le16 Reserved; 568 } __packed; 569 570 struct create_lease { 571 struct create_context ccontext; 572 __u8 Name[8]; 573 struct lease_context lcontext; 574 } __packed; 575 576 struct create_lease_v2 { 577 struct create_context ccontext; 578 __u8 Name[8]; 579 struct lease_context_v2 lcontext; 580 __u8 Pad[4]; 581 } __packed; 582 583 struct create_durable { 584 struct create_context ccontext; 585 __u8 Name[8]; 586 union { 587 __u8 Reserved[16]; 588 struct { 589 __u64 PersistentFileId; 590 __u64 VolatileFileId; 591 } Fid; 592 } Data; 593 } __packed; 594 595 /* See MS-SMB2 2.2.13.2.11 */ 596 /* Flags */ 597 #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 598 struct durable_context_v2 { 599 __le32 Timeout; 600 __le32 Flags; 601 __u64 Reserved; 602 __u8 CreateGuid[16]; 603 } __packed; 604 605 struct create_durable_v2 { 606 struct create_context ccontext; 607 __u8 Name[8]; 608 struct durable_context_v2 dcontext; 609 } __packed; 610 611 /* See MS-SMB2 2.2.13.2.12 */ 612 struct durable_reconnect_context_v2 { 613 struct { 614 __u64 PersistentFileId; 615 __u64 VolatileFileId; 616 } Fid; 617 __u8 CreateGuid[16]; 618 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */ 619 } __packed; 620 621 /* See MS-SMB2 2.2.14.2.12 */ 622 struct durable_reconnect_context_v2_rsp { 623 __le32 Timeout; 624 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */ 625 } __packed; 626 627 struct create_durable_handle_reconnect_v2 { 628 struct create_context ccontext; 629 __u8 Name[8]; 630 struct durable_reconnect_context_v2 dcontext; 631 } __packed; 632 633 #define COPY_CHUNK_RES_KEY_SIZE 24 634 struct resume_key_req { 635 char ResumeKey[COPY_CHUNK_RES_KEY_SIZE]; 636 __le32 ContextLength; /* MBZ */ 637 char Context[0]; /* ignored, Windows sets to 4 bytes of zero */ 638 } __packed; 639 640 /* this goes in the ioctl buffer when doing a copychunk request */ 641 struct copychunk_ioctl { 642 char SourceKey[COPY_CHUNK_RES_KEY_SIZE]; 643 __le32 ChunkCount; /* we are only sending 1 */ 644 __le32 Reserved; 645 /* array will only be one chunk long for us */ 646 __le64 SourceOffset; 647 __le64 TargetOffset; 648 __le32 Length; /* how many bytes to copy */ 649 __u32 Reserved2; 650 } __packed; 651 652 /* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */ 653 struct file_zero_data_information { 654 __le64 FileOffset; 655 __le64 BeyondFinalZero; 656 } __packed; 657 658 struct copychunk_ioctl_rsp { 659 __le32 ChunksWritten; 660 __le32 ChunkBytesWritten; 661 __le32 TotalBytesWritten; 662 } __packed; 663 664 struct fsctl_set_integrity_information_req { 665 __le16 ChecksumAlgorithm; 666 __le16 Reserved; 667 __le32 Flags; 668 } __packed; 669 670 struct fsctl_get_integrity_information_rsp { 671 __le16 ChecksumAlgorithm; 672 __le16 Reserved; 673 __le32 Flags; 674 __le32 ChecksumChunkSizeInBytes; 675 __le32 ClusterSizeInBytes; 676 } __packed; 677 678 /* Integrity ChecksumAlgorithm choices for above */ 679 #define CHECKSUM_TYPE_NONE 0x0000 680 #define CHECKSUM_TYPE_CRC64 0x0002 681 #define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */ 682 683 /* Integrity flags for above */ 684 #define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001 685 686 /* See MS-SMB2 2.2.31.3 */ 687 struct network_resiliency_req { 688 __le32 Timeout; 689 __le32 Reserved; 690 } __packed; 691 /* There is no buffer for the response ie no struct network_resiliency_rsp */ 692 693 694 struct validate_negotiate_info_req { 695 __le32 Capabilities; 696 __u8 Guid[SMB2_CLIENT_GUID_SIZE]; 697 __le16 SecurityMode; 698 __le16 DialectCount; 699 __le16 Dialects[1]; /* dialect (someday maybe list) client asked for */ 700 } __packed; 701 702 struct validate_negotiate_info_rsp { 703 __le32 Capabilities; 704 __u8 Guid[SMB2_CLIENT_GUID_SIZE]; 705 __le16 SecurityMode; 706 __le16 Dialect; /* Dialect in use for the connection */ 707 } __packed; 708 709 #define RSS_CAPABLE 0x00000001 710 #define RDMA_CAPABLE 0x00000002 711 712 struct network_interface_info_ioctl_rsp { 713 __le32 Next; /* next interface. zero if this is last one */ 714 __le32 IfIndex; 715 __le32 Capability; /* RSS or RDMA Capable */ 716 __le32 Reserved; 717 __le64 LinkSpeed; 718 char SockAddr_Storage[128]; 719 } __packed; 720 721 #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */ 722 723 struct compress_ioctl { 724 __le16 CompressionState; /* See cifspdu.h for possible flag values */ 725 } __packed; 726 727 struct duplicate_extents_to_file { 728 __u64 PersistentFileHandle; /* source file handle, opaque endianness */ 729 __u64 VolatileFileHandle; 730 __le64 SourceFileOffset; 731 __le64 TargetFileOffset; 732 __le64 ByteCount; /* Bytes to be copied */ 733 } __packed; 734 735 struct smb2_ioctl_req { 736 struct smb2_hdr hdr; 737 __le16 StructureSize; /* Must be 57 */ 738 __u16 Reserved; 739 __le32 CtlCode; 740 __u64 PersistentFileId; /* opaque endianness */ 741 __u64 VolatileFileId; /* opaque endianness */ 742 __le32 InputOffset; 743 __le32 InputCount; 744 __le32 MaxInputResponse; 745 __le32 OutputOffset; 746 __le32 OutputCount; 747 __le32 MaxOutputResponse; 748 __le32 Flags; 749 __u32 Reserved2; 750 __u8 Buffer[0]; 751 } __packed; 752 753 struct smb2_ioctl_rsp { 754 struct smb2_hdr hdr; 755 __le16 StructureSize; /* Must be 57 */ 756 __u16 Reserved; 757 __le32 CtlCode; 758 __u64 PersistentFileId; /* opaque endianness */ 759 __u64 VolatileFileId; /* opaque endianness */ 760 __le32 InputOffset; 761 __le32 InputCount; 762 __le32 OutputOffset; 763 __le32 OutputCount; 764 __le32 Flags; 765 __u32 Reserved2; 766 /* char * buffer[] */ 767 } __packed; 768 769 /* Currently defined values for close flags */ 770 #define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001) 771 struct smb2_close_req { 772 struct smb2_hdr hdr; 773 __le16 StructureSize; /* Must be 24 */ 774 __le16 Flags; 775 __le32 Reserved; 776 __u64 PersistentFileId; /* opaque endianness */ 777 __u64 VolatileFileId; /* opaque endianness */ 778 } __packed; 779 780 struct smb2_close_rsp { 781 struct smb2_hdr hdr; 782 __le16 StructureSize; /* 60 */ 783 __le16 Flags; 784 __le32 Reserved; 785 __le64 CreationTime; 786 __le64 LastAccessTime; 787 __le64 LastWriteTime; 788 __le64 ChangeTime; 789 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ 790 __le64 EndOfFile; 791 __le32 Attributes; 792 } __packed; 793 794 struct smb2_flush_req { 795 struct smb2_hdr hdr; 796 __le16 StructureSize; /* Must be 24 */ 797 __le16 Reserved1; 798 __le32 Reserved2; 799 __u64 PersistentFileId; /* opaque endianness */ 800 __u64 VolatileFileId; /* opaque endianness */ 801 } __packed; 802 803 struct smb2_flush_rsp { 804 struct smb2_hdr hdr; 805 __le16 StructureSize; 806 __le16 Reserved; 807 } __packed; 808 809 /* For read request Flags field below, following flag is defined for SMB3.02 */ 810 #define SMB2_READFLAG_READ_UNBUFFERED 0x01 811 812 /* Channel field for read and write: exactly one of following flags can be set*/ 813 #define SMB2_CHANNEL_NONE 0x00000000 814 #define SMB2_CHANNEL_RDMA_V1 0x00000001 /* SMB3 or later */ 815 #define SMB2_CHANNEL_RDMA_V1_INVALIDATE 0x00000001 /* SMB3.02 or later */ 816 817 struct smb2_read_req { 818 struct smb2_hdr hdr; 819 __le16 StructureSize; /* Must be 49 */ 820 __u8 Padding; /* offset from start of SMB2 header to place read */ 821 __u8 Flags; /* MBZ unless SMB3.02 or later */ 822 __le32 Length; 823 __le64 Offset; 824 __u64 PersistentFileId; /* opaque endianness */ 825 __u64 VolatileFileId; /* opaque endianness */ 826 __le32 MinimumCount; 827 __le32 Channel; /* MBZ except for SMB3 or later */ 828 __le32 RemainingBytes; 829 __le16 ReadChannelInfoOffset; /* Reserved MBZ */ 830 __le16 ReadChannelInfoLength; /* Reserved MBZ */ 831 __u8 Buffer[1]; 832 } __packed; 833 834 struct smb2_read_rsp { 835 struct smb2_hdr hdr; 836 __le16 StructureSize; /* Must be 17 */ 837 __u8 DataOffset; 838 __u8 Reserved; 839 __le32 DataLength; 840 __le32 DataRemaining; 841 __u32 Reserved2; 842 __u8 Buffer[1]; 843 } __packed; 844 845 /* For write request Flags field below the following flags are defined: */ 846 #define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */ 847 #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */ 848 849 struct smb2_write_req { 850 struct smb2_hdr hdr; 851 __le16 StructureSize; /* Must be 49 */ 852 __le16 DataOffset; /* offset from start of SMB2 header to write data */ 853 __le32 Length; 854 __le64 Offset; 855 __u64 PersistentFileId; /* opaque endianness */ 856 __u64 VolatileFileId; /* opaque endianness */ 857 __le32 Channel; /* Reserved MBZ */ 858 __le32 RemainingBytes; 859 __le16 WriteChannelInfoOffset; /* Reserved MBZ */ 860 __le16 WriteChannelInfoLength; /* Reserved MBZ */ 861 __le32 Flags; 862 __u8 Buffer[1]; 863 } __packed; 864 865 struct smb2_write_rsp { 866 struct smb2_hdr hdr; 867 __le16 StructureSize; /* Must be 17 */ 868 __u8 DataOffset; 869 __u8 Reserved; 870 __le32 DataLength; 871 __le32 DataRemaining; 872 __u32 Reserved2; 873 __u8 Buffer[1]; 874 } __packed; 875 876 #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001 877 #define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002 878 #define SMB2_LOCKFLAG_UNLOCK 0x0004 879 #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010 880 881 struct smb2_lock_element { 882 __le64 Offset; 883 __le64 Length; 884 __le32 Flags; 885 __le32 Reserved; 886 } __packed; 887 888 struct smb2_lock_req { 889 struct smb2_hdr hdr; 890 __le16 StructureSize; /* Must be 48 */ 891 __le16 LockCount; 892 __le32 Reserved; 893 __u64 PersistentFileId; /* opaque endianness */ 894 __u64 VolatileFileId; /* opaque endianness */ 895 /* Followed by at least one */ 896 struct smb2_lock_element locks[1]; 897 } __packed; 898 899 struct smb2_lock_rsp { 900 struct smb2_hdr hdr; 901 __le16 StructureSize; /* Must be 4 */ 902 __le16 Reserved; 903 } __packed; 904 905 struct smb2_echo_req { 906 struct smb2_hdr hdr; 907 __le16 StructureSize; /* Must be 4 */ 908 __u16 Reserved; 909 } __packed; 910 911 struct smb2_echo_rsp { 912 struct smb2_hdr hdr; 913 __le16 StructureSize; /* Must be 4 */ 914 __u16 Reserved; 915 } __packed; 916 917 /* search (query_directory) Flags field */ 918 #define SMB2_RESTART_SCANS 0x01 919 #define SMB2_RETURN_SINGLE_ENTRY 0x02 920 #define SMB2_INDEX_SPECIFIED 0x04 921 #define SMB2_REOPEN 0x10 922 923 struct smb2_query_directory_req { 924 struct smb2_hdr hdr; 925 __le16 StructureSize; /* Must be 33 */ 926 __u8 FileInformationClass; 927 __u8 Flags; 928 __le32 FileIndex; 929 __u64 PersistentFileId; /* opaque endianness */ 930 __u64 VolatileFileId; /* opaque endianness */ 931 __le16 FileNameOffset; 932 __le16 FileNameLength; 933 __le32 OutputBufferLength; 934 __u8 Buffer[1]; 935 } __packed; 936 937 struct smb2_query_directory_rsp { 938 struct smb2_hdr hdr; 939 __le16 StructureSize; /* Must be 9 */ 940 __le16 OutputBufferOffset; 941 __le32 OutputBufferLength; 942 __u8 Buffer[1]; 943 } __packed; 944 945 /* Possible InfoType values */ 946 #define SMB2_O_INFO_FILE 0x01 947 #define SMB2_O_INFO_FILESYSTEM 0x02 948 #define SMB2_O_INFO_SECURITY 0x03 949 #define SMB2_O_INFO_QUOTA 0x04 950 951 /* Security info type additionalinfo flags. See MS-SMB2 (2.2.37) or MS-DTYP */ 952 #define OWNER_SECINFO 0x00000001 953 #define GROUP_SECINFO 0x00000002 954 #define DACL_SECINFO 0x00000004 955 #define SACL_SECINFO 0x00000008 956 #define LABEL_SECINFO 0x00000010 957 #define ATTRIBUTE_SECINFO 0x00000020 958 #define SCOPE_SECINFO 0x00000040 959 #define BACKUP_SECINFO 0x00010000 960 #define UNPROTECTED_SACL_SECINFO 0x10000000 961 #define UNPROTECTED_DACL_SECINFO 0x20000000 962 #define PROTECTED_SACL_SECINFO 0x40000000 963 #define PROTECTED_DACL_SECINFO 0x80000000 964 965 /* Flags used for FileFullEAinfo */ 966 #define SL_RESTART_SCAN 0x00000001 967 #define SL_RETURN_SINGLE_ENTRY 0x00000002 968 #define SL_INDEX_SPECIFIED 0x00000004 969 970 struct smb2_query_info_req { 971 struct smb2_hdr hdr; 972 __le16 StructureSize; /* Must be 41 */ 973 __u8 InfoType; 974 __u8 FileInfoClass; 975 __le32 OutputBufferLength; 976 __le16 InputBufferOffset; 977 __u16 Reserved; 978 __le32 InputBufferLength; 979 __le32 AdditionalInformation; 980 __le32 Flags; 981 __u64 PersistentFileId; /* opaque endianness */ 982 __u64 VolatileFileId; /* opaque endianness */ 983 __u8 Buffer[1]; 984 } __packed; 985 986 struct smb2_query_info_rsp { 987 struct smb2_hdr hdr; 988 __le16 StructureSize; /* Must be 9 */ 989 __le16 OutputBufferOffset; 990 __le32 OutputBufferLength; 991 __u8 Buffer[1]; 992 } __packed; 993 994 struct smb2_set_info_req { 995 struct smb2_hdr hdr; 996 __le16 StructureSize; /* Must be 33 */ 997 __u8 InfoType; 998 __u8 FileInfoClass; 999 __le32 BufferLength; 1000 __le16 BufferOffset; 1001 __u16 Reserved; 1002 __le32 AdditionalInformation; 1003 __u64 PersistentFileId; /* opaque endianness */ 1004 __u64 VolatileFileId; /* opaque endianness */ 1005 __u8 Buffer[1]; 1006 } __packed; 1007 1008 struct smb2_set_info_rsp { 1009 struct smb2_hdr hdr; 1010 __le16 StructureSize; /* Must be 2 */ 1011 } __packed; 1012 1013 struct smb2_oplock_break { 1014 struct smb2_hdr hdr; 1015 __le16 StructureSize; /* Must be 24 */ 1016 __u8 OplockLevel; 1017 __u8 Reserved; 1018 __le32 Reserved2; 1019 __u64 PersistentFid; 1020 __u64 VolatileFid; 1021 } __packed; 1022 1023 #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01) 1024 1025 struct smb2_lease_break { 1026 struct smb2_hdr hdr; 1027 __le16 StructureSize; /* Must be 44 */ 1028 __le16 Reserved; 1029 __le32 Flags; 1030 __u8 LeaseKey[16]; 1031 __le32 CurrentLeaseState; 1032 __le32 NewLeaseState; 1033 __le32 BreakReason; 1034 __le32 AccessMaskHint; 1035 __le32 ShareMaskHint; 1036 } __packed; 1037 1038 struct smb2_lease_ack { 1039 struct smb2_hdr hdr; 1040 __le16 StructureSize; /* Must be 36 */ 1041 __le16 Reserved; 1042 __le32 Flags; 1043 __u8 LeaseKey[16]; 1044 __le32 LeaseState; 1045 __le64 LeaseDuration; 1046 } __packed; 1047 1048 /* 1049 * PDU infolevel structure definitions 1050 * BB consider moving to a different header 1051 */ 1052 1053 /* File System Information Classes */ 1054 #define FS_VOLUME_INFORMATION 1 /* Query */ 1055 #define FS_LABEL_INFORMATION 2 /* Local only */ 1056 #define FS_SIZE_INFORMATION 3 /* Query */ 1057 #define FS_DEVICE_INFORMATION 4 /* Query */ 1058 #define FS_ATTRIBUTE_INFORMATION 5 /* Query */ 1059 #define FS_CONTROL_INFORMATION 6 /* Query, Set */ 1060 #define FS_FULL_SIZE_INFORMATION 7 /* Query */ 1061 #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */ 1062 #define FS_DRIVER_PATH_INFORMATION 9 /* Local only */ 1063 #define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */ 1064 #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */ 1065 1066 struct smb2_fs_full_size_info { 1067 __le64 TotalAllocationUnits; 1068 __le64 CallerAvailableAllocationUnits; 1069 __le64 ActualAvailableAllocationUnits; 1070 __le32 SectorsPerAllocationUnit; 1071 __le32 BytesPerSector; 1072 } __packed; 1073 1074 #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001 1075 #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002 1076 #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004 1077 #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008 1078 1079 /* sector size info struct */ 1080 struct smb3_fs_ss_info { 1081 __le32 LogicalBytesPerSector; 1082 __le32 PhysicalBytesPerSectorForAtomicity; 1083 __le32 PhysicalBytesPerSectorForPerf; 1084 __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity; 1085 __le32 Flags; 1086 __le32 ByteOffsetForSectorAlignment; 1087 __le32 ByteOffsetForPartitionAlignment; 1088 } __packed; 1089 1090 /* partial list of QUERY INFO levels */ 1091 #define FILE_DIRECTORY_INFORMATION 1 1092 #define FILE_FULL_DIRECTORY_INFORMATION 2 1093 #define FILE_BOTH_DIRECTORY_INFORMATION 3 1094 #define FILE_BASIC_INFORMATION 4 1095 #define FILE_STANDARD_INFORMATION 5 1096 #define FILE_INTERNAL_INFORMATION 6 1097 #define FILE_EA_INFORMATION 7 1098 #define FILE_ACCESS_INFORMATION 8 1099 #define FILE_NAME_INFORMATION 9 1100 #define FILE_RENAME_INFORMATION 10 1101 #define FILE_LINK_INFORMATION 11 1102 #define FILE_NAMES_INFORMATION 12 1103 #define FILE_DISPOSITION_INFORMATION 13 1104 #define FILE_POSITION_INFORMATION 14 1105 #define FILE_FULL_EA_INFORMATION 15 1106 #define FILE_MODE_INFORMATION 16 1107 #define FILE_ALIGNMENT_INFORMATION 17 1108 #define FILE_ALL_INFORMATION 18 1109 #define FILE_ALLOCATION_INFORMATION 19 1110 #define FILE_END_OF_FILE_INFORMATION 20 1111 #define FILE_ALTERNATE_NAME_INFORMATION 21 1112 #define FILE_STREAM_INFORMATION 22 1113 #define FILE_PIPE_INFORMATION 23 1114 #define FILE_PIPE_LOCAL_INFORMATION 24 1115 #define FILE_PIPE_REMOTE_INFORMATION 25 1116 #define FILE_MAILSLOT_QUERY_INFORMATION 26 1117 #define FILE_MAILSLOT_SET_INFORMATION 27 1118 #define FILE_COMPRESSION_INFORMATION 28 1119 #define FILE_OBJECT_ID_INFORMATION 29 1120 /* Number 30 not defined in documents */ 1121 #define FILE_MOVE_CLUSTER_INFORMATION 31 1122 #define FILE_QUOTA_INFORMATION 32 1123 #define FILE_REPARSE_POINT_INFORMATION 33 1124 #define FILE_NETWORK_OPEN_INFORMATION 34 1125 #define FILE_ATTRIBUTE_TAG_INFORMATION 35 1126 #define FILE_TRACKING_INFORMATION 36 1127 #define FILEID_BOTH_DIRECTORY_INFORMATION 37 1128 #define FILEID_FULL_DIRECTORY_INFORMATION 38 1129 #define FILE_VALID_DATA_LENGTH_INFORMATION 39 1130 #define FILE_SHORT_NAME_INFORMATION 40 1131 #define FILE_SFIO_RESERVE_INFORMATION 44 1132 #define FILE_SFIO_VOLUME_INFORMATION 45 1133 #define FILE_HARD_LINK_INFORMATION 46 1134 #define FILE_NORMALIZED_NAME_INFORMATION 48 1135 #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50 1136 #define FILE_STANDARD_LINK_INFORMATION 54 1137 1138 struct smb2_file_internal_info { 1139 __le64 IndexNumber; 1140 } __packed; /* level 6 Query */ 1141 1142 struct smb2_file_rename_info { /* encoding of request for level 10 */ 1143 __u8 ReplaceIfExists; /* 1 = replace existing target with new */ 1144 /* 0 = fail if target already exists */ 1145 __u8 Reserved[7]; 1146 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ 1147 __le32 FileNameLength; 1148 char FileName[0]; /* New name to be assigned */ 1149 } __packed; /* level 10 Set */ 1150 1151 struct smb2_file_link_info { /* encoding of request for level 11 */ 1152 __u8 ReplaceIfExists; /* 1 = replace existing link with new */ 1153 /* 0 = fail if link already exists */ 1154 __u8 Reserved[7]; 1155 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ 1156 __le32 FileNameLength; 1157 char FileName[0]; /* Name to be assigned to new link */ 1158 } __packed; /* level 11 Set */ 1159 1160 /* 1161 * This level 18, although with struct with same name is different from cifs 1162 * level 0x107. Level 0x107 has an extra u64 between AccessFlags and 1163 * CurrentByteOffset. 1164 */ 1165 struct smb2_file_all_info { /* data block encoding of response to level 18 */ 1166 __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */ 1167 __le64 LastAccessTime; 1168 __le64 LastWriteTime; 1169 __le64 ChangeTime; 1170 __le32 Attributes; 1171 __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */ 1172 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ 1173 __le64 EndOfFile; /* size ie offset to first free byte in file */ 1174 __le32 NumberOfLinks; /* hard links */ 1175 __u8 DeletePending; 1176 __u8 Directory; 1177 __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */ 1178 __le64 IndexNumber; 1179 __le32 EASize; 1180 __le32 AccessFlags; 1181 __le64 CurrentByteOffset; 1182 __le32 Mode; 1183 __le32 AlignmentRequirement; 1184 __le32 FileNameLength; 1185 char FileName[1]; 1186 } __packed; /* level 18 Query */ 1187 1188 struct smb2_file_eof_info { /* encoding of request for level 10 */ 1189 __le64 EndOfFile; /* new end of file value */ 1190 } __packed; /* level 20 Set */ 1191 1192 #endif /* _SMB2PDU_H */ 1193