blob: e3188abdafd0e144be62064fb7ee47c5e2575dc6 [file] [log] [blame]
Steve Frenchddfbefb2011-03-15 02:08:48 +00001/*
2 * fs/cifs/smb2pdu.h
3 *
Steve Frenchbe7457d2013-06-19 17:41:10 -05004 * Copyright (c) International Business Machines Corp., 2009, 2013
Steve Frenchddfbefb2011-03-15 02:08:48 +00005 * 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/*
Pavel Shilovsky2dc7e1c2011-12-26 22:53:34 +040030 * 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 NUMBER_OF_SMB2_COMMANDS 0x0013
84
85/* BB FIXME - analyze following length BB */
86#define MAX_SMB2_HDR_SIZE 0x78 /* 4 len + 64 hdr + (2*24 wct) + 2 bct + 2 pad */
87
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +040088#define SMB2_PROTO_NUMBER __constant_cpu_to_le32(0x424d53fe)
89
Pavel Shilovsky2dc7e1c2011-12-26 22:53:34 +040090/*
Steve Frenchddfbefb2011-03-15 02:08:48 +000091 * SMB2 Header Definition
92 *
93 * "MBZ" : Must be Zero
94 * "BB" : BugBug, Something to check/review/analyze later
95 * "PDU" : "Protocol Data Unit" (ie a network "frame")
96 *
97 */
Pavel Shilovsky74112862012-07-27 01:20:41 +040098
Pavel Shilovskyb2ede582012-09-04 15:49:31 +040099#define SMB2_HEADER_STRUCTURE_SIZE __constant_cpu_to_le16(64)
Pavel Shilovsky74112862012-07-27 01:20:41 +0400100
Steve Frenchddfbefb2011-03-15 02:08:48 +0000101struct smb2_hdr {
102 __be32 smb2_buf_length; /* big endian on wire */
103 /* length is only two or three bytes - with
104 one or two byte type preceding it that MBZ */
105 __u8 ProtocolId[4]; /* 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 __u64 MessageId; /* opaque - so can stay little endian */
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
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +0400120struct smb2_pdu {
121 struct smb2_hdr hdr;
122 __le16 StructureSize2; /* size of wct area (varies, request specific) */
123} __packed;
124
Steve French0cbaa532013-11-15 23:50:24 -0600125struct smb2_transform_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 __u8 ProtocolId[4]; /* 0xFD 'S' 'M' 'B' */
130 __u8 Signature[16];
131 __u8 Nonce[11];
132 __u8 Reserved[5];
133 __le32 OriginalMessageSize;
134 __u16 Reserved1;
135 __le16 EncryptionAlgorithm;
136 __u64 SessionId;
137} __packed;
138
139/* Encryption Algorithms */
140#define SMB2_ENCRYPTION_AES128_CCM __constant_cpu_to_le16(0x0001)
141
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +0400142/*
143 * SMB2 flag definitions
144 */
145#define SMB2_FLAGS_SERVER_TO_REDIR __constant_cpu_to_le32(0x00000001)
146#define SMB2_FLAGS_ASYNC_COMMAND __constant_cpu_to_le32(0x00000002)
147#define SMB2_FLAGS_RELATED_OPERATIONS __constant_cpu_to_le32(0x00000004)
148#define SMB2_FLAGS_SIGNED __constant_cpu_to_le32(0x00000008)
149#define SMB2_FLAGS_DFS_OPERATIONS __constant_cpu_to_le32(0x10000000)
150
151/*
152 * Definitions for SMB2 Protocol Data Units (network frames)
153 *
154 * See MS-SMB2.PDF specification for protocol details.
155 * The Naming convention is the lower case version of the SMB2
156 * command code name for the struct. Note that structures must be packed.
157 *
158 */
Pavel Shilovsky74112862012-07-27 01:20:41 +0400159
Pavel Shilovskyb2ede582012-09-04 15:49:31 +0400160#define SMB2_ERROR_STRUCTURE_SIZE2 __constant_cpu_to_le16(9)
Pavel Shilovsky74112862012-07-27 01:20:41 +0400161
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +0400162struct smb2_err_rsp {
163 struct smb2_hdr hdr;
164 __le16 StructureSize;
165 __le16 Reserved; /* MBZ */
166 __le32 ByteCount; /* even if zero, at least one byte follows */
167 __u8 ErrorData[1]; /* variable length */
168} __packed;
169
Pavel Shilovskyb42bf882013-08-14 19:25:21 +0400170struct smb2_symlink_err_rsp {
171 __le32 SymLinkLength;
172 __le32 SymLinkErrorTag;
173 __le32 ReparseTag;
174 __le16 ReparseDataLength;
175 __le16 UnparsedPathLength;
176 __le16 SubstituteNameOffset;
177 __le16 SubstituteNameLength;
178 __le16 PrintNameOffset;
179 __le16 PrintNameLength;
180 __le32 Flags;
181 __u8 PathBuffer[0];
182} __packed;
183
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700184#define SMB2_CLIENT_GUID_SIZE 16
185
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400186struct smb2_negotiate_req {
187 struct smb2_hdr hdr;
188 __le16 StructureSize; /* Must be 36 */
189 __le16 DialectCount;
190 __le16 SecurityMode;
191 __le16 Reserved; /* MBZ */
192 __le32 Capabilities;
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700193 __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE];
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400194 __le64 ClientStartTime; /* MBZ */
Steve Frenche4aa25e2012-10-01 12:26:22 -0500195 __le16 Dialects[1]; /* One dialect (vers=) at a time for now */
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400196} __packed;
197
Steve Frenche4aa25e2012-10-01 12:26:22 -0500198/* Dialects */
199#define SMB20_PROT_ID 0x0202
200#define SMB21_PROT_ID 0x0210
201#define SMB30_PROT_ID 0x0300
Steve French20b6d8b2013-06-12 22:48:41 -0500202#define SMB302_PROT_ID 0x0302
Steve Frenche4aa25e2012-10-01 12:26:22 -0500203#define BAD_PROT_ID 0xFFFF
204
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400205/* SecurityMode flags */
206#define SMB2_NEGOTIATE_SIGNING_ENABLED 0x0001
207#define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x0002
208/* Capabilities flags */
209#define SMB2_GLOBAL_CAP_DFS 0x00000001
210#define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */
211#define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */
Steve Frenche4aa25e2012-10-01 12:26:22 -0500212#define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */
213#define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */
214#define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */
215#define SMB2_GLOBAL_CAP_ENCRYPTION 0x00000040 /* New to SMB3 */
Pavel Shilovsky29e20f92012-07-13 13:58:14 +0400216/* Internal types */
217#define SMB2_NT_FIND 0x00100000
218#define SMB2_LARGE_FILES 0x00200000
Pavel Shilovskyec2e4522011-12-27 16:12:43 +0400219
220struct smb2_negotiate_rsp {
221 struct smb2_hdr hdr;
222 __le16 StructureSize; /* Must be 65 */
223 __le16 SecurityMode;
224 __le16 DialectRevision;
225 __le16 Reserved; /* MBZ */
226 __u8 ServerGUID[16];
227 __le32 Capabilities;
228 __le32 MaxTransactSize;
229 __le32 MaxReadSize;
230 __le32 MaxWriteSize;
231 __le64 SystemTime; /* MBZ */
232 __le64 ServerStartTime;
233 __le16 SecurityBufferOffset;
234 __le16 SecurityBufferLength;
235 __le32 Reserved2; /* may be any value, ignore */
236 __u8 Buffer[1]; /* variable length GSS security buffer */
237} __packed;
238
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400239struct smb2_sess_setup_req {
240 struct smb2_hdr hdr;
241 __le16 StructureSize; /* Must be 25 */
242 __u8 VcNumber;
243 __u8 SecurityMode;
244 __le32 Capabilities;
245 __le32 Channel;
246 __le16 SecurityBufferOffset;
247 __le16 SecurityBufferLength;
248 __le64 PreviousSessionId;
249 __u8 Buffer[1]; /* variable length GSS security buffer */
250} __packed;
251
252/* Currently defined SessionFlags */
253#define SMB2_SESSION_FLAG_IS_GUEST 0x0001
254#define SMB2_SESSION_FLAG_IS_NULL 0x0002
Steve French0cbaa532013-11-15 23:50:24 -0600255#define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004
Pavel Shilovsky5478f9b2011-12-27 16:22:00 +0400256struct smb2_sess_setup_rsp {
257 struct smb2_hdr hdr;
258 __le16 StructureSize; /* Must be 9 */
259 __le16 SessionFlags;
260 __le16 SecurityBufferOffset;
261 __le16 SecurityBufferLength;
262 __u8 Buffer[1]; /* variable length GSS security buffer */
263} __packed;
264
265struct smb2_logoff_req {
266 struct smb2_hdr hdr;
267 __le16 StructureSize; /* Must be 4 */
268 __le16 Reserved;
269} __packed;
270
271struct smb2_logoff_rsp {
272 struct smb2_hdr hdr;
273 __le16 StructureSize; /* Must be 4 */
274 __le16 Reserved;
275} __packed;
276
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400277struct smb2_tree_connect_req {
278 struct smb2_hdr hdr;
279 __le16 StructureSize; /* Must be 9 */
280 __le16 Reserved;
281 __le16 PathOffset;
282 __le16 PathLength;
283 __u8 Buffer[1]; /* variable length */
284} __packed;
285
286struct smb2_tree_connect_rsp {
287 struct smb2_hdr hdr;
288 __le16 StructureSize; /* Must be 16 */
289 __u8 ShareType; /* see below */
290 __u8 Reserved;
291 __le32 ShareFlags; /* see below */
292 __le32 Capabilities; /* see below */
293 __le32 MaximalAccess;
294} __packed;
295
296/* Possible ShareType values */
297#define SMB2_SHARE_TYPE_DISK 0x01
298#define SMB2_SHARE_TYPE_PIPE 0x02
299#define SMB2_SHARE_TYPE_PRINT 0x03
300
301/*
302 * Possible ShareFlags - exactly one and only one of the first 4 caching flags
303 * must be set (any of the remaining, SHI1005, flags may be set individually
304 * or in combination.
305 */
306#define SMB2_SHAREFLAG_MANUAL_CACHING 0x00000000
307#define SMB2_SHAREFLAG_AUTO_CACHING 0x00000010
308#define SMB2_SHAREFLAG_VDO_CACHING 0x00000020
309#define SMB2_SHAREFLAG_NO_CACHING 0x00000030
310#define SHI1005_FLAGS_DFS 0x00000001
311#define SHI1005_FLAGS_DFS_ROOT 0x00000002
312#define SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS 0x00000100
313#define SHI1005_FLAGS_FORCE_SHARED_DELETE 0x00000200
314#define SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING 0x00000400
315#define SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM 0x00000800
316#define SHI1005_FLAGS_FORCE_LEVELII_OPLOCK 0x00001000
Steve Frenchc8664732013-06-21 15:35:45 -0500317#define SHI1005_FLAGS_ENABLE_HASH_V1 0x00002000
318#define SHI1005_FLAGS_ENABLE_HASH_V2 0x00004000
319#define SHI1005_FLAGS_ENCRYPT_DATA 0x00008000
320#define SHI1005_FLAGS_ALL 0x0000FF33
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400321
322/* Possible share capabilities */
Steve French2b5dc282013-06-13 10:51:10 -0500323#define SMB2_SHARE_CAP_DFS cpu_to_le32(0x00000008) /* all dialects */
324#define SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY cpu_to_le32(0x00000010) /* 3.0 */
325#define SMB2_SHARE_CAP_SCALEOUT cpu_to_le32(0x00000020) /* 3.0 */
326#define SMB2_SHARE_CAP_CLUSTER cpu_to_le32(0x00000040) /* 3.0 */
327#define SMB2_SHARE_CAP_ASYMMETRIC cpu_to_le32(0x00000080) /* 3.02 */
Pavel Shilovskyfaaf9462011-12-27 16:04:00 +0400328
329struct smb2_tree_disconnect_req {
330 struct smb2_hdr hdr;
331 __le16 StructureSize; /* Must be 4 */
332 __le16 Reserved;
333} __packed;
334
335struct smb2_tree_disconnect_rsp {
336 struct smb2_hdr hdr;
337 __le16 StructureSize; /* Must be 4 */
338 __le16 Reserved;
339} __packed;
340
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400341/* File Attrubutes */
342#define FILE_ATTRIBUTE_READONLY 0x00000001
343#define FILE_ATTRIBUTE_HIDDEN 0x00000002
344#define FILE_ATTRIBUTE_SYSTEM 0x00000004
345#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
346#define FILE_ATTRIBUTE_ARCHIVE 0x00000020
347#define FILE_ATTRIBUTE_NORMAL 0x00000080
348#define FILE_ATTRIBUTE_TEMPORARY 0x00000100
349#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
350#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
351#define FILE_ATTRIBUTE_COMPRESSED 0x00000800
352#define FILE_ATTRIBUTE_OFFLINE 0x00001000
353#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
354#define FILE_ATTRIBUTE_ENCRYPTED 0x00004000
Steve French73322972014-09-23 19:25:42 -0500355#define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
356#define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400357
358/* Oplock levels */
359#define SMB2_OPLOCK_LEVEL_NONE 0x00
360#define SMB2_OPLOCK_LEVEL_II 0x01
361#define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
362#define SMB2_OPLOCK_LEVEL_BATCH 0x09
363#define SMB2_OPLOCK_LEVEL_LEASE 0xFF
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700364/* Non-spec internal type */
365#define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400366
367/* Desired Access Flags */
368#define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
369#define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
370#define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
371#define FILE_READ_EA_LE cpu_to_le32(0x00000008)
372#define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
373#define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
374#define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
375#define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
376#define FILE_DELETE_LE cpu_to_le32(0x00010000)
377#define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
378#define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
379#define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
380#define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
381#define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
382#define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
383#define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
384#define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
385#define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
386#define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
387
388/* ShareAccess Flags */
389#define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
390#define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
391#define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
392#define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
393
394/* CreateDisposition Flags */
395#define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
396#define FILE_OPEN_LE cpu_to_le32(0x00000001)
397#define FILE_CREATE_LE cpu_to_le32(0x00000002)
398#define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
399#define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
400#define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
401
402/* CreateOptions Flags */
403#define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
404/* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
405#define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
406#define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
407#define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008)
408#define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010)
409#define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020)
410#define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
411#define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
412#define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
413#define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
414#define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
415#define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
416#define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
417#define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
418#define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
419#define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
420#define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
421#define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000)
422
423#define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
424 | FILE_READ_ATTRIBUTES_LE)
425#define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
426 | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
427#define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
428
429/* Impersonation Levels */
430#define IL_ANONYMOUS cpu_to_le32(0x00000000)
431#define IL_IDENTIFICATION cpu_to_le32(0x00000001)
432#define IL_IMPERSONATION cpu_to_le32(0x00000002)
433#define IL_DELEGATE cpu_to_le32(0x00000003)
434
435/* Create Context Values */
436#define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */
437#define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */
438#define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
439#define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
Steve French12197a72014-05-14 05:29:40 -0700440#define SMB2_CREATE_ALLOCATION_SIZE "AISi"
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400441#define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
442#define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
443#define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
444#define SMB2_CREATE_REQUEST_LEASE "RqLs"
Steve French12197a72014-05-14 05:29:40 -0700445#define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q"
446#define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C"
447#define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74
448#define SVHDX_OPEN_DEVICE_CONTEXT 0x83CE6F1AD851E0986E34401CC9BCFCE9
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400449
450struct smb2_create_req {
451 struct smb2_hdr hdr;
452 __le16 StructureSize; /* Must be 57 */
453 __u8 SecurityFlags;
454 __u8 RequestedOplockLevel;
455 __le32 ImpersonationLevel;
456 __le64 SmbCreateFlags;
457 __le64 Reserved;
458 __le32 DesiredAccess;
459 __le32 FileAttributes;
460 __le32 ShareAccess;
461 __le32 CreateDisposition;
462 __le32 CreateOptions;
463 __le16 NameOffset;
464 __le16 NameLength;
465 __le32 CreateContextsOffset;
466 __le32 CreateContextsLength;
Pavel Shilovsky59aa3712013-07-04 19:41:24 +0400467 __u8 Buffer[0];
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400468} __packed;
469
470struct smb2_create_rsp {
471 struct smb2_hdr hdr;
472 __le16 StructureSize; /* Must be 89 */
473 __u8 OplockLevel;
474 __u8 Reserved;
475 __le32 CreateAction;
476 __le64 CreationTime;
477 __le64 LastAccessTime;
478 __le64 LastWriteTime;
479 __le64 ChangeTime;
480 __le64 AllocationSize;
481 __le64 EndofFile;
482 __le32 FileAttributes;
483 __le32 Reserved2;
484 __u64 PersistentFileId; /* opaque endianness */
485 __u64 VolatileFileId; /* opaque endianness */
486 __le32 CreateContextsOffset;
487 __le32 CreateContextsLength;
488 __u8 Buffer[1];
489} __packed;
490
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700491struct create_context {
492 __le32 Next;
493 __le16 NameOffset;
494 __le16 NameLength;
495 __le16 Reserved;
496 __le16 DataOffset;
497 __le32 DataLength;
498 __u8 Buffer[0];
499} __packed;
500
Pavel Shilovsky53ef1012013-09-05 16:11:28 +0400501#define SMB2_LEASE_READ_CACHING_HE 0x01
502#define SMB2_LEASE_HANDLE_CACHING_HE 0x02
503#define SMB2_LEASE_WRITE_CACHING_HE 0x04
504
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700505#define SMB2_LEASE_NONE __constant_cpu_to_le32(0x00)
506#define SMB2_LEASE_READ_CACHING __constant_cpu_to_le32(0x01)
507#define SMB2_LEASE_HANDLE_CACHING __constant_cpu_to_le32(0x02)
508#define SMB2_LEASE_WRITE_CACHING __constant_cpu_to_le32(0x04)
509
510#define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS __constant_cpu_to_le32(0x02)
511
512#define SMB2_LEASE_KEY_SIZE 16
513
514struct lease_context {
515 __le64 LeaseKeyLow;
516 __le64 LeaseKeyHigh;
517 __le32 LeaseState;
518 __le32 LeaseFlags;
519 __le64 LeaseDuration;
520} __packed;
521
Pavel Shilovskyf0473902013-09-04 13:44:05 +0400522struct lease_context_v2 {
523 __le64 LeaseKeyLow;
524 __le64 LeaseKeyHigh;
525 __le32 LeaseState;
526 __le32 LeaseFlags;
527 __le64 LeaseDuration;
528 __le64 ParentLeaseKeyLow;
529 __le64 ParentLeaseKeyHigh;
530 __le16 Epoch;
531 __le16 Reserved;
532} __packed;
533
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700534struct create_lease {
535 struct create_context ccontext;
536 __u8 Name[8];
537 struct lease_context lcontext;
538} __packed;
539
Pavel Shilovskyf0473902013-09-04 13:44:05 +0400540struct create_lease_v2 {
541 struct create_context ccontext;
542 __u8 Name[8];
543 struct lease_context_v2 lcontext;
544 __u8 Pad[4];
545} __packed;
546
Pavel Shilovsky63eb3de2013-07-04 18:41:09 +0400547struct create_durable {
548 struct create_context ccontext;
549 __u8 Name[8];
Pavel Shilovsky9cbc0b72013-07-09 18:40:58 +0400550 union {
551 __u8 Reserved[16];
552 struct {
553 __u64 PersistentFileId;
554 __u64 VolatileFileId;
555 } Fid;
556 } Data;
Pavel Shilovsky63eb3de2013-07-04 18:41:09 +0400557} __packed;
558
Steve French41c13582013-11-14 00:05:36 -0600559#define COPY_CHUNK_RES_KEY_SIZE 24
560struct resume_key_req {
561 char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
562 __le32 ContextLength; /* MBZ */
563 char Context[0]; /* ignored, Windows sets to 4 bytes of zero */
564} __packed;
565
Steve Frenchbe7457d2013-06-19 17:41:10 -0500566/* this goes in the ioctl buffer when doing a copychunk request */
567struct copychunk_ioctl {
Steve French41c13582013-11-14 00:05:36 -0600568 char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
Steve Frenchbe7457d2013-06-19 17:41:10 -0500569 __le32 ChunkCount; /* we are only sending 1 */
570 __le32 Reserved;
571 /* array will only be one chunk long for us */
572 __le64 SourceOffset;
573 __le64 TargetOffset;
Steve Frenchc8664732013-06-21 15:35:45 -0500574 __le32 Length; /* how many bytes to copy */
Steve Frenchbe7457d2013-06-19 17:41:10 -0500575 __u32 Reserved2;
576} __packed;
577
Steve French31742c52014-08-17 08:38:47 -0500578/* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */
579struct file_zero_data_information {
580 __le64 FileOffset;
581 __le64 BeyondFinalZero;
582} __packed;
583
Steve French41c13582013-11-14 00:05:36 -0600584struct copychunk_ioctl_rsp {
585 __le32 ChunksWritten;
586 __le32 ChunkBytesWritten;
587 __le32 TotalBytesWritten;
588} __packed;
589
Steve Frenchff1c0382013-11-19 23:44:46 -0600590struct validate_negotiate_info_req {
Steve French4a72daf2013-06-25 00:20:49 -0500591 __le32 Capabilities;
592 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
593 __le16 SecurityMode;
594 __le16 DialectCount;
Steve Frenchff1c0382013-11-19 23:44:46 -0600595 __le16 Dialects[1]; /* dialect (someday maybe list) client asked for */
596} __packed;
597
598struct validate_negotiate_info_rsp {
599 __le32 Capabilities;
600 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
601 __le16 SecurityMode;
602 __le16 Dialect; /* Dialect in use for the connection */
Steve French4a72daf2013-06-25 00:20:49 -0500603} __packed;
604
605#define RSS_CAPABLE 0x00000001
606#define RDMA_CAPABLE 0x00000002
607
608struct network_interface_info_ioctl_rsp {
609 __le32 Next; /* next interface. zero if this is last one */
610 __le32 IfIndex;
611 __le32 Capability; /* RSS or RDMA Capable */
612 __le32 Reserved;
613 __le64 LinkSpeed;
614 char SockAddr_Storage[128];
615} __packed;
616
617#define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
618
Steve French64a5cfa2013-10-14 15:31:32 -0500619struct compress_ioctl {
Steve Frenchc7f508a2013-10-14 15:27:32 -0500620 __le16 CompressionState; /* See cifspdu.h for possible flag values */
Steve French64a5cfa2013-10-14 15:31:32 -0500621} __packed;
622
Steve Frenchbe7457d2013-06-19 17:41:10 -0500623struct smb2_ioctl_req {
624 struct smb2_hdr hdr;
625 __le16 StructureSize; /* Must be 57 */
626 __u16 Reserved;
627 __le32 CtlCode;
628 __u64 PersistentFileId; /* opaque endianness */
629 __u64 VolatileFileId; /* opaque endianness */
630 __le32 InputOffset;
631 __le32 InputCount;
632 __le32 MaxInputResponse;
633 __le32 OutputOffset;
634 __le32 OutputCount;
635 __le32 MaxOutputResponse;
636 __le32 Flags;
637 __u32 Reserved2;
Steve French64a5cfa2013-10-14 15:31:32 -0500638 __u8 Buffer[0];
Steve Frenchbe7457d2013-06-19 17:41:10 -0500639} __packed;
640
641struct smb2_ioctl_rsp {
642 struct smb2_hdr hdr;
643 __le16 StructureSize; /* Must be 57 */
644 __u16 Reserved;
645 __le32 CtlCode;
646 __u64 PersistentFileId; /* opaque endianness */
647 __u64 VolatileFileId; /* opaque endianness */
648 __le32 InputOffset;
649 __le32 InputCount;
650 __le32 OutputOffset;
651 __le32 OutputCount;
652 __le32 Flags;
653 __u32 Reserved2;
654 /* char * buffer[] */
655} __packed;
656
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400657/* Currently defined values for close flags */
658#define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001)
659struct smb2_close_req {
660 struct smb2_hdr hdr;
661 __le16 StructureSize; /* Must be 24 */
662 __le16 Flags;
663 __le32 Reserved;
664 __u64 PersistentFileId; /* opaque endianness */
665 __u64 VolatileFileId; /* opaque endianness */
666} __packed;
667
668struct smb2_close_rsp {
669 struct smb2_hdr hdr;
670 __le16 StructureSize; /* 60 */
671 __le16 Flags;
672 __le32 Reserved;
673 __le64 CreationTime;
674 __le64 LastAccessTime;
675 __le64 LastWriteTime;
676 __le64 ChangeTime;
677 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
678 __le64 EndOfFile;
679 __le32 Attributes;
680} __packed;
681
Pavel Shilovsky7a5cfb12012-09-18 16:20:28 -0700682struct smb2_flush_req {
683 struct smb2_hdr hdr;
684 __le16 StructureSize; /* Must be 24 */
685 __le16 Reserved1;
686 __le32 Reserved2;
687 __u64 PersistentFileId; /* opaque endianness */
688 __u64 VolatileFileId; /* opaque endianness */
689} __packed;
690
691struct smb2_flush_rsp {
692 struct smb2_hdr hdr;
693 __le16 StructureSize;
694 __le16 Reserved;
695} __packed;
696
Steve French2b5dc282013-06-13 10:51:10 -0500697/* For read request Flags field below, following flag is defined for SMB3.02 */
698#define SMB2_READFLAG_READ_UNBUFFERED 0x01
699
700/* Channel field for read and write: exactly one of following flags can be set*/
701#define SMB2_CHANNEL_NONE 0x00000000
702#define SMB2_CHANNEL_RDMA_V1 0x00000001 /* SMB3 or later */
703#define SMB2_CHANNEL_RDMA_V1_INVALIDATE 0x00000001 /* SMB3.02 or later */
704
Pavel Shilovsky09a47072012-09-18 16:20:29 -0700705struct smb2_read_req {
706 struct smb2_hdr hdr;
707 __le16 StructureSize; /* Must be 49 */
708 __u8 Padding; /* offset from start of SMB2 header to place read */
Steve French2b5dc282013-06-13 10:51:10 -0500709 __u8 Flags; /* MBZ unless SMB3.02 or later */
Pavel Shilovsky09a47072012-09-18 16:20:29 -0700710 __le32 Length;
711 __le64 Offset;
712 __u64 PersistentFileId; /* opaque endianness */
713 __u64 VolatileFileId; /* opaque endianness */
714 __le32 MinimumCount;
Steve French2b5dc282013-06-13 10:51:10 -0500715 __le32 Channel; /* MBZ except for SMB3 or later */
Pavel Shilovsky09a47072012-09-18 16:20:29 -0700716 __le32 RemainingBytes;
717 __le16 ReadChannelInfoOffset; /* Reserved MBZ */
718 __le16 ReadChannelInfoLength; /* Reserved MBZ */
719 __u8 Buffer[1];
720} __packed;
721
722struct smb2_read_rsp {
723 struct smb2_hdr hdr;
724 __le16 StructureSize; /* Must be 17 */
725 __u8 DataOffset;
726 __u8 Reserved;
727 __le32 DataLength;
728 __le32 DataRemaining;
729 __u32 Reserved2;
730 __u8 Buffer[1];
731} __packed;
732
Steve French2b5dc282013-06-13 10:51:10 -0500733/* For write request Flags field below the following flags are defined: */
734#define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */
735#define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */
Pavel Shilovsky33319142012-09-18 16:20:29 -0700736
737struct smb2_write_req {
738 struct smb2_hdr hdr;
739 __le16 StructureSize; /* Must be 49 */
740 __le16 DataOffset; /* offset from start of SMB2 header to write data */
741 __le32 Length;
742 __le64 Offset;
743 __u64 PersistentFileId; /* opaque endianness */
744 __u64 VolatileFileId; /* opaque endianness */
745 __le32 Channel; /* Reserved MBZ */
746 __le32 RemainingBytes;
747 __le16 WriteChannelInfoOffset; /* Reserved MBZ */
748 __le16 WriteChannelInfoLength; /* Reserved MBZ */
749 __le32 Flags;
750 __u8 Buffer[1];
751} __packed;
752
753struct smb2_write_rsp {
754 struct smb2_hdr hdr;
755 __le16 StructureSize; /* Must be 17 */
756 __u8 DataOffset;
757 __u8 Reserved;
758 __le32 DataLength;
759 __le32 DataRemaining;
760 __u32 Reserved2;
761 __u8 Buffer[1];
762} __packed;
763
Pavel Shilovsky027e8ee2012-09-19 06:22:43 -0700764#define SMB2_LOCKFLAG_SHARED_LOCK 0x0001
765#define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002
766#define SMB2_LOCKFLAG_UNLOCK 0x0004
767#define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
768
Pavel Shilovskyf7ba7fe2012-09-19 06:22:43 -0700769struct smb2_lock_element {
770 __le64 Offset;
771 __le64 Length;
772 __le32 Flags;
773 __le32 Reserved;
774} __packed;
775
776struct smb2_lock_req {
777 struct smb2_hdr hdr;
778 __le16 StructureSize; /* Must be 48 */
779 __le16 LockCount;
780 __le32 Reserved;
781 __u64 PersistentFileId; /* opaque endianness */
782 __u64 VolatileFileId; /* opaque endianness */
783 /* Followed by at least one */
784 struct smb2_lock_element locks[1];
785} __packed;
786
787struct smb2_lock_rsp {
788 struct smb2_hdr hdr;
789 __le16 StructureSize; /* Must be 4 */
790 __le16 Reserved;
791} __packed;
792
Pavel Shilovsky9094fad2012-07-12 18:30:44 +0400793struct smb2_echo_req {
794 struct smb2_hdr hdr;
795 __le16 StructureSize; /* Must be 4 */
796 __u16 Reserved;
797} __packed;
798
799struct smb2_echo_rsp {
800 struct smb2_hdr hdr;
801 __le16 StructureSize; /* Must be 4 */
802 __u16 Reserved;
803} __packed;
804
Pavel Shilovskyd324f08d2012-09-18 16:20:33 -0700805/* search (query_directory) Flags field */
806#define SMB2_RESTART_SCANS 0x01
807#define SMB2_RETURN_SINGLE_ENTRY 0x02
808#define SMB2_INDEX_SPECIFIED 0x04
809#define SMB2_REOPEN 0x10
810
811struct smb2_query_directory_req {
812 struct smb2_hdr hdr;
813 __le16 StructureSize; /* Must be 33 */
814 __u8 FileInformationClass;
815 __u8 Flags;
816 __le32 FileIndex;
817 __u64 PersistentFileId; /* opaque endianness */
818 __u64 VolatileFileId; /* opaque endianness */
819 __le16 FileNameOffset;
820 __le16 FileNameLength;
821 __le32 OutputBufferLength;
822 __u8 Buffer[1];
823} __packed;
824
825struct smb2_query_directory_rsp {
826 struct smb2_hdr hdr;
827 __le16 StructureSize; /* Must be 9 */
828 __le16 OutputBufferOffset;
829 __le32 OutputBufferLength;
830 __u8 Buffer[1];
831} __packed;
832
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400833/* Possible InfoType values */
834#define SMB2_O_INFO_FILE 0x01
835#define SMB2_O_INFO_FILESYSTEM 0x02
836#define SMB2_O_INFO_SECURITY 0x03
837#define SMB2_O_INFO_QUOTA 0x04
838
839struct smb2_query_info_req {
840 struct smb2_hdr hdr;
841 __le16 StructureSize; /* Must be 41 */
842 __u8 InfoType;
843 __u8 FileInfoClass;
844 __le32 OutputBufferLength;
845 __le16 InputBufferOffset;
846 __u16 Reserved;
847 __le32 InputBufferLength;
848 __le32 AdditionalInformation;
849 __le32 Flags;
850 __u64 PersistentFileId; /* opaque endianness */
851 __u64 VolatileFileId; /* opaque endianness */
852 __u8 Buffer[1];
853} __packed;
854
855struct smb2_query_info_rsp {
856 struct smb2_hdr hdr;
857 __le16 StructureSize; /* Must be 9 */
858 __le16 OutputBufferOffset;
859 __le32 OutputBufferLength;
860 __u8 Buffer[1];
861} __packed;
862
Pavel Shilovsky35143eb2012-09-18 16:20:31 -0700863struct smb2_set_info_req {
864 struct smb2_hdr hdr;
865 __le16 StructureSize; /* Must be 33 */
866 __u8 InfoType;
867 __u8 FileInfoClass;
868 __le32 BufferLength;
869 __le16 BufferOffset;
870 __u16 Reserved;
871 __le32 AdditionalInformation;
872 __u64 PersistentFileId; /* opaque endianness */
873 __u64 VolatileFileId; /* opaque endianness */
874 __u8 Buffer[1];
875} __packed;
876
877struct smb2_set_info_rsp {
878 struct smb2_hdr hdr;
879 __le16 StructureSize; /* Must be 2 */
880} __packed;
881
Pavel Shilovsky983c88a2012-09-18 16:20:33 -0700882struct smb2_oplock_break {
883 struct smb2_hdr hdr;
884 __le16 StructureSize; /* Must be 24 */
885 __u8 OplockLevel;
886 __u8 Reserved;
887 __le32 Reserved2;
888 __u64 PersistentFid;
889 __u64 VolatileFid;
890} __packed;
891
Pavel Shilovsky0822f512012-09-19 06:22:45 -0700892#define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
893
894struct smb2_lease_break {
895 struct smb2_hdr hdr;
896 __le16 StructureSize; /* Must be 44 */
897 __le16 Reserved;
898 __le32 Flags;
899 __u8 LeaseKey[16];
900 __le32 CurrentLeaseState;
901 __le32 NewLeaseState;
902 __le32 BreakReason;
903 __le32 AccessMaskHint;
904 __le32 ShareMaskHint;
905} __packed;
906
907struct smb2_lease_ack {
908 struct smb2_hdr hdr;
909 __le16 StructureSize; /* Must be 36 */
910 __le16 Reserved;
911 __le32 Flags;
912 __u8 LeaseKey[16];
913 __le32 LeaseState;
914 __le64 LeaseDuration;
915} __packed;
916
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400917/*
918 * PDU infolevel structure definitions
919 * BB consider moving to a different header
920 */
921
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -0700922/* File System Information Classes */
923#define FS_VOLUME_INFORMATION 1 /* Query */
Steven Frenchaf6a12e2013-10-09 20:55:53 -0500924#define FS_LABEL_INFORMATION 2 /* Local only */
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -0700925#define FS_SIZE_INFORMATION 3 /* Query */
926#define FS_DEVICE_INFORMATION 4 /* Query */
927#define FS_ATTRIBUTE_INFORMATION 5 /* Query */
928#define FS_CONTROL_INFORMATION 6 /* Query, Set */
929#define FS_FULL_SIZE_INFORMATION 7 /* Query */
930#define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
Steven Frenchaf6a12e2013-10-09 20:55:53 -0500931#define FS_DRIVER_PATH_INFORMATION 9 /* Local only */
932#define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */
933#define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -0700934
935struct smb2_fs_full_size_info {
936 __le64 TotalAllocationUnits;
937 __le64 CallerAvailableAllocationUnits;
938 __le64 ActualAvailableAllocationUnits;
939 __le32 SectorsPerAllocationUnit;
940 __le32 BytesPerSector;
941} __packed;
942
Steven Frenchaf6a12e2013-10-09 20:55:53 -0500943#define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
944#define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
945#define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
946#define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
947
948/* sector size info struct */
949struct smb3_fs_ss_info {
950 __le32 LogicalBytesPerSector;
951 __le32 PhysicalBytesPerSectorForAtomicity;
952 __le32 PhysicalBytesPerSectorForPerf;
953 __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
954 __le32 Flags;
955 __le32 ByteOffsetForSectorAlignment;
956 __le32 ByteOffsetForPartitionAlignment;
957} __packed;
958
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400959/* partial list of QUERY INFO levels */
960#define FILE_DIRECTORY_INFORMATION 1
961#define FILE_FULL_DIRECTORY_INFORMATION 2
962#define FILE_BOTH_DIRECTORY_INFORMATION 3
963#define FILE_BASIC_INFORMATION 4
964#define FILE_STANDARD_INFORMATION 5
965#define FILE_INTERNAL_INFORMATION 6
966#define FILE_EA_INFORMATION 7
967#define FILE_ACCESS_INFORMATION 8
968#define FILE_NAME_INFORMATION 9
969#define FILE_RENAME_INFORMATION 10
970#define FILE_LINK_INFORMATION 11
971#define FILE_NAMES_INFORMATION 12
972#define FILE_DISPOSITION_INFORMATION 13
973#define FILE_POSITION_INFORMATION 14
974#define FILE_FULL_EA_INFORMATION 15
975#define FILE_MODE_INFORMATION 16
976#define FILE_ALIGNMENT_INFORMATION 17
977#define FILE_ALL_INFORMATION 18
978#define FILE_ALLOCATION_INFORMATION 19
979#define FILE_END_OF_FILE_INFORMATION 20
980#define FILE_ALTERNATE_NAME_INFORMATION 21
981#define FILE_STREAM_INFORMATION 22
982#define FILE_PIPE_INFORMATION 23
983#define FILE_PIPE_LOCAL_INFORMATION 24
984#define FILE_PIPE_REMOTE_INFORMATION 25
985#define FILE_MAILSLOT_QUERY_INFORMATION 26
986#define FILE_MAILSLOT_SET_INFORMATION 27
987#define FILE_COMPRESSION_INFORMATION 28
988#define FILE_OBJECT_ID_INFORMATION 29
989/* Number 30 not defined in documents */
990#define FILE_MOVE_CLUSTER_INFORMATION 31
991#define FILE_QUOTA_INFORMATION 32
992#define FILE_REPARSE_POINT_INFORMATION 33
993#define FILE_NETWORK_OPEN_INFORMATION 34
994#define FILE_ATTRIBUTE_TAG_INFORMATION 35
995#define FILE_TRACKING_INFORMATION 36
996#define FILEID_BOTH_DIRECTORY_INFORMATION 37
997#define FILEID_FULL_DIRECTORY_INFORMATION 38
998#define FILE_VALID_DATA_LENGTH_INFORMATION 39
999#define FILE_SHORT_NAME_INFORMATION 40
1000#define FILE_SFIO_RESERVE_INFORMATION 44
1001#define FILE_SFIO_VOLUME_INFORMATION 45
1002#define FILE_HARD_LINK_INFORMATION 46
1003#define FILE_NORMALIZED_NAME_INFORMATION 48
1004#define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
1005#define FILE_STANDARD_LINK_INFORMATION 54
1006
Pavel Shilovskyf0df7372012-09-18 16:20:26 -07001007struct smb2_file_internal_info {
1008 __le64 IndexNumber;
1009} __packed; /* level 6 Query */
1010
Pavel Shilovsky35143eb2012-09-18 16:20:31 -07001011struct smb2_file_rename_info { /* encoding of request for level 10 */
1012 __u8 ReplaceIfExists; /* 1 = replace existing target with new */
1013 /* 0 = fail if target already exists */
1014 __u8 Reserved[7];
1015 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1016 __le32 FileNameLength;
1017 char FileName[0]; /* New name to be assigned */
1018} __packed; /* level 10 Set */
1019
Pavel Shilovsky568798c2012-09-18 16:20:31 -07001020struct smb2_file_link_info { /* encoding of request for level 11 */
1021 __u8 ReplaceIfExists; /* 1 = replace existing link with new */
1022 /* 0 = fail if link already exists */
1023 __u8 Reserved[7];
1024 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1025 __le32 FileNameLength;
1026 char FileName[0]; /* Name to be assigned to new link */
1027} __packed; /* level 11 Set */
1028
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +04001029/*
1030 * This level 18, although with struct with same name is different from cifs
1031 * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
1032 * CurrentByteOffset.
1033 */
1034struct smb2_file_all_info { /* data block encoding of response to level 18 */
1035 __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
1036 __le64 LastAccessTime;
1037 __le64 LastWriteTime;
1038 __le64 ChangeTime;
1039 __le32 Attributes;
1040 __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
1041 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
1042 __le64 EndOfFile; /* size ie offset to first free byte in file */
1043 __le32 NumberOfLinks; /* hard links */
1044 __u8 DeletePending;
1045 __u8 Directory;
1046 __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */
1047 __le64 IndexNumber;
1048 __le32 EASize;
1049 __le32 AccessFlags;
1050 __le64 CurrentByteOffset;
1051 __le32 Mode;
1052 __le32 AlignmentRequirement;
1053 __le32 FileNameLength;
1054 char FileName[1];
1055} __packed; /* level 18 Query */
1056
Pavel Shilovskyc839ff22012-09-18 16:20:32 -07001057struct smb2_file_eof_info { /* encoding of request for level 10 */
1058 __le64 EndOfFile; /* new end of file value */
1059} __packed; /* level 20 Set */
1060
Steve Frenchddfbefb2011-03-15 02:08:48 +00001061#endif /* _SMB2PDU_H */