Skip to content

Commit c4a2a49

Browse files
ChenXiaoSongsmfrench
authored andcommitted
smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/fscc.h
Modify the following places: - struct filesystem_attribute_info -> FILE_SYSTEM_ATTRIBUTE_INFO - Remove MIN_FS_ATTR_INFO_SIZE definition - Introduce MAX_FS_NAME_LEN - max_len of FileFsAttributeInformation -> sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) + MAX_FS_NAME_LEN - min_len of FileFsAttributeInformation -> sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) - SMB2_QFS_attr(): memcpy(..., min_len) Then move FILE_SYSTEM_ATTRIBUTE_INFO to common header file. I have tested the relevant code related to FILE_SYSTEM_ATTRIBUTE_INFO (Link[1]). Link[1]: https://chenxiaosong.com/en/FILE_SYSTEM_ATTRIBUTE_INFO.html Suggested-by: Namjae Jeon <linkinjeon@kernel.org> Tested-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent e4442b2 commit c4a2a49

5 files changed

Lines changed: 15 additions & 23 deletions

File tree

fs/smb/client/cifspdu.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,16 +2068,6 @@ typedef struct {
20682068
#define FILE_PORTABLE_DEVICE 0x00004000
20692069
#define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL 0x00020000
20702070

2071-
/* minimum includes first three fields, and empty FS Name */
2072-
#define MIN_FS_ATTR_INFO_SIZE 12
2073-
2074-
typedef struct {
2075-
__le32 Attributes;
2076-
__le32 MaxPathNameComponentLength;
2077-
__le32 FileSystemNameLen;
2078-
char FileSystemName[52]; /* do not have to save this - get subset? */
2079-
} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
2080-
20812071
/******************************************************************************/
20822072
/* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
20832073
/******************************************************************************/

fs/smb/client/smb2pdu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5981,8 +5981,8 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
59815981
max_len = sizeof(FILE_SYSTEM_DEVICE_INFO);
59825982
min_len = sizeof(FILE_SYSTEM_DEVICE_INFO);
59835983
} else if (level == FS_ATTRIBUTE_INFORMATION) {
5984-
max_len = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO);
5985-
min_len = MIN_FS_ATTR_INFO_SIZE;
5984+
max_len = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) + MAX_FS_NAME_LEN;
5985+
min_len = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO);
59865986
} else if (level == FS_SECTOR_SIZE_INFORMATION) {
59875987
max_len = sizeof(struct smb3_fs_ss_info);
59885988
min_len = sizeof(struct smb3_fs_ss_info);
@@ -6028,7 +6028,7 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
60286028
if (level == FS_ATTRIBUTE_INFORMATION)
60296029
memcpy(&tcon->fsAttrInfo, offset
60306030
+ (char *)rsp, min_t(unsigned int,
6031-
rsp_len, max_len));
6031+
rsp_len, min_len));
60326032
else if (level == FS_DEVICE_INFORMATION)
60336033
memcpy(&tcon->fsDevInfo, offset
60346034
+ (char *)rsp, sizeof(FILE_SYSTEM_DEVICE_INFO));

fs/smb/common/fscc.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ struct smb2_file_network_open_info {
9494
__le32 Reserved;
9595
} __packed; /* level 34 Query also similar returned in close rsp and open rsp */
9696

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+
97106
/* List of FileSystemAttributes - see MS-FSCC 2.5.1 */
98107
#define FILE_SUPPORTS_SPARSE_VDL 0x10000000 /* faster nonsparse extend */
99108
#define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000 /* allow ioctl dup extents */

fs/smb/server/smb2pdu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5479,10 +5479,10 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
54795479
}
54805480
case FS_ATTRIBUTE_INFORMATION:
54815481
{
5482-
struct filesystem_attribute_info *info;
5482+
FILE_SYSTEM_ATTRIBUTE_INFO *info;
54835483
size_t sz;
54845484

5485-
info = (struct filesystem_attribute_info *)rsp->Buffer;
5485+
info = (FILE_SYSTEM_ATTRIBUTE_INFO *)rsp->Buffer;
54865486
info->Attributes = cpu_to_le32(FILE_SUPPORTS_OBJECT_IDS |
54875487
FILE_PERSISTENT_ACLS |
54885488
FILE_UNICODE_ON_DISK |
@@ -5501,7 +5501,7 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
55015501
"NTFS", PATH_MAX, conn->local_nls, 0);
55025502
len = len * 2;
55035503
info->FileSystemNameLen = cpu_to_le32(len);
5504-
sz = sizeof(struct filesystem_attribute_info) + len;
5504+
sz = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) + len;
55055505
rsp->OutputBufferLength = cpu_to_le32(sz);
55065506
break;
55075507
}

fs/smb/server/smb_common.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,6 @@ struct smb_negotiate_rsp {
9090
__le16 ByteCount;
9191
} __packed;
9292

93-
struct filesystem_attribute_info {
94-
__le32 Attributes;
95-
__le32 MaxPathNameComponentLength;
96-
__le32 FileSystemNameLen;
97-
__le16 FileSystemName[]; /* do not have to save this - get subset? */
98-
} __packed;
99-
10093
struct filesystem_vol_info {
10194
__le64 VolumeCreationTime;
10295
__le32 SerialNumber;

0 commit comments

Comments
 (0)