]>
Commit | Line | Data |
---|---|---|
929be906 | 1 | /* SPDX-License-Identifier: LGPL-2.1 */ |
ddfbefbd | 2 | /* |
ddfbefbd | 3 | * |
be7457d3 | 4 | * Copyright (c) International Business Machines Corp., 2009, 2013 |
ddfbefbd SF |
5 | * Etersoft, 2012 |
6 | * Author(s): Steve French (sfrench@us.ibm.com) | |
7 | * Pavel Shilovsky (pshilovsky@samba.org) 2012 | |
8 | * | |
ddfbefbd SF |
9 | */ |
10 | ||
11 | #ifndef _SMB2PDU_H | |
12 | #define _SMB2PDU_H | |
13 | ||
14 | #include <net/sock.h> | |
90810c25 | 15 | #include "cifsacl.h" |
ddfbefbd | 16 | |
58d15ed1 | 17 | /* 52 transform hdr + 64 hdr + 88 create rsp */ |
c4627e66 | 18 | #define SMB2_TRANSFORM_HEADER_SIZE 52 |
58d15ed1 | 19 | #define MAX_SMB2_HDR_SIZE 204 |
2dc7e1c0 | 20 | |
f7950cb0 | 21 | /* The total header size for SMB2 read and write */ |
0d35e382 | 22 | #define SMB2_READWRITE_PDU_HEADER_SIZE (48 + sizeof(struct smb2_hdr)) |
8f233431 | 23 | |
3984bdc0 SF |
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 | ||
bb9cad1b SF |
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 { | |
3984bdc0 SF |
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 | ||
093b2bda PS |
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 | */ | |
74112860 | 56 | |
730928c8 RS |
57 | #define COMPOUND_FID 0xFFFFFFFFFFFFFFFFULL |
58 | ||
bc09d141 | 59 | #define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9) |
74112860 | 60 | |
093b2bda | 61 | struct smb2_err_rsp { |
0d35e382 | 62 | struct smb2_hdr hdr; |
093b2bda PS |
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 | ||
df070afd RS |
69 | #define SYMLINK_ERROR_TAG 0x4c4d5953 |
70 | ||
b42bf888 PS |
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; | |
cff2def5 | 82 | __u8 PathBuffer[]; |
b42bf888 PS |
83 | } __packed; |
84 | ||
5f60a564 SF |
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 | ||
8895c66f SF |
92 | /* ErrorId values */ |
93 | #define SMB2_ERROR_ID_DEFAULT 0x00000000 | |
94 | #define SMB2_ERROR_ID_SHARE_REDIRECT cpu_to_le32(0x72645253) /* "rdRS" */ | |
95 | ||
5f60a564 SF |
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; | |
2438c0bd | 111 | __le16 Reserved; |
5f60a564 SF |
112 | __le16 TargetType; |
113 | __le32 IPAddrCount; | |
cff2def5 | 114 | struct move_dst_ipaddr IpAddrMoveList[]; |
5f60a564 SF |
115 | /* __u8 ResourceName[] */ /* Name of share as counted Unicode string */ |
116 | } __packed; | |
117 | ||
2503a0db PS |
118 | /* File Attrubutes */ |
119 | #define FILE_ATTRIBUTE_READONLY 0x00000001 | |
120 | #define FILE_ATTRIBUTE_HIDDEN 0x00000002 | |
121 | #define FILE_ATTRIBUTE_SYSTEM 0x00000004 | |
122 | #define FILE_ATTRIBUTE_DIRECTORY 0x00000010 | |
123 | #define FILE_ATTRIBUTE_ARCHIVE 0x00000020 | |
124 | #define FILE_ATTRIBUTE_NORMAL 0x00000080 | |
125 | #define FILE_ATTRIBUTE_TEMPORARY 0x00000100 | |
126 | #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 | |
127 | #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 | |
128 | #define FILE_ATTRIBUTE_COMPRESSED 0x00000800 | |
129 | #define FILE_ATTRIBUTE_OFFLINE 0x00001000 | |
130 | #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 | |
131 | #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 | |
73322979 SF |
132 | #define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000 |
133 | #define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000 | |
2503a0db PS |
134 | |
135 | /* Oplock levels */ | |
136 | #define SMB2_OPLOCK_LEVEL_NONE 0x00 | |
137 | #define SMB2_OPLOCK_LEVEL_II 0x01 | |
138 | #define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08 | |
139 | #define SMB2_OPLOCK_LEVEL_BATCH 0x09 | |
140 | #define SMB2_OPLOCK_LEVEL_LEASE 0xFF | |
b8c32dbb PS |
141 | /* Non-spec internal type */ |
142 | #define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99 | |
2503a0db PS |
143 | |
144 | /* Desired Access Flags */ | |
145 | #define FILE_READ_DATA_LE cpu_to_le32(0x00000001) | |
146 | #define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002) | |
147 | #define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004) | |
148 | #define FILE_READ_EA_LE cpu_to_le32(0x00000008) | |
149 | #define FILE_WRITE_EA_LE cpu_to_le32(0x00000010) | |
150 | #define FILE_EXECUTE_LE cpu_to_le32(0x00000020) | |
151 | #define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080) | |
152 | #define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100) | |
153 | #define FILE_DELETE_LE cpu_to_le32(0x00010000) | |
154 | #define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000) | |
155 | #define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000) | |
156 | #define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000) | |
157 | #define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000) | |
158 | #define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000) | |
159 | #define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000) | |
160 | #define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000) | |
161 | #define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000) | |
162 | #define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000) | |
163 | #define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000) | |
164 | ||
165 | /* ShareAccess Flags */ | |
166 | #define FILE_SHARE_READ_LE cpu_to_le32(0x00000001) | |
167 | #define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002) | |
168 | #define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004) | |
169 | #define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007) | |
170 | ||
171 | /* CreateDisposition Flags */ | |
172 | #define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000) | |
173 | #define FILE_OPEN_LE cpu_to_le32(0x00000001) | |
174 | #define FILE_CREATE_LE cpu_to_le32(0x00000002) | |
175 | #define FILE_OPEN_IF_LE cpu_to_le32(0x00000003) | |
176 | #define FILE_OVERWRITE_LE cpu_to_le32(0x00000004) | |
177 | #define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005) | |
178 | ||
179 | /* CreateOptions Flags */ | |
180 | #define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001) | |
181 | /* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */ | |
182 | #define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002) | |
183 | #define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004) | |
184 | #define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008) | |
185 | #define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010) | |
186 | #define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020) | |
187 | #define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040) | |
188 | #define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100) | |
189 | #define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200) | |
190 | #define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800) | |
191 | #define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000) | |
192 | #define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000) | |
193 | #define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000) | |
194 | #define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000) | |
195 | #define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000) | |
196 | #define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000) | |
197 | #define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000) | |
198 | #define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000) | |
199 | ||
200 | #define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \ | |
201 | | FILE_READ_ATTRIBUTES_LE) | |
202 | #define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \ | |
203 | | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE) | |
204 | #define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE) | |
205 | ||
8895c66f | 206 | /* Impersonation Levels. See MS-WPO section 9.7 and MSDN-IMPERS */ |
2503a0db PS |
207 | #define IL_ANONYMOUS cpu_to_le32(0x00000000) |
208 | #define IL_IDENTIFICATION cpu_to_le32(0x00000001) | |
209 | #define IL_IMPERSONATION cpu_to_le32(0x00000002) | |
210 | #define IL_DELEGATE cpu_to_le32(0x00000003) | |
211 | ||
212 | /* Create Context Values */ | |
213 | #define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */ | |
214 | #define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */ | |
215 | #define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ" | |
216 | #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC" | |
12197a7f | 217 | #define SMB2_CREATE_ALLOCATION_SIZE "AISi" |
2503a0db PS |
218 | #define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc" |
219 | #define SMB2_CREATE_TIMEWARP_REQUEST "TWrp" | |
220 | #define SMB2_CREATE_QUERY_ON_DISK_ID "QFid" | |
221 | #define SMB2_CREATE_REQUEST_LEASE "RqLs" | |
12197a7f SF |
222 | #define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q" |
223 | #define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C" | |
224 | #define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74 | |
e7348e35 | 225 | #define SMB2_CREATE_APP_INSTANCE_VERSION 0xB982D0B73B56074FA07B524A8116A010 |
fe048402 SF |
226 | #define SVHDX_OPEN_DEVICE_CONTEX 0x9CCBCF9E04C1E643980E158DA1F6EC83 |
227 | #define SMB2_CREATE_TAG_POSIX 0x93AD25509CB411E7B42383DE968BCD7C | |
228 | ||
37e6a705 SF |
229 | /* Flag (SMB3 open response) values */ |
230 | #define SMB2_CREATE_FLAG_REPARSEPOINT 0x01 | |
2503a0db | 231 | |
4d8dfafc RS |
232 | /* |
233 | * Maximum number of iovs we need for an open/create request. | |
234 | * [0] : struct smb2_create_req | |
235 | * [1] : path | |
236 | * [2] : lease context | |
237 | * [3] : durable context | |
238 | * [4] : posix context | |
239 | * [5] : time warp context | |
ff2a09e9 SF |
240 | * [6] : query id context |
241 | * [7] : compound padding | |
4d8dfafc | 242 | */ |
ff2a09e9 | 243 | #define SMB2_CREATE_IOV_SIZE 8 |
4d8dfafc | 244 | |
2503a0db | 245 | struct smb2_create_req { |
0d35e382 | 246 | struct smb2_hdr hdr; |
2503a0db PS |
247 | __le16 StructureSize; /* Must be 57 */ |
248 | __u8 SecurityFlags; | |
249 | __u8 RequestedOplockLevel; | |
250 | __le32 ImpersonationLevel; | |
251 | __le64 SmbCreateFlags; | |
252 | __le64 Reserved; | |
253 | __le32 DesiredAccess; | |
254 | __le32 FileAttributes; | |
255 | __le32 ShareAccess; | |
256 | __le32 CreateDisposition; | |
257 | __le32 CreateOptions; | |
258 | __le16 NameOffset; | |
259 | __le16 NameLength; | |
260 | __le32 CreateContextsOffset; | |
261 | __le32 CreateContextsLength; | |
cff2def5 | 262 | __u8 Buffer[]; |
2503a0db PS |
263 | } __packed; |
264 | ||
c4627e66 RS |
265 | /* |
266 | * Maximum size of a SMB2_CREATE response is 64 (smb2 header) + | |
ff2a09e9 | 267 | * 88 (fixed part of create response) + 520 (path) + 208 (contexts) + |
c4627e66 RS |
268 | * 2 bytes of padding. |
269 | */ | |
ff2a09e9 | 270 | #define MAX_SMB2_CREATE_RESPONSE_SIZE 880 |
c4627e66 | 271 | |
2503a0db | 272 | struct smb2_create_rsp { |
0d35e382 | 273 | struct smb2_hdr hdr; |
2503a0db PS |
274 | __le16 StructureSize; /* Must be 89 */ |
275 | __u8 OplockLevel; | |
37e6a705 | 276 | __u8 Flag; /* 0x01 if reparse point */ |
2503a0db PS |
277 | __le32 CreateAction; |
278 | __le64 CreationTime; | |
279 | __le64 LastAccessTime; | |
280 | __le64 LastWriteTime; | |
281 | __le64 ChangeTime; | |
282 | __le64 AllocationSize; | |
283 | __le64 EndofFile; | |
284 | __le32 FileAttributes; | |
285 | __le32 Reserved2; | |
286 | __u64 PersistentFileId; /* opaque endianness */ | |
287 | __u64 VolatileFileId; /* opaque endianness */ | |
288 | __le32 CreateContextsOffset; | |
289 | __le32 CreateContextsLength; | |
290 | __u8 Buffer[1]; | |
291 | } __packed; | |
292 | ||
b8c32dbb PS |
293 | struct create_context { |
294 | __le32 Next; | |
295 | __le16 NameOffset; | |
296 | __le16 NameLength; | |
297 | __le16 Reserved; | |
298 | __le16 DataOffset; | |
299 | __le32 DataLength; | |
cff2def5 | 300 | __u8 Buffer[]; |
b8c32dbb PS |
301 | } __packed; |
302 | ||
53ef1016 PS |
303 | #define SMB2_LEASE_READ_CACHING_HE 0x01 |
304 | #define SMB2_LEASE_HANDLE_CACHING_HE 0x02 | |
305 | #define SMB2_LEASE_WRITE_CACHING_HE 0x04 | |
306 | ||
bc09d141 FF |
307 | #define SMB2_LEASE_NONE cpu_to_le32(0x00) |
308 | #define SMB2_LEASE_READ_CACHING cpu_to_le32(0x01) | |
309 | #define SMB2_LEASE_HANDLE_CACHING cpu_to_le32(0x02) | |
310 | #define SMB2_LEASE_WRITE_CACHING cpu_to_le32(0x04) | |
b8c32dbb | 311 | |
8895c66f | 312 | #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS cpu_to_le32(0x00000002) |
5f60a564 | 313 | #define SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET cpu_to_le32(0x00000004) |
b8c32dbb PS |
314 | |
315 | #define SMB2_LEASE_KEY_SIZE 16 | |
316 | ||
317 | struct lease_context { | |
729c0c9d | 318 | u8 LeaseKey[SMB2_LEASE_KEY_SIZE]; |
b8c32dbb PS |
319 | __le32 LeaseState; |
320 | __le32 LeaseFlags; | |
321 | __le64 LeaseDuration; | |
322 | } __packed; | |
323 | ||
f047390a | 324 | struct lease_context_v2 { |
729c0c9d | 325 | u8 LeaseKey[SMB2_LEASE_KEY_SIZE]; |
f047390a PS |
326 | __le32 LeaseState; |
327 | __le32 LeaseFlags; | |
328 | __le64 LeaseDuration; | |
329 | __le64 ParentLeaseKeyLow; | |
330 | __le64 ParentLeaseKeyHigh; | |
331 | __le16 Epoch; | |
332 | __le16 Reserved; | |
333 | } __packed; | |
334 | ||
b8c32dbb PS |
335 | struct create_lease { |
336 | struct create_context ccontext; | |
337 | __u8 Name[8]; | |
338 | struct lease_context lcontext; | |
339 | } __packed; | |
340 | ||
f047390a PS |
341 | struct create_lease_v2 { |
342 | struct create_context ccontext; | |
343 | __u8 Name[8]; | |
344 | struct lease_context_v2 lcontext; | |
345 | __u8 Pad[4]; | |
346 | } __packed; | |
347 | ||
63eb3def PS |
348 | struct create_durable { |
349 | struct create_context ccontext; | |
350 | __u8 Name[8]; | |
9cbc0b73 PS |
351 | union { |
352 | __u8 Reserved[16]; | |
353 | struct { | |
354 | __u64 PersistentFileId; | |
355 | __u64 VolatileFileId; | |
356 | } Fid; | |
357 | } Data; | |
63eb3def PS |
358 | } __packed; |
359 | ||
fe048402 SF |
360 | struct create_posix { |
361 | struct create_context ccontext; | |
362 | __u8 Name[16]; | |
363 | __le32 Mode; | |
364 | __u32 Reserved; | |
365 | } __packed; | |
366 | ||
b56eae4d SF |
367 | /* See MS-SMB2 2.2.13.2.11 */ |
368 | /* Flags */ | |
369 | #define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002 | |
370 | struct durable_context_v2 { | |
371 | __le32 Timeout; | |
372 | __le32 Flags; | |
373 | __u64 Reserved; | |
374 | __u8 CreateGuid[16]; | |
375 | } __packed; | |
376 | ||
377 | struct create_durable_v2 { | |
378 | struct create_context ccontext; | |
379 | __u8 Name[8]; | |
380 | struct durable_context_v2 dcontext; | |
381 | } __packed; | |
382 | ||
383 | /* See MS-SMB2 2.2.13.2.12 */ | |
384 | struct durable_reconnect_context_v2 { | |
385 | struct { | |
386 | __u64 PersistentFileId; | |
387 | __u64 VolatileFileId; | |
388 | } Fid; | |
389 | __u8 CreateGuid[16]; | |
390 | __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */ | |
391 | } __packed; | |
392 | ||
e7348e35 | 393 | /* See MS-SMB2 2.2.14.2.9 */ |
89a5bfa3 SF |
394 | struct create_on_disk_id { |
395 | struct create_context ccontext; | |
396 | __u8 Name[8]; | |
e7348e35 SF |
397 | __le64 DiskFileId; |
398 | __le64 VolumeId; | |
ff2a09e9 | 399 | __u32 Reserved[4]; |
e7348e35 SF |
400 | } __packed; |
401 | ||
b56eae4d SF |
402 | /* See MS-SMB2 2.2.14.2.12 */ |
403 | struct durable_reconnect_context_v2_rsp { | |
404 | __le32 Timeout; | |
405 | __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */ | |
406 | } __packed; | |
407 | ||
408 | struct create_durable_handle_reconnect_v2 { | |
409 | struct create_context ccontext; | |
410 | __u8 Name[8]; | |
411 | struct durable_reconnect_context_v2 dcontext; | |
d243af7a | 412 | __u8 Pad[4]; |
b56eae4d SF |
413 | } __packed; |
414 | ||
cdeaf9d0 SF |
415 | /* See MS-SMB2 2.2.13.2.5 */ |
416 | struct crt_twarp_ctxt { | |
417 | struct create_context ccontext; | |
418 | __u8 Name[8]; | |
419 | __le64 Timestamp; | |
420 | ||
421 | } __packed; | |
422 | ||
ff2a09e9 SF |
423 | /* See MS-SMB2 2.2.13.2.9 */ |
424 | struct crt_query_id_ctxt { | |
425 | struct create_context ccontext; | |
426 | __u8 Name[8]; | |
427 | } __packed; | |
428 | ||
fdef665b SF |
429 | struct crt_sd_ctxt { |
430 | struct create_context ccontext; | |
431 | __u8 Name[8]; | |
432 | struct smb3_sd sd; | |
fdef665b SF |
433 | } __packed; |
434 | ||
435 | ||
41c1358e SF |
436 | #define COPY_CHUNK_RES_KEY_SIZE 24 |
437 | struct resume_key_req { | |
438 | char ResumeKey[COPY_CHUNK_RES_KEY_SIZE]; | |
439 | __le32 ContextLength; /* MBZ */ | |
cff2def5 | 440 | char Context[]; /* ignored, Windows sets to 4 bytes of zero */ |
41c1358e SF |
441 | } __packed; |
442 | ||
be7457d3 SF |
443 | /* this goes in the ioctl buffer when doing a copychunk request */ |
444 | struct copychunk_ioctl { | |
41c1358e | 445 | char SourceKey[COPY_CHUNK_RES_KEY_SIZE]; |
be7457d3 SF |
446 | __le32 ChunkCount; /* we are only sending 1 */ |
447 | __le32 Reserved; | |
448 | /* array will only be one chunk long for us */ | |
449 | __le64 SourceOffset; | |
450 | __le64 TargetOffset; | |
c8664730 | 451 | __le32 Length; /* how many bytes to copy */ |
be7457d3 SF |
452 | __u32 Reserved2; |
453 | } __packed; | |
454 | ||
31742c5a SF |
455 | /* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */ |
456 | struct file_zero_data_information { | |
457 | __le64 FileOffset; | |
458 | __le64 BeyondFinalZero; | |
459 | } __packed; | |
460 | ||
41c1358e SF |
461 | struct copychunk_ioctl_rsp { |
462 | __le32 ChunksWritten; | |
463 | __le32 ChunkBytesWritten; | |
464 | __le32 TotalBytesWritten; | |
465 | } __packed; | |
466 | ||
7d03ae4d SF |
467 | /* See MS-FSCC 2.3.29 and 2.3.30 */ |
468 | struct get_retrieval_pointer_count_req { | |
469 | __le64 StartingVcn; /* virtual cluster number (signed) */ | |
470 | } __packed; | |
471 | ||
472 | struct get_retrieval_pointer_count_rsp { | |
473 | __le32 ExtentCount; | |
474 | } __packed; | |
475 | ||
476 | /* | |
477 | * See MS-FSCC 2.3.33 and 2.3.34 | |
478 | * request is the same as get_retrieval_point_count_req struct above | |
479 | */ | |
480 | struct smb3_extents { | |
481 | __le64 NextVcn; | |
482 | __le64 Lcn; /* logical cluster number */ | |
483 | } __packed; | |
484 | ||
485 | struct get_retrieval_pointers_refcount_rsp { | |
486 | __le32 ExtentCount; | |
487 | __u32 Reserved; | |
488 | __le64 StartingVcn; | |
489 | struct smb3_extents extents[]; | |
490 | } __packed; | |
491 | ||
9d1b0660 SF |
492 | struct fsctl_set_integrity_information_req { |
493 | __le16 ChecksumAlgorithm; | |
494 | __le16 Reserved; | |
495 | __le32 Flags; | |
496 | } __packed; | |
497 | ||
498 | struct fsctl_get_integrity_information_rsp { | |
499 | __le16 ChecksumAlgorithm; | |
500 | __le16 Reserved; | |
501 | __le32 Flags; | |
502 | __le32 ChecksumChunkSizeInBytes; | |
503 | __le32 ClusterSizeInBytes; | |
504 | } __packed; | |
505 | ||
2f3ebaba RS |
506 | struct file_allocated_range_buffer { |
507 | __le64 file_offset; | |
508 | __le64 length; | |
509 | } __packed; | |
510 | ||
9d1b0660 SF |
511 | /* Integrity ChecksumAlgorithm choices for above */ |
512 | #define CHECKSUM_TYPE_NONE 0x0000 | |
513 | #define CHECKSUM_TYPE_CRC64 0x0002 | |
b3152e2c | 514 | #define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */ |
9d1b0660 SF |
515 | |
516 | /* Integrity flags for above */ | |
517 | #define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001 | |
518 | ||
0df444a0 SF |
519 | /* Reparse structures - see MS-FSCC 2.1.2 */ |
520 | ||
521 | /* struct fsctl_reparse_info_req is empty, only response structs (see below) */ | |
522 | ||
523 | struct reparse_data_buffer { | |
524 | __le32 ReparseTag; | |
525 | __le16 ReparseDataLength; | |
526 | __u16 Reserved; | |
cff2def5 | 527 | __u8 DataBuffer[]; /* Variable Length */ |
0df444a0 SF |
528 | } __packed; |
529 | ||
530 | struct reparse_guid_data_buffer { | |
531 | __le32 ReparseTag; | |
532 | __le16 ReparseDataLength; | |
533 | __u16 Reserved; | |
534 | __u8 ReparseGuid[16]; | |
cff2def5 | 535 | __u8 DataBuffer[]; /* Variable Length */ |
0df444a0 SF |
536 | } __packed; |
537 | ||
538 | struct reparse_mount_point_data_buffer { | |
539 | __le32 ReparseTag; | |
540 | __le16 ReparseDataLength; | |
541 | __u16 Reserved; | |
542 | __le16 SubstituteNameOffset; | |
543 | __le16 SubstituteNameLength; | |
544 | __le16 PrintNameOffset; | |
545 | __le16 PrintNameLength; | |
cff2def5 | 546 | __u8 PathBuffer[]; /* Variable Length */ |
0df444a0 SF |
547 | } __packed; |
548 | ||
5de254dc RS |
549 | #define SYMLINK_FLAG_RELATIVE 0x00000001 |
550 | ||
551 | struct reparse_symlink_data_buffer { | |
552 | __le32 ReparseTag; | |
553 | __le16 ReparseDataLength; | |
554 | __u16 Reserved; | |
555 | __le16 SubstituteNameOffset; | |
556 | __le16 SubstituteNameLength; | |
557 | __le16 PrintNameOffset; | |
558 | __le16 PrintNameLength; | |
559 | __le32 Flags; | |
cff2def5 | 560 | __u8 PathBuffer[]; /* Variable Length */ |
5de254dc | 561 | } __packed; |
0df444a0 SF |
562 | |
563 | /* See MS-FSCC 2.1.2.6 and cifspdu.h for struct reparse_posix_data */ | |
564 | ||
565 | ||
9d49640a AA |
566 | /* See MS-DFSC 2.2.2 */ |
567 | struct fsctl_get_dfs_referral_req { | |
568 | __le16 MaxReferralLevel; | |
569 | __u8 RequestFileName[]; | |
570 | } __packed; | |
571 | ||
572 | /* DFS response is struct get_dfs_refer_rsp */ | |
573 | ||
b56eae4d SF |
574 | /* See MS-SMB2 2.2.31.3 */ |
575 | struct network_resiliency_req { | |
576 | __le32 Timeout; | |
577 | __le32 Reserved; | |
578 | } __packed; | |
579 | /* There is no buffer for the response ie no struct network_resiliency_rsp */ | |
580 | ||
9d1b0660 | 581 | |
ff1c038a | 582 | struct validate_negotiate_info_req { |
4a72dafa SF |
583 | __le32 Capabilities; |
584 | __u8 Guid[SMB2_CLIENT_GUID_SIZE]; | |
585 | __le16 SecurityMode; | |
586 | __le16 DialectCount; | |
d5c7076b | 587 | __le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */ |
ff1c038a SF |
588 | } __packed; |
589 | ||
590 | struct validate_negotiate_info_rsp { | |
591 | __le32 Capabilities; | |
592 | __u8 Guid[SMB2_CLIENT_GUID_SIZE]; | |
593 | __le16 SecurityMode; | |
594 | __le16 Dialect; /* Dialect in use for the connection */ | |
4a72dafa SF |
595 | } __packed; |
596 | ||
bead042c AA |
597 | #define RSS_CAPABLE cpu_to_le32(0x00000001) |
598 | #define RDMA_CAPABLE cpu_to_le32(0x00000002) | |
599 | ||
600 | #define INTERNETWORK cpu_to_le16(0x0002) | |
601 | #define INTERNETWORKV6 cpu_to_le16(0x0017) | |
4a72dafa SF |
602 | |
603 | struct network_interface_info_ioctl_rsp { | |
604 | __le32 Next; /* next interface. zero if this is last one */ | |
605 | __le32 IfIndex; | |
606 | __le32 Capability; /* RSS or RDMA Capable */ | |
607 | __le32 Reserved; | |
608 | __le64 LinkSpeed; | |
bead042c AA |
609 | __le16 Family; |
610 | __u8 Buffer[126]; | |
611 | } __packed; | |
612 | ||
613 | struct iface_info_ipv4 { | |
614 | __be16 Port; | |
615 | __be32 IPv4Address; | |
616 | __be64 Reserved; | |
617 | } __packed; | |
618 | ||
619 | struct iface_info_ipv6 { | |
620 | __be16 Port; | |
621 | __be32 FlowInfo; | |
622 | __u8 IPv6Address[16]; | |
623 | __be32 ScopeId; | |
4a72dafa SF |
624 | } __packed; |
625 | ||
626 | #define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */ | |
627 | ||
64a5cfa6 | 628 | struct compress_ioctl { |
c7f508a9 | 629 | __le16 CompressionState; /* See cifspdu.h for possible flag values */ |
64a5cfa6 SF |
630 | } __packed; |
631 | ||
02b16665 SF |
632 | struct duplicate_extents_to_file { |
633 | __u64 PersistentFileHandle; /* source file handle, opaque endianness */ | |
634 | __u64 VolatileFileHandle; | |
635 | __le64 SourceFileOffset; | |
636 | __le64 TargetFileOffset; | |
637 | __le64 ByteCount; /* Bytes to be copied */ | |
638 | } __packed; | |
639 | ||
72c419d9 RS |
640 | /* |
641 | * Maximum number of iovs we need for an ioctl request. | |
642 | * [0] : struct smb2_ioctl_req | |
643 | * [1] : in_data | |
644 | */ | |
645 | #define SMB2_IOCTL_IOV_SIZE 2 | |
646 | ||
be7457d3 | 647 | struct smb2_ioctl_req { |
0d35e382 | 648 | struct smb2_hdr hdr; |
be7457d3 SF |
649 | __le16 StructureSize; /* Must be 57 */ |
650 | __u16 Reserved; | |
651 | __le32 CtlCode; | |
652 | __u64 PersistentFileId; /* opaque endianness */ | |
653 | __u64 VolatileFileId; /* opaque endianness */ | |
654 | __le32 InputOffset; | |
655 | __le32 InputCount; | |
656 | __le32 MaxInputResponse; | |
657 | __le32 OutputOffset; | |
658 | __le32 OutputCount; | |
659 | __le32 MaxOutputResponse; | |
660 | __le32 Flags; | |
661 | __u32 Reserved2; | |
cff2def5 | 662 | __u8 Buffer[]; |
be7457d3 SF |
663 | } __packed; |
664 | ||
665 | struct smb2_ioctl_rsp { | |
0d35e382 | 666 | struct smb2_hdr hdr; |
be7457d3 SF |
667 | __le16 StructureSize; /* Must be 57 */ |
668 | __u16 Reserved; | |
669 | __le32 CtlCode; | |
670 | __u64 PersistentFileId; /* opaque endianness */ | |
671 | __u64 VolatileFileId; /* opaque endianness */ | |
672 | __le32 InputOffset; | |
673 | __le32 InputCount; | |
674 | __le32 OutputOffset; | |
675 | __le32 OutputCount; | |
676 | __le32 Flags; | |
677 | __u32 Reserved2; | |
678 | /* char * buffer[] */ | |
679 | } __packed; | |
680 | ||
027e8eec PS |
681 | #define SMB2_LOCKFLAG_SHARED_LOCK 0x0001 |
682 | #define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002 | |
683 | #define SMB2_LOCKFLAG_UNLOCK 0x0004 | |
684 | #define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010 | |
685 | ||
f7ba7fe6 PS |
686 | struct smb2_lock_element { |
687 | __le64 Offset; | |
688 | __le64 Length; | |
689 | __le32 Flags; | |
690 | __le32 Reserved; | |
691 | } __packed; | |
692 | ||
693 | struct smb2_lock_req { | |
0d35e382 | 694 | struct smb2_hdr hdr; |
f7ba7fe6 PS |
695 | __le16 StructureSize; /* Must be 48 */ |
696 | __le16 LockCount; | |
bb9cad1b SF |
697 | /* |
698 | * The least significant four bits are the index, the other 28 bits are | |
699 | * the lock sequence number (0 to 64). See MS-SMB2 2.2.26 | |
700 | */ | |
701 | __le32 LockSequenceNumber; | |
f7ba7fe6 PS |
702 | __u64 PersistentFileId; /* opaque endianness */ |
703 | __u64 VolatileFileId; /* opaque endianness */ | |
704 | /* Followed by at least one */ | |
705 | struct smb2_lock_element locks[1]; | |
706 | } __packed; | |
707 | ||
708 | struct smb2_lock_rsp { | |
0d35e382 | 709 | struct smb2_hdr hdr; |
f7ba7fe6 PS |
710 | __le16 StructureSize; /* Must be 4 */ |
711 | __le16 Reserved; | |
712 | } __packed; | |
713 | ||
9094fad1 | 714 | struct smb2_echo_req { |
0d35e382 | 715 | struct smb2_hdr hdr; |
9094fad1 PS |
716 | __le16 StructureSize; /* Must be 4 */ |
717 | __u16 Reserved; | |
718 | } __packed; | |
719 | ||
720 | struct smb2_echo_rsp { | |
0d35e382 | 721 | struct smb2_hdr hdr; |
9094fad1 PS |
722 | __le16 StructureSize; /* Must be 4 */ |
723 | __u16 Reserved; | |
724 | } __packed; | |
725 | ||
d324f08d PS |
726 | /* search (query_directory) Flags field */ |
727 | #define SMB2_RESTART_SCANS 0x01 | |
728 | #define SMB2_RETURN_SINGLE_ENTRY 0x02 | |
729 | #define SMB2_INDEX_SPECIFIED 0x04 | |
730 | #define SMB2_REOPEN 0x10 | |
731 | ||
0a17799c RS |
732 | #define SMB2_QUERY_DIRECTORY_IOV_SIZE 2 |
733 | ||
2438c0bd SF |
734 | /* |
735 | * Valid FileInformation classes. | |
736 | * | |
737 | * Note that these are a subset of the (file) QUERY_INFO levels defined | |
738 | * later in this file (but since QUERY_DIRECTORY uses equivalent numbers | |
739 | * we do not redefine them here) | |
740 | * | |
741 | * FileDirectoryInfomation 0x01 | |
742 | * FileFullDirectoryInformation 0x02 | |
743 | * FileIdFullDirectoryInformation 0x26 | |
744 | * FileBothDirectoryInformation 0x03 | |
745 | * FileIdBothDirectoryInformation 0x25 | |
746 | * FileNamesInformation 0x0C | |
747 | * FileIdExtdDirectoryInformation 0x3C | |
748 | */ | |
749 | ||
d324f08d | 750 | struct smb2_query_directory_req { |
0d35e382 | 751 | struct smb2_hdr hdr; |
d324f08d PS |
752 | __le16 StructureSize; /* Must be 33 */ |
753 | __u8 FileInformationClass; | |
754 | __u8 Flags; | |
755 | __le32 FileIndex; | |
756 | __u64 PersistentFileId; /* opaque endianness */ | |
757 | __u64 VolatileFileId; /* opaque endianness */ | |
758 | __le16 FileNameOffset; | |
759 | __le16 FileNameLength; | |
760 | __le32 OutputBufferLength; | |
761 | __u8 Buffer[1]; | |
762 | } __packed; | |
763 | ||
764 | struct smb2_query_directory_rsp { | |
0d35e382 | 765 | struct smb2_hdr hdr; |
d324f08d PS |
766 | __le16 StructureSize; /* Must be 9 */ |
767 | __le16 OutputBufferOffset; | |
768 | __le32 OutputBufferLength; | |
769 | __u8 Buffer[1]; | |
770 | } __packed; | |
771 | ||
be4cb9e3 PS |
772 | /* Possible InfoType values */ |
773 | #define SMB2_O_INFO_FILE 0x01 | |
774 | #define SMB2_O_INFO_FILESYSTEM 0x02 | |
775 | #define SMB2_O_INFO_SECURITY 0x03 | |
776 | #define SMB2_O_INFO_QUOTA 0x04 | |
777 | ||
911a8dfa SF |
778 | /* Security info type additionalinfo flags. See MS-SMB2 (2.2.37) or MS-DTYP */ |
779 | #define OWNER_SECINFO 0x00000001 | |
780 | #define GROUP_SECINFO 0x00000002 | |
781 | #define DACL_SECINFO 0x00000004 | |
782 | #define SACL_SECINFO 0x00000008 | |
783 | #define LABEL_SECINFO 0x00000010 | |
784 | #define ATTRIBUTE_SECINFO 0x00000020 | |
785 | #define SCOPE_SECINFO 0x00000040 | |
786 | #define BACKUP_SECINFO 0x00010000 | |
787 | #define UNPROTECTED_SACL_SECINFO 0x10000000 | |
788 | #define UNPROTECTED_DACL_SECINFO 0x20000000 | |
789 | #define PROTECTED_SACL_SECINFO 0x40000000 | |
790 | #define PROTECTED_DACL_SECINFO 0x80000000 | |
791 | ||
792 | /* Flags used for FileFullEAinfo */ | |
793 | #define SL_RESTART_SCAN 0x00000001 | |
794 | #define SL_RETURN_SINGLE_ENTRY 0x00000002 | |
795 | #define SL_INDEX_SPECIFIED 0x00000004 | |
796 | ||
be4cb9e3 | 797 | struct smb2_query_info_req { |
0d35e382 | 798 | struct smb2_hdr hdr; |
be4cb9e3 PS |
799 | __le16 StructureSize; /* Must be 41 */ |
800 | __u8 InfoType; | |
801 | __u8 FileInfoClass; | |
802 | __le32 OutputBufferLength; | |
803 | __le16 InputBufferOffset; | |
804 | __u16 Reserved; | |
805 | __le32 InputBufferLength; | |
806 | __le32 AdditionalInformation; | |
807 | __le32 Flags; | |
808 | __u64 PersistentFileId; /* opaque endianness */ | |
809 | __u64 VolatileFileId; /* opaque endianness */ | |
810 | __u8 Buffer[1]; | |
811 | } __packed; | |
812 | ||
813 | struct smb2_query_info_rsp { | |
0d35e382 | 814 | struct smb2_hdr hdr; |
be4cb9e3 PS |
815 | __le16 StructureSize; /* Must be 9 */ |
816 | __le16 OutputBufferOffset; | |
817 | __le32 OutputBufferLength; | |
818 | __u8 Buffer[1]; | |
819 | } __packed; | |
820 | ||
14e562ad RS |
821 | /* |
822 | * Maximum number of iovs we need for a set-info request. | |
823 | * The largest one is rename/hardlink | |
824 | * [0] : struct smb2_set_info_req + smb2_file_[rename|link]_info | |
825 | * [1] : path | |
826 | * [2] : compound padding | |
827 | */ | |
828 | #define SMB2_SET_INFO_IOV_SIZE 3 | |
829 | ||
35143eb5 | 830 | struct smb2_set_info_req { |
0d35e382 | 831 | struct smb2_hdr hdr; |
35143eb5 PS |
832 | __le16 StructureSize; /* Must be 33 */ |
833 | __u8 InfoType; | |
834 | __u8 FileInfoClass; | |
835 | __le32 BufferLength; | |
836 | __le16 BufferOffset; | |
837 | __u16 Reserved; | |
838 | __le32 AdditionalInformation; | |
839 | __u64 PersistentFileId; /* opaque endianness */ | |
840 | __u64 VolatileFileId; /* opaque endianness */ | |
841 | __u8 Buffer[1]; | |
842 | } __packed; | |
843 | ||
844 | struct smb2_set_info_rsp { | |
0d35e382 | 845 | struct smb2_hdr hdr; |
35143eb5 PS |
846 | __le16 StructureSize; /* Must be 2 */ |
847 | } __packed; | |
848 | ||
0d5a288d | 849 | struct smb2_oplock_break { |
0d35e382 | 850 | struct smb2_hdr hdr; |
21ad9487 RS |
851 | __le16 StructureSize; /* Must be 24 */ |
852 | __u8 OplockLevel; | |
853 | __u8 Reserved; | |
854 | __le32 Reserved2; | |
855 | __u64 PersistentFid; | |
856 | __u64 VolatileFid; | |
857 | } __packed; | |
983c88a4 | 858 | |
0822f514 PS |
859 | #define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01) |
860 | ||
861 | struct smb2_lease_break { | |
0d35e382 | 862 | struct smb2_hdr hdr; |
0822f514 | 863 | __le16 StructureSize; /* Must be 44 */ |
9bd45408 | 864 | __le16 Epoch; |
0822f514 PS |
865 | __le32 Flags; |
866 | __u8 LeaseKey[16]; | |
867 | __le32 CurrentLeaseState; | |
868 | __le32 NewLeaseState; | |
869 | __le32 BreakReason; | |
870 | __le32 AccessMaskHint; | |
871 | __le32 ShareMaskHint; | |
872 | } __packed; | |
873 | ||
874 | struct smb2_lease_ack { | |
0d35e382 | 875 | struct smb2_hdr hdr; |
0822f514 PS |
876 | __le16 StructureSize; /* Must be 36 */ |
877 | __le16 Reserved; | |
878 | __le32 Flags; | |
879 | __u8 LeaseKey[16]; | |
880 | __le32 LeaseState; | |
881 | __le64 LeaseDuration; | |
882 | } __packed; | |
883 | ||
be4cb9e3 PS |
884 | /* |
885 | * PDU infolevel structure definitions | |
886 | * BB consider moving to a different header | |
887 | */ | |
888 | ||
6fc05c25 PS |
889 | /* File System Information Classes */ |
890 | #define FS_VOLUME_INFORMATION 1 /* Query */ | |
af6a12ea | 891 | #define FS_LABEL_INFORMATION 2 /* Local only */ |
6fc05c25 PS |
892 | #define FS_SIZE_INFORMATION 3 /* Query */ |
893 | #define FS_DEVICE_INFORMATION 4 /* Query */ | |
894 | #define FS_ATTRIBUTE_INFORMATION 5 /* Query */ | |
895 | #define FS_CONTROL_INFORMATION 6 /* Query, Set */ | |
896 | #define FS_FULL_SIZE_INFORMATION 7 /* Query */ | |
897 | #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */ | |
af6a12ea SF |
898 | #define FS_DRIVER_PATH_INFORMATION 9 /* Local only */ |
899 | #define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */ | |
900 | #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */ | |
2d304217 | 901 | #define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */ |
6fc05c25 PS |
902 | |
903 | struct smb2_fs_full_size_info { | |
904 | __le64 TotalAllocationUnits; | |
905 | __le64 CallerAvailableAllocationUnits; | |
906 | __le64 ActualAvailableAllocationUnits; | |
907 | __le32 SectorsPerAllocationUnit; | |
908 | __le32 BytesPerSector; | |
909 | } __packed; | |
910 | ||
af6a12ea SF |
911 | #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001 |
912 | #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002 | |
913 | #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004 | |
914 | #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008 | |
915 | ||
916 | /* sector size info struct */ | |
917 | struct smb3_fs_ss_info { | |
918 | __le32 LogicalBytesPerSector; | |
919 | __le32 PhysicalBytesPerSectorForAtomicity; | |
920 | __le32 PhysicalBytesPerSectorForPerf; | |
921 | __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity; | |
922 | __le32 Flags; | |
923 | __le32 ByteOffsetForSectorAlignment; | |
924 | __le32 ByteOffsetForPartitionAlignment; | |
925 | } __packed; | |
926 | ||
21ba3845 SF |
927 | /* volume info struct - see MS-FSCC 2.5.9 */ |
928 | #define MAX_VOL_LABEL_LEN 32 | |
929 | struct smb3_fs_vol_info { | |
930 | __le64 VolumeCreationTime; | |
931 | __u32 VolumeSerialNumber; | |
932 | __le32 VolumeLabelLength; /* includes trailing null */ | |
933 | __u8 SupportsObjects; /* True if eg like NTFS, supports objects */ | |
934 | __u8 Reserved; | |
cff2def5 | 935 | __u8 VolumeLabel[]; /* variable len */ |
21ba3845 SF |
936 | } __packed; |
937 | ||
be4cb9e3 PS |
938 | /* partial list of QUERY INFO levels */ |
939 | #define FILE_DIRECTORY_INFORMATION 1 | |
940 | #define FILE_FULL_DIRECTORY_INFORMATION 2 | |
941 | #define FILE_BOTH_DIRECTORY_INFORMATION 3 | |
942 | #define FILE_BASIC_INFORMATION 4 | |
943 | #define FILE_STANDARD_INFORMATION 5 | |
944 | #define FILE_INTERNAL_INFORMATION 6 | |
945 | #define FILE_EA_INFORMATION 7 | |
946 | #define FILE_ACCESS_INFORMATION 8 | |
947 | #define FILE_NAME_INFORMATION 9 | |
948 | #define FILE_RENAME_INFORMATION 10 | |
949 | #define FILE_LINK_INFORMATION 11 | |
950 | #define FILE_NAMES_INFORMATION 12 | |
951 | #define FILE_DISPOSITION_INFORMATION 13 | |
952 | #define FILE_POSITION_INFORMATION 14 | |
953 | #define FILE_FULL_EA_INFORMATION 15 | |
954 | #define FILE_MODE_INFORMATION 16 | |
955 | #define FILE_ALIGNMENT_INFORMATION 17 | |
956 | #define FILE_ALL_INFORMATION 18 | |
957 | #define FILE_ALLOCATION_INFORMATION 19 | |
958 | #define FILE_END_OF_FILE_INFORMATION 20 | |
959 | #define FILE_ALTERNATE_NAME_INFORMATION 21 | |
960 | #define FILE_STREAM_INFORMATION 22 | |
961 | #define FILE_PIPE_INFORMATION 23 | |
962 | #define FILE_PIPE_LOCAL_INFORMATION 24 | |
963 | #define FILE_PIPE_REMOTE_INFORMATION 25 | |
964 | #define FILE_MAILSLOT_QUERY_INFORMATION 26 | |
965 | #define FILE_MAILSLOT_SET_INFORMATION 27 | |
966 | #define FILE_COMPRESSION_INFORMATION 28 | |
967 | #define FILE_OBJECT_ID_INFORMATION 29 | |
968 | /* Number 30 not defined in documents */ | |
969 | #define FILE_MOVE_CLUSTER_INFORMATION 31 | |
970 | #define FILE_QUOTA_INFORMATION 32 | |
971 | #define FILE_REPARSE_POINT_INFORMATION 33 | |
972 | #define FILE_NETWORK_OPEN_INFORMATION 34 | |
973 | #define FILE_ATTRIBUTE_TAG_INFORMATION 35 | |
974 | #define FILE_TRACKING_INFORMATION 36 | |
975 | #define FILEID_BOTH_DIRECTORY_INFORMATION 37 | |
976 | #define FILEID_FULL_DIRECTORY_INFORMATION 38 | |
977 | #define FILE_VALID_DATA_LENGTH_INFORMATION 39 | |
978 | #define FILE_SHORT_NAME_INFORMATION 40 | |
979 | #define FILE_SFIO_RESERVE_INFORMATION 44 | |
980 | #define FILE_SFIO_VOLUME_INFORMATION 45 | |
981 | #define FILE_HARD_LINK_INFORMATION 46 | |
982 | #define FILE_NORMALIZED_NAME_INFORMATION 48 | |
983 | #define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50 | |
984 | #define FILE_STANDARD_LINK_INFORMATION 54 | |
51d92d69 | 985 | #define FILE_ID_INFORMATION 59 |
2438c0bd | 986 | #define FILE_ID_EXTD_DIRECTORY_INFORMATION 60 |
be4cb9e3 | 987 | |
f0df737e PS |
988 | struct smb2_file_internal_info { |
989 | __le64 IndexNumber; | |
990 | } __packed; /* level 6 Query */ | |
991 | ||
35143eb5 PS |
992 | struct smb2_file_rename_info { /* encoding of request for level 10 */ |
993 | __u8 ReplaceIfExists; /* 1 = replace existing target with new */ | |
994 | /* 0 = fail if target already exists */ | |
995 | __u8 Reserved[7]; | |
996 | __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ | |
997 | __le32 FileNameLength; | |
cff2def5 | 998 | char FileName[]; /* New name to be assigned */ |
7d03ae4d | 999 | /* padding - overall struct size must be >= 24 so filename + pad >= 6 */ |
35143eb5 PS |
1000 | } __packed; /* level 10 Set */ |
1001 | ||
568798cc PS |
1002 | struct smb2_file_link_info { /* encoding of request for level 11 */ |
1003 | __u8 ReplaceIfExists; /* 1 = replace existing link with new */ | |
1004 | /* 0 = fail if link already exists */ | |
1005 | __u8 Reserved[7]; | |
1006 | __u64 RootDirectory; /* MBZ for network operations (why says spec?) */ | |
1007 | __le32 FileNameLength; | |
cff2def5 | 1008 | char FileName[]; /* Name to be assigned to new link */ |
568798cc PS |
1009 | } __packed; /* level 11 Set */ |
1010 | ||
95907fea RS |
1011 | struct smb2_file_full_ea_info { /* encoding of response for level 15 */ |
1012 | __le32 next_entry_offset; | |
1013 | __u8 flags; | |
1014 | __u8 ea_name_length; | |
1015 | __le16 ea_value_length; | |
cff2def5 | 1016 | char ea_data[]; /* \0 terminated name plus value */ |
95907fea RS |
1017 | } __packed; /* level 15 Set */ |
1018 | ||
be4cb9e3 PS |
1019 | /* |
1020 | * This level 18, although with struct with same name is different from cifs | |
1021 | * level 0x107. Level 0x107 has an extra u64 between AccessFlags and | |
1022 | * CurrentByteOffset. | |
1023 | */ | |
1024 | struct smb2_file_all_info { /* data block encoding of response to level 18 */ | |
1025 | __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */ | |
1026 | __le64 LastAccessTime; | |
1027 | __le64 LastWriteTime; | |
1028 | __le64 ChangeTime; | |
1029 | __le32 Attributes; | |
1030 | __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */ | |
1031 | __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ | |
1032 | __le64 EndOfFile; /* size ie offset to first free byte in file */ | |
1033 | __le32 NumberOfLinks; /* hard links */ | |
1034 | __u8 DeletePending; | |
1035 | __u8 Directory; | |
1036 | __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */ | |
1037 | __le64 IndexNumber; | |
1038 | __le32 EASize; | |
1039 | __le32 AccessFlags; | |
1040 | __le64 CurrentByteOffset; | |
1041 | __le32 Mode; | |
1042 | __le32 AlignmentRequirement; | |
1043 | __le32 FileNameLength; | |
1044 | char FileName[1]; | |
1045 | } __packed; /* level 18 Query */ | |
1046 | ||
c839ff24 PS |
1047 | struct smb2_file_eof_info { /* encoding of request for level 10 */ |
1048 | __le64 EndOfFile; /* new end of file value */ | |
1049 | } __packed; /* level 20 Set */ | |
1050 | ||
2e4564b3 SF |
1051 | struct smb2_file_reparse_point_info { |
1052 | __le64 IndexNumber; | |
1053 | __le32 Tag; | |
1054 | } __packed; | |
1055 | ||
43f8a6a7 SF |
1056 | struct smb2_file_network_open_info { |
1057 | __le64 CreationTime; | |
1058 | __le64 LastAccessTime; | |
1059 | __le64 LastWriteTime; | |
1060 | __le64 ChangeTime; | |
1061 | __le64 AllocationSize; | |
1062 | __le64 EndOfFile; | |
1063 | __le32 Attributes; | |
1064 | __le32 Reserved; | |
1065 | } __packed; /* level 34 Query also similar returned in close rsp and open rsp */ | |
1066 | ||
2438c0bd | 1067 | /* See MS-FSCC 2.4.21 */ |
51d92d69 SF |
1068 | struct smb2_file_id_information { |
1069 | __le64 VolumeSerialNumber; | |
1070 | __u64 PersistentFileId; /* opaque endianness */ | |
1071 | __u64 VolatileFileId; /* opaque endianness */ | |
1072 | } __packed; /* level 59 */ | |
1073 | ||
2438c0bd SF |
1074 | /* See MS-FSCC 2.4.18 */ |
1075 | struct smb2_file_id_extd_directory_info { | |
1076 | __le32 NextEntryOffset; | |
1077 | __u32 FileIndex; | |
1078 | __le64 CreationTime; | |
1079 | __le64 LastAccessTime; | |
1080 | __le64 LastWriteTime; | |
1081 | __le64 ChangeTime; | |
1082 | __le64 EndOfFile; | |
1083 | __le64 AllocationSize; | |
1084 | __le32 FileAttributes; | |
1085 | __le32 FileNameLength; | |
1086 | __le32 EaSize; /* EA size */ | |
1087 | __le32 ReparsePointTag; /* valid if FILE_ATTR_REPARSE_POINT set in FileAttributes */ | |
1088 | __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit */ | |
1089 | char FileName[1]; | |
1090 | } __packed; /* level 60 */ | |
1091 | ||
730928c8 RS |
1092 | extern char smb2_padding[7]; |
1093 | ||
ab3459d8 | 1094 | /* equivalent of the contents of SMB3.1.1 POSIX open context response */ |
2e8af978 | 1095 | struct create_posix_rsp { |
69dda305 AA |
1096 | u32 nlink; |
1097 | u32 reparse_tag; | |
1098 | u32 mode; | |
1099 | struct cifs_sid owner; /* var-sized on the wire */ | |
1100 | struct cifs_sid group; /* var-sized on the wire */ | |
2e8af978 | 1101 | } __packed; |
349e13ad AA |
1102 | |
1103 | /* | |
6a5f6592 | 1104 | * SMB2-only POSIX info level for query dir |
349e13ad AA |
1105 | * |
1106 | * See posix_info_sid_size(), posix_info_extra_size() and | |
1107 | * posix_info_parse() to help with the handling of this struct. | |
1108 | */ | |
1109 | struct smb2_posix_info { | |
1110 | __le32 NextEntryOffset; | |
1111 | __u32 Ignored; | |
1112 | __le64 CreationTime; | |
1113 | __le64 LastAccessTime; | |
1114 | __le64 LastWriteTime; | |
1115 | __le64 ChangeTime; | |
1116 | __le64 EndOfFile; | |
1117 | __le64 AllocationSize; | |
1118 | __le32 DosAttributes; | |
1119 | __le64 Inode; | |
1120 | __le32 DeviceId; | |
1121 | __le32 Zero; | |
1122 | /* beginning of POSIX Create Context Response */ | |
1123 | __le32 HardLinks; | |
1124 | __le32 ReparseTag; | |
1125 | __le32 Mode; | |
1126 | /* | |
1127 | * var sized owner SID | |
1128 | * var sized group SID | |
1129 | * le32 filenamelength | |
1130 | * u8 filename[] | |
1131 | */ | |
1132 | } __packed; | |
1133 | ||
6a5f6592 SF |
1134 | /* Level 100 query info */ |
1135 | struct smb311_posix_qinfo { | |
1136 | __le64 CreationTime; | |
1137 | __le64 LastAccessTime; | |
1138 | __le64 LastWriteTime; | |
1139 | __le64 ChangeTime; | |
1140 | __le64 EndOfFile; | |
1141 | __le64 AllocationSize; | |
1142 | __le32 DosAttributes; | |
1143 | __le64 Inode; | |
1144 | __le32 DeviceId; | |
1145 | __le32 Zero; | |
1146 | /* beginning of POSIX Create Context Response */ | |
1147 | __le32 HardLinks; | |
1148 | __le32 ReparseTag; | |
1149 | __le32 Mode; | |
1150 | u8 Sids[]; | |
1151 | /* | |
1152 | * var sized owner SID | |
1153 | * var sized group SID | |
1154 | * le32 filenamelength | |
1155 | * u8 filename[] | |
1156 | */ | |
1157 | } __packed; | |
1158 | ||
349e13ad AA |
1159 | /* |
1160 | * Parsed version of the above struct. Allows direct access to the | |
1161 | * variable length fields | |
1162 | */ | |
1163 | struct smb2_posix_info_parsed { | |
1164 | const struct smb2_posix_info *base; | |
1165 | size_t size; | |
1166 | struct cifs_sid owner; | |
1167 | struct cifs_sid group; | |
1168 | int name_len; | |
1169 | const u8 *name; | |
ab3459d8 | 1170 | }; |
349e13ad | 1171 | |
ddfbefbd | 1172 | #endif /* _SMB2PDU_H */ |