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