1 /* SPDX-License-Identifier: LGPL-2.1 */ 2 /* 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 */ 10 11 #ifndef _SMB2PDU_H 12 #define _SMB2PDU_H 13 14 #include <net/sock.h> 15 #include "cifsacl.h" 16 17 /* 52 transform hdr + 64 hdr + 88 create rsp */ 18 #define SMB2_TRANSFORM_HEADER_SIZE 52 19 #define MAX_SMB2_HDR_SIZE 204 20 21 /* The total header size for SMB2 read and write */ 22 #define SMB2_READWRITE_PDU_HEADER_SIZE (48 + sizeof(struct smb2_hdr)) 23 24 /* See MS-SMB2 2.2.43 */ 25 struct smb2_rdma_transform { 26 __le16 RdmaDescriptorOffset; 27 __le16 RdmaDescriptorLength; 28 __le32 Channel; /* for values see channel description in smb2 read above */ 29 __le16 TransformCount; 30 __le16 Reserved1; 31 __le32 Reserved2; 32 } __packed; 33 34 /* TransformType */ 35 #define SMB2_RDMA_TRANSFORM_TYPE_ENCRYPTION 0x0001 36 #define SMB2_RDMA_TRANSFORM_TYPE_SIGNING 0x0002 37 38 struct smb2_rdma_crypto_transform { 39 __le16 TransformType; 40 __le16 SignatureLength; 41 __le16 NonceLength; 42 __u16 Reserved; 43 __u8 Signature[]; /* variable length */ 44 /* u8 Nonce[] */ 45 /* followed by padding */ 46 } __packed; 47 48 /* 49 * Definitions for SMB2 Protocol Data Units (network frames) 50 * 51 * See MS-SMB2.PDF specification for protocol details. 52 * The Naming convention is the lower case version of the SMB2 53 * command code name for the struct. Note that structures must be packed. 54 * 55 */ 56 57 #define COMPOUND_FID 0xFFFFFFFFFFFFFFFFULL 58 59 #define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9) 60 61 struct smb2_err_rsp { 62 struct smb2_hdr hdr; 63 __le16 StructureSize; 64 __le16 Reserved; /* MBZ */ 65 __le32 ByteCount; /* even if zero, at least one byte follows */ 66 __u8 ErrorData[1]; /* variable length */ 67 } __packed; 68 69 #define SYMLINK_ERROR_TAG 0x4c4d5953 70 71 struct smb2_symlink_err_rsp { 72 __le32 SymLinkLength; 73 __le32 SymLinkErrorTag; 74 __le32 ReparseTag; 75 __le16 ReparseDataLength; 76 __le16 UnparsedPathLength; 77 __le16 SubstituteNameOffset; 78 __le16 SubstituteNameLength; 79 __le16 PrintNameOffset; 80 __le16 PrintNameLength; 81 __le32 Flags; 82 __u8 PathBuffer[]; 83 } __packed; 84 85 /* SMB 3.1.1 and later dialects. See MS-SMB2 section 2.2.2.1 */ 86 struct smb2_error_context_rsp { 87 __le32 ErrorDataLength; 88 __le32 ErrorId; 89 __u8 ErrorContextData; /* ErrorDataLength long array */ 90 } __packed; 91 92 /* ErrorId values */ 93 #define SMB2_ERROR_ID_DEFAULT 0x00000000 94 #define SMB2_ERROR_ID_SHARE_REDIRECT cpu_to_le32(0x72645253) /* "rdRS" */ 95 96 /* Defines for Type field below (see MS-SMB2 2.2.2.2.2.1) */ 97 #define MOVE_DST_IPADDR_V4 cpu_to_le32(0x00000001) 98 #define MOVE_DST_IPADDR_V6 cpu_to_le32(0x00000002) 99 100 struct move_dst_ipaddr { 101 __le32 Type; 102 __u32 Reserved; 103 __u8 address[16]; /* IPv4 followed by 12 bytes rsvd or IPv6 address */ 104 } __packed; 105 106 struct share_redirect_error_context_rsp { 107 __le32 StructureSize; 108 __le32 NotificationType; 109 __le32 ResourceNameOffset; 110 __le32 ResourceNameLength; 111 __le16 Reserved; 112 __le16 TargetType; 113 __le32 IPAddrCount; 114 struct move_dst_ipaddr IpAddrMoveList[]; 115 /* __u8 ResourceName[] */ /* Name of share as counted Unicode string */ 116 } __packed; 117 118 /* 119 * Maximum number of iovs we need for an open/create request. 120 * [0] : struct smb2_create_req 121 * [1] : path 122 * [2] : lease context 123 * [3] : durable context 124 * [4] : posix context 125 * [5] : time warp context 126 * [6] : query id context 127 * [7] : compound padding 128 */ 129 #define SMB2_CREATE_IOV_SIZE 8 130 131 /* 132 * Maximum size of a SMB2_CREATE response is 64 (smb2 header) + 133 * 88 (fixed part of create response) + 520 (path) + 208 (contexts) + 134 * 2 bytes of padding. 135 */ 136 #define MAX_SMB2_CREATE_RESPONSE_SIZE 880 137 138 #define SMB2_LEASE_READ_CACHING_HE 0x01 139 #define SMB2_LEASE_HANDLE_CACHING_HE 0x02 140 #define SMB2_LEASE_WRITE_CACHING_HE 0x04 141 142 #define SMB2_LEASE_NONE cpu_to_le32(0x00) 143 #define SMB2_LEASE_READ_CACHING cpu_to_le32(0x01) 144 #define SMB2_LEASE_HANDLE_CACHING cpu_to_le32(0x02) 145 #define SMB2_LEASE_WRITE_CACHING cpu_to_le32(0x04) 146 147 #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS cpu_to_le32(0x00000002) 148 #define SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET cpu_to_le32(0x00000004) 149 150 #define SMB2_LEASE_KEY_SIZE 16 151 152 struct lease_context { 153 u8 LeaseKey[SMB2_LEASE_KEY_SIZE]; 154 __le32 LeaseState; 155 __le32 LeaseFlags; 156 __le64 LeaseDuration; 157 } __packed; 158 159 struct lease_context_v2 { 160 u8 LeaseKey[SMB2_LEASE_KEY_SIZE]; 161 __le32 LeaseState; 162 __le32 LeaseFlags; 163 __le64 LeaseDuration; 164 __le64 ParentLeaseKeyLow; 165 __le64 ParentLeaseKeyHigh; 166 __le16 Epoch; 167 __le16 Reserved; 168 } __packed; 169 170 struct create_lease { 171 struct create_context ccontext; 172 __u8 Name[8]; 173 struct lease_context lcontext; 174 } __packed; 175 176 struct create_lease_v2 { 177 struct create_context ccontext; 178 __u8 Name[8]; 179 struct lease_context_v2 lcontext; 180 __u8 Pad[4]; 181 } __packed; 182 183 struct create_durable { 184 struct create_context ccontext; 185 __u8 Name[8]; 186 union { 187 __u8 Reserved[16]; 188 struct { 189 __u64 PersistentFileId; 190 __u64 VolatileFileId; 191 } Fid; 192 } Data; 193 } __packed; 194 195 struct create_posix { 196 struct create_context ccontext; 197 __u8 Name[16]; 198 __le32 Mode; 199 __u32 Reserved; 200 } __packed; 201 202 /* See MS-SMB2 2.2.13.2.11 */ 203 /* Flags */ 204 #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 205 struct durable_context_v2 { 206 __le32 Timeout; 207 __le32 Flags; 208 __u64 Reserved; 209 __u8 CreateGuid[16]; 210 } __packed; 211 212 struct create_durable_v2 { 213 struct create_context ccontext; 214 __u8 Name[8]; 215 struct durable_context_v2 dcontext; 216 } __packed; 217 218 /* See MS-SMB2 2.2.13.2.12 */ 219 struct durable_reconnect_context_v2 { 220 struct { 221 __u64 PersistentFileId; 222 __u64 VolatileFileId; 223 } Fid; 224 __u8 CreateGuid[16]; 225 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */ 226 } __packed; 227 228 /* See MS-SMB2 2.2.14.2.9 */ 229 struct create_on_disk_id { 230 struct create_context ccontext; 231 __u8 Name[8]; 232 __le64 DiskFileId; 233 __le64 VolumeId; 234 __u32 Reserved[4]; 235 } __packed; 236 237 /* See MS-SMB2 2.2.14.2.12 */ 238 struct durable_reconnect_context_v2_rsp { 239 __le32 Timeout; 240 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */ 241 } __packed; 242 243 struct create_durable_handle_reconnect_v2 { 244 struct create_context ccontext; 245 __u8 Name[8]; 246 struct durable_reconnect_context_v2 dcontext; 247 __u8 Pad[4]; 248 } __packed; 249 250 /* See MS-SMB2 2.2.13.2.5 */ 251 struct crt_twarp_ctxt { 252 struct create_context ccontext; 253 __u8 Name[8]; 254 __le64 Timestamp; 255 256 } __packed; 257 258 /* See MS-SMB2 2.2.13.2.9 */ 259 struct crt_query_id_ctxt { 260 struct create_context ccontext; 261 __u8 Name[8]; 262 } __packed; 263 264 struct crt_sd_ctxt { 265 struct create_context ccontext; 266 __u8 Name[8]; 267 struct smb3_sd sd; 268 } __packed; 269 270 271 #define COPY_CHUNK_RES_KEY_SIZE 24 272 struct resume_key_req { 273 char ResumeKey[COPY_CHUNK_RES_KEY_SIZE]; 274 __le32 ContextLength; /* MBZ */ 275 char Context[]; /* ignored, Windows sets to 4 bytes of zero */ 276 } __packed; 277 278 /* this goes in the ioctl buffer when doing a copychunk request */ 279 struct copychunk_ioctl { 280 char SourceKey[COPY_CHUNK_RES_KEY_SIZE]; 281 __le32 ChunkCount; /* we are only sending 1 */ 282 __le32 Reserved; 283 /* array will only be one chunk long for us */ 284 __le64 SourceOffset; 285 __le64 TargetOffset; 286 __le32 Length; /* how many bytes to copy */ 287 __u32 Reserved2; 288 } __packed; 289 290 /* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */ 291 struct file_zero_data_information { 292 __le64 FileOffset; 293 __le64 BeyondFinalZero; 294 } __packed; 295 296 struct copychunk_ioctl_rsp { 297 __le32 ChunksWritten; 298 __le32 ChunkBytesWritten; 299 __le32 TotalBytesWritten; 300 } __packed; 301 302 /* See MS-FSCC 2.3.29 and 2.3.30 */ 303 struct get_retrieval_pointer_count_req { 304 __le64 StartingVcn; /* virtual cluster number (signed) */ 305 } __packed; 306 307 struct get_retrieval_pointer_count_rsp { 308 __le32 ExtentCount; 309 } __packed; 310 311 /* 312 * See MS-FSCC 2.3.33 and 2.3.34 313 * request is the same as get_retrieval_point_count_req struct above 314 */ 315 struct smb3_extents { 316 __le64 NextVcn; 317 __le64 Lcn; /* logical cluster number */ 318 } __packed; 319 320 struct get_retrieval_pointers_refcount_rsp { 321 __le32 ExtentCount; 322 __u32 Reserved; 323 __le64 StartingVcn; 324 struct smb3_extents extents[]; 325 } __packed; 326 327 struct fsctl_set_integrity_information_req { 328 __le16 ChecksumAlgorithm; 329 __le16 Reserved; 330 __le32 Flags; 331 } __packed; 332 333 struct fsctl_get_integrity_information_rsp { 334 __le16 ChecksumAlgorithm; 335 __le16 Reserved; 336 __le32 Flags; 337 __le32 ChecksumChunkSizeInBytes; 338 __le32 ClusterSizeInBytes; 339 } __packed; 340 341 struct file_allocated_range_buffer { 342 __le64 file_offset; 343 __le64 length; 344 } __packed; 345 346 /* Integrity ChecksumAlgorithm choices for above */ 347 #define CHECKSUM_TYPE_NONE 0x0000 348 #define CHECKSUM_TYPE_CRC64 0x0002 349 #define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */ 350 351 /* Integrity flags for above */ 352 #define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001 353 354 /* Reparse structures - see MS-FSCC 2.1.2 */ 355 356 /* struct fsctl_reparse_info_req is empty, only response structs (see below) */ 357 358 struct reparse_data_buffer { 359 __le32 ReparseTag; 360 __le16 ReparseDataLength; 361 __u16 Reserved; 362 __u8 DataBuffer[]; /* Variable Length */ 363 } __packed; 364 365 struct reparse_guid_data_buffer { 366 __le32 ReparseTag; 367 __le16 ReparseDataLength; 368 __u16 Reserved; 369 __u8 ReparseGuid[16]; 370 __u8 DataBuffer[]; /* Variable Length */ 371 } __packed; 372 373 struct reparse_mount_point_data_buffer { 374 __le32 ReparseTag; 375 __le16 ReparseDataLength; 376 __u16 Reserved; 377 __le16 SubstituteNameOffset; 378 __le16 SubstituteNameLength; 379 __le16 PrintNameOffset; 380 __le16 PrintNameLength; 381 __u8 PathBuffer[]; /* Variable Length */ 382 } __packed; 383 384 #define SYMLINK_FLAG_RELATIVE 0x00000001 385 386 struct reparse_symlink_data_buffer { 387 __le32 ReparseTag; 388 __le16 ReparseDataLength; 389 __u16 Reserved; 390 __le16 SubstituteNameOffset; 391 __le16 SubstituteNameLength; 392 __le16 PrintNameOffset; 393 __le16 PrintNameLength; 394 __le32 Flags; 395 __u8 PathBuffer[]; /* Variable Length */ 396 } __packed; 397 398 /* See MS-FSCC 2.1.2.6 and cifspdu.h for struct reparse_posix_data */ 399 400 401 /* See MS-DFSC 2.2.2 */ 402 struct fsctl_get_dfs_referral_req { 403 __le16 MaxReferralLevel; 404 __u8 RequestFileName[]; 405 } __packed; 406 407 /* DFS response is struct get_dfs_refer_rsp */ 408 409 /* See MS-SMB2 2.2.31.3 */ 410 struct network_resiliency_req { 411 __le32 Timeout; 412 __le32 Reserved; 413 } __packed; 414 /* There is no buffer for the response ie no struct network_resiliency_rsp */ 415 416 417 struct validate_negotiate_info_req { 418 __le32 Capabilities; 419 __u8 Guid[SMB2_CLIENT_GUID_SIZE]; 420 __le16 SecurityMode; 421 __le16 DialectCount; 422 __le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */ 423 } __packed; 424 425 struct validate_negotiate_info_rsp { 426 __le32 Capabilities; 427 __u8 Guid[SMB2_CLIENT_GUID_SIZE]; 428 __le16 SecurityMode; 429 __le16 Dialect; /* Dialect in use for the connection */ 430 } __packed; 431 432 #define RSS_CAPABLE cpu_to_le32(0x00000001) 433 #define RDMA_CAPABLE cpu_to_le32(0x00000002) 434 435 #define INTERNETWORK cpu_to_le16(0x0002) 436 #define INTERNETWORKV6 cpu_to_le16(0x0017) 437 438 struct network_interface_info_ioctl_rsp { 439 __le32 Next; /* next interface. zero if this is last one */ 440 __le32 IfIndex; 441 __le32 Capability; /* RSS or RDMA Capable */ 442 __le32 Reserved; 443 __le64 LinkSpeed; 444 __le16 Family; 445 __u8 Buffer[126]; 446 } __packed; 447 448 struct iface_info_ipv4 { 449 __be16 Port; 450 __be32 IPv4Address; 451 __be64 Reserved; 452 } __packed; 453 454 struct iface_info_ipv6 { 455 __be16 Port; 456 __be32 FlowInfo; 457 __u8 IPv6Address[16]; 458 __be32 ScopeId; 459 } __packed; 460 461 #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */ 462 463 struct compress_ioctl { 464 __le16 CompressionState; /* See cifspdu.h for possible flag values */ 465 } __packed; 466 467 struct duplicate_extents_to_file { 468 __u64 PersistentFileHandle; /* source file handle, opaque endianness */ 469 __u64 VolatileFileHandle; 470 __le64 SourceFileOffset; 471 __le64 TargetFileOffset; 472 __le64 ByteCount; /* Bytes to be copied */ 473 } __packed; 474 475 /* 476 * Maximum number of iovs we need for an ioctl request. 477 * [0] : struct smb2_ioctl_req 478 * [1] : in_data 479 */ 480 #define SMB2_IOCTL_IOV_SIZE 2 481 482 struct smb2_ioctl_req { 483 struct smb2_hdr hdr; 484 __le16 StructureSize; /* Must be 57 */ 485 __u16 Reserved; 486 __le32 CtlCode; 487 __u64 PersistentFileId; /* opaque endianness */ 488 __u64 VolatileFileId; /* opaque endianness */ 489 __le32 InputOffset; 490 __le32 InputCount; 491 __le32 MaxInputResponse; 492 __le32 OutputOffset; 493 __le32 OutputCount; 494 __le32 MaxOutputResponse; 495 __le32 Flags; 496 __u32 Reserved2; 497 __u8 Buffer[]; 498 } __packed; 499 500 struct smb2_ioctl_rsp { 501 struct smb2_hdr hdr; 502 __le16 StructureSize; /* Must be 57 */ 503 __u16 Reserved; 504 __le32 CtlCode; 505 __u64 PersistentFileId; /* opaque endianness */ 506 __u64 VolatileFileId; /* opaque endianness */ 507 __le32 InputOffset; 508 __le32 InputCount; 509 __le32 OutputOffset; 510 __le32 OutputCount; 511 __le32 Flags; 512 __u32 Reserved2; 513 /* char * buffer[] */ 514 } __packed; 515 516 #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001 517 #define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002 518 #define SMB2_LOCKFLAG_UNLOCK 0x0004 519 #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010 520 521 struct smb2_lock_element { 522 __le64 Offset; 523 __le64 Length; 524 __le32 Flags; 525 __le32 Reserved; 526 } __packed; 527 528 struct smb2_lock_req { 529 struct smb2_hdr hdr; 530 __le16 StructureSize; /* Must be 48 */ 531 __le16 LockCount; 532 /* 533 * The least significant four bits are the index, the other 28 bits are 534 * the lock sequence number (0 to 64). See MS-SMB2 2.2.26 535 */ 536 __le32 LockSequenceNumber; 537 __u64 PersistentFileId; /* opaque endianness */ 538 __u64 VolatileFileId; /* opaque endianness */ 539 /* Followed by at least one */ 540 struct smb2_lock_element locks[1]; 541 } __packed; 542 543 struct smb2_lock_rsp { 544 struct smb2_hdr hdr; 545 __le16 StructureSize; /* Must be 4 */ 546 __le16 Reserved; 547 } __packed; 548 549 struct smb2_echo_req { 550 struct smb2_hdr hdr; 551 __le16 StructureSize; /* Must be 4 */ 552 __u16 Reserved; 553 } __packed; 554 555 struct smb2_echo_rsp { 556 struct smb2_hdr hdr; 557 __le16 StructureSize; /* Must be 4 */ 558 __u16 Reserved; 559 } __packed; 560 561 /* search (query_directory) Flags field */ 562 #define SMB2_RESTART_SCANS 0x01 563 #define SMB2_RETURN_SINGLE_ENTRY 0x02 564 #define SMB2_INDEX_SPECIFIED 0x04 565 #define SMB2_REOPEN 0x10 566 567 #define SMB2_QUERY_DIRECTORY_IOV_SIZE 2 568 569 /* 570 * Valid FileInformation classes. 571 * 572 * Note that these are a subset of the (file) QUERY_INFO levels defined 573 * later in this file (but since QUERY_DIRECTORY uses equivalent numbers 574 * we do not redefine them here) 575 * 576 * FileDirectoryInfomation 0x01 577 * FileFullDirectoryInformation 0x02 578 * FileIdFullDirectoryInformation 0x26 579 * FileBothDirectoryInformation 0x03 580 * FileIdBothDirectoryInformation 0x25 581 * FileNamesInformation 0x0C 582 * FileIdExtdDirectoryInformation 0x3C 583 */ 584 585 struct smb2_query_directory_req { 586 struct smb2_hdr hdr; 587 __le16 StructureSize; /* Must be 33 */ 588 __u8 FileInformationClass; 589 __u8 Flags; 590 __le32 FileIndex; 591 __u64 PersistentFileId; /* opaque endianness */ 592 __u64 VolatileFileId; /* opaque endianness */ 593 __le16 FileNameOffset; 594 __le16 FileNameLength; 595 __le32 OutputBufferLength; 596 __u8 Buffer[1]; 597 } __packed; 598 599 struct smb2_query_directory_rsp { 600 struct smb2_hdr hdr; 601 __le16 StructureSize; /* Must be 9 */ 602 __le16 OutputBufferOffset; 603 __le32 OutputBufferLength; 604 __u8 Buffer[1]; 605 } __packed; 606 607 /* Possible InfoType values */ 608 #define SMB2_O_INFO_FILE 0x01 609 #define SMB2_O_INFO_FILESYSTEM 0x02 610 #define SMB2_O_INFO_SECURITY 0x03 611 #define SMB2_O_INFO_QUOTA 0x04 612 613 /* Security info type additionalinfo flags. See MS-SMB2 (2.2.37) or MS-DTYP */ 614 #define OWNER_SECINFO 0x00000001 615 #define GROUP_SECINFO 0x00000002 616 #define DACL_SECINFO 0x00000004 617 #define SACL_SECINFO 0x00000008 618 #define LABEL_SECINFO 0x00000010 619 #define ATTRIBUTE_SECINFO 0x00000020 620 #define SCOPE_SECINFO 0x00000040 621 #define BACKUP_SECINFO 0x00010000 622 #define UNPROTECTED_SACL_SECINFO 0x10000000 623 #define UNPROTECTED_DACL_SECINFO 0x20000000 624 #define PROTECTED_SACL_SECINFO 0x40000000 625 #define PROTECTED_DACL_SECINFO 0x80000000 626 627 /* Flags used for FileFullEAinfo */ 628 #define SL_RESTART_SCAN 0x00000001 629 #define SL_RETURN_SINGLE_ENTRY 0x00000002 630 #define SL_INDEX_SPECIFIED 0x00000004 631 632 struct smb2_query_info_req { 633 struct smb2_hdr hdr; 634 __le16 StructureSize; /* Must be 41 */ 635 __u8 InfoType; 636 __u8 FileInfoClass; 637 __le32 OutputBufferLength; 638 __le16 InputBufferOffset; 639 __u16 Reserved; 640 __le32 InputBufferLength; 641 __le32 AdditionalInformation; 642 __le32 Flags; 643 __u64 PersistentFileId; /* opaque endianness */ 644 __u64 VolatileFileId; /* opaque endianness */ 645 __u8 Buffer[1]; 646 } __packed; 647 648 struct smb2_query_info_rsp { 649 struct smb2_hdr hdr; 650 __le16 StructureSize; /* Must be 9 */ 651 __le16 OutputBufferOffset; 652 __le32 OutputBufferLength; 653 __u8 Buffer[1]; 654 } __packed; 655 656 /* 657 * Maximum number of iovs we need for a set-info request. 658 * The largest one is rename/hardlink 659 * [0] : struct smb2_set_info_req + smb2_file_[rename|link]_info 660 * [1] : path 661 * [2] : compound padding 662 */ 663 #define SMB2_SET_INFO_IOV_SIZE 3 664 665 struct smb2_set_info_req { 666 struct smb2_hdr hdr; 667 __le16 StructureSize; /* Must be 33 */ 668 __u8 InfoType; 669 __u8 FileInfoClass; 670 __le32 BufferLength; 671 __le16 BufferOffset; 672 __u16 Reserved; 673 __le32 AdditionalInformation; 674 __u64 PersistentFileId; /* opaque endianness */ 675 __u64 VolatileFileId; /* opaque endianness */ 676 __u8 Buffer[1]; 677 } __packed; 678 679 struct smb2_set_info_rsp { 680 struct smb2_hdr hdr; 681 __le16 StructureSize; /* Must be 2 */ 682 } __packed; 683 684 struct smb2_oplock_break { 685 struct smb2_hdr hdr; 686 __le16 StructureSize; /* Must be 24 */ 687 __u8 OplockLevel; 688 __u8 Reserved; 689 __le32 Reserved2; 690 __u64 PersistentFid; 691 __u64 VolatileFid; 692 } __packed; 693 694 #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01) 695 696 struct smb2_lease_break { 697 struct smb2_hdr hdr; 698 __le16 StructureSize; /* Must be 44 */ 699 __le16 Epoch; 700 __le32 Flags; 701 __u8 LeaseKey[16]; 702 __le32 CurrentLeaseState; 703 __le32 NewLeaseState; 704 __le32 BreakReason; 705 __le32 AccessMaskHint; 706 __le32 ShareMaskHint; 707 } __packed; 708 709 struct smb2_lease_ack { 710 struct smb2_hdr hdr; 711 __le16 StructureSize; /* Must be 36 */ 712 __le16 Reserved; 713 __le32 Flags; 714 __u8 LeaseKey[16]; 715 __le32 LeaseState; 716 __le64 LeaseDuration; 717 } __packed; 718 719 /* 720 * PDU infolevel structure definitions 721 * BB consider moving to a different header 722 */ 723 724 /* File System Information Classes */ 725 #define FS_VOLUME_INFORMATION 1 /* Query */ 726 #define FS_LABEL_INFORMATION 2 /* Local only */ 727 #define FS_SIZE_INFORMATION 3 /* Query */ 728 #define FS_DEVICE_INFORMATION 4 /* Query */ 729 #define FS_ATTRIBUTE_INFORMATION 5 /* Query */ 730 #define FS_CONTROL_INFORMATION 6 /* Query, Set */ 731 #define FS_FULL_SIZE_INFORMATION 7 /* Query */ 732 #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */ 733 #define FS_DRIVER_PATH_INFORMATION 9 /* Local only */ 734 #define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */ 735 #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */ 736 #define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */ 737 738 struct smb2_fs_full_size_info { 739 __le64 TotalAllocationUnits; 740 __le64 CallerAvailableAllocationUnits; 741 __le64 ActualAvailableAllocationUnits; 742 __le32 SectorsPerAllocationUnit; 743 __le32 BytesPerSector; 744 } __packed; 745 746 #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001 747 #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002 748 #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004 749 #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008 750 751 /* sector size info struct */ 752 struct smb3_fs_ss_info { 753 __le32 LogicalBytesPerSector; 754 __le32 PhysicalBytesPerSectorForAtomicity; 755 __le32 PhysicalBytesPerSectorForPerf; 756 __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity; 757 __le32 Flags; 758 __le32 ByteOffsetForSectorAlignment; 759 __le32 ByteOffsetForPartitionAlignment; 760 } __packed; 761 762 /* volume info struct - see MS-FSCC 2.5.9 */ 763 #define MAX_VOL_LABEL_LEN 32 764 struct smb3_fs_vol_info { 765 __le64 VolumeCreationTime; 766 __u32 VolumeSerialNumber; 767 __le32 VolumeLabelLength; /* includes trailing null */ 768 __u8 SupportsObjects; /* True if eg like NTFS, supports objects */ 769 __u8 Reserved; 770 __u8 VolumeLabel[]; /* variable len */ 771 } __packed; 772 773 /* partial list of QUERY INFO levels */ 774 #define FILE_DIRECTORY_INFORMATION 1 775 #define FILE_FULL_DIRECTORY_INFORMATION 2 776 #define FILE_BOTH_DIRECTORY_INFORMATION 3 777 #define FILE_BASIC_INFORMATION 4 778 #define FILE_STANDARD_INFORMATION 5 779 #define FILE_INTERNAL_INFORMATION 6 780 #define FILE_EA_INFORMATION 7 781 #define FILE_ACCESS_INFORMATION 8 782 #define FILE_NAME_INFORMATION 9 783 #define FILE_RENAME_INFORMATION 10 784 #define FILE_LINK_INFORMATION 11 785 #define FILE_NAMES_INFORMATION 12 786 #define FILE_DISPOSITION_INFORMATION 13 787 #define FILE_POSITION_INFORMATION 14 788 #define FILE_FULL_EA_INFORMATION 15 789 #define FILE_MODE_INFORMATION 16 790 #define FILE_ALIGNMENT_INFORMATION 17 791 #define FILE_ALL_INFORMATION 18 792 #define FILE_ALLOCATION_INFORMATION 19 793 #define FILE_END_OF_FILE_INFORMATION 20 794 #define FILE_ALTERNATE_NAME_INFORMATION 21 795 #define FILE_STREAM_INFORMATION 22 796 #define FILE_PIPE_INFORMATION 23 797 #define FILE_PIPE_LOCAL_INFORMATION 24 798 #define FILE_PIPE_REMOTE_INFORMATION 25 799 #define FILE_MAILSLOT_QUERY_INFORMATION 26 800 #define FILE_MAILSLOT_SET_INFORMATION 27 801 #define FILE_COMPRESSION_INFORMATION 28 802 #define FILE_OBJECT_ID_INFORMATION 29 803 /* Number 30 not defined in documents */ 804 #define FILE_MOVE_CLUSTER_INFORMATION 31 805 #define FILE_QUOTA_INFORMATION 32 806 #define FILE_REPARSE_POINT_INFORMATION 33 807 #define FILE_NETWORK_OPEN_INFORMATION 34 808 #define FILE_ATTRIBUTE_TAG_INFORMATION 35 809 #define FILE_TRACKING_INFORMATION 36 810 #define FILEID_BOTH_DIRECTORY_INFORMATION 37 811 #define FILEID_FULL_DIRECTORY_INFORMATION 38 812 #define FILE_VALID_DATA_LENGTH_INFORMATION 39 813 #define FILE_SHORT_NAME_INFORMATION 40 814 #define FILE_SFIO_RESERVE_INFORMATION 44 815 #define FILE_SFIO_VOLUME_INFORMATION 45 816 #define FILE_HARD_LINK_INFORMATION 46 817 #define FILE_NORMALIZED_NAME_INFORMATION 48 818 #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50 819 #define FILE_STANDARD_LINK_INFORMATION 54 820 #define FILE_ID_INFORMATION 59 821 #define FILE_ID_EXTD_DIRECTORY_INFORMATION 60 822 823 struct smb2_file_internal_info { 824 __le64 IndexNumber; 825 } __packed; /* level 6 Query */ 826 827 struct smb2_file_rename_info { /* encoding of request for level 10 */ 828 __u8 ReplaceIfExists; /* 1 = replace existing target with new */ 829 /* 0 = fail if target already exists */ 830 __u8 Reserved[7]; 831 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ 832 __le32 FileNameLength; 833 char FileName[]; /* New name to be assigned */ 834 /* padding - overall struct size must be >= 24 so filename + pad >= 6 */ 835 } __packed; /* level 10 Set */ 836 837 struct smb2_file_link_info { /* encoding of request for level 11 */ 838 __u8 ReplaceIfExists; /* 1 = replace existing link with new */ 839 /* 0 = fail if link already exists */ 840 __u8 Reserved[7]; 841 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ 842 __le32 FileNameLength; 843 char FileName[]; /* Name to be assigned to new link */ 844 } __packed; /* level 11 Set */ 845 846 struct smb2_file_full_ea_info { /* encoding of response for level 15 */ 847 __le32 next_entry_offset; 848 __u8 flags; 849 __u8 ea_name_length; 850 __le16 ea_value_length; 851 char ea_data[]; /* \0 terminated name plus value */ 852 } __packed; /* level 15 Set */ 853 854 /* 855 * This level 18, although with struct with same name is different from cifs 856 * level 0x107. Level 0x107 has an extra u64 between AccessFlags and 857 * CurrentByteOffset. 858 */ 859 struct smb2_file_all_info { /* data block encoding of response to level 18 */ 860 __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */ 861 __le64 LastAccessTime; 862 __le64 LastWriteTime; 863 __le64 ChangeTime; 864 __le32 Attributes; 865 __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */ 866 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ 867 __le64 EndOfFile; /* size ie offset to first free byte in file */ 868 __le32 NumberOfLinks; /* hard links */ 869 __u8 DeletePending; 870 __u8 Directory; 871 __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */ 872 __le64 IndexNumber; 873 __le32 EASize; 874 __le32 AccessFlags; 875 __le64 CurrentByteOffset; 876 __le32 Mode; 877 __le32 AlignmentRequirement; 878 __le32 FileNameLength; 879 char FileName[1]; 880 } __packed; /* level 18 Query */ 881 882 struct smb2_file_eof_info { /* encoding of request for level 10 */ 883 __le64 EndOfFile; /* new end of file value */ 884 } __packed; /* level 20 Set */ 885 886 struct smb2_file_reparse_point_info { 887 __le64 IndexNumber; 888 __le32 Tag; 889 } __packed; 890 891 struct smb2_file_network_open_info { 892 __le64 CreationTime; 893 __le64 LastAccessTime; 894 __le64 LastWriteTime; 895 __le64 ChangeTime; 896 __le64 AllocationSize; 897 __le64 EndOfFile; 898 __le32 Attributes; 899 __le32 Reserved; 900 } __packed; /* level 34 Query also similar returned in close rsp and open rsp */ 901 902 /* See MS-FSCC 2.4.21 */ 903 struct smb2_file_id_information { 904 __le64 VolumeSerialNumber; 905 __u64 PersistentFileId; /* opaque endianness */ 906 __u64 VolatileFileId; /* opaque endianness */ 907 } __packed; /* level 59 */ 908 909 /* See MS-FSCC 2.4.18 */ 910 struct smb2_file_id_extd_directory_info { 911 __le32 NextEntryOffset; 912 __u32 FileIndex; 913 __le64 CreationTime; 914 __le64 LastAccessTime; 915 __le64 LastWriteTime; 916 __le64 ChangeTime; 917 __le64 EndOfFile; 918 __le64 AllocationSize; 919 __le32 FileAttributes; 920 __le32 FileNameLength; 921 __le32 EaSize; /* EA size */ 922 __le32 ReparsePointTag; /* valid if FILE_ATTR_REPARSE_POINT set in FileAttributes */ 923 __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit */ 924 char FileName[1]; 925 } __packed; /* level 60 */ 926 927 extern char smb2_padding[7]; 928 929 /* equivalent of the contents of SMB3.1.1 POSIX open context response */ 930 struct create_posix_rsp { 931 u32 nlink; 932 u32 reparse_tag; 933 u32 mode; 934 struct cifs_sid owner; /* var-sized on the wire */ 935 struct cifs_sid group; /* var-sized on the wire */ 936 } __packed; 937 938 /* 939 * SMB2-only POSIX info level for query dir 940 * 941 * See posix_info_sid_size(), posix_info_extra_size() and 942 * posix_info_parse() to help with the handling of this struct. 943 */ 944 struct smb2_posix_info { 945 __le32 NextEntryOffset; 946 __u32 Ignored; 947 __le64 CreationTime; 948 __le64 LastAccessTime; 949 __le64 LastWriteTime; 950 __le64 ChangeTime; 951 __le64 EndOfFile; 952 __le64 AllocationSize; 953 __le32 DosAttributes; 954 __le64 Inode; 955 __le32 DeviceId; 956 __le32 Zero; 957 /* beginning of POSIX Create Context Response */ 958 __le32 HardLinks; 959 __le32 ReparseTag; 960 __le32 Mode; 961 /* 962 * var sized owner SID 963 * var sized group SID 964 * le32 filenamelength 965 * u8 filename[] 966 */ 967 } __packed; 968 969 /* Level 100 query info */ 970 struct smb311_posix_qinfo { 971 __le64 CreationTime; 972 __le64 LastAccessTime; 973 __le64 LastWriteTime; 974 __le64 ChangeTime; 975 __le64 EndOfFile; 976 __le64 AllocationSize; 977 __le32 DosAttributes; 978 __le64 Inode; 979 __le32 DeviceId; 980 __le32 Zero; 981 /* beginning of POSIX Create Context Response */ 982 __le32 HardLinks; 983 __le32 ReparseTag; 984 __le32 Mode; 985 u8 Sids[]; 986 /* 987 * var sized owner SID 988 * var sized group SID 989 * le32 filenamelength 990 * u8 filename[] 991 */ 992 } __packed; 993 994 /* 995 * Parsed version of the above struct. Allows direct access to the 996 * variable length fields 997 */ 998 struct smb2_posix_info_parsed { 999 const struct smb2_posix_info *base; 1000 size_t size; 1001 struct cifs_sid owner; 1002 struct cifs_sid group; 1003 int name_len; 1004 const u8 *name; 1005 }; 1006 1007 #endif /* _SMB2PDU_H */ 1008