]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/fscc.h
authorChenXiaoSong <chenxiaosong@kylinos.cn>
Mon, 17 Nov 2025 11:28:38 +0000 (19:28 +0800)
committerSteve French <stfrench@microsoft.com>
Mon, 1 Dec 2025 03:11:45 +0000 (21:11 -0600)
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>
fs/smb/client/cifspdu.h
fs/smb/client/smb2pdu.c
fs/smb/common/fscc.h
fs/smb/server/smb2pdu.c
fs/smb/server/smb_common.h

index d84e10b1477fa5a240e16cc8c84daf506f6c1947..49f35cb3cf2e9775f8e771ee79dba2d0d82fb488 100644 (file)
@@ -2068,16 +2068,6 @@ typedef struct {
 #define FILE_PORTABLE_DEVICE                   0x00004000
 #define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL 0x00020000
 
-/* minimum includes first three fields, and empty FS Name */
-#define MIN_FS_ATTR_INFO_SIZE 12
-
-typedef struct {
-       __le32 Attributes;
-       __le32 MaxPathNameComponentLength;
-       __le32 FileSystemNameLen;
-       char FileSystemName[52]; /* do not have to save this - get subset? */
-} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
-
 /******************************************************************************/
 /* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
 /******************************************************************************/
index 032b4b037f072ad4c7e72cd181f3dc15726199df..ef2c6ac500f7c4cacaac83ae4f60f153de213667 100644 (file)
@@ -5981,8 +5981,8 @@ replay_again:
                max_len = sizeof(FILE_SYSTEM_DEVICE_INFO);
                min_len = sizeof(FILE_SYSTEM_DEVICE_INFO);
        } else if (level == FS_ATTRIBUTE_INFORMATION) {
-               max_len = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO);
-               min_len = MIN_FS_ATTR_INFO_SIZE;
+               max_len = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) + MAX_FS_NAME_LEN;
+               min_len = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO);
        } else if (level == FS_SECTOR_SIZE_INFORMATION) {
                max_len = sizeof(struct smb3_fs_ss_info);
                min_len = sizeof(struct smb3_fs_ss_info);
@@ -6028,7 +6028,7 @@ replay_again:
        if (level == FS_ATTRIBUTE_INFORMATION)
                memcpy(&tcon->fsAttrInfo, offset
                        + (char *)rsp, min_t(unsigned int,
-                       rsp_len, max_len));
+                       rsp_len, min_len));
        else if (level == FS_DEVICE_INFORMATION)
                memcpy(&tcon->fsDevInfo, offset
                        + (char *)rsp, sizeof(FILE_SYSTEM_DEVICE_INFO));
index a0580a772a41818b190afbac4406006e6bcd0181..35dbacdbb9020d6afbd918a48b731a6f01cfda6b 100644 (file)
@@ -94,6 +94,15 @@ struct smb2_file_network_open_info {
        __le32 Reserved;
 } __packed; /* level 34 Query also similar returned in close rsp and open rsp */
 
+/* See MS-FSCC 2.5.1 */
+#define MAX_FS_NAME_LEN                52
+typedef struct {
+       __le32 Attributes;
+       __le32 MaxPathNameComponentLength;
+       __le32 FileSystemNameLen;
+       __le16 FileSystemName[]; /* do not have to save this - get subset? */
+} __packed FILE_SYSTEM_ATTRIBUTE_INFO;
+
 /* List of FileSystemAttributes - see MS-FSCC 2.5.1 */
 #define FILE_SUPPORTS_SPARSE_VDL       0x10000000 /* faster nonsparse extend */
 #define FILE_SUPPORTS_BLOCK_REFCOUNTING        0x08000000 /* allow ioctl dup extents */
index 11d3fab9bde3806fc3c3c056ef8277c96e0eeda9..b638d7fb5f5167122df9a11a3c38a8603a512f52 100644 (file)
@@ -5479,10 +5479,10 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
        }
        case FS_ATTRIBUTE_INFORMATION:
        {
-               struct filesystem_attribute_info *info;
+               FILE_SYSTEM_ATTRIBUTE_INFO *info;
                size_t sz;
 
-               info = (struct filesystem_attribute_info *)rsp->Buffer;
+               info = (FILE_SYSTEM_ATTRIBUTE_INFO *)rsp->Buffer;
                info->Attributes = cpu_to_le32(FILE_SUPPORTS_OBJECT_IDS |
                                               FILE_PERSISTENT_ACLS |
                                               FILE_UNICODE_ON_DISK |
@@ -5501,7 +5501,7 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
                                        "NTFS", PATH_MAX, conn->local_nls, 0);
                len = len * 2;
                info->FileSystemNameLen = cpu_to_le32(len);
-               sz = sizeof(struct filesystem_attribute_info) + len;
+               sz = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO) + len;
                rsp->OutputBufferLength = cpu_to_le32(sz);
                break;
        }
index a91717da3895eb34a9d8e28de64baaca23b62c4e..2baf4aa330ebbeef0af7f32ce4fbe182d1a2644e 100644 (file)
@@ -90,13 +90,6 @@ struct smb_negotiate_rsp {
        __le16 ByteCount;
 } __packed;
 
-struct filesystem_attribute_info {
-       __le32 Attributes;
-       __le32 MaxPathNameComponentLength;
-       __le32 FileSystemNameLen;
-       __le16 FileSystemName[]; /* do not have to save this - get subset? */
-} __packed;
-
 struct filesystem_vol_info {
        __le64 VolumeCreationTime;
        __le32 SerialNumber;