1212#ifndef _COMMON_SMB_FSCC_H
1313#define _COMMON_SMB_FSCC_H
1414
15+ /* Reparse structures - see MS-FSCC 2.1.2 */
16+
17+ /* struct fsctl_reparse_info_req is empty, only response structs (see below) */
18+ struct reparse_data_buffer {
19+ __le32 ReparseTag ;
20+ __le16 ReparseDataLength ;
21+ __u16 Reserved ;
22+ __u8 DataBuffer []; /* Variable Length */
23+ } __packed ;
24+
25+ struct reparse_guid_data_buffer {
26+ __le32 ReparseTag ;
27+ __le16 ReparseDataLength ;
28+ __u16 Reserved ;
29+ __u8 ReparseGuid [16 ];
30+ __u8 DataBuffer []; /* Variable Length */
31+ } __packed ;
32+
33+ struct reparse_mount_point_data_buffer {
34+ __le32 ReparseTag ;
35+ __le16 ReparseDataLength ;
36+ __u16 Reserved ;
37+ __le16 SubstituteNameOffset ;
38+ __le16 SubstituteNameLength ;
39+ __le16 PrintNameOffset ;
40+ __le16 PrintNameLength ;
41+ __u8 PathBuffer []; /* Variable Length */
42+ } __packed ;
43+
44+ #define SYMLINK_FLAG_RELATIVE 0x00000001
45+
46+ struct reparse_symlink_data_buffer {
47+ __le32 ReparseTag ;
48+ __le16 ReparseDataLength ;
49+ __u16 Reserved ;
50+ __le16 SubstituteNameOffset ;
51+ __le16 SubstituteNameLength ;
52+ __le16 PrintNameOffset ;
53+ __le16 PrintNameLength ;
54+ __le32 Flags ;
55+ __u8 PathBuffer []; /* Variable Length */
56+ } __packed ;
57+
58+ /* For IO_REPARSE_TAG_NFS - see MS-FSCC 2.1.2.6 */
59+ #define NFS_SPECFILE_LNK 0x00000000014B4E4C
60+ #define NFS_SPECFILE_CHR 0x0000000000524843
61+ #define NFS_SPECFILE_BLK 0x00000000004B4C42
62+ #define NFS_SPECFILE_FIFO 0x000000004F464946
63+ #define NFS_SPECFILE_SOCK 0x000000004B434F53
64+ struct reparse_nfs_data_buffer {
65+ __le32 ReparseTag ;
66+ __le16 ReparseDataLength ;
67+ __u16 Reserved ;
68+ __le64 InodeType ; /* NFS_SPECFILE_* */
69+ __u8 DataBuffer [];
70+ } __packed ;
71+
72+ /* For IO_REPARSE_TAG_LX_SYMLINK - see MS-FSCC 2.1.2.7 */
73+ struct reparse_wsl_symlink_data_buffer {
74+ __le32 ReparseTag ;
75+ __le16 ReparseDataLength ;
76+ __u16 Reserved ;
77+ __le32 Version ; /* Always 2 */
78+ __u8 Target []; /* Variable Length UTF-8 string without nul-term */
79+ } __packed ;
80+
81+ /* See MS-FSCC 2.3.7 */
82+ struct duplicate_extents_to_file {
83+ __u64 PersistentFileHandle ; /* source file handle, opaque endianness */
84+ __u64 VolatileFileHandle ;
85+ __le64 SourceFileOffset ;
86+ __le64 TargetFileOffset ;
87+ __le64 ByteCount ; /* Bytes to be copied */
88+ } __packed ;
89+
90+ /* See MS-FSCC 2.3.9 */
91+ #define DUPLICATE_EXTENTS_DATA_EX_SOURCE_ATOMIC 0x00000001
92+ struct duplicate_extents_to_file_ex {
93+ __le64 StructureSize ; /* MUST be set to 0x30 */
94+ __u64 PersistentFileHandle ; /* source file handle, opaque endianness */
95+ __u64 VolatileFileHandle ;
96+ __le64 SourceFileOffset ;
97+ __le64 TargetFileOffset ;
98+ __le64 ByteCount ; /* Bytes to be copied */
99+ __le32 Flags ;
100+ __le32 Reserved ;
101+ } __packed ;
102+
103+ /* See MS-FSCC 2.3.20 */
104+ struct fsctl_get_integrity_information_rsp {
105+ __le16 ChecksumAlgorithm ;
106+ __le16 Reserved ;
107+ __le32 Flags ;
108+ __le32 ChecksumChunkSizeInBytes ;
109+ __le32 ClusterSizeInBytes ;
110+ } __packed ;
111+
112+ /* See MS-FSCC 2.3.52 */
113+ struct file_allocated_range_buffer {
114+ __le64 file_offset ;
115+ __le64 length ;
116+ } __packed ;
117+
118+ /* See MS-FSCC 2.3.55 */
119+ struct fsctl_query_file_regions_req {
120+ __le64 FileOffset ;
121+ __le64 Length ;
122+ __le32 DesiredUsage ;
123+ __le32 Reserved ;
124+ } __packed ;
125+
126+ /* DesiredUsage flags see MS-FSCC 2.3.56.1 */
127+ #define FILE_USAGE_INVALID_RANGE 0x00000000
128+ #define FILE_USAGE_VALID_CACHED_DATA 0x00000001
129+ #define FILE_USAGE_NONCACHED_DATA 0x00000002
130+ struct file_region_info {
131+ __le64 FileOffset ;
132+ __le64 Length ;
133+ __le32 DesiredUsage ;
134+ __le32 Reserved ;
135+ } __packed ;
136+
137+ /* See MS-FSCC 2.3.56 */
138+ struct fsctl_query_file_region_rsp {
139+ __le32 Flags ;
140+ __le32 TotalRegionEntryCount ;
141+ __le32 RegionEntryCount ;
142+ __u32 Reserved ;
143+ struct file_region_info Regions [];
144+ } __packed ;
145+
146+ /* See MS-FSCC 2.3.58 */
147+ struct fsctl_query_on_disk_vol_info_rsp {
148+ __le64 DirectoryCount ;
149+ __le64 FileCount ;
150+ __le16 FsFormatMajVersion ;
151+ __le16 FsFormatMinVersion ;
152+ __u8 FsFormatName [24 ];
153+ __le64 FormatTime ;
154+ __le64 LastUpdateTime ;
155+ __u8 CopyrightInfo [68 ];
156+ __u8 AbstractInfo [68 ];
157+ __u8 FormatImplInfo [68 ];
158+ __u8 LastModifyImplInfo [68 ];
159+ } __packed ;
160+
161+ /* See MS-FSCC 2.3.73 */
162+ struct fsctl_set_integrity_information_req {
163+ __le16 ChecksumAlgorithm ;
164+ __le16 Reserved ;
165+ __le32 Flags ;
166+ } __packed ;
167+
168+ /* See MS-FSCC 2.3.75 */
169+ struct fsctl_set_integrity_info_ex_req {
170+ __u8 EnableIntegrity ;
171+ __u8 KeepState ;
172+ __u16 Reserved ;
173+ __le32 Flags ;
174+ __u8 Version ;
175+ __u8 Reserved2 [7 ];
176+ } __packed ;
177+
178+ /*
179+ * this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA
180+ * See MS-FSCC 2.3.85
181+ */
182+ struct file_zero_data_information {
183+ __le64 FileOffset ;
184+ __le64 BeyondFinalZero ;
185+ } __packed ;
186+
187+ /*
188+ * This level 18, although with struct with same name is different from cifs
189+ * level 0x107. Level 0x107 has an extra u64 between AccessFlags and
190+ * CurrentByteOffset.
191+ * See MS-FSCC 2.4.2
192+ */
193+ struct smb2_file_all_info { /* data block encoding of response to level 18 */
194+ __le64 CreationTime ; /* Beginning of FILE_BASIC_INFO equivalent */
195+ __le64 LastAccessTime ;
196+ __le64 LastWriteTime ;
197+ __le64 ChangeTime ;
198+ __le32 Attributes ;
199+ __u32 Pad1 ; /* End of FILE_BASIC_INFO_INFO equivalent */
200+ __le64 AllocationSize ; /* Beginning of FILE_STANDARD_INFO equivalent */
201+ __le64 EndOfFile ; /* size ie offset to first free byte in file */
202+ __le32 NumberOfLinks ; /* hard links */
203+ __u8 DeletePending ;
204+ __u8 Directory ;
205+ __u16 Pad2 ; /* End of FILE_STANDARD_INFO equivalent */
206+ __le64 IndexNumber ;
207+ __le32 EASize ;
208+ __le32 AccessFlags ;
209+ __le64 CurrentByteOffset ;
210+ __le32 Mode ;
211+ __le32 AlignmentRequirement ;
212+ __le32 FileNameLength ;
213+ union {
214+ char __pad ; /* Legacy structure padding */
215+ DECLARE_FLEX_ARRAY (char , FileName );
216+ };
217+ } __packed ; /* level 18 Query */
218+
15219/* See MS-FSCC 2.4.8 */
16220typedef struct {
17221 __le32 NextEntryOffset ;
@@ -46,6 +250,11 @@ typedef struct {
46250 char FileName [];
47251} __packed FILE_DIRECTORY_INFO ; /* level 0x101 FF resp data */
48252
253+ /* See MS-FSCC 2.4.13 */
254+ struct smb2_file_eof_info { /* encoding of request for level 10 */
255+ __le64 EndOfFile ; /* new end of file value */
256+ } __packed ; /* level 20 Set */
257+
49258/* See MS-FSCC 2.4.14 */
50259typedef struct {
51260 __le32 NextEntryOffset ;
@@ -80,6 +289,26 @@ typedef struct {
80289 char FileName [];
81290} __packed FILE_ID_FULL_DIR_INFO ; /* level 0x105 FF rsp data */
82291
292+ /* See MS-FSCC 2.4.27 */
293+ struct smb2_file_internal_info {
294+ __le64 IndexNumber ;
295+ } __packed ; /* level 6 Query */
296+
297+ /* See MS-FSCC 2.4.28.2 */
298+ struct smb2_file_link_info { /* encoding of request for level 11 */
299+ /* New members MUST be added within the struct_group() macro below. */
300+ __struct_group (smb2_file_link_info_hdr , __hdr , __packed ,
301+ __u8 ReplaceIfExists ; /* 1 = replace existing link with new */
302+ /* 0 = fail if link already exists */
303+ __u8 Reserved [7 ];
304+ __u64 RootDirectory ; /* MBZ for network operations (why says spec?) */
305+ __le32 FileNameLength ;
306+ );
307+ char FileName []; /* Name to be assigned to new link */
308+ } __packed ; /* level 11 Set */
309+ static_assert (offsetof(struct smb2_file_link_info , FileName ) == sizeof (struct smb2_file_link_info_hdr ),
310+ "struct member likely outside of __struct_group()" );
311+
83312/* See MS-FSCC 2.4.34 */
84313struct smb2_file_network_open_info {
85314 struct_group_attr (network_open_info , __packed ,
@@ -94,6 +323,37 @@ struct smb2_file_network_open_info {
94323 __le32 Reserved ;
95324} __packed ; /* level 34 Query also similar returned in close rsp and open rsp */
96325
326+ /* See MS-FSCC 2.4.42.2 */
327+ struct smb2_file_rename_info { /* encoding of request for level 10 */
328+ /* New members MUST be added within the struct_group() macro below. */
329+ __struct_group (smb2_file_rename_info_hdr , __hdr , __packed ,
330+ __u8 ReplaceIfExists ; /* 1 = replace existing target with new */
331+ /* 0 = fail if target already exists */
332+ __u8 Reserved [7 ];
333+ __u64 RootDirectory ; /* MBZ for network operations (why says spec?) */
334+ __le32 FileNameLength ;
335+ );
336+ char FileName []; /* New name to be assigned */
337+ /* padding - overall struct size must be >= 24 so filename + pad >= 6 */
338+ } __packed ; /* level 10 Set */
339+ static_assert (offsetof(struct smb2_file_rename_info , FileName ) == sizeof (struct smb2_file_rename_info_hdr ),
340+ "struct member likely outside of __struct_group()" );
341+
342+ /* File System Information Classes */
343+ /* See MS-FSCC 2.5 */
344+ #define FS_VOLUME_INFORMATION 1 /* Query */
345+ #define FS_LABEL_INFORMATION 2 /* Set */
346+ #define FS_SIZE_INFORMATION 3 /* Query */
347+ #define FS_DEVICE_INFORMATION 4 /* Query */
348+ #define FS_ATTRIBUTE_INFORMATION 5 /* Query */
349+ #define FS_CONTROL_INFORMATION 6 /* Query, Set */
350+ #define FS_FULL_SIZE_INFORMATION 7 /* Query */
351+ #define FS_OBJECT_ID_INFORMATION 8 /* Query, Set */
352+ #define FS_DRIVER_PATH_INFORMATION 9 /* Query */
353+ #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
354+ /* See POSIX Extensions to MS-FSCC 2.3.1.1 */
355+ #define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */
356+
97357/* See MS-FSCC 2.5.1 */
98358#define MAX_FS_NAME_LEN 52
99359typedef struct {
@@ -130,6 +390,45 @@ typedef struct {
130390#define FILE_CASE_PRESERVED_NAMES 0x00000002
131391#define FILE_CASE_SENSITIVE_SEARCH 0x00000001
132392
393+ /*
394+ * File System Control Information
395+ * See MS-FSCC 2.5.2
396+ */
397+ struct smb2_fs_control_info {
398+ __le64 FreeSpaceStartFiltering ;
399+ __le64 FreeSpaceThreshold ;
400+ __le64 FreeSpaceStopFiltering ;
401+ __le64 DefaultQuotaThreshold ;
402+ __le64 DefaultQuotaLimit ;
403+ __le32 FileSystemControlFlags ;
404+ __le32 Padding ;
405+ } __packed ;
406+
407+ /* See MS-FSCC 2.5.4 */
408+ struct smb2_fs_full_size_info {
409+ __le64 TotalAllocationUnits ;
410+ __le64 CallerAvailableAllocationUnits ;
411+ __le64 ActualAvailableAllocationUnits ;
412+ __le32 SectorsPerAllocationUnit ;
413+ __le32 BytesPerSector ;
414+ } __packed ;
415+
416+ /* See MS-FSCC 2.5.7 */
417+ #define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001
418+ #define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002
419+ #define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004
420+ #define SSINFO_FLAGS_TRIM_ENABLED 0x00000008
421+ /* sector size info struct */
422+ struct smb3_fs_ss_info {
423+ __le32 LogicalBytesPerSector ;
424+ __le32 PhysicalBytesPerSectorForAtomicity ;
425+ __le32 PhysicalBytesPerSectorForPerf ;
426+ __le32 FSEffPhysicalBytesPerSectorForAtomicity ;
427+ __le32 Flags ;
428+ __le32 ByteOffsetForSectorAlignment ;
429+ __le32 ByteOffsetForPartitionAlignment ;
430+ } __packed ;
431+
133432/* See MS-FSCC 2.5.8 */
134433typedef struct {
135434 __le64 TotalAllocationUnits ;
@@ -189,6 +488,22 @@ typedef struct {
189488#define FILE_ATTRIBUTE_NO_SCRUB_DATA_LE cpu_to_le32(FILE_ATTRIBUTE_NO_SCRUB_DATA)
190489#define FILE_ATTRIBUTE_MASK_LE cpu_to_le32(FILE_ATTRIBUTE_MASK)
191490
491+ /*
492+ * SMB2 Notify Action Flags
493+ * See MS-FSCC 2.7.1
494+ */
495+ #define FILE_ACTION_ADDED 0x00000001
496+ #define FILE_ACTION_REMOVED 0x00000002
497+ #define FILE_ACTION_MODIFIED 0x00000003
498+ #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
499+ #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
500+ #define FILE_ACTION_ADDED_STREAM 0x00000006
501+ #define FILE_ACTION_REMOVED_STREAM 0x00000007
502+ #define FILE_ACTION_MODIFIED_STREAM 0x00000008
503+ #define FILE_ACTION_REMOVED_BY_DELETE 0x00000009
504+ #define FILE_ACTION_ID_NOT_TUNNELLED 0x0000000A
505+ #define FILE_ACTION_TUNNELLED_ID_COLLISION 0x0000000B
506+
192507/*
193508 * Response contains array of the following structures
194509 * See MS-FSCC 2.7.1
0 commit comments