Steve French | 929be90 | 2021-06-18 00:31:49 -0500 | [diff] [blame] | 1 | /* SPDX-License-Identifier: LGPL-2.1 */ |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 2 | /* |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 3 | * |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 4 | * Copyright (c) International Business Machines Corp., 2009, 2013 |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 5 | * Etersoft, 2012 |
| 6 | * Author(s): Steve French (sfrench@us.ibm.com) |
| 7 | * Pavel Shilovsky (pshilovsky@samba.org) 2012 |
| 8 | * |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #ifndef _SMB2PDU_H |
| 12 | #define _SMB2PDU_H |
| 13 | |
| 14 | #include <net/sock.h> |
Steve French | 90810c2 | 2021-07-03 15:49:35 -0500 | [diff] [blame] | 15 | #include "cifsacl.h" |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 16 | |
Ronnie Sahlberg | 58d15ed | 2019-01-29 12:46:16 +1000 | [diff] [blame] | 17 | /* 52 transform hdr + 64 hdr + 88 create rsp */ |
Ronnie Sahlberg | c4627e6 | 2019-01-29 12:46:17 +1000 | [diff] [blame] | 18 | #define SMB2_TRANSFORM_HEADER_SIZE 52 |
Ronnie Sahlberg | 58d15ed | 2019-01-29 12:46:16 +1000 | [diff] [blame] | 19 | #define MAX_SMB2_HDR_SIZE 204 |
Pavel Shilovsky | 2dc7e1c | 2011-12-26 22:53:34 +0400 | [diff] [blame] | 20 | |
Long Li | f7950cb | 2020-03-26 19:42:24 -0700 | [diff] [blame] | 21 | /* The total header size for SMB2 read and write */ |
Ronnie Sahlberg | 0d35e38 | 2021-11-05 08:39:01 +0900 | [diff] [blame] | 22 | #define SMB2_READWRITE_PDU_HEADER_SIZE (48 + sizeof(struct smb2_hdr)) |
Steve French | 8f23343 | 2020-03-15 18:04:13 -0500 | [diff] [blame] | 23 | |
Steve French | 3984bdc | 2020-10-04 17:42:27 -0500 | [diff] [blame] | 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 | |
Steve French | bb9cad1 | 2021-04-09 15:20:24 -0500 | [diff] [blame] | 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 { |
Steve French | 3984bdc | 2020-10-04 17:42:27 -0500 | [diff] [blame] | 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 | |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 48 | /* |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 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 | */ |
Pavel Shilovsky | 7411286 | 2012-07-27 01:20:41 +0400 | [diff] [blame] | 56 | |
Ronnie Sahlberg | 730928c | 2018-08-08 15:07:49 +1000 | [diff] [blame] | 57 | #define COMPOUND_FID 0xFFFFFFFFFFFFFFFFULL |
| 58 | |
Fabian Frederick | bc09d14 | 2014-12-10 15:41:15 -0800 | [diff] [blame] | 59 | #define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9) |
Pavel Shilovsky | 7411286 | 2012-07-27 01:20:41 +0400 | [diff] [blame] | 60 | |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 61 | struct smb2_err_rsp { |
Ronnie Sahlberg | 0d35e38 | 2021-11-05 08:39:01 +0900 | [diff] [blame] | 62 | struct smb2_hdr hdr; |
Pavel Shilovsky | 093b2bd | 2011-06-08 15:51:07 +0400 | [diff] [blame] | 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 | |
Ronnie Sahlberg | df070af | 2019-07-09 18:41:11 +1000 | [diff] [blame] | 69 | #define SYMLINK_ERROR_TAG 0x4c4d5953 |
| 70 | |
Pavel Shilovsky | b42bf88 | 2013-08-14 19:25:21 +0400 | [diff] [blame] | 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; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 82 | __u8 PathBuffer[]; |
Pavel Shilovsky | b42bf88 | 2013-08-14 19:25:21 +0400 | [diff] [blame] | 83 | } __packed; |
| 84 | |
Steve French | 5f60a56 | 2018-02-05 14:46:18 -0600 | [diff] [blame] | 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 | |
Steve French | 8895c66 | 2020-03-17 01:53:39 -0500 | [diff] [blame] | 92 | /* ErrorId values */ |
| 93 | #define SMB2_ERROR_ID_DEFAULT 0x00000000 |
| 94 | #define SMB2_ERROR_ID_SHARE_REDIRECT cpu_to_le32(0x72645253) /* "rdRS" */ |
| 95 | |
Steve French | 5f60a56 | 2018-02-05 14:46:18 -0600 | [diff] [blame] | 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; |
Steve French | 2438c0b | 2021-06-22 13:56:20 -0500 | [diff] [blame] | 111 | __le16 Reserved; |
Steve French | 5f60a56 | 2018-02-05 14:46:18 -0600 | [diff] [blame] | 112 | __le16 TargetType; |
| 113 | __le32 IPAddrCount; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 114 | struct move_dst_ipaddr IpAddrMoveList[]; |
Steve French | 5f60a56 | 2018-02-05 14:46:18 -0600 | [diff] [blame] | 115 | /* __u8 ResourceName[] */ /* Name of share as counted Unicode string */ |
| 116 | } __packed; |
| 117 | |
Ronnie Sahlberg | 4d8dfaf | 2018-08-21 11:49:21 +1000 | [diff] [blame] | 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 |
Steve French | ff2a09e | 2019-07-06 14:41:38 -0500 | [diff] [blame] | 126 | * [6] : query id context |
| 127 | * [7] : compound padding |
Ronnie Sahlberg | 4d8dfaf | 2018-08-21 11:49:21 +1000 | [diff] [blame] | 128 | */ |
Steve French | ff2a09e | 2019-07-06 14:41:38 -0500 | [diff] [blame] | 129 | #define SMB2_CREATE_IOV_SIZE 8 |
Ronnie Sahlberg | 4d8dfaf | 2018-08-21 11:49:21 +1000 | [diff] [blame] | 130 | |
Ronnie Sahlberg | c4627e6 | 2019-01-29 12:46:17 +1000 | [diff] [blame] | 131 | /* |
| 132 | * Maximum size of a SMB2_CREATE response is 64 (smb2 header) + |
Steve French | ff2a09e | 2019-07-06 14:41:38 -0500 | [diff] [blame] | 133 | * 88 (fixed part of create response) + 520 (path) + 208 (contexts) + |
Ronnie Sahlberg | c4627e6 | 2019-01-29 12:46:17 +1000 | [diff] [blame] | 134 | * 2 bytes of padding. |
| 135 | */ |
Steve French | ff2a09e | 2019-07-06 14:41:38 -0500 | [diff] [blame] | 136 | #define MAX_SMB2_CREATE_RESPONSE_SIZE 880 |
Ronnie Sahlberg | c4627e6 | 2019-01-29 12:46:17 +1000 | [diff] [blame] | 137 | |
Pavel Shilovsky | 53ef101 | 2013-09-05 16:11:28 +0400 | [diff] [blame] | 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 | |
Fabian Frederick | bc09d14 | 2014-12-10 15:41:15 -0800 | [diff] [blame] | 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) |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 146 | |
Steve French | 8895c66 | 2020-03-17 01:53:39 -0500 | [diff] [blame] | 147 | #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS cpu_to_le32(0x00000002) |
Steve French | 5f60a56 | 2018-02-05 14:46:18 -0600 | [diff] [blame] | 148 | #define SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET cpu_to_le32(0x00000004) |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 149 | |
| 150 | #define SMB2_LEASE_KEY_SIZE 16 |
| 151 | |
| 152 | struct lease_context { |
Stefano Brivio | 729c0c9 | 2018-07-05 15:10:02 +0200 | [diff] [blame] | 153 | u8 LeaseKey[SMB2_LEASE_KEY_SIZE]; |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 154 | __le32 LeaseState; |
| 155 | __le32 LeaseFlags; |
| 156 | __le64 LeaseDuration; |
| 157 | } __packed; |
| 158 | |
Pavel Shilovsky | f047390 | 2013-09-04 13:44:05 +0400 | [diff] [blame] | 159 | struct lease_context_v2 { |
Stefano Brivio | 729c0c9 | 2018-07-05 15:10:02 +0200 | [diff] [blame] | 160 | u8 LeaseKey[SMB2_LEASE_KEY_SIZE]; |
Pavel Shilovsky | f047390 | 2013-09-04 13:44:05 +0400 | [diff] [blame] | 161 | __le32 LeaseState; |
| 162 | __le32 LeaseFlags; |
| 163 | __le64 LeaseDuration; |
| 164 | __le64 ParentLeaseKeyLow; |
| 165 | __le64 ParentLeaseKeyHigh; |
| 166 | __le16 Epoch; |
| 167 | __le16 Reserved; |
| 168 | } __packed; |
| 169 | |
Pavel Shilovsky | b8c32db | 2012-09-19 06:22:44 -0700 | [diff] [blame] | 170 | struct create_lease { |
| 171 | struct create_context ccontext; |
| 172 | __u8 Name[8]; |
| 173 | struct lease_context lcontext; |
| 174 | } __packed; |
| 175 | |
Pavel Shilovsky | f047390 | 2013-09-04 13:44:05 +0400 | [diff] [blame] | 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 | |
Pavel Shilovsky | 63eb3de | 2013-07-04 18:41:09 +0400 | [diff] [blame] | 183 | struct create_durable { |
| 184 | struct create_context ccontext; |
| 185 | __u8 Name[8]; |
Pavel Shilovsky | 9cbc0b7 | 2013-07-09 18:40:58 +0400 | [diff] [blame] | 186 | union { |
| 187 | __u8 Reserved[16]; |
| 188 | struct { |
| 189 | __u64 PersistentFileId; |
| 190 | __u64 VolatileFileId; |
| 191 | } Fid; |
| 192 | } Data; |
Pavel Shilovsky | 63eb3de | 2013-07-04 18:41:09 +0400 | [diff] [blame] | 193 | } __packed; |
| 194 | |
Steve French | fe04840 | 2018-05-30 17:10:25 -0500 | [diff] [blame] | 195 | struct create_posix { |
| 196 | struct create_context ccontext; |
| 197 | __u8 Name[16]; |
| 198 | __le32 Mode; |
| 199 | __u32 Reserved; |
| 200 | } __packed; |
| 201 | |
Steve French | b56eae4 | 2015-11-03 09:26:27 -0600 | [diff] [blame] | 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 | |
Steve French | e7348e3 | 2019-06-28 02:35:10 -0500 | [diff] [blame] | 228 | /* See MS-SMB2 2.2.14.2.9 */ |
Steve French | 89a5bfa | 2019-07-18 17:22:18 -0500 | [diff] [blame] | 229 | struct create_on_disk_id { |
| 230 | struct create_context ccontext; |
| 231 | __u8 Name[8]; |
Steve French | e7348e3 | 2019-06-28 02:35:10 -0500 | [diff] [blame] | 232 | __le64 DiskFileId; |
| 233 | __le64 VolumeId; |
Steve French | ff2a09e | 2019-07-06 14:41:38 -0500 | [diff] [blame] | 234 | __u32 Reserved[4]; |
Steve French | e7348e3 | 2019-06-28 02:35:10 -0500 | [diff] [blame] | 235 | } __packed; |
| 236 | |
Steve French | b56eae4 | 2015-11-03 09:26:27 -0600 | [diff] [blame] | 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; |
Pavel Shilovsky | d243af7 | 2019-11-06 13:58:15 -0800 | [diff] [blame] | 247 | __u8 Pad[4]; |
Steve French | b56eae4 | 2015-11-03 09:26:27 -0600 | [diff] [blame] | 248 | } __packed; |
| 249 | |
Steve French | cdeaf9d | 2018-08-10 02:25:06 -0500 | [diff] [blame] | 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 | |
Steve French | ff2a09e | 2019-07-06 14:41:38 -0500 | [diff] [blame] | 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 | |
Steve French | fdef665 | 2019-12-06 02:02:38 -0600 | [diff] [blame] | 264 | struct crt_sd_ctxt { |
| 265 | struct create_context ccontext; |
| 266 | __u8 Name[8]; |
| 267 | struct smb3_sd sd; |
Steve French | fdef665 | 2019-12-06 02:02:38 -0600 | [diff] [blame] | 268 | } __packed; |
| 269 | |
| 270 | |
Steve French | 41c1358 | 2013-11-14 00:05:36 -0600 | [diff] [blame] | 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 */ |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 275 | char Context[]; /* ignored, Windows sets to 4 bytes of zero */ |
Steve French | 41c1358 | 2013-11-14 00:05:36 -0600 | [diff] [blame] | 276 | } __packed; |
| 277 | |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 278 | /* this goes in the ioctl buffer when doing a copychunk request */ |
| 279 | struct copychunk_ioctl { |
Steve French | 41c1358 | 2013-11-14 00:05:36 -0600 | [diff] [blame] | 280 | char SourceKey[COPY_CHUNK_RES_KEY_SIZE]; |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 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; |
Steve French | c866473 | 2013-06-21 15:35:45 -0500 | [diff] [blame] | 286 | __le32 Length; /* how many bytes to copy */ |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 287 | __u32 Reserved2; |
| 288 | } __packed; |
| 289 | |
Steve French | 31742c5 | 2014-08-17 08:38:47 -0500 | [diff] [blame] | 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 | |
Steve French | 41c1358 | 2013-11-14 00:05:36 -0600 | [diff] [blame] | 296 | struct copychunk_ioctl_rsp { |
| 297 | __le32 ChunksWritten; |
| 298 | __le32 ChunkBytesWritten; |
| 299 | __le32 TotalBytesWritten; |
| 300 | } __packed; |
| 301 | |
Steve French | 7d03ae4 | 2020-10-23 15:21:38 -0500 | [diff] [blame] | 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 | |
Steve French | 9d1b066 | 2015-06-24 02:12:19 -0500 | [diff] [blame] | 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 | |
Ronnie Sahlberg | 2f3ebab | 2019-04-25 16:45:29 +1000 | [diff] [blame] | 341 | struct file_allocated_range_buffer { |
| 342 | __le64 file_offset; |
| 343 | __le64 length; |
| 344 | } __packed; |
| 345 | |
Steve French | 9d1b066 | 2015-06-24 02:12:19 -0500 | [diff] [blame] | 346 | /* Integrity ChecksumAlgorithm choices for above */ |
| 347 | #define CHECKSUM_TYPE_NONE 0x0000 |
| 348 | #define CHECKSUM_TYPE_CRC64 0x0002 |
Steve French | b3152e2 | 2015-06-24 03:17:02 -0500 | [diff] [blame] | 349 | #define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */ |
Steve French | 9d1b066 | 2015-06-24 02:12:19 -0500 | [diff] [blame] | 350 | |
| 351 | /* Integrity flags for above */ |
| 352 | #define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001 |
| 353 | |
Steve French | 0df444a | 2018-10-31 11:24:33 -0500 | [diff] [blame] | 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; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 362 | __u8 DataBuffer[]; /* Variable Length */ |
Steve French | 0df444a | 2018-10-31 11:24:33 -0500 | [diff] [blame] | 363 | } __packed; |
| 364 | |
| 365 | struct reparse_guid_data_buffer { |
| 366 | __le32 ReparseTag; |
| 367 | __le16 ReparseDataLength; |
| 368 | __u16 Reserved; |
| 369 | __u8 ReparseGuid[16]; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 370 | __u8 DataBuffer[]; /* Variable Length */ |
Steve French | 0df444a | 2018-10-31 11:24:33 -0500 | [diff] [blame] | 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; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 381 | __u8 PathBuffer[]; /* Variable Length */ |
Steve French | 0df444a | 2018-10-31 11:24:33 -0500 | [diff] [blame] | 382 | } __packed; |
| 383 | |
Ronnie Sahlberg | 5de254d | 2019-06-27 14:57:02 +1000 | [diff] [blame] | 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; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 395 | __u8 PathBuffer[]; /* Variable Length */ |
Ronnie Sahlberg | 5de254d | 2019-06-27 14:57:02 +1000 | [diff] [blame] | 396 | } __packed; |
Steve French | 0df444a | 2018-10-31 11:24:33 -0500 | [diff] [blame] | 397 | |
| 398 | /* See MS-FSCC 2.1.2.6 and cifspdu.h for struct reparse_posix_data */ |
| 399 | |
| 400 | |
Aurelien Aptel | 9d49640 | 2017-02-13 16:16:49 +0100 | [diff] [blame] | 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 | |
Steve French | b56eae4 | 2015-11-03 09:26:27 -0600 | [diff] [blame] | 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 | |
Steve French | 9d1b066 | 2015-06-24 02:12:19 -0500 | [diff] [blame] | 416 | |
Steve French | ff1c038 | 2013-11-19 23:44:46 -0600 | [diff] [blame] | 417 | struct validate_negotiate_info_req { |
Steve French | 4a72daf | 2013-06-25 00:20:49 -0500 | [diff] [blame] | 418 | __le32 Capabilities; |
| 419 | __u8 Guid[SMB2_CLIENT_GUID_SIZE]; |
| 420 | __le16 SecurityMode; |
| 421 | __le16 DialectCount; |
Steve French | d5c7076 | 2019-01-03 02:37:21 -0600 | [diff] [blame] | 422 | __le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */ |
Steve French | ff1c038 | 2013-11-19 23:44:46 -0600 | [diff] [blame] | 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 */ |
Steve French | 4a72daf | 2013-06-25 00:20:49 -0500 | [diff] [blame] | 430 | } __packed; |
| 431 | |
Aurelien Aptel | bead042 | 2018-06-14 15:43:17 +0200 | [diff] [blame] | 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) |
Steve French | 4a72daf | 2013-06-25 00:20:49 -0500 | [diff] [blame] | 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; |
Aurelien Aptel | bead042 | 2018-06-14 15:43:17 +0200 | [diff] [blame] | 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; |
Steve French | 4a72daf | 2013-06-25 00:20:49 -0500 | [diff] [blame] | 459 | } __packed; |
| 460 | |
| 461 | #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */ |
| 462 | |
Steve French | 64a5cfa | 2013-10-14 15:31:32 -0500 | [diff] [blame] | 463 | struct compress_ioctl { |
Steve French | c7f508a | 2013-10-14 15:27:32 -0500 | [diff] [blame] | 464 | __le16 CompressionState; /* See cifspdu.h for possible flag values */ |
Steve French | 64a5cfa | 2013-10-14 15:31:32 -0500 | [diff] [blame] | 465 | } __packed; |
| 466 | |
Steve French | 02b1666 | 2015-06-27 21:18:36 -0700 | [diff] [blame] | 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 | |
Ronnie Sahlberg | 72c419d | 2019-03-13 14:37:49 +1000 | [diff] [blame] | 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 | |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 482 | struct smb2_ioctl_req { |
Ronnie Sahlberg | 0d35e38 | 2021-11-05 08:39:01 +0900 | [diff] [blame] | 483 | struct smb2_hdr hdr; |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 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; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 497 | __u8 Buffer[]; |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 498 | } __packed; |
| 499 | |
| 500 | struct smb2_ioctl_rsp { |
Ronnie Sahlberg | 0d35e38 | 2021-11-05 08:39:01 +0900 | [diff] [blame] | 501 | struct smb2_hdr hdr; |
Steve French | be7457d | 2013-06-19 17:41:10 -0500 | [diff] [blame] | 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 | |
Pavel Shilovsky | 027e8ee | 2012-09-19 06:22:43 -0700 | [diff] [blame] | 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 | |
Pavel Shilovsky | f7ba7fe | 2012-09-19 06:22:43 -0700 | [diff] [blame] | 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 { |
Ronnie Sahlberg | 0d35e38 | 2021-11-05 08:39:01 +0900 | [diff] [blame] | 529 | struct smb2_hdr hdr; |
Pavel Shilovsky | f7ba7fe | 2012-09-19 06:22:43 -0700 | [diff] [blame] | 530 | __le16 StructureSize; /* Must be 48 */ |
| 531 | __le16 LockCount; |
Steve French | bb9cad1 | 2021-04-09 15:20:24 -0500 | [diff] [blame] | 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; |
Pavel Shilovsky | f7ba7fe | 2012-09-19 06:22:43 -0700 | [diff] [blame] | 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 { |
Ronnie Sahlberg | 0d35e38 | 2021-11-05 08:39:01 +0900 | [diff] [blame] | 544 | struct smb2_hdr hdr; |
Pavel Shilovsky | f7ba7fe | 2012-09-19 06:22:43 -0700 | [diff] [blame] | 545 | __le16 StructureSize; /* Must be 4 */ |
| 546 | __le16 Reserved; |
| 547 | } __packed; |
| 548 | |
Pavel Shilovsky | 9094fad | 2012-07-12 18:30:44 +0400 | [diff] [blame] | 549 | struct smb2_echo_req { |
Ronnie Sahlberg | 0d35e38 | 2021-11-05 08:39:01 +0900 | [diff] [blame] | 550 | struct smb2_hdr hdr; |
Pavel Shilovsky | 9094fad | 2012-07-12 18:30:44 +0400 | [diff] [blame] | 551 | __le16 StructureSize; /* Must be 4 */ |
| 552 | __u16 Reserved; |
| 553 | } __packed; |
| 554 | |
| 555 | struct smb2_echo_rsp { |
Ronnie Sahlberg | 0d35e38 | 2021-11-05 08:39:01 +0900 | [diff] [blame] | 556 | struct smb2_hdr hdr; |
Pavel Shilovsky | 9094fad | 2012-07-12 18:30:44 +0400 | [diff] [blame] | 557 | __le16 StructureSize; /* Must be 4 */ |
| 558 | __u16 Reserved; |
| 559 | } __packed; |
| 560 | |
Pavel Shilovsky | d324f08d | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 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 | |
Ronnie Sahlberg | 0a17799 | 2020-01-08 13:08:04 +1000 | [diff] [blame] | 567 | #define SMB2_QUERY_DIRECTORY_IOV_SIZE 2 |
| 568 | |
Steve French | 2438c0b | 2021-06-22 13:56:20 -0500 | [diff] [blame] | 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 | |
Pavel Shilovsky | d324f08d | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 585 | struct smb2_query_directory_req { |
Ronnie Sahlberg | 0d35e38 | 2021-11-05 08:39:01 +0900 | [diff] [blame] | 586 | struct smb2_hdr hdr; |
Pavel Shilovsky | d324f08d | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 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 { |
Ronnie Sahlberg | 0d35e38 | 2021-11-05 08:39:01 +0900 | [diff] [blame] | 600 | struct smb2_hdr hdr; |
Pavel Shilovsky | d324f08d | 2012-09-18 16:20:33 -0700 | [diff] [blame] | 601 | __le16 StructureSize; /* Must be 9 */ |
| 602 | __le16 OutputBufferOffset; |
| 603 | __le32 OutputBufferLength; |
| 604 | __u8 Buffer[1]; |
| 605 | } __packed; |
| 606 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 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 | |
Steve French | 911a8df | 2014-10-19 19:18:05 -0500 | [diff] [blame] | 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 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 632 | struct smb2_query_info_req { |
Ronnie Sahlberg | 0d35e38 | 2021-11-05 08:39:01 +0900 | [diff] [blame] | 633 | struct smb2_hdr hdr; |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 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 { |
Ronnie Sahlberg | 0d35e38 | 2021-11-05 08:39:01 +0900 | [diff] [blame] | 649 | struct smb2_hdr hdr; |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 650 | __le16 StructureSize; /* Must be 9 */ |
| 651 | __le16 OutputBufferOffset; |
| 652 | __le32 OutputBufferLength; |
| 653 | __u8 Buffer[1]; |
| 654 | } __packed; |
| 655 | |
Ronnie Sahlberg | 14e562a | 2018-09-03 13:33:50 +1000 | [diff] [blame] | 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 | |
Pavel Shilovsky | 35143eb | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 665 | struct smb2_set_info_req { |
Ronnie Sahlberg | 0d35e38 | 2021-11-05 08:39:01 +0900 | [diff] [blame] | 666 | struct smb2_hdr hdr; |
Pavel Shilovsky | 35143eb | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 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 { |
Ronnie Sahlberg | 0d35e38 | 2021-11-05 08:39:01 +0900 | [diff] [blame] | 680 | struct smb2_hdr hdr; |
Pavel Shilovsky | 35143eb | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 681 | __le16 StructureSize; /* Must be 2 */ |
| 682 | } __packed; |
| 683 | |
Ronnie Sahlberg | 0d5a288 | 2018-06-01 10:53:03 +1000 | [diff] [blame] | 684 | struct smb2_oplock_break { |
Ronnie Sahlberg | 0d35e38 | 2021-11-05 08:39:01 +0900 | [diff] [blame] | 685 | struct smb2_hdr hdr; |
Ronnie Sahlberg | 21ad948 | 2017-11-20 11:24:43 +1100 | [diff] [blame] | 686 | __le16 StructureSize; /* Must be 24 */ |
| 687 | __u8 OplockLevel; |
| 688 | __u8 Reserved; |
| 689 | __le32 Reserved2; |
| 690 | __u64 PersistentFid; |
| 691 | __u64 VolatileFid; |
| 692 | } __packed; |
| 693 | |
Pavel Shilovsky | 0822f51 | 2012-09-19 06:22:45 -0700 | [diff] [blame] | 694 | #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01) |
| 695 | |
| 696 | struct smb2_lease_break { |
Ronnie Sahlberg | 0d35e38 | 2021-11-05 08:39:01 +0900 | [diff] [blame] | 697 | struct smb2_hdr hdr; |
Pavel Shilovsky | 0822f51 | 2012-09-19 06:22:45 -0700 | [diff] [blame] | 698 | __le16 StructureSize; /* Must be 44 */ |
Pavel Shilovsky | 9bd4540 | 2019-10-29 16:51:19 -0700 | [diff] [blame] | 699 | __le16 Epoch; |
Pavel Shilovsky | 0822f51 | 2012-09-19 06:22:45 -0700 | [diff] [blame] | 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 { |
Ronnie Sahlberg | 0d35e38 | 2021-11-05 08:39:01 +0900 | [diff] [blame] | 710 | struct smb2_hdr hdr; |
Pavel Shilovsky | 0822f51 | 2012-09-19 06:22:45 -0700 | [diff] [blame] | 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 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 719 | /* |
| 720 | * PDU infolevel structure definitions |
| 721 | * BB consider moving to a different header |
| 722 | */ |
| 723 | |
Pavel Shilovsky | 6fc05c2 | 2012-09-18 16:20:34 -0700 | [diff] [blame] | 724 | /* File System Information Classes */ |
| 725 | #define FS_VOLUME_INFORMATION 1 /* Query */ |
Steven French | af6a12e | 2013-10-09 20:55:53 -0500 | [diff] [blame] | 726 | #define FS_LABEL_INFORMATION 2 /* Local only */ |
Pavel Shilovsky | 6fc05c2 | 2012-09-18 16:20:34 -0700 | [diff] [blame] | 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 */ |
Steven French | af6a12e | 2013-10-09 20:55:53 -0500 | [diff] [blame] | 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 */ |
Steve French | 2d30421 | 2018-06-24 23:28:12 -0500 | [diff] [blame] | 736 | #define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */ |
Pavel Shilovsky | 6fc05c2 | 2012-09-18 16:20:34 -0700 | [diff] [blame] | 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 | |
Steven French | af6a12e | 2013-10-09 20:55:53 -0500 | [diff] [blame] | 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 | |
Steve French | 21ba384 | 2018-06-24 23:18:52 -0500 | [diff] [blame] | 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; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 770 | __u8 VolumeLabel[]; /* variable len */ |
Steve French | 21ba384 | 2018-06-24 23:18:52 -0500 | [diff] [blame] | 771 | } __packed; |
| 772 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 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 |
Steve French | 51d92d6 | 2020-02-06 12:32:03 -0600 | [diff] [blame] | 820 | #define FILE_ID_INFORMATION 59 |
Steve French | 2438c0b | 2021-06-22 13:56:20 -0500 | [diff] [blame] | 821 | #define FILE_ID_EXTD_DIRECTORY_INFORMATION 60 |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 822 | |
Pavel Shilovsky | f0df737 | 2012-09-18 16:20:26 -0700 | [diff] [blame] | 823 | struct smb2_file_internal_info { |
| 824 | __le64 IndexNumber; |
| 825 | } __packed; /* level 6 Query */ |
| 826 | |
Pavel Shilovsky | 35143eb | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 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; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 833 | char FileName[]; /* New name to be assigned */ |
Steve French | 7d03ae4 | 2020-10-23 15:21:38 -0500 | [diff] [blame] | 834 | /* padding - overall struct size must be >= 24 so filename + pad >= 6 */ |
Pavel Shilovsky | 35143eb | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 835 | } __packed; /* level 10 Set */ |
| 836 | |
Pavel Shilovsky | 568798c | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 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; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 843 | char FileName[]; /* Name to be assigned to new link */ |
Pavel Shilovsky | 568798c | 2012-09-18 16:20:31 -0700 | [diff] [blame] | 844 | } __packed; /* level 11 Set */ |
| 845 | |
Ronnie Sahlberg | 95907fe | 2017-08-24 11:24:55 +1000 | [diff] [blame] | 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; |
Gustavo A. R. Silva | cff2def | 2020-03-09 10:44:51 -0500 | [diff] [blame] | 851 | char ea_data[]; /* \0 terminated name plus value */ |
Ronnie Sahlberg | 95907fe | 2017-08-24 11:24:55 +1000 | [diff] [blame] | 852 | } __packed; /* level 15 Set */ |
| 853 | |
Pavel Shilovsky | be4cb9e | 2011-12-29 17:06:33 +0400 | [diff] [blame] | 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 | |
Pavel Shilovsky | c839ff2 | 2012-09-18 16:20:32 -0700 | [diff] [blame] | 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 | |
Steve French | 2e4564b | 2020-10-22 22:03:14 -0500 | [diff] [blame] | 886 | struct smb2_file_reparse_point_info { |
| 887 | __le64 IndexNumber; |
| 888 | __le32 Tag; |
| 889 | } __packed; |
| 890 | |
Steve French | 43f8a6a | 2019-12-02 21:46:54 -0600 | [diff] [blame] | 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 | |
Steve French | 2438c0b | 2021-06-22 13:56:20 -0500 | [diff] [blame] | 902 | /* See MS-FSCC 2.4.21 */ |
Steve French | 51d92d6 | 2020-02-06 12:32:03 -0600 | [diff] [blame] | 903 | struct smb2_file_id_information { |
| 904 | __le64 VolumeSerialNumber; |
| 905 | __u64 PersistentFileId; /* opaque endianness */ |
| 906 | __u64 VolatileFileId; /* opaque endianness */ |
| 907 | } __packed; /* level 59 */ |
| 908 | |
Steve French | 2438c0b | 2021-06-22 13:56:20 -0500 | [diff] [blame] | 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 | |
Ronnie Sahlberg | 730928c | 2018-08-08 15:07:49 +1000 | [diff] [blame] | 927 | extern char smb2_padding[7]; |
| 928 | |
Steve French | ab3459d | 2020-02-06 17:31:56 -0600 | [diff] [blame] | 929 | /* equivalent of the contents of SMB3.1.1 POSIX open context response */ |
Aurelien Aptel | 2e8af97 | 2020-02-08 15:50:56 +0100 | [diff] [blame] | 930 | struct create_posix_rsp { |
Aurelien Aptel | 69dda30 | 2020-03-02 17:53:22 +0100 | [diff] [blame] | 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 */ |
Aurelien Aptel | 2e8af97 | 2020-02-08 15:50:56 +0100 | [diff] [blame] | 936 | } __packed; |
Aurelien Aptel | 349e13a | 2020-02-08 15:50:57 +0100 | [diff] [blame] | 937 | |
| 938 | /* |
Steve French | 6a5f659 | 2020-06-11 19:25:47 -0500 | [diff] [blame] | 939 | * SMB2-only POSIX info level for query dir |
Aurelien Aptel | 349e13a | 2020-02-08 15:50:57 +0100 | [diff] [blame] | 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 | |
Steve French | 6a5f659 | 2020-06-11 19:25:47 -0500 | [diff] [blame] | 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 | |
Aurelien Aptel | 349e13a | 2020-02-08 15:50:57 +0100 | [diff] [blame] | 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; |
Steve French | ab3459d | 2020-02-06 17:31:56 -0600 | [diff] [blame] | 1005 | }; |
Aurelien Aptel | 349e13a | 2020-02-08 15:50:57 +0100 | [diff] [blame] | 1006 | |
Steve French | ddfbefb | 2011-03-15 02:08:48 +0000 | [diff] [blame] | 1007 | #endif /* _SMB2PDU_H */ |