Re: [PATCH v3 15/22] smb: move FILE_SYSTEM_ATTRIBUTE_INFO to common/cifspdu.h

ChenXiaoSong
2025-10-21T06:36:42Z

Thanks for your suggestions. I’ll send v4 soon.

--
Thanks,
ChenXiaoSong.

On 10/20/25 1:35 PM, Namjae Jeon wrote:
> On Tue, Oct 14, 2025 at 4:30 PM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>>
>> From: ChenXiaoSong <chenxiaosong@kylinos.cn>
>>
>> Rename "struct filesystem_attribute_info" to "FILE_SYSTEM_ATTRIBUTE_INFO",
>> then move duplicate definitions to common header file.
>>
>> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> Please check the warnings from checkpatch.pl.
>
> WARNING: do not add new typedefs
> #109: FILE: fs/smb/common/cifspdu.h:352:
> +typedef struct {
>
> WARNING: Prefer __packed over __attribute__((packed))
> #114: FILE: fs/smb/common/cifspdu.h:357:
> +} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
>
>> ---
>> fs/smb/client/cifspdu.h | 7 -------
>> fs/smb/common/cifspdu.h | 8 ++++++++
>> fs/smb/server/smb2pdu.c | 6 +++---
>> fs/smb/server/smb_common.h | 7 -------
>> 4 files changed, 11 insertions(+), 17 deletions(-)
>>
>> diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
>> index 07eb821654e1..a6f7e168961e 100644
>> --- a/fs/smb/client/cifspdu.h
>> +++ b/fs/smb/client/cifspdu.h
>> @@ -1937,13 +1937,6 @@ typedef struct {
>> /* 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 */
>> /******************************************************************************/
>> diff --git a/fs/smb/common/cifspdu.h b/fs/smb/common/cifspdu.h
>> index 1109c20f7bf8..560900617be7 100644
>> --- a/fs/smb/common/cifspdu.h
>> +++ b/fs/smb/common/cifspdu.h
>> @@ -348,4 +348,12 @@ typedef struct server_negotiate_rsp {
>> #define FILE_CASE_PRESERVED_NAMES 0x00000002
>> #define FILE_CASE_SENSITIVE_SEARCH 0x00000001
>>
>> +/* See FS-FSCC 2.5.1 */
>> +typedef struct {
>> + __le32 Attributes;
>> + __le32 MaxPathNameComponentLength;
>> + __le32 FileSystemNameLen;
>> + __le16 FileSystemName[]; /* do not have to save this - get subset? */
>> +} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
>> +
>> #endif /* _COMMON_CIFSPDU_H */
>> diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
>> index a46d4ddade9e..a05b04799c0d 100644
>> --- a/fs/smb/server/smb2pdu.c
>> +++ b/fs/smb/server/smb2pdu.c
>> @@ -5485,10 +5485,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 |
>> @@ -5507,7 +5507,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;
>> }
>> diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
>> index a5dd656c36f1..016ec93e6df4 100644
>> --- a/fs/smb/server/smb_common.h
>> +++ b/fs/smb/server/smb_common.h
>> @@ -56,13 +56,6 @@
>> FILE_EXECUTE | FILE_DELETE_CHILD | \
>> FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES)
>>
>> -struct filesystem_attribute_info {
>> - __le32 Attributes;
>> - __le32 MaxPathNameComponentLength;
>> - __le32 FileSystemNameLen;
>> - __le16 FileSystemName[]; /* do not have to save this - get subset? */
>> -} __packed;
>> -
>> struct filesystem_device_info {
>> __le32 DeviceType;
>> __le32 DeviceCharacteristics;
>> --
>> 2.43.0
>>