Skip to content

Commit d7edd38

Browse files
ChenXiaoSongsmfrench
authored andcommitted
smb: move some duplicate struct definitions to common/fscc.h
Modify the following places: - smb2_file_ntwrk_info -> smb2_file_network_open_info - struct filesystem_device_info -> FILE_SYSTEM_DEVICE_INFO - struct file_directory_info -> FILE_DIRECTORY_INFO - struct file_full_directory_info -> FILE_FULL_DIRECTORY_INFO - struct file_both_directory_info -> FILE_BOTH_DIRECTORY_INFO - struct file_id_full_dir_info -> FILE_ID_FULL_DIR_INFO - struct filesystem_posix_info -> FILE_SYSTEM_POSIX_INFO The fields of these structures are exactly the same on both client and server, so move duplicate definitions to common header file. Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 84d8d4c commit d7edd38

10 files changed

Lines changed: 156 additions & 248 deletions

File tree

fs/smb/client/cifspdu.h

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,28 +2036,6 @@ typedef struct {
20362036

20372037
#define CIFS_POSIX_EXTENSIONS 0x00000010 /* support for new QFSInfo */
20382038

2039-
typedef struct {
2040-
/* For undefined recommended transfer size return -1 in that field */
2041-
__le32 OptimalTransferSize; /* bsize on some os, iosize on other os */
2042-
__le32 BlockSize;
2043-
/* The next three fields are in terms of the block size.
2044-
(above). If block size is unknown, 4096 would be a
2045-
reasonable block size for a server to report.
2046-
Note that returning the blocks/blocksavail removes need
2047-
to make a second call (to QFSInfo level 0x103 to get this info.
2048-
UserBlockAvail is typically less than or equal to BlocksAvail,
2049-
if no distinction is made return the same value in each */
2050-
__le64 TotalBlocks;
2051-
__le64 BlocksAvail; /* bfree */
2052-
__le64 UserBlocksAvail; /* bavail */
2053-
/* For undefined Node fields or FSID return -1 */
2054-
__le64 TotalFileNodes;
2055-
__le64 FreeFileNodes;
2056-
__le64 FileSysIdentifier; /* fsid */
2057-
/* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
2058-
/* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */
2059-
} __attribute__((packed)) FILE_SYSTEM_POSIX_INFO;
2060-
20612039
/* DeviceType Flags */
20622040
#define FILE_DEVICE_CD_ROM 0x00000002
20632041
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
@@ -2092,11 +2070,6 @@ typedef struct {
20922070
#define FILE_PORTABLE_DEVICE 0x00004000
20932071
#define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL 0x00020000
20942072

2095-
typedef struct {
2096-
__le32 DeviceType;
2097-
__le32 DeviceCharacteristics;
2098-
} __attribute__((packed)) FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */
2099-
21002073
/* minimum includes first three fields, and empty FS Name */
21012074
#define MIN_FS_ATTR_INFO_SIZE 12
21022075

@@ -2332,70 +2305,6 @@ typedef struct {
23322305
};
23332306
} __attribute__((packed)) FILE_UNIX_INFO; /* level 0x202 */
23342307

2335-
typedef struct {
2336-
__le32 NextEntryOffset;
2337-
__u32 FileIndex;
2338-
__le64 CreationTime;
2339-
__le64 LastAccessTime;
2340-
__le64 LastWriteTime;
2341-
__le64 ChangeTime;
2342-
__le64 EndOfFile;
2343-
__le64 AllocationSize;
2344-
__le32 ExtFileAttributes;
2345-
__le32 FileNameLength;
2346-
char FileName[];
2347-
} __attribute__((packed)) FILE_DIRECTORY_INFO; /* level 0x101 FF resp data */
2348-
2349-
typedef struct {
2350-
__le32 NextEntryOffset;
2351-
__u32 FileIndex;
2352-
__le64 CreationTime;
2353-
__le64 LastAccessTime;
2354-
__le64 LastWriteTime;
2355-
__le64 ChangeTime;
2356-
__le64 EndOfFile;
2357-
__le64 AllocationSize;
2358-
__le32 ExtFileAttributes;
2359-
__le32 FileNameLength;
2360-
__le32 EaSize; /* length of the xattrs */
2361-
char FileName[];
2362-
} __attribute__((packed)) FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */
2363-
2364-
typedef struct {
2365-
__le32 NextEntryOffset;
2366-
__u32 FileIndex;
2367-
__le64 CreationTime;
2368-
__le64 LastAccessTime;
2369-
__le64 LastWriteTime;
2370-
__le64 ChangeTime;
2371-
__le64 EndOfFile;
2372-
__le64 AllocationSize;
2373-
__le32 ExtFileAttributes;
2374-
__le32 FileNameLength;
2375-
__le32 EaSize; /* EA size */
2376-
__le32 Reserved;
2377-
__le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
2378-
char FileName[];
2379-
} __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */
2380-
2381-
typedef struct {
2382-
__le32 NextEntryOffset;
2383-
__u32 FileIndex;
2384-
__le64 CreationTime;
2385-
__le64 LastAccessTime;
2386-
__le64 LastWriteTime;
2387-
__le64 ChangeTime;
2388-
__le64 EndOfFile;
2389-
__le64 AllocationSize;
2390-
__le32 ExtFileAttributes;
2391-
__le32 FileNameLength;
2392-
__le32 EaSize; /* length of the xattrs */
2393-
__u8 ShortNameLength;
2394-
__u8 Reserved;
2395-
__u8 ShortName[24];
2396-
char FileName[];
2397-
} __attribute__((packed)) FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FFrsp data */
2398-
23992308
typedef struct {
24002309
__u32 ResumeKey;
24012310
__le16 CreationDate; /* SMB Date */

fs/smb/client/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ static int cifs_get_fattr(struct cifs_open_info_data *data,
13281328
/* for easier reading */
13291329
FILE_ALL_INFO *fi;
13301330
FILE_DIRECTORY_INFO *fdi;
1331-
SEARCH_ID_FULL_DIR_INFO *si;
1331+
FILE_ID_FULL_DIR_INFO *si;
13321332

13331333
rc = cifs_backup_query_path_info(xid, tcon, sb,
13341334
full_path,
@@ -1339,7 +1339,7 @@ static int cifs_get_fattr(struct cifs_open_info_data *data,
13391339

13401340
move_cifs_info_to_smb2(&data->fi, fi);
13411341
fdi = (FILE_DIRECTORY_INFO *)fi;
1342-
si = (SEARCH_ID_FULL_DIR_INFO *)fi;
1342+
si = (FILE_ID_FULL_DIR_INFO *)fi;
13431343

13441344
cifs_dir_info_to_fattr(fattr, fdi, cifs_sb);
13451345
fattr->cf_uniqueid = le64_to_cpu(si->UniqueId);

fs/smb/client/readdir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ static void cifs_fill_dirent_full(struct cifs_dirent *de,
548548
}
549549

550550
static void cifs_fill_dirent_search(struct cifs_dirent *de,
551-
const SEARCH_ID_FULL_DIR_INFO *info)
551+
const FILE_ID_FULL_DIR_INFO *info)
552552
{
553553
de->name = &info->FileName[0];
554554
de->namelen = le32_to_cpu(info->FileNameLength);

fs/smb/client/smb2pdu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5454,7 +5454,7 @@ smb2_parse_query_directory(struct cifs_tcon *tcon,
54545454
info_buf_size = sizeof(FILE_DIRECTORY_INFO);
54555455
break;
54565456
case SMB_FIND_FILE_ID_FULL_DIR_INFO:
5457-
info_buf_size = sizeof(SEARCH_ID_FULL_DIR_INFO);
5457+
info_buf_size = sizeof(FILE_ID_FULL_DIR_INFO);
54585458
break;
54595459
case SMB_FIND_FILE_POSIX_INFO:
54605460
/* note that posix payload are variable size */

fs/smb/client/smb2pdu.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -224,19 +224,6 @@ struct smb2_file_reparse_point_info {
224224
__le32 Tag;
225225
} __packed;
226226

227-
struct smb2_file_network_open_info {
228-
struct_group_attr(network_open_info, __packed,
229-
__le64 CreationTime;
230-
__le64 LastAccessTime;
231-
__le64 LastWriteTime;
232-
__le64 ChangeTime;
233-
__le64 AllocationSize;
234-
__le64 EndOfFile;
235-
__le32 Attributes;
236-
);
237-
__le32 Reserved;
238-
} __packed; /* level 34 Query also similar returned in close rsp and open rsp */
239-
240227
/* See MS-FSCC 2.4.21 */
241228
struct smb2_file_id_information {
242229
__le64 VolumeSerialNumber;

fs/smb/common/fscc.h

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,88 @@
1212
#ifndef _COMMON_SMB_FSCC_H
1313
#define _COMMON_SMB_FSCC_H
1414

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+
1597
/* List of FileSystemAttributes - see MS-FSCC 2.5.1 */
1698
#define FILE_SUPPORTS_SPARSE_VDL 0x10000000 /* faster nonsparse extend */
1799
#define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000 /* allow ioctl dup extents */
@@ -39,4 +121,37 @@
39121
#define FILE_CASE_PRESERVED_NAMES 0x00000002
40122
#define FILE_CASE_SENSITIVE_SEARCH 0x00000001
41123

124+
/* See MS-FSCC 2.5.10 */
125+
typedef struct {
126+
__le32 DeviceType;
127+
__le32 DeviceCharacteristics;
128+
} __packed FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */
129+
130+
/*
131+
* See POSIX Extensions to MS-FSCC 2.3.2.1
132+
* Link: https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/fscc_posix_extensions.md
133+
*/
134+
typedef struct {
135+
/* For undefined recommended transfer size return -1 in that field */
136+
__le32 OptimalTransferSize; /* bsize on some os, iosize on other os */
137+
__le32 BlockSize;
138+
/* The next three fields are in terms of the block size.
139+
* (above). If block size is unknown, 4096 would be a
140+
* reasonable block size for a server to report.
141+
* Note that returning the blocks/blocksavail removes need
142+
* to make a second call (to QFSInfo level 0x103 to get this info.
143+
* UserBlockAvail is typically less than or equal to BlocksAvail,
144+
* if no distinction is made return the same value in each
145+
*/
146+
__le64 TotalBlocks;
147+
__le64 BlocksAvail; /* bfree */
148+
__le64 UserBlocksAvail; /* bavail */
149+
/* For undefined Node fields or FSID return -1 */
150+
__le64 TotalFileNodes;
151+
__le64 FreeFileNodes;
152+
__le64 FileSysIdentifier; /* fsid */
153+
/* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
154+
/* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */
155+
} __packed FILE_SYSTEM_POSIX_INFO;
156+
42157
#endif /* _COMMON_SMB_FSCC_H */

0 commit comments

Comments
 (0)