blob: fbe486c285a90aff757a43569330fb32c9bbb50d [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
355
356/* Oplock levels */
357#define SMB2_OPLOCK_LEVEL_NONE 0x00
358#define SMB2_OPLOCK_LEVEL_II 0x01
359#define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
360#define SMB2_OPLOCK_LEVEL_BATCH 0x09
361#define SMB2_OPLOCK_LEVEL_LEASE 0xFF
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700362/* Non-spec internal type */
363#define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400364
365/* Desired Access Flags */
366#define FILE_READ_DATA_LE cpu_to_le32(0x00000001)
367#define FILE_WRITE_DATA_LE cpu_to_le32(0x00000002)
368#define FILE_APPEND_DATA_LE cpu_to_le32(0x00000004)
369#define FILE_READ_EA_LE cpu_to_le32(0x00000008)
370#define FILE_WRITE_EA_LE cpu_to_le32(0x00000010)
371#define FILE_EXECUTE_LE cpu_to_le32(0x00000020)
372#define FILE_READ_ATTRIBUTES_LE cpu_to_le32(0x00000080)
373#define FILE_WRITE_ATTRIBUTES_LE cpu_to_le32(0x00000100)
374#define FILE_DELETE_LE cpu_to_le32(0x00010000)
375#define FILE_READ_CONTROL_LE cpu_to_le32(0x00020000)
376#define FILE_WRITE_DAC_LE cpu_to_le32(0x00040000)
377#define FILE_WRITE_OWNER_LE cpu_to_le32(0x00080000)
378#define FILE_SYNCHRONIZE_LE cpu_to_le32(0x00100000)
379#define FILE_ACCESS_SYSTEM_SECURITY_LE cpu_to_le32(0x01000000)
380#define FILE_MAXIMAL_ACCESS_LE cpu_to_le32(0x02000000)
381#define FILE_GENERIC_ALL_LE cpu_to_le32(0x10000000)
382#define FILE_GENERIC_EXECUTE_LE cpu_to_le32(0x20000000)
383#define FILE_GENERIC_WRITE_LE cpu_to_le32(0x40000000)
384#define FILE_GENERIC_READ_LE cpu_to_le32(0x80000000)
385
386/* ShareAccess Flags */
387#define FILE_SHARE_READ_LE cpu_to_le32(0x00000001)
388#define FILE_SHARE_WRITE_LE cpu_to_le32(0x00000002)
389#define FILE_SHARE_DELETE_LE cpu_to_le32(0x00000004)
390#define FILE_SHARE_ALL_LE cpu_to_le32(0x00000007)
391
392/* CreateDisposition Flags */
393#define FILE_SUPERSEDE_LE cpu_to_le32(0x00000000)
394#define FILE_OPEN_LE cpu_to_le32(0x00000001)
395#define FILE_CREATE_LE cpu_to_le32(0x00000002)
396#define FILE_OPEN_IF_LE cpu_to_le32(0x00000003)
397#define FILE_OVERWRITE_LE cpu_to_le32(0x00000004)
398#define FILE_OVERWRITE_IF_LE cpu_to_le32(0x00000005)
399
400/* CreateOptions Flags */
401#define FILE_DIRECTORY_FILE_LE cpu_to_le32(0x00000001)
402/* same as #define CREATE_NOT_FILE_LE cpu_to_le32(0x00000001) */
403#define FILE_WRITE_THROUGH_LE cpu_to_le32(0x00000002)
404#define FILE_SEQUENTIAL_ONLY_LE cpu_to_le32(0x00000004)
405#define FILE_NO_INTERMEDIATE_BUFFERRING_LE cpu_to_le32(0x00000008)
406#define FILE_SYNCHRONOUS_IO_ALERT_LE cpu_to_le32(0x00000010)
407#define FILE_SYNCHRONOUS_IO_NON_ALERT_LE cpu_to_le32(0x00000020)
408#define FILE_NON_DIRECTORY_FILE_LE cpu_to_le32(0x00000040)
409#define FILE_COMPLETE_IF_OPLOCKED_LE cpu_to_le32(0x00000100)
410#define FILE_NO_EA_KNOWLEDGE_LE cpu_to_le32(0x00000200)
411#define FILE_RANDOM_ACCESS_LE cpu_to_le32(0x00000800)
412#define FILE_DELETE_ON_CLOSE_LE cpu_to_le32(0x00001000)
413#define FILE_OPEN_BY_FILE_ID_LE cpu_to_le32(0x00002000)
414#define FILE_OPEN_FOR_BACKUP_INTENT_LE cpu_to_le32(0x00004000)
415#define FILE_NO_COMPRESSION_LE cpu_to_le32(0x00008000)
416#define FILE_RESERVE_OPFILTER_LE cpu_to_le32(0x00100000)
417#define FILE_OPEN_REPARSE_POINT_LE cpu_to_le32(0x00200000)
418#define FILE_OPEN_NO_RECALL_LE cpu_to_le32(0x00400000)
419#define FILE_OPEN_FOR_FREE_SPACE_QUERY_LE cpu_to_le32(0x00800000)
420
421#define FILE_READ_RIGHTS_LE (FILE_READ_DATA_LE | FILE_READ_EA_LE \
422 | FILE_READ_ATTRIBUTES_LE)
423#define FILE_WRITE_RIGHTS_LE (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE \
424 | FILE_WRITE_EA_LE | FILE_WRITE_ATTRIBUTES_LE)
425#define FILE_EXEC_RIGHTS_LE (FILE_EXECUTE_LE)
426
427/* Impersonation Levels */
428#define IL_ANONYMOUS cpu_to_le32(0x00000000)
429#define IL_IDENTIFICATION cpu_to_le32(0x00000001)
430#define IL_IMPERSONATION cpu_to_le32(0x00000002)
431#define IL_DELEGATE cpu_to_le32(0x00000003)
432
433/* Create Context Values */
434#define SMB2_CREATE_EA_BUFFER "ExtA" /* extended attributes */
435#define SMB2_CREATE_SD_BUFFER "SecD" /* security descriptor */
436#define SMB2_CREATE_DURABLE_HANDLE_REQUEST "DHnQ"
437#define SMB2_CREATE_DURABLE_HANDLE_RECONNECT "DHnC"
Steve French12197a72014-05-14 05:29:40 -0700438#define SMB2_CREATE_ALLOCATION_SIZE "AISi"
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400439#define SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQUEST "MxAc"
440#define SMB2_CREATE_TIMEWARP_REQUEST "TWrp"
441#define SMB2_CREATE_QUERY_ON_DISK_ID "QFid"
442#define SMB2_CREATE_REQUEST_LEASE "RqLs"
Steve French12197a72014-05-14 05:29:40 -0700443#define SMB2_CREATE_DURABLE_HANDLE_REQUEST_V2 "DH2Q"
444#define SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 "DH2C"
445#define SMB2_CREATE_APP_INSTANCE_ID 0x45BCA66AEFA7F74A9008FA462E144D74
446#define SVHDX_OPEN_DEVICE_CONTEXT 0x83CE6F1AD851E0986E34401CC9BCFCE9
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400447
448struct smb2_create_req {
449 struct smb2_hdr hdr;
450 __le16 StructureSize; /* Must be 57 */
451 __u8 SecurityFlags;
452 __u8 RequestedOplockLevel;
453 __le32 ImpersonationLevel;
454 __le64 SmbCreateFlags;
455 __le64 Reserved;
456 __le32 DesiredAccess;
457 __le32 FileAttributes;
458 __le32 ShareAccess;
459 __le32 CreateDisposition;
460 __le32 CreateOptions;
461 __le16 NameOffset;
462 __le16 NameLength;
463 __le32 CreateContextsOffset;
464 __le32 CreateContextsLength;
Pavel Shilovsky59aa3712013-07-04 19:41:24 +0400465 __u8 Buffer[0];
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400466} __packed;
467
468struct smb2_create_rsp {
469 struct smb2_hdr hdr;
470 __le16 StructureSize; /* Must be 89 */
471 __u8 OplockLevel;
472 __u8 Reserved;
473 __le32 CreateAction;
474 __le64 CreationTime;
475 __le64 LastAccessTime;
476 __le64 LastWriteTime;
477 __le64 ChangeTime;
478 __le64 AllocationSize;
479 __le64 EndofFile;
480 __le32 FileAttributes;
481 __le32 Reserved2;
482 __u64 PersistentFileId; /* opaque endianness */
483 __u64 VolatileFileId; /* opaque endianness */
484 __le32 CreateContextsOffset;
485 __le32 CreateContextsLength;
486 __u8 Buffer[1];
487} __packed;
488
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700489struct create_context {
490 __le32 Next;
491 __le16 NameOffset;
492 __le16 NameLength;
493 __le16 Reserved;
494 __le16 DataOffset;
495 __le32 DataLength;
496 __u8 Buffer[0];
497} __packed;
498
Pavel Shilovsky53ef1012013-09-05 16:11:28 +0400499#define SMB2_LEASE_READ_CACHING_HE 0x01
500#define SMB2_LEASE_HANDLE_CACHING_HE 0x02
501#define SMB2_LEASE_WRITE_CACHING_HE 0x04
502
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700503#define SMB2_LEASE_NONE __constant_cpu_to_le32(0x00)
504#define SMB2_LEASE_READ_CACHING __constant_cpu_to_le32(0x01)
505#define SMB2_LEASE_HANDLE_CACHING __constant_cpu_to_le32(0x02)
506#define SMB2_LEASE_WRITE_CACHING __constant_cpu_to_le32(0x04)
507
508#define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS __constant_cpu_to_le32(0x02)
509
510#define SMB2_LEASE_KEY_SIZE 16
511
512struct lease_context {
513 __le64 LeaseKeyLow;
514 __le64 LeaseKeyHigh;
515 __le32 LeaseState;
516 __le32 LeaseFlags;
517 __le64 LeaseDuration;
518} __packed;
519
Pavel Shilovskyf0473902013-09-04 13:44:05 +0400520struct lease_context_v2 {
521 __le64 LeaseKeyLow;
522 __le64 LeaseKeyHigh;
523 __le32 LeaseState;
524 __le32 LeaseFlags;
525 __le64 LeaseDuration;
526 __le64 ParentLeaseKeyLow;
527 __le64 ParentLeaseKeyHigh;
528 __le16 Epoch;
529 __le16 Reserved;
530} __packed;
531
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700532struct create_lease {
533 struct create_context ccontext;
534 __u8 Name[8];
535 struct lease_context lcontext;
536} __packed;
537
Pavel Shilovskyf0473902013-09-04 13:44:05 +0400538struct create_lease_v2 {
539 struct create_context ccontext;
540 __u8 Name[8];
541 struct lease_context_v2 lcontext;
542 __u8 Pad[4];
543} __packed;
544
Pavel Shilovsky63eb3de2013-07-04 18:41:09 +0400545struct create_durable {
546 struct create_context ccontext;
547 __u8 Name[8];
Pavel Shilovsky9cbc0b72013-07-09 18:40:58 +0400548 union {
549 __u8 Reserved[16];
550 struct {
551 __u64 PersistentFileId;
552 __u64 VolatileFileId;
553 } Fid;
554 } Data;
Pavel Shilovsky63eb3de2013-07-04 18:41:09 +0400555} __packed;
556
Steve French41c13582013-11-14 00:05:36 -0600557#define COPY_CHUNK_RES_KEY_SIZE 24
558struct resume_key_req {
559 char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
560 __le32 ContextLength; /* MBZ */
561 char Context[0]; /* ignored, Windows sets to 4 bytes of zero */
562} __packed;
563
Steve Frenchbe7457d2013-06-19 17:41:10 -0500564/* this goes in the ioctl buffer when doing a copychunk request */
565struct copychunk_ioctl {
Steve French41c13582013-11-14 00:05:36 -0600566 char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
Steve Frenchbe7457d2013-06-19 17:41:10 -0500567 __le32 ChunkCount; /* we are only sending 1 */
568 __le32 Reserved;
569 /* array will only be one chunk long for us */
570 __le64 SourceOffset;
571 __le64 TargetOffset;
Steve Frenchc8664732013-06-21 15:35:45 -0500572 __le32 Length; /* how many bytes to copy */
Steve Frenchbe7457d2013-06-19 17:41:10 -0500573 __u32 Reserved2;
574} __packed;
575
Steve French31742c52014-08-17 08:38:47 -0500576/* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */
577struct file_zero_data_information {
578 __le64 FileOffset;
579 __le64 BeyondFinalZero;
580} __packed;
581
Steve French41c13582013-11-14 00:05:36 -0600582struct copychunk_ioctl_rsp {
583 __le32 ChunksWritten;
584 __le32 ChunkBytesWritten;
585 __le32 TotalBytesWritten;
586} __packed;
587
Steve Frenchff1c0382013-11-19 23:44:46 -0600588struct validate_negotiate_info_req {
Steve French4a72daf2013-06-25 00:20:49 -0500589 __le32 Capabilities;
590 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
591 __le16 SecurityMode;
592 __le16 DialectCount;
Steve Frenchff1c0382013-11-19 23:44:46 -0600593 __le16 Dialects[1]; /* dialect (someday maybe list) client asked for */
594} __packed;
595
596struct validate_negotiate_info_rsp {
597 __le32 Capabilities;
598 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
599 __le16 SecurityMode;
600 __le16 Dialect; /* Dialect in use for the connection */
Steve French4a72daf2013-06-25 00:20:49 -0500601} __packed;
602
603#define RSS_CAPABLE 0x00000001
604#define RDMA_CAPABLE 0x00000002
605
606struct network_interface_info_ioctl_rsp {
607 __le32 Next; /* next interface. zero if this is last one */
608 __le32 IfIndex;
609 __le32 Capability; /* RSS or RDMA Capable */
610 __le32 Reserved;
611 __le64 LinkSpeed;
612 char SockAddr_Storage[128];
613} __packed;
614
615#define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
616
Steve French64a5cfa2013-10-14 15:31:32 -0500617struct compress_ioctl {
Steve Frenchc7f508a2013-10-14 15:27:32 -0500618 __le16 CompressionState; /* See cifspdu.h for possible flag values */
Steve French64a5cfa2013-10-14 15:31:32 -0500619} __packed;
620
Steve Frenchbe7457d2013-06-19 17:41:10 -0500621struct smb2_ioctl_req {
622 struct smb2_hdr hdr;
623 __le16 StructureSize; /* Must be 57 */
624 __u16 Reserved;
625 __le32 CtlCode;
626 __u64 PersistentFileId; /* opaque endianness */
627 __u64 VolatileFileId; /* opaque endianness */
628 __le32 InputOffset;
629 __le32 InputCount;
630 __le32 MaxInputResponse;
631 __le32 OutputOffset;
632 __le32 OutputCount;
633 __le32 MaxOutputResponse;
634 __le32 Flags;
635 __u32 Reserved2;
Steve French64a5cfa2013-10-14 15:31:32 -0500636 __u8 Buffer[0];
Steve Frenchbe7457d2013-06-19 17:41:10 -0500637} __packed;
638
639struct smb2_ioctl_rsp {
640 struct smb2_hdr hdr;
641 __le16 StructureSize; /* Must be 57 */
642 __u16 Reserved;
643 __le32 CtlCode;
644 __u64 PersistentFileId; /* opaque endianness */
645 __u64 VolatileFileId; /* opaque endianness */
646 __le32 InputOffset;
647 __le32 InputCount;
648 __le32 OutputOffset;
649 __le32 OutputCount;
650 __le32 Flags;
651 __u32 Reserved2;
652 /* char * buffer[] */
653} __packed;
654
Pavel Shilovsky2503a0d2011-12-26 22:58:46 +0400655/* Currently defined values for close flags */
656#define SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB cpu_to_le16(0x0001)
657struct smb2_close_req {
658 struct smb2_hdr hdr;
659 __le16 StructureSize; /* Must be 24 */
660 __le16 Flags;
661 __le32 Reserved;
662 __u64 PersistentFileId; /* opaque endianness */
663 __u64 VolatileFileId; /* opaque endianness */
664} __packed;
665
666struct smb2_close_rsp {
667 struct smb2_hdr hdr;
668 __le16 StructureSize; /* 60 */
669 __le16 Flags;
670 __le32 Reserved;
671 __le64 CreationTime;
672 __le64 LastAccessTime;
673 __le64 LastWriteTime;
674 __le64 ChangeTime;
675 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
676 __le64 EndOfFile;
677 __le32 Attributes;
678} __packed;
679
Pavel Shilovsky7a5cfb12012-09-18 16:20:28 -0700680struct smb2_flush_req {
681 struct smb2_hdr hdr;
682 __le16 StructureSize; /* Must be 24 */
683 __le16 Reserved1;
684 __le32 Reserved2;
685 __u64 PersistentFileId; /* opaque endianness */
686 __u64 VolatileFileId; /* opaque endianness */
687} __packed;
688
689struct smb2_flush_rsp {
690 struct smb2_hdr hdr;
691 __le16 StructureSize;
692 __le16 Reserved;
693} __packed;
694
Steve French2b5dc282013-06-13 10:51:10 -0500695/* For read request Flags field below, following flag is defined for SMB3.02 */
696#define SMB2_READFLAG_READ_UNBUFFERED 0x01
697
698/* Channel field for read and write: exactly one of following flags can be set*/
699#define SMB2_CHANNEL_NONE 0x00000000
700#define SMB2_CHANNEL_RDMA_V1 0x00000001 /* SMB3 or later */
701#define SMB2_CHANNEL_RDMA_V1_INVALIDATE 0x00000001 /* SMB3.02 or later */
702
Pavel Shilovsky09a47072012-09-18 16:20:29 -0700703struct smb2_read_req {
704 struct smb2_hdr hdr;
705 __le16 StructureSize; /* Must be 49 */
706 __u8 Padding; /* offset from start of SMB2 header to place read */
Steve French2b5dc282013-06-13 10:51:10 -0500707 __u8 Flags; /* MBZ unless SMB3.02 or later */
Pavel Shilovsky09a47072012-09-18 16:20:29 -0700708 __le32 Length;
709 __le64 Offset;
710 __u64 PersistentFileId; /* opaque endianness */
711 __u64 VolatileFileId; /* opaque endianness */
712 __le32 MinimumCount;
Steve French2b5dc282013-06-13 10:51:10 -0500713 __le32 Channel; /* MBZ except for SMB3 or later */
Pavel Shilovsky09a47072012-09-18 16:20:29 -0700714 __le32 RemainingBytes;
715 __le16 ReadChannelInfoOffset; /* Reserved MBZ */
716 __le16 ReadChannelInfoLength; /* Reserved MBZ */
717 __u8 Buffer[1];
718} __packed;
719
720struct smb2_read_rsp {
721 struct smb2_hdr hdr;
722 __le16 StructureSize; /* Must be 17 */
723 __u8 DataOffset;
724 __u8 Reserved;
725 __le32 DataLength;
726 __le32 DataRemaining;
727 __u32 Reserved2;
728 __u8 Buffer[1];
729} __packed;
730
Steve French2b5dc282013-06-13 10:51:10 -0500731/* For write request Flags field below the following flags are defined: */
732#define SMB2_WRITEFLAG_WRITE_THROUGH 0x00000001 /* SMB2.1 or later */
733#define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */
Pavel Shilovsky33319142012-09-18 16:20:29 -0700734
735struct smb2_write_req {
736 struct smb2_hdr hdr;
737 __le16 StructureSize; /* Must be 49 */
738 __le16 DataOffset; /* offset from start of SMB2 header to write data */
739 __le32 Length;
740 __le64 Offset;
741 __u64 PersistentFileId; /* opaque endianness */
742 __u64 VolatileFileId; /* opaque endianness */
743 __le32 Channel; /* Reserved MBZ */
744 __le32 RemainingBytes;
745 __le16 WriteChannelInfoOffset; /* Reserved MBZ */
746 __le16 WriteChannelInfoLength; /* Reserved MBZ */
747 __le32 Flags;
748 __u8 Buffer[1];
749} __packed;
750
751struct smb2_write_rsp {
752 struct smb2_hdr hdr;
753 __le16 StructureSize; /* Must be 17 */
754 __u8 DataOffset;
755 __u8 Reserved;
756 __le32 DataLength;
757 __le32 DataRemaining;
758 __u32 Reserved2;
759 __u8 Buffer[1];
760} __packed;
761
Pavel Shilovsky027e8ee2012-09-19 06:22:43 -0700762#define SMB2_LOCKFLAG_SHARED_LOCK 0x0001
763#define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002
764#define SMB2_LOCKFLAG_UNLOCK 0x0004
765#define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
766
Pavel Shilovskyf7ba7fe2012-09-19 06:22:43 -0700767struct smb2_lock_element {
768 __le64 Offset;
769 __le64 Length;
770 __le32 Flags;
771 __le32 Reserved;
772} __packed;
773
774struct smb2_lock_req {
775 struct smb2_hdr hdr;
776 __le16 StructureSize; /* Must be 48 */
777 __le16 LockCount;
778 __le32 Reserved;
779 __u64 PersistentFileId; /* opaque endianness */
780 __u64 VolatileFileId; /* opaque endianness */
781 /* Followed by at least one */
782 struct smb2_lock_element locks[1];
783} __packed;
784
785struct smb2_lock_rsp {
786 struct smb2_hdr hdr;
787 __le16 StructureSize; /* Must be 4 */
788 __le16 Reserved;
789} __packed;
790
Pavel Shilovsky9094fad2012-07-12 18:30:44 +0400791struct smb2_echo_req {
792 struct smb2_hdr hdr;
793 __le16 StructureSize; /* Must be 4 */
794 __u16 Reserved;
795} __packed;
796
797struct smb2_echo_rsp {
798 struct smb2_hdr hdr;
799 __le16 StructureSize; /* Must be 4 */
800 __u16 Reserved;
801} __packed;
802
Pavel Shilovskyd324f08d2012-09-18 16:20:33 -0700803/* search (query_directory) Flags field */
804#define SMB2_RESTART_SCANS 0x01
805#define SMB2_RETURN_SINGLE_ENTRY 0x02
806#define SMB2_INDEX_SPECIFIED 0x04
807#define SMB2_REOPEN 0x10
808
809struct smb2_query_directory_req {
810 struct smb2_hdr hdr;
811 __le16 StructureSize; /* Must be 33 */
812 __u8 FileInformationClass;
813 __u8 Flags;
814 __le32 FileIndex;
815 __u64 PersistentFileId; /* opaque endianness */
816 __u64 VolatileFileId; /* opaque endianness */
817 __le16 FileNameOffset;
818 __le16 FileNameLength;
819 __le32 OutputBufferLength;
820 __u8 Buffer[1];
821} __packed;
822
823struct smb2_query_directory_rsp {
824 struct smb2_hdr hdr;
825 __le16 StructureSize; /* Must be 9 */
826 __le16 OutputBufferOffset;
827 __le32 OutputBufferLength;
828 __u8 Buffer[1];
829} __packed;
830
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400831/* Possible InfoType values */
832#define SMB2_O_INFO_FILE 0x01
833#define SMB2_O_INFO_FILESYSTEM 0x02
834#define SMB2_O_INFO_SECURITY 0x03
835#define SMB2_O_INFO_QUOTA 0x04
836
837struct smb2_query_info_req {
838 struct smb2_hdr hdr;
839 __le16 StructureSize; /* Must be 41 */
840 __u8 InfoType;
841 __u8 FileInfoClass;
842 __le32 OutputBufferLength;
843 __le16 InputBufferOffset;
844 __u16 Reserved;
845 __le32 InputBufferLength;
846 __le32 AdditionalInformation;
847 __le32 Flags;
848 __u64 PersistentFileId; /* opaque endianness */
849 __u64 VolatileFileId; /* opaque endianness */
850 __u8 Buffer[1];
851} __packed;
852
853struct smb2_query_info_rsp {
854 struct smb2_hdr hdr;
855 __le16 StructureSize; /* Must be 9 */
856 __le16 OutputBufferOffset;
857 __le32 OutputBufferLength;
858 __u8 Buffer[1];
859} __packed;
860
Pavel Shilovsky35143eb2012-09-18 16:20:31 -0700861struct smb2_set_info_req {
862 struct smb2_hdr hdr;
863 __le16 StructureSize; /* Must be 33 */
864 __u8 InfoType;
865 __u8 FileInfoClass;
866 __le32 BufferLength;
867 __le16 BufferOffset;
868 __u16 Reserved;
869 __le32 AdditionalInformation;
870 __u64 PersistentFileId; /* opaque endianness */
871 __u64 VolatileFileId; /* opaque endianness */
872 __u8 Buffer[1];
873} __packed;
874
875struct smb2_set_info_rsp {
876 struct smb2_hdr hdr;
877 __le16 StructureSize; /* Must be 2 */
878} __packed;
879
Pavel Shilovsky983c88a2012-09-18 16:20:33 -0700880struct smb2_oplock_break {
881 struct smb2_hdr hdr;
882 __le16 StructureSize; /* Must be 24 */
883 __u8 OplockLevel;
884 __u8 Reserved;
885 __le32 Reserved2;
886 __u64 PersistentFid;
887 __u64 VolatileFid;
888} __packed;
889
Pavel Shilovsky0822f512012-09-19 06:22:45 -0700890#define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
891
892struct smb2_lease_break {
893 struct smb2_hdr hdr;
894 __le16 StructureSize; /* Must be 44 */
895 __le16 Reserved;
896 __le32 Flags;
897 __u8 LeaseKey[16];
898 __le32 CurrentLeaseState;
899 __le32 NewLeaseState;
900 __le32 BreakReason;
901 __le32 AccessMaskHint;
902 __le32 ShareMaskHint;
903} __packed;
904
905struct smb2_lease_ack {
906 struct smb2_hdr hdr;
907 __le16 StructureSize; /* Must be 36 */
908 __le16 Reserved;
909 __le32 Flags;
910 __u8 LeaseKey[16];
911 __le32 LeaseState;
912 __le64 LeaseDuration;
913} __packed;
914
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400915/*
916 * PDU infolevel structure definitions
917 * BB consider moving to a different header
918 */
919
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -0700920/* File System Information Classes */
921#define FS_VOLUME_INFORMATION 1 /* Query */
Steven Frenchaf6a12e2013-10-09 20:55:53 -0500922#define FS_LABEL_INFORMATION 2 /* Local only */
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -0700923#define FS_SIZE_INFORMATION 3 /* Query */
924#define FS_DEVICE_INFORMATION 4 /* Query */
925#define FS_ATTRIBUTE_INFORMATION 5 /* Query */
926#define FS_CONTROL_INFORMATION 6 /* Query, Set */
927#define FS_FULL_SIZE_INFORMATION 7 /* Query */
928#define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
Steven Frenchaf6a12e2013-10-09 20:55:53 -0500929#define FS_DRIVER_PATH_INFORMATION 9 /* Local only */
930#define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */
931#define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -0700932
933struct smb2_fs_full_size_info {
934 __le64 TotalAllocationUnits;
935 __le64 CallerAvailableAllocationUnits;
936 __le64 ActualAvailableAllocationUnits;
937 __le32 SectorsPerAllocationUnit;
938 __le32 BytesPerSector;
939} __packed;
940
Steven Frenchaf6a12e2013-10-09 20:55:53 -0500941#define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
942#define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
943#define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
944#define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
945
946/* sector size info struct */
947struct smb3_fs_ss_info {
948 __le32 LogicalBytesPerSector;
949 __le32 PhysicalBytesPerSectorForAtomicity;
950 __le32 PhysicalBytesPerSectorForPerf;
951 __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
952 __le32 Flags;
953 __le32 ByteOffsetForSectorAlignment;
954 __le32 ByteOffsetForPartitionAlignment;
955} __packed;
956
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400957/* partial list of QUERY INFO levels */
958#define FILE_DIRECTORY_INFORMATION 1
959#define FILE_FULL_DIRECTORY_INFORMATION 2
960#define FILE_BOTH_DIRECTORY_INFORMATION 3
961#define FILE_BASIC_INFORMATION 4
962#define FILE_STANDARD_INFORMATION 5
963#define FILE_INTERNAL_INFORMATION 6
964#define FILE_EA_INFORMATION 7
965#define FILE_ACCESS_INFORMATION 8
966#define FILE_NAME_INFORMATION 9
967#define FILE_RENAME_INFORMATION 10
968#define FILE_LINK_INFORMATION 11
969#define FILE_NAMES_INFORMATION 12
970#define FILE_DISPOSITION_INFORMATION 13
971#define FILE_POSITION_INFORMATION 14
972#define FILE_FULL_EA_INFORMATION 15
973#define FILE_MODE_INFORMATION 16
974#define FILE_ALIGNMENT_INFORMATION 17
975#define FILE_ALL_INFORMATION 18
976#define FILE_ALLOCATION_INFORMATION 19
977#define FILE_END_OF_FILE_INFORMATION 20
978#define FILE_ALTERNATE_NAME_INFORMATION 21
979#define FILE_STREAM_INFORMATION 22
980#define FILE_PIPE_INFORMATION 23
981#define FILE_PIPE_LOCAL_INFORMATION 24
982#define FILE_PIPE_REMOTE_INFORMATION 25
983#define FILE_MAILSLOT_QUERY_INFORMATION 26
984#define FILE_MAILSLOT_SET_INFORMATION 27
985#define FILE_COMPRESSION_INFORMATION 28
986#define FILE_OBJECT_ID_INFORMATION 29
987/* Number 30 not defined in documents */
988#define FILE_MOVE_CLUSTER_INFORMATION 31
989#define FILE_QUOTA_INFORMATION 32
990#define FILE_REPARSE_POINT_INFORMATION 33
991#define FILE_NETWORK_OPEN_INFORMATION 34
992#define FILE_ATTRIBUTE_TAG_INFORMATION 35
993#define FILE_TRACKING_INFORMATION 36
994#define FILEID_BOTH_DIRECTORY_INFORMATION 37
995#define FILEID_FULL_DIRECTORY_INFORMATION 38
996#define FILE_VALID_DATA_LENGTH_INFORMATION 39
997#define FILE_SHORT_NAME_INFORMATION 40
998#define FILE_SFIO_RESERVE_INFORMATION 44
999#define FILE_SFIO_VOLUME_INFORMATION 45
1000#define FILE_HARD_LINK_INFORMATION 46
1001#define FILE_NORMALIZED_NAME_INFORMATION 48
1002#define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
1003#define FILE_STANDARD_LINK_INFORMATION 54
1004
Pavel Shilovskyf0df7372012-09-18 16:20:26 -07001005struct smb2_file_internal_info {
1006 __le64 IndexNumber;
1007} __packed; /* level 6 Query */
1008
Pavel Shilovsky35143eb2012-09-18 16:20:31 -07001009struct smb2_file_rename_info { /* encoding of request for level 10 */
1010 __u8 ReplaceIfExists; /* 1 = replace existing target with new */
1011 /* 0 = fail if target already exists */
1012 __u8 Reserved[7];
1013 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1014 __le32 FileNameLength;
1015 char FileName[0]; /* New name to be assigned */
1016} __packed; /* level 10 Set */
1017
Pavel Shilovsky568798c2012-09-18 16:20:31 -07001018struct smb2_file_link_info { /* encoding of request for level 11 */
1019 __u8 ReplaceIfExists; /* 1 = replace existing link with new */
1020 /* 0 = fail if link already exists */
1021 __u8 Reserved[7];
1022 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
1023 __le32 FileNameLength;
1024 char FileName[0]; /* Name to be assigned to new link */
1025} __packed; /* level 11 Set */
1026
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +04001027/*
1028 * This level 18, although with struct with same name is different from cifs
1029 * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
1030 * CurrentByteOffset.
1031 */
1032struct smb2_file_all_info { /* data block encoding of response to level 18 */
1033 __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
1034 __le64 LastAccessTime;
1035 __le64 LastWriteTime;
1036 __le64 ChangeTime;
1037 __le32 Attributes;
1038 __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
1039 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
1040 __le64 EndOfFile; /* size ie offset to first free byte in file */
1041 __le32 NumberOfLinks; /* hard links */
1042 __u8 DeletePending;
1043 __u8 Directory;
1044 __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */
1045 __le64 IndexNumber;
1046 __le32 EASize;
1047 __le32 AccessFlags;
1048 __le64 CurrentByteOffset;
1049 __le32 Mode;
1050 __le32 AlignmentRequirement;
1051 __le32 FileNameLength;
1052 char FileName[1];
1053} __packed; /* level 18 Query */
1054
Pavel Shilovskyc839ff22012-09-18 16:20:32 -07001055struct smb2_file_eof_info { /* encoding of request for level 10 */
1056 __le64 EndOfFile; /* new end of file value */
1057} __packed; /* level 20 Set */
1058
Steve Frenchddfbefb2011-03-15 02:08:48 +00001059#endif /* _SMB2PDU_H */