xref: /linux/fs/smb/common/fscc.h (revision 509d3f45847627f4c5cdce004c3ec79262b5239c)
1 /* SPDX-License-Identifier: LGPL-2.1 */
2 /*
3  *
4  *   Copyright (c) International Business Machines  Corp., 2009, 2013
5  *                 Etersoft, 2012
6  *                 2018 Samsung Electronics Co., Ltd.
7  *   Author(s): Steve French (sfrench@us.ibm.com)
8  *              Pavel Shilovsky (pshilovsky@samba.org) 2012
9  *              Namjae Jeon (linkinjeon@kernel.org)
10  *
11  */
12 #ifndef _COMMON_SMB_FSCC_H
13 #define _COMMON_SMB_FSCC_H
14 
15 /* See MS-FSCC 2.4.8 */
16 typedef struct {
17 	__le32 NextEntryOffset;
18 	__u32 FileIndex;
19 	__le64 CreationTime;
20 	__le64 LastAccessTime;
21 	__le64 LastWriteTime;
22 	__le64 ChangeTime;
23 	__le64 EndOfFile;
24 	__le64 AllocationSize;
25 	__le32 ExtFileAttributes;
26 	__le32 FileNameLength;
27 	__le32 EaSize; /* length of the xattrs */
28 	__u8   ShortNameLength;
29 	__u8   Reserved;
30 	__u8   ShortName[24];
31 	char FileName[];
32 } __packed FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FFrsp data */
33 
34 /* See MS-FSCC 2.4.10 */
35 typedef struct {
36 	__le32 NextEntryOffset;
37 	__u32 FileIndex;
38 	__le64 CreationTime;
39 	__le64 LastAccessTime;
40 	__le64 LastWriteTime;
41 	__le64 ChangeTime;
42 	__le64 EndOfFile;
43 	__le64 AllocationSize;
44 	__le32 ExtFileAttributes;
45 	__le32 FileNameLength;
46 	char FileName[];
47 } __packed FILE_DIRECTORY_INFO;   /* level 0x101 FF resp data */
48 
49 /* See MS-FSCC 2.4.14 */
50 typedef struct {
51 	__le32 NextEntryOffset;
52 	__u32 FileIndex;
53 	__le64 CreationTime;
54 	__le64 LastAccessTime;
55 	__le64 LastWriteTime;
56 	__le64 ChangeTime;
57 	__le64 EndOfFile;
58 	__le64 AllocationSize;
59 	__le32 ExtFileAttributes;
60 	__le32 FileNameLength;
61 	__le32 EaSize; /* length of the xattrs */
62 	char FileName[];
63 } __packed FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */
64 
65 /* See MS-FSCC 2.4.24 */
66 typedef struct {
67 	__le32 NextEntryOffset;
68 	__u32 FileIndex;
69 	__le64 CreationTime;
70 	__le64 LastAccessTime;
71 	__le64 LastWriteTime;
72 	__le64 ChangeTime;
73 	__le64 EndOfFile;
74 	__le64 AllocationSize;
75 	__le32 ExtFileAttributes;
76 	__le32 FileNameLength;
77 	__le32 EaSize; /* EA size */
78 	__le32 Reserved;
79 	__le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
80 	char FileName[];
81 } __packed FILE_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */
82 
83 /* See MS-FSCC 2.4.34 */
84 struct smb2_file_network_open_info {
85 	struct_group_attr(network_open_info, __packed,
86 		__le64 CreationTime;
87 		__le64 LastAccessTime;
88 		__le64 LastWriteTime;
89 		__le64 ChangeTime;
90 		__le64 AllocationSize;
91 		__le64 EndOfFile;
92 		__le32 Attributes;
93 	);
94 	__le32 Reserved;
95 } __packed; /* level 34 Query also similar returned in close rsp and open rsp */
96 
97 /* See MS-FSCC 2.5.1 */
98 #define MAX_FS_NAME_LEN		52
99 typedef struct {
100 	__le32 Attributes;
101 	__le32 MaxPathNameComponentLength;
102 	__le32 FileSystemNameLen;
103 	__le16 FileSystemName[]; /* do not have to save this - get subset? */
104 } __packed FILE_SYSTEM_ATTRIBUTE_INFO;
105 
106 /* List of FileSystemAttributes - see MS-FSCC 2.5.1 */
107 #define FILE_SUPPORTS_SPARSE_VDL	0x10000000 /* faster nonsparse extend */
108 #define FILE_SUPPORTS_BLOCK_REFCOUNTING	0x08000000 /* allow ioctl dup extents */
109 #define FILE_SUPPORT_INTEGRITY_STREAMS	0x04000000
110 #define FILE_SUPPORTS_USN_JOURNAL	0x02000000
111 #define FILE_SUPPORTS_OPEN_BY_FILE_ID	0x01000000
112 #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
113 #define FILE_SUPPORTS_HARD_LINKS	0x00400000
114 #define FILE_SUPPORTS_TRANSACTIONS	0x00200000
115 #define FILE_SEQUENTIAL_WRITE_ONCE	0x00100000
116 #define FILE_READ_ONLY_VOLUME		0x00080000
117 #define FILE_NAMED_STREAMS		0x00040000
118 #define FILE_SUPPORTS_ENCRYPTION	0x00020000
119 #define FILE_SUPPORTS_OBJECT_IDS	0x00010000
120 #define FILE_VOLUME_IS_COMPRESSED	0x00008000
121 #define FILE_SUPPORTS_POSIX_UNLINK_RENAME 0x00000400
122 #define FILE_RETURNS_CLEANUP_RESULT_INFO  0x00000200
123 #define FILE_SUPPORTS_REMOTE_STORAGE	0x00000100
124 #define FILE_SUPPORTS_REPARSE_POINTS	0x00000080
125 #define FILE_SUPPORTS_SPARSE_FILES	0x00000040
126 #define FILE_VOLUME_QUOTAS		0x00000020
127 #define FILE_FILE_COMPRESSION		0x00000010
128 #define FILE_PERSISTENT_ACLS		0x00000008
129 #define FILE_UNICODE_ON_DISK		0x00000004
130 #define FILE_CASE_PRESERVED_NAMES	0x00000002
131 #define FILE_CASE_SENSITIVE_SEARCH	0x00000001
132 
133 /* See MS-FSCC 2.5.8 */
134 typedef struct {
135 	__le64 TotalAllocationUnits;
136 	__le64 AvailableAllocationUnits;
137 	__le32 SectorsPerAllocationUnit;
138 	__le32 BytesPerSector;
139 } __packed FILE_SYSTEM_SIZE_INFO;	/* size info, level 0x103 */
140 
141 /* See MS-FSCC 2.5.10 */
142 typedef struct {
143 	__le32 DeviceType;
144 	__le32 DeviceCharacteristics;
145 } __packed FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */
146 
147 /*
148  * See POSIX Extensions to MS-FSCC 2.3.2.1
149  * Link: https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/fscc_posix_extensions.md
150  */
151 typedef struct {
152 	/* For undefined recommended transfer size return -1 in that field */
153 	__le32 OptimalTransferSize;  /* bsize on some os, iosize on other os */
154 	__le32 BlockSize;
155 	/* The next three fields are in terms of the block size.
156 	 * (above). If block size is unknown, 4096 would be a
157 	 * reasonable block size for a server to report.
158 	 * Note that returning the blocks/blocksavail removes need
159 	 * to make a second call (to QFSInfo level 0x103 to get this info.
160 	 * UserBlockAvail is typically less than or equal to BlocksAvail,
161 	 * if no distinction is made return the same value in each
162 	 */
163 	__le64 TotalBlocks;
164 	__le64 BlocksAvail;       /* bfree */
165 	__le64 UserBlocksAvail;   /* bavail */
166 	/* For undefined Node fields or FSID return -1 */
167 	__le64 TotalFileNodes;
168 	__le64 FreeFileNodes;
169 	__le64 FileSysIdentifier;   /* fsid */
170 	/* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
171 	/* NB flags can come from FILE_SYSTEM_DEVICE_INFO call   */
172 } __packed FILE_SYSTEM_POSIX_INFO;
173 
174 #endif /* _COMMON_SMB_FSCC_H */
175