blob: 33cfd0a1adf12ca43bde5261184f1956d417b0bc [file] [log] [blame]
Steve French929be902021-06-18 00:31:49 -05001/* SPDX-License-Identifier: LGPL-2.1 */
Steve Frenchddfbefb2011-03-15 02:08:48 +00002/*
Steve Frenchddfbefb2011-03-15 02:08:48 +00003 *
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 *
Steve Frenchddfbefb2011-03-15 02:08:48 +00009 */
10
11#ifndef _SMB2PDU_H
12#define _SMB2PDU_H
13
14#include <net/sock.h>
Steve French90810c22021-07-03 15:49:35 -050015#include "cifsacl.h"
Steve Frenchddfbefb2011-03-15 02:08:48 +000016
Ronnie Sahlberg58d15ed2019-01-29 12:46:16 +100017/* 52 transform hdr + 64 hdr + 88 create rsp */
Ronnie Sahlbergc4627e62019-01-29 12:46:17 +100018#define SMB2_TRANSFORM_HEADER_SIZE 52
Ronnie Sahlberg58d15ed2019-01-29 12:46:16 +100019#define MAX_SMB2_HDR_SIZE 204
Pavel Shilovsky2dc7e1c2011-12-26 22:53:34 +040020
Long Lif7950cb2020-03-26 19:42:24 -070021/* The total header size for SMB2 read and write */
Ronnie Sahlberg0d35e382021-11-05 08:39:01 +090022#define SMB2_READWRITE_PDU_HEADER_SIZE (48 + sizeof(struct smb2_hdr))
Steve French8f233432020-03-15 18:04:13 -050023
Steve French3984bdc2020-10-04 17:42:27 -050024/* See MS-SMB2 2.2.43 */
25struct smb2_rdma_transform {
26 __le16 RdmaDescriptorOffset;
27 __le16 RdmaDescriptorLength;
28 __le32 Channel; /* for values see channel description in smb2 read above */
29 __le16 TransformCount;
30 __le16 Reserved1;
31 __le32 Reserved2;
32} __packed;
33
Steve Frenchbb9cad12021-04-09 15:20:24 -050034/* TransformType */
35#define SMB2_RDMA_TRANSFORM_TYPE_ENCRYPTION 0x0001
36#define SMB2_RDMA_TRANSFORM_TYPE_SIGNING 0x0002
37
38struct smb2_rdma_crypto_transform {
Steve French3984bdc2020-10-04 17:42:27 -050039 __le16 TransformType;
40 __le16 SignatureLength;
41 __le16 NonceLength;
42 __u16 Reserved;
43 __u8 Signature[]; /* variable length */
44 /* u8 Nonce[] */
45 /* followed by padding */
46} __packed;
47
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +040048/*
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +040049 * Definitions for SMB2 Protocol Data Units (network frames)
50 *
51 * See MS-SMB2.PDF specification for protocol details.
52 * The Naming convention is the lower case version of the SMB2
53 * command code name for the struct. Note that structures must be packed.
54 *
55 */
Pavel Shilovsky74112862012-07-27 01:20:41 +040056
Ronnie Sahlberg730928c2018-08-08 15:07:49 +100057#define COMPOUND_FID 0xFFFFFFFFFFFFFFFFULL
58
Fabian Frederickbc09d142014-12-10 15:41:15 -080059#define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9)
Pavel Shilovsky74112862012-07-27 01:20:41 +040060
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +040061struct smb2_err_rsp {
Ronnie Sahlberg0d35e382021-11-05 08:39:01 +090062 struct smb2_hdr hdr;
Pavel Shilovsky093b2bd2011-06-08 15:51:07 +040063 __le16 StructureSize;
64 __le16 Reserved; /* MBZ */
65 __le32 ByteCount; /* even if zero, at least one byte follows */
66 __u8 ErrorData[1]; /* variable length */
67} __packed;
68
Ronnie Sahlbergdf070af2019-07-09 18:41:11 +100069#define SYMLINK_ERROR_TAG 0x4c4d5953
70
Pavel Shilovskyb42bf882013-08-14 19:25:21 +040071struct smb2_symlink_err_rsp {
72 __le32 SymLinkLength;
73 __le32 SymLinkErrorTag;
74 __le32 ReparseTag;
75 __le16 ReparseDataLength;
76 __le16 UnparsedPathLength;
77 __le16 SubstituteNameOffset;
78 __le16 SubstituteNameLength;
79 __le16 PrintNameOffset;
80 __le16 PrintNameLength;
81 __le32 Flags;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -050082 __u8 PathBuffer[];
Pavel Shilovskyb42bf882013-08-14 19:25:21 +040083} __packed;
84
Steve French5f60a562018-02-05 14:46:18 -060085/* SMB 3.1.1 and later dialects. See MS-SMB2 section 2.2.2.1 */
86struct smb2_error_context_rsp {
87 __le32 ErrorDataLength;
88 __le32 ErrorId;
89 __u8 ErrorContextData; /* ErrorDataLength long array */
90} __packed;
91
Steve French8895c662020-03-17 01:53:39 -050092/* ErrorId values */
93#define SMB2_ERROR_ID_DEFAULT 0x00000000
94#define SMB2_ERROR_ID_SHARE_REDIRECT cpu_to_le32(0x72645253) /* "rdRS" */
95
Steve French5f60a562018-02-05 14:46:18 -060096/* Defines for Type field below (see MS-SMB2 2.2.2.2.2.1) */
97#define MOVE_DST_IPADDR_V4 cpu_to_le32(0x00000001)
98#define MOVE_DST_IPADDR_V6 cpu_to_le32(0x00000002)
99
100struct move_dst_ipaddr {
101 __le32 Type;
102 __u32 Reserved;
103 __u8 address[16]; /* IPv4 followed by 12 bytes rsvd or IPv6 address */
104} __packed;
105
106struct share_redirect_error_context_rsp {
107 __le32 StructureSize;
108 __le32 NotificationType;
109 __le32 ResourceNameOffset;
110 __le32 ResourceNameLength;
Steve French2438c0b2021-06-22 13:56:20 -0500111 __le16 Reserved;
Steve French5f60a562018-02-05 14:46:18 -0600112 __le16 TargetType;
113 __le32 IPAddrCount;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500114 struct move_dst_ipaddr IpAddrMoveList[];
Steve French5f60a562018-02-05 14:46:18 -0600115 /* __u8 ResourceName[] */ /* Name of share as counted Unicode string */
116} __packed;
117
Ronnie Sahlberg4d8dfaf2018-08-21 11:49:21 +1000118/*
119 * Maximum number of iovs we need for an open/create request.
120 * [0] : struct smb2_create_req
121 * [1] : path
122 * [2] : lease context
123 * [3] : durable context
124 * [4] : posix context
125 * [5] : time warp context
Steve Frenchff2a09e2019-07-06 14:41:38 -0500126 * [6] : query id context
127 * [7] : compound padding
Ronnie Sahlberg4d8dfaf2018-08-21 11:49:21 +1000128 */
Steve Frenchff2a09e2019-07-06 14:41:38 -0500129#define SMB2_CREATE_IOV_SIZE 8
Ronnie Sahlberg4d8dfaf2018-08-21 11:49:21 +1000130
Ronnie Sahlbergc4627e62019-01-29 12:46:17 +1000131/*
132 * Maximum size of a SMB2_CREATE response is 64 (smb2 header) +
Steve Frenchff2a09e2019-07-06 14:41:38 -0500133 * 88 (fixed part of create response) + 520 (path) + 208 (contexts) +
Ronnie Sahlbergc4627e62019-01-29 12:46:17 +1000134 * 2 bytes of padding.
135 */
Steve Frenchff2a09e2019-07-06 14:41:38 -0500136#define MAX_SMB2_CREATE_RESPONSE_SIZE 880
Ronnie Sahlbergc4627e62019-01-29 12:46:17 +1000137
Pavel Shilovsky53ef1012013-09-05 16:11:28 +0400138#define SMB2_LEASE_READ_CACHING_HE 0x01
139#define SMB2_LEASE_HANDLE_CACHING_HE 0x02
140#define SMB2_LEASE_WRITE_CACHING_HE 0x04
141
Fabian Frederickbc09d142014-12-10 15:41:15 -0800142#define SMB2_LEASE_NONE cpu_to_le32(0x00)
143#define SMB2_LEASE_READ_CACHING cpu_to_le32(0x01)
144#define SMB2_LEASE_HANDLE_CACHING cpu_to_le32(0x02)
145#define SMB2_LEASE_WRITE_CACHING cpu_to_le32(0x04)
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700146
Steve French8895c662020-03-17 01:53:39 -0500147#define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS cpu_to_le32(0x00000002)
Steve French5f60a562018-02-05 14:46:18 -0600148#define SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET cpu_to_le32(0x00000004)
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700149
150#define SMB2_LEASE_KEY_SIZE 16
151
152struct lease_context {
Stefano Brivio729c0c92018-07-05 15:10:02 +0200153 u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700154 __le32 LeaseState;
155 __le32 LeaseFlags;
156 __le64 LeaseDuration;
157} __packed;
158
Pavel Shilovskyf0473902013-09-04 13:44:05 +0400159struct lease_context_v2 {
Stefano Brivio729c0c92018-07-05 15:10:02 +0200160 u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
Pavel Shilovskyf0473902013-09-04 13:44:05 +0400161 __le32 LeaseState;
162 __le32 LeaseFlags;
163 __le64 LeaseDuration;
164 __le64 ParentLeaseKeyLow;
165 __le64 ParentLeaseKeyHigh;
166 __le16 Epoch;
167 __le16 Reserved;
168} __packed;
169
Pavel Shilovskyb8c32db2012-09-19 06:22:44 -0700170struct create_lease {
171 struct create_context ccontext;
172 __u8 Name[8];
173 struct lease_context lcontext;
174} __packed;
175
Pavel Shilovskyf0473902013-09-04 13:44:05 +0400176struct create_lease_v2 {
177 struct create_context ccontext;
178 __u8 Name[8];
179 struct lease_context_v2 lcontext;
180 __u8 Pad[4];
181} __packed;
182
Pavel Shilovsky63eb3de2013-07-04 18:41:09 +0400183struct create_durable {
184 struct create_context ccontext;
185 __u8 Name[8];
Pavel Shilovsky9cbc0b72013-07-09 18:40:58 +0400186 union {
187 __u8 Reserved[16];
188 struct {
189 __u64 PersistentFileId;
190 __u64 VolatileFileId;
191 } Fid;
192 } Data;
Pavel Shilovsky63eb3de2013-07-04 18:41:09 +0400193} __packed;
194
Steve Frenchfe048402018-05-30 17:10:25 -0500195struct create_posix {
196 struct create_context ccontext;
197 __u8 Name[16];
198 __le32 Mode;
199 __u32 Reserved;
200} __packed;
201
Steve Frenchb56eae42015-11-03 09:26:27 -0600202/* See MS-SMB2 2.2.13.2.11 */
203/* Flags */
204#define SMB2_DHANDLE_FLAG_PERSISTENT 0x00000002
205struct durable_context_v2 {
206 __le32 Timeout;
207 __le32 Flags;
208 __u64 Reserved;
209 __u8 CreateGuid[16];
210} __packed;
211
212struct create_durable_v2 {
213 struct create_context ccontext;
214 __u8 Name[8];
215 struct durable_context_v2 dcontext;
216} __packed;
217
218/* See MS-SMB2 2.2.13.2.12 */
219struct durable_reconnect_context_v2 {
220 struct {
221 __u64 PersistentFileId;
222 __u64 VolatileFileId;
223 } Fid;
224 __u8 CreateGuid[16];
225 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
226} __packed;
227
Steve Frenche7348e32019-06-28 02:35:10 -0500228/* See MS-SMB2 2.2.14.2.9 */
Steve French89a5bfa2019-07-18 17:22:18 -0500229struct create_on_disk_id {
230 struct create_context ccontext;
231 __u8 Name[8];
Steve Frenche7348e32019-06-28 02:35:10 -0500232 __le64 DiskFileId;
233 __le64 VolumeId;
Steve Frenchff2a09e2019-07-06 14:41:38 -0500234 __u32 Reserved[4];
Steve Frenche7348e32019-06-28 02:35:10 -0500235} __packed;
236
Steve Frenchb56eae42015-11-03 09:26:27 -0600237/* See MS-SMB2 2.2.14.2.12 */
238struct durable_reconnect_context_v2_rsp {
239 __le32 Timeout;
240 __le32 Flags; /* see above DHANDLE_FLAG_PERSISTENT */
241} __packed;
242
243struct create_durable_handle_reconnect_v2 {
244 struct create_context ccontext;
245 __u8 Name[8];
246 struct durable_reconnect_context_v2 dcontext;
Pavel Shilovskyd243af72019-11-06 13:58:15 -0800247 __u8 Pad[4];
Steve Frenchb56eae42015-11-03 09:26:27 -0600248} __packed;
249
Steve Frenchcdeaf9d2018-08-10 02:25:06 -0500250/* See MS-SMB2 2.2.13.2.5 */
251struct crt_twarp_ctxt {
252 struct create_context ccontext;
253 __u8 Name[8];
254 __le64 Timestamp;
255
256} __packed;
257
Steve Frenchff2a09e2019-07-06 14:41:38 -0500258/* See MS-SMB2 2.2.13.2.9 */
259struct crt_query_id_ctxt {
260 struct create_context ccontext;
261 __u8 Name[8];
262} __packed;
263
Steve Frenchfdef6652019-12-06 02:02:38 -0600264struct crt_sd_ctxt {
265 struct create_context ccontext;
266 __u8 Name[8];
267 struct smb3_sd sd;
Steve Frenchfdef6652019-12-06 02:02:38 -0600268} __packed;
269
270
Steve French41c13582013-11-14 00:05:36 -0600271#define COPY_CHUNK_RES_KEY_SIZE 24
272struct resume_key_req {
273 char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
274 __le32 ContextLength; /* MBZ */
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500275 char Context[]; /* ignored, Windows sets to 4 bytes of zero */
Steve French41c13582013-11-14 00:05:36 -0600276} __packed;
277
Steve Frenchbe7457d2013-06-19 17:41:10 -0500278/* this goes in the ioctl buffer when doing a copychunk request */
279struct copychunk_ioctl {
Steve French41c13582013-11-14 00:05:36 -0600280 char SourceKey[COPY_CHUNK_RES_KEY_SIZE];
Steve Frenchbe7457d2013-06-19 17:41:10 -0500281 __le32 ChunkCount; /* we are only sending 1 */
282 __le32 Reserved;
283 /* array will only be one chunk long for us */
284 __le64 SourceOffset;
285 __le64 TargetOffset;
Steve Frenchc8664732013-06-21 15:35:45 -0500286 __le32 Length; /* how many bytes to copy */
Steve Frenchbe7457d2013-06-19 17:41:10 -0500287 __u32 Reserved2;
288} __packed;
289
Steve French31742c52014-08-17 08:38:47 -0500290/* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */
291struct file_zero_data_information {
292 __le64 FileOffset;
293 __le64 BeyondFinalZero;
294} __packed;
295
Steve French41c13582013-11-14 00:05:36 -0600296struct copychunk_ioctl_rsp {
297 __le32 ChunksWritten;
298 __le32 ChunkBytesWritten;
299 __le32 TotalBytesWritten;
300} __packed;
301
Steve French7d03ae42020-10-23 15:21:38 -0500302/* See MS-FSCC 2.3.29 and 2.3.30 */
303struct get_retrieval_pointer_count_req {
304 __le64 StartingVcn; /* virtual cluster number (signed) */
305} __packed;
306
307struct get_retrieval_pointer_count_rsp {
308 __le32 ExtentCount;
309} __packed;
310
311/*
312 * See MS-FSCC 2.3.33 and 2.3.34
313 * request is the same as get_retrieval_point_count_req struct above
314 */
315struct smb3_extents {
316 __le64 NextVcn;
317 __le64 Lcn; /* logical cluster number */
318} __packed;
319
320struct get_retrieval_pointers_refcount_rsp {
321 __le32 ExtentCount;
322 __u32 Reserved;
323 __le64 StartingVcn;
324 struct smb3_extents extents[];
325} __packed;
326
Steve French9d1b0662015-06-24 02:12:19 -0500327struct fsctl_set_integrity_information_req {
328 __le16 ChecksumAlgorithm;
329 __le16 Reserved;
330 __le32 Flags;
331} __packed;
332
333struct fsctl_get_integrity_information_rsp {
334 __le16 ChecksumAlgorithm;
335 __le16 Reserved;
336 __le32 Flags;
337 __le32 ChecksumChunkSizeInBytes;
338 __le32 ClusterSizeInBytes;
339} __packed;
340
Ronnie Sahlberg2f3ebab2019-04-25 16:45:29 +1000341struct file_allocated_range_buffer {
342 __le64 file_offset;
343 __le64 length;
344} __packed;
345
Steve French9d1b0662015-06-24 02:12:19 -0500346/* Integrity ChecksumAlgorithm choices for above */
347#define CHECKSUM_TYPE_NONE 0x0000
348#define CHECKSUM_TYPE_CRC64 0x0002
Steve Frenchb3152e22015-06-24 03:17:02 -0500349#define CHECKSUM_TYPE_UNCHANGED 0xFFFF /* set only */
Steve French9d1b0662015-06-24 02:12:19 -0500350
351/* Integrity flags for above */
352#define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001
353
Steve French0df444a2018-10-31 11:24:33 -0500354/* Reparse structures - see MS-FSCC 2.1.2 */
355
356/* struct fsctl_reparse_info_req is empty, only response structs (see below) */
357
358struct reparse_data_buffer {
359 __le32 ReparseTag;
360 __le16 ReparseDataLength;
361 __u16 Reserved;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500362 __u8 DataBuffer[]; /* Variable Length */
Steve French0df444a2018-10-31 11:24:33 -0500363} __packed;
364
365struct reparse_guid_data_buffer {
366 __le32 ReparseTag;
367 __le16 ReparseDataLength;
368 __u16 Reserved;
369 __u8 ReparseGuid[16];
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500370 __u8 DataBuffer[]; /* Variable Length */
Steve French0df444a2018-10-31 11:24:33 -0500371} __packed;
372
373struct reparse_mount_point_data_buffer {
374 __le32 ReparseTag;
375 __le16 ReparseDataLength;
376 __u16 Reserved;
377 __le16 SubstituteNameOffset;
378 __le16 SubstituteNameLength;
379 __le16 PrintNameOffset;
380 __le16 PrintNameLength;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500381 __u8 PathBuffer[]; /* Variable Length */
Steve French0df444a2018-10-31 11:24:33 -0500382} __packed;
383
Ronnie Sahlberg5de254d2019-06-27 14:57:02 +1000384#define SYMLINK_FLAG_RELATIVE 0x00000001
385
386struct reparse_symlink_data_buffer {
387 __le32 ReparseTag;
388 __le16 ReparseDataLength;
389 __u16 Reserved;
390 __le16 SubstituteNameOffset;
391 __le16 SubstituteNameLength;
392 __le16 PrintNameOffset;
393 __le16 PrintNameLength;
394 __le32 Flags;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500395 __u8 PathBuffer[]; /* Variable Length */
Ronnie Sahlberg5de254d2019-06-27 14:57:02 +1000396} __packed;
Steve French0df444a2018-10-31 11:24:33 -0500397
398/* See MS-FSCC 2.1.2.6 and cifspdu.h for struct reparse_posix_data */
399
400
Aurelien Aptel9d496402017-02-13 16:16:49 +0100401/* See MS-DFSC 2.2.2 */
402struct fsctl_get_dfs_referral_req {
403 __le16 MaxReferralLevel;
404 __u8 RequestFileName[];
405} __packed;
406
407/* DFS response is struct get_dfs_refer_rsp */
408
Steve Frenchb56eae42015-11-03 09:26:27 -0600409/* See MS-SMB2 2.2.31.3 */
410struct network_resiliency_req {
411 __le32 Timeout;
412 __le32 Reserved;
413} __packed;
414/* There is no buffer for the response ie no struct network_resiliency_rsp */
415
Steve French9d1b0662015-06-24 02:12:19 -0500416
Steve Frenchff1c0382013-11-19 23:44:46 -0600417struct validate_negotiate_info_req {
Steve French4a72daf2013-06-25 00:20:49 -0500418 __le32 Capabilities;
419 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
420 __le16 SecurityMode;
421 __le16 DialectCount;
Steve Frenchd5c70762019-01-03 02:37:21 -0600422 __le16 Dialects[4]; /* BB expand this if autonegotiate > 4 dialects */
Steve Frenchff1c0382013-11-19 23:44:46 -0600423} __packed;
424
425struct validate_negotiate_info_rsp {
426 __le32 Capabilities;
427 __u8 Guid[SMB2_CLIENT_GUID_SIZE];
428 __le16 SecurityMode;
429 __le16 Dialect; /* Dialect in use for the connection */
Steve French4a72daf2013-06-25 00:20:49 -0500430} __packed;
431
Aurelien Aptelbead0422018-06-14 15:43:17 +0200432#define RSS_CAPABLE cpu_to_le32(0x00000001)
433#define RDMA_CAPABLE cpu_to_le32(0x00000002)
434
435#define INTERNETWORK cpu_to_le16(0x0002)
436#define INTERNETWORKV6 cpu_to_le16(0x0017)
Steve French4a72daf2013-06-25 00:20:49 -0500437
438struct network_interface_info_ioctl_rsp {
439 __le32 Next; /* next interface. zero if this is last one */
440 __le32 IfIndex;
441 __le32 Capability; /* RSS or RDMA Capable */
442 __le32 Reserved;
443 __le64 LinkSpeed;
Aurelien Aptelbead0422018-06-14 15:43:17 +0200444 __le16 Family;
445 __u8 Buffer[126];
446} __packed;
447
448struct iface_info_ipv4 {
449 __be16 Port;
450 __be32 IPv4Address;
451 __be64 Reserved;
452} __packed;
453
454struct iface_info_ipv6 {
455 __be16 Port;
456 __be32 FlowInfo;
457 __u8 IPv6Address[16];
458 __be32 ScopeId;
Steve French4a72daf2013-06-25 00:20:49 -0500459} __packed;
460
461#define NO_FILE_ID 0xFFFFFFFFFFFFFFFFULL /* general ioctls to srv not to file */
462
Steve French64a5cfa2013-10-14 15:31:32 -0500463struct compress_ioctl {
Steve Frenchc7f508a2013-10-14 15:27:32 -0500464 __le16 CompressionState; /* See cifspdu.h for possible flag values */
Steve French64a5cfa2013-10-14 15:31:32 -0500465} __packed;
466
Steve French02b16662015-06-27 21:18:36 -0700467struct duplicate_extents_to_file {
468 __u64 PersistentFileHandle; /* source file handle, opaque endianness */
469 __u64 VolatileFileHandle;
470 __le64 SourceFileOffset;
471 __le64 TargetFileOffset;
472 __le64 ByteCount; /* Bytes to be copied */
473} __packed;
474
Ronnie Sahlberg72c419d2019-03-13 14:37:49 +1000475/*
476 * Maximum number of iovs we need for an ioctl request.
477 * [0] : struct smb2_ioctl_req
478 * [1] : in_data
479 */
480#define SMB2_IOCTL_IOV_SIZE 2
481
Steve Frenchbe7457d2013-06-19 17:41:10 -0500482struct smb2_ioctl_req {
Ronnie Sahlberg0d35e382021-11-05 08:39:01 +0900483 struct smb2_hdr hdr;
Steve Frenchbe7457d2013-06-19 17:41:10 -0500484 __le16 StructureSize; /* Must be 57 */
485 __u16 Reserved;
486 __le32 CtlCode;
487 __u64 PersistentFileId; /* opaque endianness */
488 __u64 VolatileFileId; /* opaque endianness */
489 __le32 InputOffset;
490 __le32 InputCount;
491 __le32 MaxInputResponse;
492 __le32 OutputOffset;
493 __le32 OutputCount;
494 __le32 MaxOutputResponse;
495 __le32 Flags;
496 __u32 Reserved2;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500497 __u8 Buffer[];
Steve Frenchbe7457d2013-06-19 17:41:10 -0500498} __packed;
499
500struct smb2_ioctl_rsp {
Ronnie Sahlberg0d35e382021-11-05 08:39:01 +0900501 struct smb2_hdr hdr;
Steve Frenchbe7457d2013-06-19 17:41:10 -0500502 __le16 StructureSize; /* Must be 57 */
503 __u16 Reserved;
504 __le32 CtlCode;
505 __u64 PersistentFileId; /* opaque endianness */
506 __u64 VolatileFileId; /* opaque endianness */
507 __le32 InputOffset;
508 __le32 InputCount;
509 __le32 OutputOffset;
510 __le32 OutputCount;
511 __le32 Flags;
512 __u32 Reserved2;
513 /* char * buffer[] */
514} __packed;
515
Pavel Shilovsky027e8ee2012-09-19 06:22:43 -0700516#define SMB2_LOCKFLAG_SHARED_LOCK 0x0001
517#define SMB2_LOCKFLAG_EXCLUSIVE_LOCK 0x0002
518#define SMB2_LOCKFLAG_UNLOCK 0x0004
519#define SMB2_LOCKFLAG_FAIL_IMMEDIATELY 0x0010
520
Pavel Shilovskyf7ba7fe2012-09-19 06:22:43 -0700521struct smb2_lock_element {
522 __le64 Offset;
523 __le64 Length;
524 __le32 Flags;
525 __le32 Reserved;
526} __packed;
527
528struct smb2_lock_req {
Ronnie Sahlberg0d35e382021-11-05 08:39:01 +0900529 struct smb2_hdr hdr;
Pavel Shilovskyf7ba7fe2012-09-19 06:22:43 -0700530 __le16 StructureSize; /* Must be 48 */
531 __le16 LockCount;
Steve Frenchbb9cad12021-04-09 15:20:24 -0500532 /*
533 * The least significant four bits are the index, the other 28 bits are
534 * the lock sequence number (0 to 64). See MS-SMB2 2.2.26
535 */
536 __le32 LockSequenceNumber;
Pavel Shilovskyf7ba7fe2012-09-19 06:22:43 -0700537 __u64 PersistentFileId; /* opaque endianness */
538 __u64 VolatileFileId; /* opaque endianness */
539 /* Followed by at least one */
540 struct smb2_lock_element locks[1];
541} __packed;
542
543struct smb2_lock_rsp {
Ronnie Sahlberg0d35e382021-11-05 08:39:01 +0900544 struct smb2_hdr hdr;
Pavel Shilovskyf7ba7fe2012-09-19 06:22:43 -0700545 __le16 StructureSize; /* Must be 4 */
546 __le16 Reserved;
547} __packed;
548
Pavel Shilovsky9094fad2012-07-12 18:30:44 +0400549struct smb2_echo_req {
Ronnie Sahlberg0d35e382021-11-05 08:39:01 +0900550 struct smb2_hdr hdr;
Pavel Shilovsky9094fad2012-07-12 18:30:44 +0400551 __le16 StructureSize; /* Must be 4 */
552 __u16 Reserved;
553} __packed;
554
555struct smb2_echo_rsp {
Ronnie Sahlberg0d35e382021-11-05 08:39:01 +0900556 struct smb2_hdr hdr;
Pavel Shilovsky9094fad2012-07-12 18:30:44 +0400557 __le16 StructureSize; /* Must be 4 */
558 __u16 Reserved;
559} __packed;
560
Pavel Shilovskyd324f08d2012-09-18 16:20:33 -0700561/* search (query_directory) Flags field */
562#define SMB2_RESTART_SCANS 0x01
563#define SMB2_RETURN_SINGLE_ENTRY 0x02
564#define SMB2_INDEX_SPECIFIED 0x04
565#define SMB2_REOPEN 0x10
566
Ronnie Sahlberg0a177992020-01-08 13:08:04 +1000567#define SMB2_QUERY_DIRECTORY_IOV_SIZE 2
568
Steve French2438c0b2021-06-22 13:56:20 -0500569/*
570 * Valid FileInformation classes.
571 *
572 * Note that these are a subset of the (file) QUERY_INFO levels defined
573 * later in this file (but since QUERY_DIRECTORY uses equivalent numbers
574 * we do not redefine them here)
575 *
576 * FileDirectoryInfomation 0x01
577 * FileFullDirectoryInformation 0x02
578 * FileIdFullDirectoryInformation 0x26
579 * FileBothDirectoryInformation 0x03
580 * FileIdBothDirectoryInformation 0x25
581 * FileNamesInformation 0x0C
582 * FileIdExtdDirectoryInformation 0x3C
583 */
584
Pavel Shilovskyd324f08d2012-09-18 16:20:33 -0700585struct smb2_query_directory_req {
Ronnie Sahlberg0d35e382021-11-05 08:39:01 +0900586 struct smb2_hdr hdr;
Pavel Shilovskyd324f08d2012-09-18 16:20:33 -0700587 __le16 StructureSize; /* Must be 33 */
588 __u8 FileInformationClass;
589 __u8 Flags;
590 __le32 FileIndex;
591 __u64 PersistentFileId; /* opaque endianness */
592 __u64 VolatileFileId; /* opaque endianness */
593 __le16 FileNameOffset;
594 __le16 FileNameLength;
595 __le32 OutputBufferLength;
596 __u8 Buffer[1];
597} __packed;
598
599struct smb2_query_directory_rsp {
Ronnie Sahlberg0d35e382021-11-05 08:39:01 +0900600 struct smb2_hdr hdr;
Pavel Shilovskyd324f08d2012-09-18 16:20:33 -0700601 __le16 StructureSize; /* Must be 9 */
602 __le16 OutputBufferOffset;
603 __le32 OutputBufferLength;
604 __u8 Buffer[1];
605} __packed;
606
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400607/* Possible InfoType values */
608#define SMB2_O_INFO_FILE 0x01
609#define SMB2_O_INFO_FILESYSTEM 0x02
610#define SMB2_O_INFO_SECURITY 0x03
611#define SMB2_O_INFO_QUOTA 0x04
612
Steve French911a8df2014-10-19 19:18:05 -0500613/* Security info type additionalinfo flags. See MS-SMB2 (2.2.37) or MS-DTYP */
614#define OWNER_SECINFO 0x00000001
615#define GROUP_SECINFO 0x00000002
616#define DACL_SECINFO 0x00000004
617#define SACL_SECINFO 0x00000008
618#define LABEL_SECINFO 0x00000010
619#define ATTRIBUTE_SECINFO 0x00000020
620#define SCOPE_SECINFO 0x00000040
621#define BACKUP_SECINFO 0x00010000
622#define UNPROTECTED_SACL_SECINFO 0x10000000
623#define UNPROTECTED_DACL_SECINFO 0x20000000
624#define PROTECTED_SACL_SECINFO 0x40000000
625#define PROTECTED_DACL_SECINFO 0x80000000
626
627/* Flags used for FileFullEAinfo */
628#define SL_RESTART_SCAN 0x00000001
629#define SL_RETURN_SINGLE_ENTRY 0x00000002
630#define SL_INDEX_SPECIFIED 0x00000004
631
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400632struct smb2_query_info_req {
Ronnie Sahlberg0d35e382021-11-05 08:39:01 +0900633 struct smb2_hdr hdr;
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400634 __le16 StructureSize; /* Must be 41 */
635 __u8 InfoType;
636 __u8 FileInfoClass;
637 __le32 OutputBufferLength;
638 __le16 InputBufferOffset;
639 __u16 Reserved;
640 __le32 InputBufferLength;
641 __le32 AdditionalInformation;
642 __le32 Flags;
643 __u64 PersistentFileId; /* opaque endianness */
644 __u64 VolatileFileId; /* opaque endianness */
645 __u8 Buffer[1];
646} __packed;
647
648struct smb2_query_info_rsp {
Ronnie Sahlberg0d35e382021-11-05 08:39:01 +0900649 struct smb2_hdr hdr;
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400650 __le16 StructureSize; /* Must be 9 */
651 __le16 OutputBufferOffset;
652 __le32 OutputBufferLength;
653 __u8 Buffer[1];
654} __packed;
655
Ronnie Sahlberg14e562a2018-09-03 13:33:50 +1000656/*
657 * Maximum number of iovs we need for a set-info request.
658 * The largest one is rename/hardlink
659 * [0] : struct smb2_set_info_req + smb2_file_[rename|link]_info
660 * [1] : path
661 * [2] : compound padding
662 */
663#define SMB2_SET_INFO_IOV_SIZE 3
664
Pavel Shilovsky35143eb2012-09-18 16:20:31 -0700665struct smb2_set_info_req {
Ronnie Sahlberg0d35e382021-11-05 08:39:01 +0900666 struct smb2_hdr hdr;
Pavel Shilovsky35143eb2012-09-18 16:20:31 -0700667 __le16 StructureSize; /* Must be 33 */
668 __u8 InfoType;
669 __u8 FileInfoClass;
670 __le32 BufferLength;
671 __le16 BufferOffset;
672 __u16 Reserved;
673 __le32 AdditionalInformation;
674 __u64 PersistentFileId; /* opaque endianness */
675 __u64 VolatileFileId; /* opaque endianness */
676 __u8 Buffer[1];
677} __packed;
678
679struct smb2_set_info_rsp {
Ronnie Sahlberg0d35e382021-11-05 08:39:01 +0900680 struct smb2_hdr hdr;
Pavel Shilovsky35143eb2012-09-18 16:20:31 -0700681 __le16 StructureSize; /* Must be 2 */
682} __packed;
683
Ronnie Sahlberg0d5a2882018-06-01 10:53:03 +1000684struct smb2_oplock_break {
Ronnie Sahlberg0d35e382021-11-05 08:39:01 +0900685 struct smb2_hdr hdr;
Ronnie Sahlberg21ad9482017-11-20 11:24:43 +1100686 __le16 StructureSize; /* Must be 24 */
687 __u8 OplockLevel;
688 __u8 Reserved;
689 __le32 Reserved2;
690 __u64 PersistentFid;
691 __u64 VolatileFid;
692} __packed;
693
Pavel Shilovsky0822f512012-09-19 06:22:45 -0700694#define SMB2_NOTIFY_BREAK_LEASE_FLAG_ACK_REQUIRED cpu_to_le32(0x01)
695
696struct smb2_lease_break {
Ronnie Sahlberg0d35e382021-11-05 08:39:01 +0900697 struct smb2_hdr hdr;
Pavel Shilovsky0822f512012-09-19 06:22:45 -0700698 __le16 StructureSize; /* Must be 44 */
Pavel Shilovsky9bd45402019-10-29 16:51:19 -0700699 __le16 Epoch;
Pavel Shilovsky0822f512012-09-19 06:22:45 -0700700 __le32 Flags;
701 __u8 LeaseKey[16];
702 __le32 CurrentLeaseState;
703 __le32 NewLeaseState;
704 __le32 BreakReason;
705 __le32 AccessMaskHint;
706 __le32 ShareMaskHint;
707} __packed;
708
709struct smb2_lease_ack {
Ronnie Sahlberg0d35e382021-11-05 08:39:01 +0900710 struct smb2_hdr hdr;
Pavel Shilovsky0822f512012-09-19 06:22:45 -0700711 __le16 StructureSize; /* Must be 36 */
712 __le16 Reserved;
713 __le32 Flags;
714 __u8 LeaseKey[16];
715 __le32 LeaseState;
716 __le64 LeaseDuration;
717} __packed;
718
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400719/*
720 * PDU infolevel structure definitions
721 * BB consider moving to a different header
722 */
723
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -0700724/* File System Information Classes */
725#define FS_VOLUME_INFORMATION 1 /* Query */
Steven Frenchaf6a12e2013-10-09 20:55:53 -0500726#define FS_LABEL_INFORMATION 2 /* Local only */
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -0700727#define FS_SIZE_INFORMATION 3 /* Query */
728#define FS_DEVICE_INFORMATION 4 /* Query */
729#define FS_ATTRIBUTE_INFORMATION 5 /* Query */
730#define FS_CONTROL_INFORMATION 6 /* Query, Set */
731#define FS_FULL_SIZE_INFORMATION 7 /* Query */
732#define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
Steven Frenchaf6a12e2013-10-09 20:55:53 -0500733#define FS_DRIVER_PATH_INFORMATION 9 /* Local only */
734#define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */
735#define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
Steve French2d304212018-06-24 23:28:12 -0500736#define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */
Pavel Shilovsky6fc05c22012-09-18 16:20:34 -0700737
738struct smb2_fs_full_size_info {
739 __le64 TotalAllocationUnits;
740 __le64 CallerAvailableAllocationUnits;
741 __le64 ActualAvailableAllocationUnits;
742 __le32 SectorsPerAllocationUnit;
743 __le32 BytesPerSector;
744} __packed;
745
Steven Frenchaf6a12e2013-10-09 20:55:53 -0500746#define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
747#define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
748#define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
749#define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
750
751/* sector size info struct */
752struct smb3_fs_ss_info {
753 __le32 LogicalBytesPerSector;
754 __le32 PhysicalBytesPerSectorForAtomicity;
755 __le32 PhysicalBytesPerSectorForPerf;
756 __le32 FileSystemEffectivePhysicalBytesPerSectorForAtomicity;
757 __le32 Flags;
758 __le32 ByteOffsetForSectorAlignment;
759 __le32 ByteOffsetForPartitionAlignment;
760} __packed;
761
Steve French21ba3842018-06-24 23:18:52 -0500762/* volume info struct - see MS-FSCC 2.5.9 */
763#define MAX_VOL_LABEL_LEN 32
764struct smb3_fs_vol_info {
765 __le64 VolumeCreationTime;
766 __u32 VolumeSerialNumber;
767 __le32 VolumeLabelLength; /* includes trailing null */
768 __u8 SupportsObjects; /* True if eg like NTFS, supports objects */
769 __u8 Reserved;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500770 __u8 VolumeLabel[]; /* variable len */
Steve French21ba3842018-06-24 23:18:52 -0500771} __packed;
772
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400773/* partial list of QUERY INFO levels */
774#define FILE_DIRECTORY_INFORMATION 1
775#define FILE_FULL_DIRECTORY_INFORMATION 2
776#define FILE_BOTH_DIRECTORY_INFORMATION 3
777#define FILE_BASIC_INFORMATION 4
778#define FILE_STANDARD_INFORMATION 5
779#define FILE_INTERNAL_INFORMATION 6
780#define FILE_EA_INFORMATION 7
781#define FILE_ACCESS_INFORMATION 8
782#define FILE_NAME_INFORMATION 9
783#define FILE_RENAME_INFORMATION 10
784#define FILE_LINK_INFORMATION 11
785#define FILE_NAMES_INFORMATION 12
786#define FILE_DISPOSITION_INFORMATION 13
787#define FILE_POSITION_INFORMATION 14
788#define FILE_FULL_EA_INFORMATION 15
789#define FILE_MODE_INFORMATION 16
790#define FILE_ALIGNMENT_INFORMATION 17
791#define FILE_ALL_INFORMATION 18
792#define FILE_ALLOCATION_INFORMATION 19
793#define FILE_END_OF_FILE_INFORMATION 20
794#define FILE_ALTERNATE_NAME_INFORMATION 21
795#define FILE_STREAM_INFORMATION 22
796#define FILE_PIPE_INFORMATION 23
797#define FILE_PIPE_LOCAL_INFORMATION 24
798#define FILE_PIPE_REMOTE_INFORMATION 25
799#define FILE_MAILSLOT_QUERY_INFORMATION 26
800#define FILE_MAILSLOT_SET_INFORMATION 27
801#define FILE_COMPRESSION_INFORMATION 28
802#define FILE_OBJECT_ID_INFORMATION 29
803/* Number 30 not defined in documents */
804#define FILE_MOVE_CLUSTER_INFORMATION 31
805#define FILE_QUOTA_INFORMATION 32
806#define FILE_REPARSE_POINT_INFORMATION 33
807#define FILE_NETWORK_OPEN_INFORMATION 34
808#define FILE_ATTRIBUTE_TAG_INFORMATION 35
809#define FILE_TRACKING_INFORMATION 36
810#define FILEID_BOTH_DIRECTORY_INFORMATION 37
811#define FILEID_FULL_DIRECTORY_INFORMATION 38
812#define FILE_VALID_DATA_LENGTH_INFORMATION 39
813#define FILE_SHORT_NAME_INFORMATION 40
814#define FILE_SFIO_RESERVE_INFORMATION 44
815#define FILE_SFIO_VOLUME_INFORMATION 45
816#define FILE_HARD_LINK_INFORMATION 46
817#define FILE_NORMALIZED_NAME_INFORMATION 48
818#define FILEID_GLOBAL_TX_DIRECTORY_INFORMATION 50
819#define FILE_STANDARD_LINK_INFORMATION 54
Steve French51d92d62020-02-06 12:32:03 -0600820#define FILE_ID_INFORMATION 59
Steve French2438c0b2021-06-22 13:56:20 -0500821#define FILE_ID_EXTD_DIRECTORY_INFORMATION 60
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400822
Pavel Shilovskyf0df7372012-09-18 16:20:26 -0700823struct smb2_file_internal_info {
824 __le64 IndexNumber;
825} __packed; /* level 6 Query */
826
Pavel Shilovsky35143eb2012-09-18 16:20:31 -0700827struct smb2_file_rename_info { /* encoding of request for level 10 */
828 __u8 ReplaceIfExists; /* 1 = replace existing target with new */
829 /* 0 = fail if target already exists */
830 __u8 Reserved[7];
831 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
832 __le32 FileNameLength;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500833 char FileName[]; /* New name to be assigned */
Steve French7d03ae42020-10-23 15:21:38 -0500834 /* padding - overall struct size must be >= 24 so filename + pad >= 6 */
Pavel Shilovsky35143eb2012-09-18 16:20:31 -0700835} __packed; /* level 10 Set */
836
Pavel Shilovsky568798c2012-09-18 16:20:31 -0700837struct smb2_file_link_info { /* encoding of request for level 11 */
838 __u8 ReplaceIfExists; /* 1 = replace existing link with new */
839 /* 0 = fail if link already exists */
840 __u8 Reserved[7];
841 __u64 RootDirectory; /* MBZ for network operations (why says spec?) */
842 __le32 FileNameLength;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500843 char FileName[]; /* Name to be assigned to new link */
Pavel Shilovsky568798c2012-09-18 16:20:31 -0700844} __packed; /* level 11 Set */
845
Ronnie Sahlberg95907fe2017-08-24 11:24:55 +1000846struct smb2_file_full_ea_info { /* encoding of response for level 15 */
847 __le32 next_entry_offset;
848 __u8 flags;
849 __u8 ea_name_length;
850 __le16 ea_value_length;
Gustavo A. R. Silvacff2def2020-03-09 10:44:51 -0500851 char ea_data[]; /* \0 terminated name plus value */
Ronnie Sahlberg95907fe2017-08-24 11:24:55 +1000852} __packed; /* level 15 Set */
853
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400854/*
855 * This level 18, although with struct with same name is different from cifs
856 * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
857 * CurrentByteOffset.
858 */
859struct smb2_file_all_info { /* data block encoding of response to level 18 */
860 __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */
861 __le64 LastAccessTime;
862 __le64 LastWriteTime;
863 __le64 ChangeTime;
864 __le32 Attributes;
865 __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */
866 __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */
867 __le64 EndOfFile; /* size ie offset to first free byte in file */
868 __le32 NumberOfLinks; /* hard links */
869 __u8 DeletePending;
870 __u8 Directory;
871 __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */
872 __le64 IndexNumber;
873 __le32 EASize;
874 __le32 AccessFlags;
875 __le64 CurrentByteOffset;
876 __le32 Mode;
877 __le32 AlignmentRequirement;
878 __le32 FileNameLength;
879 char FileName[1];
880} __packed; /* level 18 Query */
881
Pavel Shilovskyc839ff22012-09-18 16:20:32 -0700882struct smb2_file_eof_info { /* encoding of request for level 10 */
883 __le64 EndOfFile; /* new end of file value */
884} __packed; /* level 20 Set */
885
Steve French2e4564b2020-10-22 22:03:14 -0500886struct smb2_file_reparse_point_info {
887 __le64 IndexNumber;
888 __le32 Tag;
889} __packed;
890
Steve French43f8a6a2019-12-02 21:46:54 -0600891struct smb2_file_network_open_info {
892 __le64 CreationTime;
893 __le64 LastAccessTime;
894 __le64 LastWriteTime;
895 __le64 ChangeTime;
896 __le64 AllocationSize;
897 __le64 EndOfFile;
898 __le32 Attributes;
899 __le32 Reserved;
900} __packed; /* level 34 Query also similar returned in close rsp and open rsp */
901
Steve French2438c0b2021-06-22 13:56:20 -0500902/* See MS-FSCC 2.4.21 */
Steve French51d92d62020-02-06 12:32:03 -0600903struct smb2_file_id_information {
904 __le64 VolumeSerialNumber;
905 __u64 PersistentFileId; /* opaque endianness */
906 __u64 VolatileFileId; /* opaque endianness */
907} __packed; /* level 59 */
908
Steve French2438c0b2021-06-22 13:56:20 -0500909/* See MS-FSCC 2.4.18 */
910struct smb2_file_id_extd_directory_info {
911 __le32 NextEntryOffset;
912 __u32 FileIndex;
913 __le64 CreationTime;
914 __le64 LastAccessTime;
915 __le64 LastWriteTime;
916 __le64 ChangeTime;
917 __le64 EndOfFile;
918 __le64 AllocationSize;
919 __le32 FileAttributes;
920 __le32 FileNameLength;
921 __le32 EaSize; /* EA size */
922 __le32 ReparsePointTag; /* valid if FILE_ATTR_REPARSE_POINT set in FileAttributes */
923 __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit */
924 char FileName[1];
925} __packed; /* level 60 */
926
Ronnie Sahlberg730928c2018-08-08 15:07:49 +1000927extern char smb2_padding[7];
928
Steve Frenchab3459d2020-02-06 17:31:56 -0600929/* equivalent of the contents of SMB3.1.1 POSIX open context response */
Aurelien Aptel2e8af972020-02-08 15:50:56 +0100930struct create_posix_rsp {
Aurelien Aptel69dda302020-03-02 17:53:22 +0100931 u32 nlink;
932 u32 reparse_tag;
933 u32 mode;
934 struct cifs_sid owner; /* var-sized on the wire */
935 struct cifs_sid group; /* var-sized on the wire */
Aurelien Aptel2e8af972020-02-08 15:50:56 +0100936} __packed;
Aurelien Aptel349e13a2020-02-08 15:50:57 +0100937
938/*
Steve French6a5f6592020-06-11 19:25:47 -0500939 * SMB2-only POSIX info level for query dir
Aurelien Aptel349e13a2020-02-08 15:50:57 +0100940 *
941 * See posix_info_sid_size(), posix_info_extra_size() and
942 * posix_info_parse() to help with the handling of this struct.
943 */
944struct smb2_posix_info {
945 __le32 NextEntryOffset;
946 __u32 Ignored;
947 __le64 CreationTime;
948 __le64 LastAccessTime;
949 __le64 LastWriteTime;
950 __le64 ChangeTime;
951 __le64 EndOfFile;
952 __le64 AllocationSize;
953 __le32 DosAttributes;
954 __le64 Inode;
955 __le32 DeviceId;
956 __le32 Zero;
957 /* beginning of POSIX Create Context Response */
958 __le32 HardLinks;
959 __le32 ReparseTag;
960 __le32 Mode;
961 /*
962 * var sized owner SID
963 * var sized group SID
964 * le32 filenamelength
965 * u8 filename[]
966 */
967} __packed;
968
Steve French6a5f6592020-06-11 19:25:47 -0500969/* Level 100 query info */
970struct smb311_posix_qinfo {
971 __le64 CreationTime;
972 __le64 LastAccessTime;
973 __le64 LastWriteTime;
974 __le64 ChangeTime;
975 __le64 EndOfFile;
976 __le64 AllocationSize;
977 __le32 DosAttributes;
978 __le64 Inode;
979 __le32 DeviceId;
980 __le32 Zero;
981 /* beginning of POSIX Create Context Response */
982 __le32 HardLinks;
983 __le32 ReparseTag;
984 __le32 Mode;
985 u8 Sids[];
986 /*
987 * var sized owner SID
988 * var sized group SID
989 * le32 filenamelength
990 * u8 filename[]
991 */
992} __packed;
993
Aurelien Aptel349e13a2020-02-08 15:50:57 +0100994/*
995 * Parsed version of the above struct. Allows direct access to the
996 * variable length fields
997 */
998struct smb2_posix_info_parsed {
999 const struct smb2_posix_info *base;
1000 size_t size;
1001 struct cifs_sid owner;
1002 struct cifs_sid group;
1003 int name_len;
1004 const u8 *name;
Steve Frenchab3459d2020-02-06 17:31:56 -06001005};
Aurelien Aptel349e13a2020-02-08 15:50:57 +01001006
Steve Frenchddfbefb2011-03-15 02:08:48 +00001007#endif /* _SMB2PDU_H */