]> git.ipfire.org Git - thirdparty/linux.git/blame - fs/cifs/smb2pdu.h
mm/CMA: fix boot regression due to physical address of high_memory
[thirdparty/linux.git] / fs / cifs / smb2pdu.h
CommitLineData
ddfbefbd
SF
1/*
2 * fs/cifs/smb2pdu.h
3 *
be7457d3 4 * Copyright (c) International Business Machines Corp., 2009, 2013
ddfbefbd
SF
5 * Etersoft, 2012
6 * Author(s): Steve French (sfrench@us.ibm.com)
7 * Pavel Shilovsky (pshilovsky@samba.org) 2012
8 *
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
2dc7e1c0
PS
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 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
093b2bda
PS
88#define SMB2_PROTO_NUMBER __constant_cpu_to_le32(0x424d53fe)
89
ddfbefbd
SF
90/*
91 * 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 */
74112860 98
b2ede58e 99#define SMB2_HEADER_STRUCTURE_SIZE __constant_cpu_to_le16(64)
74112860 100
ddfbefbd
SF
101struct 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
093b2bda
PS
120struct smb2_pdu {
121 struct smb2_hdr hdr;
122 __le16 StructureSize2; /* size of wct area (varies, request specific) */
123} __packed;
124
0cbaa53c
SF
125struct 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
093b2bda
PS
142/*
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 */
74112860 159
b2ede58e 160#define SMB2_ERROR_STRUCTURE_SIZE2 __constant_cpu_to_le16(9)
74112860 161
093b2bda
PS
162struct 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
b42bf888
PS
170struct 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
b8c32dbb
PS
184#define SMB2_CLIENT_GUID_SIZE 16
185
ec2e4523
PS
186struct 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;
b8c32dbb 193 __u8 ClientGUID[SMB2_CLIENT_GUID_SIZE];
ec2e4523 194 __le64 ClientStartTime; /* MBZ */
e4aa25e7 195 __le16 Dialects[1]; /* One dialect (vers=) at a time for now */
ec2e4523
PS
196} __packed;
197
e4aa25e7
SF
198/* Dialects */
199#define SMB20_PROT_ID 0x0202
200#define SMB21_PROT_ID 0x0210
201#define SMB30_PROT_ID 0x0300
20b6d8b4 202#define SMB302_PROT_ID 0x0302
e4aa25e7
SF
203#define BAD_PROT_ID 0xFFFF
204
ec2e4523
PS
205/* 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 */
e4aa25e7
SF
212#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 */
29e20f9c
PS
216/* Internal types */
217#define SMB2_NT_FIND 0x00100000
218#define SMB2_LARGE_FILES 0x00200000
ec2e4523
PS
219
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
5478f9ba
PS
239struct 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
0cbaa53c 255#define SMB2_SESSION_FLAG_ENCRYPT_DATA 0x0004
5478f9ba
PS
256struct 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
faaf946a
PS
277struct 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
c8664730
SF
317#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
faaf946a
PS
321
322/* Possible share capabilities */
2b5dc286
SF
323#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 */
faaf946a
PS
328
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
2503a0db
PS
341/* 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
73322979
SF
355#define FILE_ATTRIBUTE_INTEGRITY_STREAM 0x00008000
356#define FILE_ATTRIBUTE_NO_SCRUB_DATA 0x00020000
2503a0db
PS
357
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
b8c32dbb
PS
364/* Non-spec internal type */
365#define SMB2_OPLOCK_LEVEL_NOCHANGE 0x99
2503a0db
PS
366
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"
12197a7f 440#define SMB2_CREATE_ALLOCATION_SIZE "AISi"
2503a0db
PS
441#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"
12197a7f
SF
445#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
2503a0db
PS
449
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;
59aa3718 467 __u8 Buffer[0];
2503a0db
PS
468} __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
b8c32dbb
PS
491struct 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
53ef1016
PS
501#define SMB2_LEASE_READ_CACHING_HE 0x01
502#define SMB2_LEASE_HANDLE_CACHING_HE 0x02
503#define SMB2_LEASE_WRITE_CACHING_HE 0x04
504
b8c32dbb
PS
505#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
f047390a
PS
522struct 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
b8c32dbb
PS
534struct create_lease {
535 struct create_context ccontext;
536 __u8 Name[8];
537 struct lease_context lcontext;
538} __packed;
539
f047390a
PS
540struct 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
63eb3def
PS
547struct create_durable {
548 struct create_context ccontext;
549 __u8 Name[8];
9cbc0b73
PS
550 union {
551 __u8 Reserved[16];
552 struct {
553 __u64 PersistentFileId;
554 __u64 VolatileFileId;
555 } Fid;
556 } Data;
63eb3def
PS
557} __packed;
558
41c1358e
SF
559#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
be7457d3
SF
566/* this goes in the ioctl buffer when doing a copychunk request */
567struct copychunk_ioctl {
41c1358e 568 char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
be7457d3
SF
569 __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;
c8664730 574 __le32 Length; /* how many bytes to copy */
be7457d3
SF
575 __u32 Reserved2;
576} __packed;
577
31742c5a
SF
578/* 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
41c1358e
SF
584struct copychunk_ioctl_rsp {
585 __le32 ChunksWritten;
586 __le32 ChunkBytesWritten;
587 __le32 TotalBytesWritten;
588} __packed;
589
ff1c038a 590struct validate_negotiate_info_req {
4a72dafa
SF
591 __le32 Capabilities;
592 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
593 __le16 SecurityMode;
594 __le16 DialectCount;
ff1c038a
SF
595 __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 */
4a72dafa
SF
603} __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
64a5cfa6 619struct compress_ioctl {
c7f508a9 620 __le16 CompressionState; /* See cifspdu.h for possible flag values */
64a5cfa6
SF
621} __packed;
622
be7457d3
SF
623struct 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;
64a5cfa6 638 __u8 Buffer[0];
be7457d3
SF
639} __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
2503a0db
PS
657/* 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
7a5cfb19
PS
682struct 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
2b5dc286
SF
697/* 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
09a4707e
PS
705struct 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 */
2b5dc286 709 __u8 Flags; /* MBZ unless SMB3.02 or later */
09a4707e
PS
710 __le32 Length;
711 __le64 Offset;
712 __u64 PersistentFileId; /* opaque endianness */
713 __u64 VolatileFileId; /* opaque endianness */
714 __le32 MinimumCount;
2b5dc286 715 __le32 Channel; /* MBZ except for SMB3 or later */
09a4707e
PS
716 __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;
33319141
PS
726 __u8 Reserved;
727 __le32 DataLength;
728 __le32 DataRemaining;
729 __u32 Reserved2;
730 __u8 Buffer[1];
731} __packed;
732
2b5dc286
SF
733/* 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 */
33319141
PS
736
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;
09a4707e
PS
757 __u8 Reserved;
758 __le32 DataLength;
759 __le32 DataRemaining;
760 __u32 Reserved2;
761 __u8 Buffer[1];
762} __packed;
763
027e8eec
PS
764#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
f7ba7fe6
PS
769struct 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
9094fad1
PS
793struct 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
d324f08d
PS
805/* 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
be4cb9e3
PS
833/* 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
35143eb5
PS
863struct 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
983c88a4
PS
882struct 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
0822f514
PS
892#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
be4cb9e3
PS
917/*
918 * PDU infolevel structure definitions
919 * BB consider moving to a different header
920 */
921
6fc05c25
PS
922/* File System Information Classes */
923#define FS_VOLUME_INFORMATION 1 /* Query */
af6a12ea 924#define FS_LABEL_INFORMATION 2 /* Local only */
6fc05c25
PS
925#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 */
af6a12ea
SF
931#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 */
6fc05c25
PS
934
935struct smb2_fs_full_size_info {
936 __le64 TotalAllocationUnits;
937 __le64 CallerAvailableAllocationUnits;
938 __le64 ActualAvailableAllocationUnits;
939 __le32 SectorsPerAllocationUnit;
940 __le32 BytesPerSector;
941} __packed;
942
af6a12ea
SF
943#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
be4cb9e3
PS
959/* 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
f0df737e
PS
1007struct smb2_file_internal_info {
1008 __le64 IndexNumber;
1009} __packed; /* level 6 Query */
1010
35143eb5
PS
1011struct 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
568798cc
PS
1020struct 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
be4cb9e3
PS
1029/*
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
c839ff24
PS
1057struct smb2_file_eof_info { /* encoding of request for level 10 */
1058 __le64 EndOfFile; /* new end of file value */
1059} __packed; /* level 20 Set */
1060
ddfbefbd 1061#endif /* _SMB2PDU_H */