smb: move duplicate definitions into common header file, part 2
Subsystems (2)
v4 cover smb: move duplicate definitions into common header file, part 2
From: ZhangGuoDong <[email protected]>
v3->v4:
- Patch #03: __le32 VolumeSerialNumber
- Add patch #04
v3: https://lore.kernel.org/linux-cifs/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/linux-cifs/[email protected]/
The following patches from v1 and v2 have already been merged into mainline:
- 94d5b8dbc5d9 smb: move some SMB1 definitions into common/smb1pdu.h
- 2b6abb893e71 smb: move File Attributes definitions into common/fscc.h
- c97503321ed3 smb: update struct duplicate_extents_to_file_ex
- 2e0d224d8988 smb/server: add comment to FileSystemName of FileFsAttributeInformation
- ab0347e67dac smb/client: remove DeviceType Flags and Device Characteristics definitions
- 08c2a7d2bae9 smb: move file_notify_information to common/fscc.h
- 6539e18517b6 smb: move SMB2 Notify Action Flags into common/smb2pdu.h
- 9ec7629b430a smb: move notify completion filter flags into common/smb2pdu.h
- bcdd6cfaf2ec smb: add documentation references for smb2 change notify definitions
This is a continuous effort to move duplicated definitions in both client and server into common header files, which makes the code easier to maintain.
The previous work is here:
- part 1: https://lore.kernel.org/linux-cifs/[email protected]/
ZhangGuoDong (5):
smb: move some definitions from common/smb2pdu.h into common/fscc.h
smb: move file_basic_info into common/fscc.h
smb: move filesystem_vol_info into common/fscc.h
smb: update some doc references
smb: introduce struct file_posix_info
fs/smb/client/cifs_debug.c | 2 +- fs/smb/client/cifs_ioctl.h | 2 +- fs/smb/client/cifsfs.c | 2 +- fs/smb/client/cifsglob.h | 2 +- fs/smb/client/fscache.c | 2 +- fs/smb/client/inode.c | 22 +-- fs/smb/client/readdir.c | 28 +-- fs/smb/client/reparse.h | 4 +- fs/smb/client/smb1pdu.h | 9 - fs/smb/client/smb2pdu.c | 6 +- fs/smb/client/smb2pdu.h | 22 +-- fs/smb/common/fscc.h | 379 ++++++++++++++++++++++++++++++++++++- fs/smb/common/smb2pdu.h | 343 --------------------------------- fs/smb/server/smb2pdu.c | 93 ++++----- fs/smb/server/smb2pdu.h | 35 +--- fs/smb/server/smb_common.h | 8 - 16 files changed, 471 insertions(+), 488 deletions(-)
Signature · 1 line
2.53.0
PATCH v4 1/5 smb: move some definitions from common/smb2pdu.h into common/fscc.h
From: ZhangGuoDong <[email protected]>
These definitions are specified in MS-FSCC, so move them into fscc.h.
Only add some documentation references, no other changes.
--- fs/smb/common/fscc.h | 315 ++++++++++++++++++++++++++++++++++++++++ fs/smb/common/smb2pdu.h | 307 --------------------------------------- 2 files changed, 315 insertions(+), 307 deletions(-)
fs/smb/common/fscc.h +315 -0
@@ -12,6 +12,210 @@ #ifndef _COMMON_SMB_FSCC_H #define _COMMON_SMB_FSCC_H +/* Reparse structures - see MS-FSCC 2.1.2 */ + +/* struct fsctl_reparse_info_req is empty, only response structs (see below) */ +struct reparse_data_buffer { + __le32 ReparseTag; + __le16 ReparseDataLength; + __u16 Reserved; + __u8 DataBuffer[]; /* Variable Length */ +} __packed; + +struct reparse_guid_data_buffer { + __le32 ReparseTag; + __le16 ReparseDataLength; + __u16 Reserved; + __u8 ReparseGuid[16]; + __u8 DataBuffer[]; /* Variable Length */ +} __packed; + +struct reparse_mount_point_data_buffer { + __le32 ReparseTag; + __le16 ReparseDataLength; + __u16 Reserved; + __le16 SubstituteNameOffset; + __le16 SubstituteNameLength; + __le16 PrintNameOffset; + __le16 PrintNameLength; + __u8 PathBuffer[]; /* Variable Length */ +} __packed; + +#define SYMLINK_FLAG_RELATIVE 0x00000001 + +struct reparse_symlink_data_buffer { + __le32 ReparseTag; + __le16 ReparseDataLength; + __u16 Reserved; + __le16 SubstituteNameOffset; + __le16 SubstituteNameLength; + __le16 PrintNameOffset; + __le16 PrintNameLength; + __le32 Flags; + __u8 PathBuffer[]; /* Variable Length */ +} __packed; + +/* For IO_REPARSE_TAG_NFS - see MS-FSCC 2.1.2.6 */ +#define NFS_SPECFILE_LNK 0x00000000014B4E4C +#define NFS_SPECFILE_CHR 0x0000000000524843 +#define NFS_SPECFILE_BLK 0x00000000004B4C42 +#define NFS_SPECFILE_FIFO 0x000000004F464946 +#define NFS_SPECFILE_SOCK 0x000000004B434F53 +struct reparse_nfs_data_buffer { + __le32 ReparseTag; + __le16 ReparseDataLength; + __u16 Reserved; + __le64 InodeType; /* NFS_SPECFILE_* */ + __u8 DataBuffer[]; +} __packed; + +/* For IO_REPARSE_TAG_LX_SYMLINK - see MS-FSCC 2.1.2.7 */ +struct reparse_wsl_symlink_data_buffer { + __le32 ReparseTag; + __le16 ReparseDataLength; + __u16 Reserved; + __le32 Version; /* Always 2 */ + __u8 Target[]; /* Variable Length UTF-8 string without nul-term */ +} __packed; + +/* See MS-FSCC 2.3.7 */ +struct duplicate_extents_to_file { + __u64 PersistentFileHandle; /* source file handle, opaque endianness */ + __u64 VolatileFileHandle; + __le64 SourceFileOffset; + __le64 TargetFileOffset; + __le64 ByteCount; /* Bytes to be copied */ +} __packed; + +/* See MS-FSCC 2.3.9 */ +#define DUPLICATE_EXTENTS_DATA_EX_SOURCE_ATOMIC 0x00000001 +struct duplicate_extents_to_file_ex { + __le64 StructureSize; /* MUST be set to 0x30 */ + __u64 PersistentFileHandle; /* source file handle, opaque endianness */ + __u64 VolatileFileHandle; + __le64 SourceFileOffset; + __le64 TargetFileOffset; + __le64 ByteCount; /* Bytes to be copied */ + __le32 Flags; + __le32 Reserved; +} __packed; + +/* See MS-FSCC 2.3.20 */ +struct fsctl_get_integrity_information_rsp { + __le16 ChecksumAlgorithm; + __le16 Reserved; + __le32 Flags; + __le32 ChecksumChunkSizeInBytes; + __le32 ClusterSizeInBytes; +} __packed; + +/* See MS-FSCC 2.3.52 */ +struct file_allocated_range_buffer { + __le64 file_offset; + __le64 length; +} __packed; + +/* See MS-FSCC 2.3.55 */ +struct fsctl_query_file_regions_req { + __le64 FileOffset; + __le64 Length; + __le32 DesiredUsage; + __le32 Reserved; +} __packed; + +/* DesiredUsage flags see MS-FSCC 2.3.56.1 */ +#define FILE_USAGE_INVALID_RANGE 0x00000000 +#define FILE_USAGE_VALID_CACHED_DATA 0x00000001 +#define FILE_USAGE_NONCACHED_DATA 0x00000002 +struct file_region_info { + __le64 FileOffset; + __le64 Length; + __le32 DesiredUsage; + __le32 Reserved; +} __packed; + +/* See MS-FSCC 2.3.56 */ +struct fsctl_query_file_region_rsp { + __le32 Flags; + __le32 TotalRegionEntryCount; + __le32 RegionEntryCount; + __u32 Reserved; + struct file_region_info Regions[]; +} __packed; + +/* See MS-FSCC 2.3.58 */ +struct fsctl_query_on_disk_vol_info_rsp { + __le64 DirectoryCount; + __le64 FileCount; + __le16 FsFormatMajVersion; + __le16 FsFormatMinVersion; + __u8 FsFormatName[24]; + __le64 FormatTime; + __le64 LastUpdateTime; + __u8 CopyrightInfo[68]; + __u8 AbstractInfo[68]; + __u8 FormatImplInfo[68]; + __u8 LastModifyImplInfo[68]; +} __packed; + +/* See MS-FSCC 2.3.73 */ +struct fsctl_set_integrity_information_req { + __le16 ChecksumAlgorithm; + __le16 Reserved; + __le32 Flags; +} __packed; + +/* See MS-FSCC 2.3.75 */ +struct fsctl_set_integrity_info_ex_req { + __u8 EnableIntegrity; + __u8 KeepState; + __u16 Reserved; + __le32 Flags; + __u8 Version; + __u8 Reserved2[7]; +} __packed; + +/* + * this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA + * See MS-FSCC 2.3.85 + */ +struct file_zero_data_information { + __le64 FileOffset; + __le64 BeyondFinalZero; +} __packed; + +/* + * This level 18, although with struct with same name is different from cifs + * level 0x107. Level 0x107 has an extra u64 between AccessFlags and + * CurrentByteOffset. + * See MS-FSCC 2.4.2 + */ +struct smb2_file_all_info { /* data block encoding of response to level 18 */ + __le64 CreationTime; /* Beginning of FILE_BASIC_INFO equivalent */ + __le64 LastAccessTime; + __le64 LastWriteTime; + __le64 ChangeTime; + __le32 Attributes; + __u32 Pad1; /* End of FILE_BASIC_INFO_INFO equivalent */ + __le64 AllocationSize; /* Beginning of FILE_STANDARD_INFO equivalent */ + __le64 EndOfFile; /* size ie offset to first free byte in file */ + __le32 NumberOfLinks; /* hard links */ + __u8 DeletePending; + __u8 Directory; + __u16 Pad2; /* End of FILE_STANDARD_INFO equivalent */ + __le64 IndexNumber; + __le32 EASize; + __le32 AccessFlags; + __le64 CurrentByteOffset; + __le32 Mode; + __le32 AlignmentRequirement; + __le32 FileNameLength; + union { + char __pad; /* Legacy structure padding */ + DECLARE_FLEX_ARRAY(char, FileName); + }; +} __packed; /* level 18 Query */ + /* See MS-FSCC 2.4.8 */ typedef struct { __le32 NextEntryOffset;
@@ -46,6 +250,11 @@ typedef struct {char FileName[]; }__packed FILE_DIRECTORY_INFO ;/* level 0x101 FF resp data */ +/* See MS-FSCC 2.4.13 */ +struct smb2_file_eof_info {/* encoding of request for level 10 */ +__le64 EndOfFile;/* new end of file value */ +} __packed;/* level 20 Set */ +/* See MS-FSCC 2.4.14 */ typedef struct { __le32 NextEntryOffset;
@@ -80,6 +289,26 @@ typedef struct {char FileName[]; }__packed FILE_ID_FULL_DIR_INFO ;/* level 0x105 FF rsp data */ +/* See MS-FSCC 2.4.27 */ +struct smb2_file_internal_info { +__le64 IndexNumber; +} __packed;/* level 6 Query */ + +/* See MS-FSCC 2.4.28.2 */ +struct smb2_file_link_info {/* encoding of request for level 11 */ +/* New members MUST be added within the struct_group() macro below. */ + __struct_group(smb2_file_link_info_hdr, __hdr, __packed, + __u8 ReplaceIfExists; /* 1 = replace existing link with new */ +/* 0 = fail if link already exists */ +__u8 Reserved[7 ]; +__u64 RootDirectory;/* MBZ for network operations (why says spec?) */ +__le32 FileNameLength; + ); +char FileName[];/* Name to be assigned to new link */ +} __packed;/* level 11 Set */ +static_assert (offsetof(struct smb2_file_link_info , FileName) ==sizeof (struct smb2_file_link_info_hdr ), +"struct member likely outside of __struct_group()" ); +/* See MS-FSCC 2.4.34 */ struct smb2_file_network_open_info { struct_group_attr(network_open_info, __packed,
@@ -94,6 +323,37 @@ 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.4.42.2 */ +struct smb2_file_rename_info {/* encoding of request for level 10 */ +/* New members MUST be added within the struct_group() macro below. */ + __struct_group(smb2_file_rename_info_hdr, __hdr, __packed, + __u8 ReplaceIfExists; /* 1 = replace existing target with new */ +/* 0 = fail if target already exists */ +__u8 Reserved[7 ]; +__u64 RootDirectory;/* MBZ for network operations (why says spec?) */ +__le32 FileNameLength; + ); +char FileName[];/* New name to be assigned */ +/* padding - overall struct size must be >= 24 so filename + pad >= 6 */ +} __packed;/* level 10 Set */ +static_assert (offsetof(struct smb2_file_rename_info , FileName) ==sizeof (struct smb2_file_rename_info_hdr ), +"struct member likely outside of __struct_group()" ); + +/* File System Information Classes */ +/* See MS-FSCC 2.5 */ +#define FS_VOLUME_INFORMATION 1/* Query */ +#define FS_LABEL_INFORMATION 2/* Set */ +#define FS_SIZE_INFORMATION 3/* Query */ +#define FS_DEVICE_INFORMATION 4/* Query */ +#define FS_ATTRIBUTE_INFORMATION 5/* Query */ +#define FS_CONTROL_INFORMATION 6/* Query, Set */ +#define FS_FULL_SIZE_INFORMATION 7/* Query */ +#define FS_OBJECT_ID_INFORMATION 8/* Query, Set */ +#define FS_DRIVER_PATH_INFORMATION 9/* Query */ +#define FS_SECTOR_SIZE_INFORMATION 11/* SMB3 or later. Query */ +/* See POSIX Extensions to MS-FSCC 2.3.1.1 */ +#define FS_POSIX_INFORMATION 100/* SMB3.1.1 POSIX. Query */ +/* See MS-FSCC 2.5.1 */ #define MAX_FS_NAME_LEN 52 typedef struct {
@@ -130,6 +390,45 @@ typedef struct {#define FILE_CASE_PRESERVED_NAMES 0x00000002#define FILE_CASE_SENSITIVE_SEARCH 0x00000001 +/* +* File System Control Information +* See MS-FSCC 2.5.2 +*/ +struct smb2_fs_control_info { +__le64 FreeSpaceStartFiltering; +__le64 FreeSpaceThreshold; +__le64 FreeSpaceStopFiltering; +__le64 DefaultQuotaThreshold; +__le64 DefaultQuotaLimit; +__le32 FileSystemControlFlags; +__le32 Padding; +} __packed; + +/* See MS-FSCC 2.5.4 */ +struct smb2_fs_full_size_info { +__le64 TotalAllocationUnits; +__le64 CallerAvailableAllocationUnits; +__le64 ActualAvailableAllocationUnits; +__le32 SectorsPerAllocationUnit; +__le32 BytesPerSector; +} __packed; + +/* See MS-FSCC 2.5.7 */ +#define SSINFO_FLAGS_ALIGNED_DEVICE 0x00000001 +#define SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE 0x00000002 +#define SSINFO_FLAGS_NO_SEEK_PENALTY 0x00000004 +#define SSINFO_FLAGS_TRIM_ENABLED 0x00000008 +/* sector size info struct */ +struct smb3_fs_ss_info { +__le32 LogicalBytesPerSector; +__le32 PhysicalBytesPerSectorForAtomicity; +__le32 PhysicalBytesPerSectorForPerf; +__le32 FSEffPhysicalBytesPerSectorForAtomicity; +__le32 Flags; +__le32 ByteOffsetForSectorAlignment; +__le32 ByteOffsetForPartitionAlignment; +} __packed; +/* See MS-FSCC 2.5.8 */ typedef struct { __le64 TotalAllocationUnits;
@@ -189,6 +488,22 @@ typedef struct {#define FILE_ATTRIBUTE_NO_SCRUB_DATA_LE cpu_to_le32(FILE_ATTRIBUTE_NO_SCRUB_DATA)#define FILE_ATTRIBUTE_MASK_LE cpu_to_le32(FILE_ATTRIBUTE_MASK) +/* +* SMB2 Notify Action Flags +* See MS-FSCC 2.7.1 +*/ +#define FILE_ACTION_ADDED 0x00000001 +#define FILE_ACTION_REMOVED 0x00000002 +#define FILE_ACTION_MODIFIED 0x00000003 +#define FILE_ACTION_RENAMED_OLD_NAME 0x00000004 +#define FILE_ACTION_RENAMED_NEW_NAME 0x00000005 +#define FILE_ACTION_ADDED_STREAM 0x00000006 +#define FILE_ACTION_REMOVED_STREAM 0x00000007 +#define FILE_ACTION_MODIFIED_STREAM 0x00000008 +#define FILE_ACTION_REMOVED_BY_DELETE 0x00000009 +#define FILE_ACTION_ID_NOT_TUNNELLED 0x0000000A +#define FILE_ACTION_TUNNELLED_ID_COLLISION 0x0000000B +/* * Response contains array of the following structures * See MS-FSCC 2.7.1
fs/smb/common/smb2pdu.h +0 -307
337 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v4 2/5 smb: move file_basic_info into common/fscc.h
In reply to [email protected]From: ZhangGuoDong <[email protected]>
This struct definition is specified in MS-FSCC, so move them into fscc.h.
Modify the following places:
- smb2_file_basic_info -> file_basic_info
- Pad1 -> Pad
--- fs/smb/client/smb1pdu.h | 9 --------- fs/smb/common/fscc.h | 10 ++++++++++ fs/smb/server/smb2pdu.c | 14 +++++++------- fs/smb/server/smb2pdu.h | 9 --------- 4 files changed, 17 insertions(+), 25 deletions(-)
fs/smb/client/smb1pdu.h +0 -9
@@ -2061,15 +2061,6 @@ typedef struct {__le32 EASize; }__packed FILE_INFO_STANDARD ;/* level 1 SetPath/FileInfo */ -typedef struct { -__le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le32 Attributes; -__u32 Pad; -} __packed FILE_BASIC_INFO; /* size info, level 0x101 */ -struct file_allocation_info {__le64 AllocationSize;/* Note old Samba srvr rounds this up too much */ } __packed;/* size used on disk, for level 0x103 for set, 0x105 for query */
fs/smb/common/fscc.h +10 -0
@@ -216,6 +216,16 @@ struct smb2_file_all_info { /* data block encoding of response to level 18 */ }; } __packed;/* level 18 Query */ +/* See MS-FSCC 2.4.7 */ +typedef struct file_basic_info {/* data block encoding of response to level 18 */ +__le64 CreationTime; +__le64 LastAccessTime; +__le64 LastWriteTime; +__le64 ChangeTime; +__le32 Attributes; +__u32 Pad; +} __packed FILE_BASIC_INFO; /* size info, level 0x101 */ +/* See MS-FSCC 2.4.8 */ typedef struct { __le32 NextEntryOffset;
fs/smb/server/smb2pdu.c +7 -7
@@ -4838,7 +4838,7 @@ static void get_file_access_info(struct smb2_query_info_rsp *rsp,static int get_file_basic_info (struct smb2_query_info_rsp *rsp,struct ksmbd_file *fp,void *rsp_org) { -struct smb2_file_basic_info *basic_info; +struct file_basic_info *basic_info;struct kstat stat;u64 time;int ret;
@@ -4854,7 +4854,7 @@ static int get_file_basic_info(struct smb2_query_info_rsp *rsp,if (ret)return ret; - basic_info = (struct smb2_file_basic_info *)rsp->Buffer; + basic_info = (struct file_basic_info *)rsp->Buffer; basic_info->CreationTime =cpu_to_le64 (fp->create_time); time =ksmbd_UnixTimeToNT (stat.atime); basic_info->LastAccessTime =cpu_to_le64 (time);
@@ -4863,9 +4863,9 @@ static int get_file_basic_info(struct smb2_query_info_rsp *rsp, time =ksmbd_UnixTimeToNT (stat.ctime); basic_info->ChangeTime =cpu_to_le64 (time); basic_info->Attributes = fp->f_ci->m_fattr; - basic_info->Pad1 =0 ; + basic_info->Pad =0 ; rsp->OutputBufferLength = -cpu_to_le32 (sizeof (struct smb2_file_basic_info )); +cpu_to_le32 (sizeof (struct file_basic_info ));return 0 ; }
@@ -6136,7 +6136,7 @@ static int smb2_create_link(struct ksmbd_work *work, }static int set_file_basic_info (struct ksmbd_file *fp, -struct smb2_file_basic_info *file_info, +struct file_basic_info *file_info,struct ksmbd_share_config *share) {struct iattr attrs;
@@ -6418,10 +6418,10 @@ static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,switch (req->FileInfoClass) {case FILE_BASIC_INFORMATION : { -if (buf_len <sizeof (struct smb2_file_basic_info )) +if (buf_len <sizeof (struct file_basic_info ))return -EMSGSIZE ; -return set_file_basic_info (fp, (struct smb2_file_basic_info *)buffer, share); +return set_file_basic_info (fp, (struct file_basic_info *)buffer, share); }case FILE_ALLOCATION_INFORMATION : {
fs/smb/server/smb2pdu.h +0 -9
@@ -183,15 +183,6 @@ struct smb2_file_alignment_info {__le32 AlignmentRequirement; } __packed; -struct smb2_file_basic_info {/* data block encoding of response to level 18 */ -__le64 CreationTime;/* Beginning of FILE_BASIC_INFO equivalent */ -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le32 Attributes; -__u32 Pad1;/* End of FILE_BASIC_INFO_INFO equivalent */ -} __packed; -struct smb2_file_alt_name_info {__le32 FileNameLength;char FileName[];
Signature · 1 line
2.53.0
PATCH v4 3/5 smb: move filesystem_vol_info into common/fscc.h
In reply to [email protected]From: ZhangGuoDong <[email protected]>
The structure definition on the server side is specified in MS-CIFS 2.2.8.2.3, but we should instead refer to MS-FSCC 2.5.9, just as the client side does.
Modify the following places:
- smb3_fs_vol_info -> filesystem_vol_info
- SerialNumber -> VolumeSerialNumber
- VolumeLabelSize -> VolumeLabelLength
- struct smb_mnt_fs_info: __le32 vol_serial_number
- struct cifs_tcon: __le32 vol_serial_number
Then move it into common header file.
--- fs/smb/client/cifs_debug.c | 2 +- fs/smb/client/cifs_ioctl.h | 2 +- fs/smb/client/cifsfs.c | 2 +- fs/smb/client/cifsglob.h | 2 +- fs/smb/client/fscache.c | 2 +- fs/smb/client/smb2pdu.c | 6 +++--- fs/smb/common/fscc.h | 11 +++++++++++ fs/smb/common/smb2pdu.h | 11 ----------- fs/smb/server/smb2pdu.c | 5 +++-- fs/smb/server/smb_common.h | 8 -------- 10 files changed, 22 insertions(+), 29 deletions(-)
fs/smb/client/cifs_debug.c +1 -1
@@ -92,7 +92,7 @@ static void cifs_debug_tcon(struct seq_file *m, struct cifs_tcon *tcon)else seq_printf (m," type: %d " , dev_type); -seq_printf (m,"Serial Number: 0x%x" , tcon->vol_serial_number); +seq_printf (m,"Serial Number: 0x%x" ,le32_to_cpu (tcon->vol_serial_number)); if ((tcon->seal) || (tcon->ses->session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA) ||
fs/smb/client/cifs_ioctl.h +1 -1
@@ -11,7 +11,7 @@ struct smb_mnt_fs_info {__u32 version;/* 0001 */ __u16 protocol_id;__u16 tcon_flags; -__u32 vol_serial_number; +__le32 vol_serial_number;__u32 vol_create_time;__u32 share_caps;__u32 share_flags;
fs/smb/client/cifsfs.c +1 -1
@@ -373,7 +373,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)else buf->f_namelen =PATH_MAX ; - buf->f_fsid.val[0 ] = tcon->vol_serial_number; + buf->f_fsid.val[0 ] =le32_to_cpu (tcon->vol_serial_number);/* are using part of create time for more randomness, see man statfs */ buf->f_fsid.val[1 ] = (int )le64_to_cpu (tcon->vol_create_time);
fs/smb/client/cifsglob.h +1 -1
@@ -1270,7 +1270,7 @@ struct cifs_tcon {__le32 capabilities;__u32 share_flags;__u32 maximal_access; -__u32 vol_serial_number; +__le32 vol_serial_number;__le64 vol_create_time;__u64 snapshot_time;/* for timewarp tokens - timestamp of snapshot */ __u32 handle_timeout;/* persistent and durable handle timeout in ms */
fs/smb/client/fscache.c +1 -1
@@ -29,7 +29,7 @@ static void cifs_fscache_fill_volume_coherency(memset (cd,0 ,sizeof (*cd)); cd->resource_id =cpu_to_le64 (tcon->resource_id); cd->vol_create_time = tcon->vol_create_time; - cd->vol_serial_number =cpu_to_le32 (tcon->vol_serial_number); + cd->vol_serial_number = tcon->vol_serial_number; }int cifs_fscache_get_super_cookie (struct cifs_tcon *tcon)
fs/smb/client/smb2pdu.c +3 -3
@@ -6164,8 +6164,8 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon, max_len =sizeof (struct smb3_fs_ss_info ); min_len =sizeof (struct smb3_fs_ss_info ); }else if (level ==FS_VOLUME_INFORMATION ) { - max_len =sizeof (struct smb3_fs_vol_info ) +MAX_VOL_LABEL_LEN ; - min_len =sizeof (struct smb3_fs_vol_info ); + max_len =sizeof (struct filesystem_vol_info ) +MAX_VOL_LABEL_LEN ; + min_len =sizeof (struct filesystem_vol_info ); }else {cifs_dbg (FYI ,"Invalid qfsinfo level %d\n" , level);return -EINVAL ;
@@ -6220,7 +6220,7 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon, tcon->perf_sector_size =le32_to_cpu (ss_info->PhysicalBytesPerSectorForPerf); }else if (level ==FS_VOLUME_INFORMATION ) { -struct smb3_fs_vol_info *vol_info = (struct smb3_fs_vol_info *) +struct filesystem_vol_info *vol_info = (struct filesystem_vol_info *) (offset + (char *)rsp); tcon->vol_serial_number = vol_info->VolumeSerialNumber; tcon->vol_create_time = vol_info->VolumeCreationTime;
fs/smb/common/fscc.h +11 -0
@@ -447,6 +447,17 @@ typedef struct {__le32 BytesPerSector; }__packed FILE_SYSTEM_SIZE_INFO ;/* size info, level 0x103 */ +/* volume info struct - see MS-FSCC 2.5.9 */ +#define MAX_VOL_LABEL_LEN 32 +struct filesystem_vol_info { +__le64 VolumeCreationTime; +__le32 VolumeSerialNumber; +__le32 VolumeLabelLength;/* includes trailing null */ +__u8 SupportsObjects;/* True if eg like NTFS, supports objects */ +__u8 Reserved; +__u8 VolumeLabel[];/* variable len */ +} __packed; +/* See MS-FSCC 2.5.10 */ typedef struct { __le32 DeviceType;
fs/smb/common/smb2pdu.h +0 -11
@@ -1635,17 +1635,6 @@ struct smb311_posix_qinfo {*/ } __packed; -/* volume info struct - see MS-FSCC 2.5.9 */ -#define MAX_VOL_LABEL_LEN 32 -struct smb3_fs_vol_info { -__le64 VolumeCreationTime; -__u32 VolumeSerialNumber; -__le32 VolumeLabelLength;/* includes trailing null */ -__u8 SupportsObjects;/* True if eg like NTFS, supports objects */ -__u8 Reserved; -__u8 VolumeLabel[];/* variable len */ -} __packed; -/* See MS-SMB2 2.2.23 through 2.2.25 */ struct smb2_oplock_break {struct smb2_hdr hdr;
fs/smb/server/smb2pdu.c +3 -2
@@ -5544,13 +5544,14 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work, serial_crc =crc32_le (serial_crc,ksmbd_netbios_name (),strlen (ksmbd_netbios_name ()));/* Taking dummy value of serial number*/ - info->SerialNumber =cpu_to_le32 (serial_crc); + info->VolumeSerialNumber =cpu_to_le32 (serial_crc); len =smbConvertToUTF16 ((__le16 *)info->VolumeLabel, share->name,PATH_MAX , conn->local_nls,0 ); len = len *2 ; - info->VolumeLabelSize =cpu_to_le32 (len); + info->VolumeLabelLength =cpu_to_le32 (len); info->Reserved =0 ; + info->SupportsObjects =0 ; sz =sizeof (struct filesystem_vol_info ) + len; rsp->OutputBufferLength =cpu_to_le32 (sz);break ;
fs/smb/server/smb_common.h +0 -8
@@ -90,14 +90,6 @@ struct smb_negotiate_rsp {__le16 ByteCount; } __packed; -struct filesystem_vol_info { -__le64 VolumeCreationTime; -__le32 SerialNumber; -__le32 VolumeLabelSize; -__le16 Reserved; -__le16 VolumeLabel[]; -} __packed; -#define EXTENDED_INFO_MAGIC 0x43667364/* Cfsd */ #define STRING_LENGTH 28
Signature · 1 line
2.53.0
Namjae Jeon
maintainerRe: [PATCH v4 3/5] smb: move filesystem_vol_info into common/fscc.h
Quoted 7 lines · On Wed, Feb 25, 2026 at 1:12 PM <[email protected]> wrote:
From: ZhangGuoDong <[email protected]>
The structure definition on the server side is specified in MS-CIFS 2.2.8.2.3, but we should instead refer to MS-FSCC 2.5.9, just as the client side does.
Quoted 7 lines
Modify the following places:
-
smb3_fs_vol_info->filesystem_vol_info
- SerialNumber -> VolumeSerialNumber
- VolumeLabelSize -> VolumeLabelLength
- structsmb_mnt_fs_info:__le32vol_serial_number
- structcifs_tcon:__le32vol_serial_number
Why did you change vol_serial_number from u32 to __le32 ?
Re: [PATCH v4 3/5] smb: move filesystem_vol_info into common/fscc.h
Maybe we should keep vol_serial_number as u32. I will update it in the next version. Do you have any suggestions for the other patches?
Quoted 1 line · Namjae Jeon
Why did you change
vol_serial_numberfrom u32 to__le32?
PATCH v4 4/5 smb: update some doc references
In reply to [email protected]From: ZhangGuoDong <[email protected]>
To make it easier to locate the documentation during development.
--- fs/smb/client/smb2pdu.h | 7 +++++-- fs/smb/server/smb2pdu.h | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-)
fs/smb/client/smb2pdu.h +5 -2
@@ -224,7 +224,7 @@ struct smb2_file_reparse_point_info {__le32 Tag; } __packed; -/* See MS-FSCC 2.4.21 */ +/* See MS-FSCC 2.4.26 */ struct smb2_file_id_information {__le64 VolumeSerialNumber;__u64 PersistentFileId;/* opaque endianness */
@@ -251,7 +251,10 @@ struct smb2_file_id_extd_directory_info {extern char smb2_padding[7 ]; -/* equivalent of the contents of SMB3.1.1 POSIX open context response */ +/* +* See POSIX-SMB2 2.2.14.2.16 +* Link: https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/smb3_posix_extensions.md +*/ struct create_posix_rsp {u32 nlink;u32 reparse_tag;
fs/smb/server/smb2pdu.h +4 -1
@@ -83,7 +83,10 @@ struct create_durable_rsp { } Data; } __packed; -/* equivalent of the contents of SMB3.1.1 POSIX open context response */ +/* +* See POSIX-SMB2 2.2.14.2.16 +* Link: https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/smb3_posix_extensions.md +*/ struct create_posix_rsp {struct create_context_hdr ccontext;__u8 Name[16 ];
Signature · 1 line
2.53.0
Re: [PATCH v4 4/5] smb: update some doc references
added to cifs-2.6.git for-next
Quoted 56 lines · On Tue, Feb 24, 2026 at 10:12 PM <[email protected]> wrote:
From: ZhangGuoDong <[email protected]>
To make it easier to locate the documentation during development.
Signed-off-by ZhangGuoDong <[email protected]>Reviewed-by ChenXiaoSong <[email protected]>--- fs/smb/client/smb2pdu.h | 7 +++++-- fs/smb/server/smb2pdu.h | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-)fs/smb/client/smb2pdu.h +5
-2@@ -224,7 +224,7 @@ struct smb2_file_reparse_point_info {__le32 Tag; } __packed; -/* See MS-FSCC 2.4.21 */ +/* See MS-FSCC 2.4.26 */ struct smb2_file_id_information {__le64 VolumeSerialNumber;__u64 PersistentFileId;/* opaque endianness */ @@ -251,7 +251,10 @@ struct smb2_file_id_extd_directory_info {extern char smb2_padding[7 ]; -/* equivalent of the contents of SMB3.1.1 POSIX open context response */ +/* +* See POSIX-SMB2 2.2.14.2.16 +* Link: https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/smb3_posix_extensions.md +*/ struct create_posix_rsp {u32 nlink;u32 reparse_tag;fs/smb/server/smb2pdu.h +4
-2@@ -83,7 +83,10 @@ struct create_durable_rsp { } Data; } __packed; -/* equivalent of the contents of SMB3.1.1 POSIX open context response */ +/* +* See POSIX-SMB2 2.2.14.2.16 +* Link: https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/smb3_posix_extensions.md +*/ struct create_posix_rsp {struct create_context_hdr ccontext;__u8 Name[16 ]; --2.53.0
Signature · 3 lines
Thanks, Steve
PATCH v4 5/5 smb: introduce struct file_posix_info
In reply to [email protected]From: ZhangGuoDong <[email protected]>
Extract the non-variable part of struct smb311_posix_qinfo/file_posix_info into a new struct.
Modify the following places:
- introduce new struct file_posix_info
- some fields in "struct smb311_posix_qinfo" -> "struct file_posix_info"
- some fields in "struct smb2_posix_info" -> "struct file_posix_info"
--- fs/smb/client/inode.c | 22 ++++++------ fs/smb/client/readdir.c | 28 ++++++++-------- fs/smb/client/reparse.h | 4 +-- fs/smb/client/smb2pdu.h | 15 +-------- fs/smb/common/fscc.h | 43 +++++++++++++++++++++++- fs/smb/common/smb2pdu.h | 25 -------------- fs/smb/server/smb2pdu.c | 74 ++++++++++++++++++++--------------------- fs/smb/server/smb2pdu.h | 21 +----------- 8 files changed, 108 insertions(+), 124 deletions(-)
fs/smb/client/inode.c +11 -11
@@ -842,16 +842,16 @@ static void smb311_posix_info_to_fattr(struct cifs_fattr *fattr,memset (fattr,0 ,sizeof (*fattr));/* no fattr->flags to set */ - fattr->cf_cifsattrs =le32_to_cpu (info->DosAttributes); - fattr->cf_uniqueid =le64_to_cpu (info->Inode); + fattr->cf_cifsattrs =le32_to_cpu (info->fpinfo.DosAttributes); + fattr->cf_uniqueid =le64_to_cpu (info->fpinfo.Inode); -if (info->LastAccessTime) - fattr->cf_atime =cifs_NTtimeToUnix (info->LastAccessTime); +if (info->fpinfo.LastAccessTime) + fattr->cf_atime =cifs_NTtimeToUnix (info->fpinfo.LastAccessTime);else ktime_get_coarse_real_ts64 (&fattr->cf_atime); - fattr->cf_ctime =cifs_NTtimeToUnix (info->ChangeTime); - fattr->cf_mtime =cifs_NTtimeToUnix (info->LastWriteTime); + fattr->cf_ctime =cifs_NTtimeToUnix (info->fpinfo.ChangeTime); + fattr->cf_mtime =cifs_NTtimeToUnix (info->fpinfo.LastWriteTime);if (data->adjust_tz) { fattr->cf_ctime.tv_sec += tcon->ses->server->timeAdj;
@@ -862,11 +862,11 @@ static void smb311_posix_info_to_fattr(struct cifs_fattr *fattr,* The srv fs device id is overridden on network mount so setting * @fattr->cf_rdev isn't needed here. */ - fattr->cf_eof =le64_to_cpu (info->EndOfFile); - fattr->cf_bytes =le64_to_cpu (info->AllocationSize); - fattr->cf_createtime =le64_to_cpu (info->CreationTime); - fattr->cf_nlink =le32_to_cpu (info->HardLinks); - fattr->cf_mode =wire_mode_to_posix (le32_to_cpu (info->Mode), + fattr->cf_eof =le64_to_cpu (info->fpinfo.EndOfFile); + fattr->cf_bytes =le64_to_cpu (info->fpinfo.AllocationSize); + fattr->cf_createtime =le64_to_cpu (info->fpinfo.CreationTime); + fattr->cf_nlink =le32_to_cpu (info->fpinfo.HardLinks); + fattr->cf_mode =wire_mode_to_posix (le32_to_cpu (info->fpinfo.Mode), fattr->cf_cifsattrs &ATTR_DIRECTORY ); if (cifs_open_data_reparse(data) &&
fs/smb/client/readdir.c +14 -14
@@ -247,22 +247,22 @@ cifs_posix_to_fattr(struct cifs_fattr *fattr, struct smb2_posix_info *info,posix_info_parse (info,NULL , &parsed);memset (fattr,0 ,sizeof (*fattr)); - fattr->cf_uniqueid =le64_to_cpu (info->Inode); - fattr->cf_bytes =le64_to_cpu (info->AllocationSize); - fattr->cf_eof =le64_to_cpu (info->EndOfFile); + fattr->cf_uniqueid =le64_to_cpu (info->fpinfo.Inode); + fattr->cf_bytes =le64_to_cpu (info->fpinfo.AllocationSize); + fattr->cf_eof =le64_to_cpu (info->fpinfo.EndOfFile); - fattr->cf_atime =cifs_NTtimeToUnix (info->LastAccessTime); - fattr->cf_mtime =cifs_NTtimeToUnix (info->LastWriteTime); - fattr->cf_ctime =cifs_NTtimeToUnix (info->CreationTime); + fattr->cf_atime =cifs_NTtimeToUnix (info->fpinfo.LastAccessTime); + fattr->cf_mtime =cifs_NTtimeToUnix (info->fpinfo.LastWriteTime); + fattr->cf_ctime =cifs_NTtimeToUnix (info->fpinfo.CreationTime); - fattr->cf_nlink =le32_to_cpu (info->HardLinks); - fattr->cf_cifsattrs =le32_to_cpu (info->DosAttributes); + fattr->cf_nlink =le32_to_cpu (info->fpinfo.HardLinks); + fattr->cf_cifsattrs =le32_to_cpu (info->fpinfo.DosAttributes);if (fattr->cf_cifsattrs &ATTR_REPARSE_POINT ) - fattr->cf_cifstag =le32_to_cpu (info->ReparseTag); + fattr->cf_cifstag =le32_to_cpu (info->fpinfo.ReparseTag);/* The Mode field in the response can now include the file type as well */ - fattr->cf_mode =wire_mode_to_posix (le32_to_cpu (info->Mode), + fattr->cf_mode =wire_mode_to_posix (le32_to_cpu (info->fpinfo.Mode), fattr->cf_cifsattrs &ATTR_DIRECTORY ); fattr->cf_dtype =S_DT (fattr->cf_mode);
@@ -277,9 +277,9 @@ cifs_posix_to_fattr(struct cifs_fattr *fattr, struct smb2_posix_info *info, }cifs_dbg (FYI ,"posix fattr: dev %d, reparse %d, mode %o\n" , -le32_to_cpu (info->DeviceId), -le32_to_cpu (info->ReparseTag), -le32_to_cpu (info->Mode)); +le32_to_cpu (info->fpinfo.DeviceId), +le32_to_cpu (info->fpinfo.ReparseTag), +le32_to_cpu (info->fpinfo.Mode));sid_to_id (cifs_sb, &parsed.owner, fattr,SIDOWNER );sid_to_id (cifs_sb, &parsed.group, fattr,SIDGROUP );
@@ -517,7 +517,7 @@ static void cifs_fill_dirent_posix(struct cifs_dirent *de, de->name = parsed.name; de->namelen = parsed.name_len; de->resume_key = info->Ignored; - de->ino =le64_to_cpu (info->Inode); + de->ino =le64_to_cpu (info->fpinfo.Inode); } static void cifs_fill_dirent_unix(struct cifs_dirent *de,
fs/smb/client/reparse.h +2 -2
@@ -106,10 +106,10 @@ static inline bool cifs_open_data_reparse(struct cifs_open_info_data *data)if (data->contains_posix_file_info) {struct smb311_posix_qinfo *fi = &data->posix_fi; - attrs =le32_to_cpu (fi->DosAttributes); + attrs =le32_to_cpu (fi->fpinfo.DosAttributes);if (data->reparse_point) { attrs |=ATTR_REPARSE_POINT ; - fi->DosAttributes =cpu_to_le32 (attrs); + fi->fpinfo.DosAttributes =cpu_to_le32 (attrs); } }else {
fs/smb/client/smb2pdu.h +1 -14
@@ -274,20 +274,7 @@ struct create_posix_rsp {struct smb2_posix_info {__le32 NextEntryOffset;__u32 Ignored; -__le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le64 EndOfFile; -__le64 AllocationSize; -__le32 DosAttributes; -__le64 Inode; -__le32 DeviceId; -__le32 Zero; -/* beginning of POSIX Create Context Response */ -__le32 HardLinks; -__le32 ReparseTag; -__le32 Mode; +struct file_posix_info fpinfo;/* * var sized owner SID * var sized group SID
fs/smb/common/fscc.h +42 -1
51 lines not on this page · raw message
fs/smb/common/smb2pdu.h +0 -25
@@ -1610,31 +1610,6 @@ struct smb2_query_info_rsp {__u8 Buffer[]; } __packed; -/* Level 100 query info */ -struct smb311_posix_qinfo { -__le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le64 EndOfFile; -__le64 AllocationSize; -__le32 DosAttributes; -__le64 Inode; -__le32 DeviceId; -__le32 Zero; -/* beginning of POSIX Create Context Response */ -__le32 HardLinks; -__le32 ReparseTag; -__le32 Mode; -u8 Sids[]; -/* -* var sized owner SID -* var sized group SID -* le32 filenamelength -* u8 filename[] -*/ -} __packed; -/* See MS-SMB2 2.2.23 through 2.2.25 */ struct smb2_oplock_break {struct smb2_hdr hdr;
fs/smb/server/smb2pdu.c +37 -37
126 lines not on this page · raw message
fs/smb/server/smb2pdu.h +1 -20
@@ -281,30 +281,11 @@ struct create_sd_buf_req {struct smb2_posix_info {__le32 NextEntryOffset;__u32 Ignored; -__le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le64 EndOfFile; -__le64 AllocationSize; -__le32 DosAttributes; -__le64 Inode; -__le32 DeviceId; -__le32 Zero; -/* beginning of POSIX Create Context Response */ -__le32 HardLinks; -__le32 ReparseTag; -__le32 Mode; +struct file_posix_info fpinfo;/* SidBuffer contain two sids (UNIX user sid(16), UNIX group sid(16)) */ u8 SidBuffer[32 ];__le32 name_len;u8 name[]; -/* -* var sized owner SID -* var sized group SID -* le32 filenamelength -* u8 filename[] -*/ } __packed;/* functions */
Signature · 1 line
2.53.0
Namjae Jeon
maintainerRe: [PATCH v4 5/5] smb: introduce struct file_posix_info
It doesn't seem to have been updated as I said.
Quoted 16 lines
fs/smb/client/smb2pdu.h +0
-8@@ -274,20 +274,7 @@ struct create_posix_rsp {struct smb2_posix_info {__le32 NextEntryOffset;__u32 Ignored; -__le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le64 EndOfFile; -__le64 AllocationSize; -__le32 DosAttributes; -__le64 Inode;
fs/smb/client/smb2pdu.h struct create_posix_rsp { · line 280
Quoted 10 lines
fs/smb/client/smb2pdu.h +1
-6-__le32 DeviceId; -__le32 Zero; -/* beginning of POSIX Create Context Response */ -__le32 HardLinks; -__le32 ReparseTag; -__le32 Mode; +struct file_posix_info fpinfo;/* * var sized owner SID * var sized group SID
Please remove these comments included filename and move it to /common.
Quoted 25 lines
fs/smb/common/fscc.h +14
-1@@ -537,9 +537,50 @@ struct file_notify_information { } __packed;/* -* See POSIX Extensions to MS-FSCC 2.3.2.1 +* [POSIX-FSCC] POSIX Extensions to MS-FSCC * Link: https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/fscc_posix_extensions.md */ + +/* +* This information class is used to query file posix information. +* See POSIX-FSCC 2.3.1.1 +*/ +struct file_posix_info { +__le64 CreationTime; +__le64 LastAccessTime; +__le64 LastWriteTime; +__le64 ChangeTime; +__le64 EndOfFile; +__le64 AllocationSize; +__le32 DosAttributes;
fs/smb/common/fscc.h struct file_notify_information { · line 565
Quoted 10 lines
fs/smb/common/fscc.h +10
-0+__le64 Inode; +__le32 DeviceId; +__le32 Zero; +/* +* beginning of POSIX Create Context Response +* See POSIX-SMB2 2.2.14.2.16 +*/ +__le32 HardLinks; +__le32 ReparseTag; +__le32 Mode;
You need to add Sids[] flex array here.
fs/smb/common/fscc.h struct file_notify_information { · line 574
Quoted 9 lines
fs/smb/common/fscc.h +9
-0+// var sized owner SID +// var sized group SID +/* end of POSIX Create Context Response */ +// le32 filenamelength +// u8 filename[] +} __packed; + +/* Level 100 query info */ +struct smb311_posix_qinfo {
Is there smb311_posix_qinfo definition in specification ? If not, It could be replaced with smb2_posix_info ?
Quoted 32 lines
fs/smb/common/fscc.h +7
-0+struct file_posix_info fpinfo; +u8 Sids[]; +/* +* le32 filenamelength +* u8 filename[] +*/ +} __packed;fs/smb/server/smb2pdu.h +1
-14@@ -281,30 +281,11 @@ struct create_sd_buf_req {struct smb2_posix_info {__le32 NextEntryOffset;__u32 Ignored; -__le64 CreationTime; -__le64 LastAccessTime; -__le64 LastWriteTime; -__le64 ChangeTime; -__le64 EndOfFile; -__le64 AllocationSize; -__le32 DosAttributes; -__le64 Inode; -__le32 DeviceId; -__le32 Zero; -/* beginning of POSIX Create Context Response */ -__le32 HardLinks; -__le32 ReparseTag; -__le32 Mode; +struct file_posix_info fpinfo;/* SidBuffer contain two sids (UNIX user sid(16), UNIX group sid(16)) */
fs/smb/server/smb2pdu.h struct create_sd_buf_req { · line 289
Quoted 10 lines
fs/smb/server/smb2pdu.h +0
-6u8 SidBuffer[32 ];__le32 name_len;u8 name[]; -/* -* var sized owner SID -* var sized group SID -* le32 filenamelength -* u8 filename[] -*/ } __packed;
It should be replaced with smb2_posix_info in common.
Re: [PATCH v4 5/5] smb: introduce struct file_posix_info
Hi Namjae,
C structure cannot have two flexible array members.
If we make Sids[] a flexible array member, then there cannot be any members after it. However, this structure still has filenamelength and filename[] after it. And filename[] is also a flexible array member.
Do you have any suggestions for this?
Quoted 7 lines · Namjae Jeon
You need to add Sids[] flex array here.
Quoted 6 lines
fs/smb/common/fscc.h +6
-0+// var sized owner SID +// var sized group SID +/* end of POSIX Create Context Response */ +// le32 filenamelength +// u8 filename[] +} __packed;
Re: [PATCH v4 5/5] smb: introduce struct file_posix_info
And we cannot use SidBuffer[32] because the size of SidBuffer[] on the client side is not necessarily 32.
Quoted 17 lines · ZhangGuoDong
Hi Namjae,
C structure cannot have two flexible array members.
If we make
Sids[]a flexible array member, then there cannot be any members after it. However, this structure still hasfilenamelengthandfilename[]after it. Andfilename[]is also a flexible array member.Do you have any suggestions for this?
Quoted 7 lines · Namjae Jeon
You need to add Sids[] flex array here.
Quoted 6 lines
+ // var sized owner SID
+ // var sized group SID
+ /* end of POSIX Create Context Response */ + // le32 filenamelength
+ // u8 filename[]
+}__packed;
ChenXiaoSong
reviewerRe: [PATCH v4 5/5] smb: introduce struct file_posix_info
How about merging the two flexible array members and naming it sids_and_name[]?
Quoted 21 lines · ZhangGuoDong
And we cannot use
SidBuffer[32]because the size ofSidBuffer[]on the client side is not necessarily 32.Quoted 17 lines · ZhangGuoDong
Hi Namjae,
C structure cannot have two flexible array members.
If we make
Sids[]a flexible array member, then there cannot be any members after it. However, this structure still hasfilenamelengthandfilename[]after it. Andfilename[]is also a flexible array member.Do you have any suggestions for this?
Quoted 7 lines · Namjae Jeon
You need to add Sids[] flex array here.
Quoted 6 lines
+ // var sized owner SID
+ // var sized group SID
+ /* end of POSIX Create Context Response */ + // le32 filenamelength
+ // u8 filename[]
+}__packed;
Signature · 2 lines
Thanks, ChenXiaoSong <[email protected]>
ChenXiaoSong
reviewerRe: [PATCH v4 5/5] smb: introduce struct file_posix_info
Hi Steve,
In client-side, it seems there is a bug in the smb2_compound_op():
SMB2_query_info_init(..., sizeof(struct smb311_posix_qinfo *) + ...)
We should calculate the size of struct smb311_posix_qinfo, not the size of its pointer.
Code refactoring is very meaningful as it can uncover some potential issues.
Thanks,
ChenXiaoSong <[email protected]>
Quoted 25 lines · ChenXiaoSong
How about merging the two flexible array members and naming it
sids_and_name[]?Quoted 21 lines · ZhangGuoDong
And we cannot use
SidBuffer[32]because the size ofSidBuffer[]on the client side is not necessarily 32.Quoted 17 lines · ZhangGuoDong
Hi Namjae,
C structure cannot have two flexible array members.
If we make
Sids[]a flexible array member, then there cannot be any members after it. However, this structure still hasfilenamelengthandfilename[]after it. Andfilename[]is also a flexible array member.Do you have any suggestions for this?
Quoted 7 lines · Namjae Jeon
You need to add Sids[] flex array here.
Quoted 6 lines
+ // var sized owner SID
+ // var sized group SID
+ /* end of POSIX Create Context Response */ + // le32 filenamelength
+ // u8 filename[]
+}__packed;
ChenXiaoSong
reviewerRe: [PATCH v4 5/5] smb: introduce struct file_posix_info
SMB311_posix_query_info() also has the same issue:
output_len = sizeof(struct file_posix_info *) + ...
I have already told ZhangGuoDong to submit patches to fix these issues.
Thanks,
ChenXiaoSong <[email protected]>
Quoted 7 lines · ChenXiaoSong
In client-side, it seems there is a bug in the
smb2_compound_op():
SMB2_query_info_init(..., sizeof(struct smb311_posix_qinfo *) + ...)We should calculate the size of
struct smb311_posix_qinfo, not the size of its pointer.Code refactoring is very meaningful as it can uncover some potential issues.