* [PATCH v4 0/5] smb: move duplicate definitions into common header file, part 2
@ 2026-02-25 4:10 zhang.guodong
2026-02-25 4:10 ` [PATCH v4 1/5] smb: move some definitions from common/smb2pdu.h into common/fscc.h zhang.guodong
` (4 more replies)
0 siblings, 5 replies; 15+ messages in thread
From: zhang.guodong @ 2026-02-25 4:10 UTC (permalink / raw)
To: smfrench, linkinjeon, chenxiaosong; +Cc: linux-cifs, ZhangGuoDong
From: ZhangGuoDong <zhangguodong@kylinos.cn>
v3->v4:
- Patch #03: __le32 VolumeSerialNumber
- Add patch #04
v3: https://lore.kernel.org/linux-cifs/20260216082018.156695-1-zhang.guodong@linux.dev/
v1: https://lore.kernel.org/all/20251209011020.3270989-1-chenxiaosong.chenxiaosong@linux.dev/
v2: https://lore.kernel.org/linux-cifs/20251211143228.172470-1-chenxiaosong.chenxiaosong@linux.dev/
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/20251117112838.473051-1-chenxiaosong.chenxiaosong@linux.dev/
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(-)
--
2.53.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v4 1/5] smb: move some definitions from common/smb2pdu.h into common/fscc.h
2026-02-25 4:10 [PATCH v4 0/5] smb: move duplicate definitions into common header file, part 2 zhang.guodong
@ 2026-02-25 4:10 ` zhang.guodong
2026-02-25 4:10 ` [PATCH v4 2/5] smb: move file_basic_info " zhang.guodong
` (3 subsequent siblings)
4 siblings, 0 replies; 15+ messages in thread
From: zhang.guodong @ 2026-02-25 4:10 UTC (permalink / raw)
To: smfrench, linkinjeon, chenxiaosong
Cc: linux-cifs, ZhangGuoDong, ChenXiaoSong, Steve French
From: ZhangGuoDong <zhangguodong@kylinos.cn>
These definitions are specified in MS-FSCC, so move them into fscc.h.
Only add some documentation references, no other changes.
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Reviewed-by: Steve French <stfrench@microsoft.com>
---
fs/smb/common/fscc.h | 315 ++++++++++++++++++++++++++++++++++++++++
fs/smb/common/smb2pdu.h | 307 ---------------------------------------
2 files changed, 315 insertions(+), 307 deletions(-)
diff --git a/fs/smb/common/fscc.h b/fs/smb/common/fscc.h
index 0123f34db1e8..415cba02d1c9 100644
--- a/fs/smb/common/fscc.h
+++ b/fs/smb/common/fscc.h
@@ -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
diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
index e482c86ceb00..538e7a12ea93 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -1006,22 +1006,6 @@ struct smb2_set_info_rsp {
#define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
#define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
-/*
- * 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
-
/* See MS-SMB2 2.2.35 */
struct smb2_change_notify_req {
struct smb2_hdr hdr;
@@ -1499,105 +1483,6 @@ struct network_interface_info_ioctl_rsp {
};
} __packed;
-/* this goes in the ioctl buffer when doing FSCTL_SET_ZERO_DATA */
-struct file_zero_data_information {
- __le64 FileOffset;
- __le64 BeyondFinalZero;
-} __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.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;
-
/* Integrity ChecksumAlgorithm choices for above */
#define CHECKSUM_TYPE_NONE 0x0000
#define CHECKSUM_TYPE_CRC64 0x0002
@@ -1606,72 +1491,6 @@ struct fsctl_set_integrity_info_ex_req {
/* Integrity flags for above */
#define FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF 0x00000001
-/* 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;
-
struct validate_negotiate_info_req {
__le32 Capabilities;
__u8 Guid[SMB2_CLIENT_GUID_SIZE];
@@ -1791,84 +1610,6 @@ struct smb2_query_info_rsp {
__u8 Buffer[];
} __packed;
-/*
- * PDU query infolevel structure definitions
- */
-
-/* See MS-FSCC 2.3.52 */
-struct file_allocated_range_buffer {
- __le64 file_offset;
- __le64 length;
-} __packed;
-
-struct smb2_file_internal_info {
- __le64 IndexNumber;
-} __packed; /* level 6 Query */
-
-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()");
-
-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()");
-
-/*
- * 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.
- */
-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 */
-
-struct smb2_file_eof_info { /* encoding of request for level 10 */
- __le64 EndOfFile; /* new end of file value */
-} __packed; /* level 20 Set */
-
/* Level 100 query info */
struct smb311_posix_qinfo {
__le64 CreationTime;
@@ -1894,54 +1635,6 @@ struct smb311_posix_qinfo {
*/
} __packed;
-/* File System Information Classes */
-#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 */
-#define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */
-
-struct smb2_fs_full_size_info {
- __le64 TotalAllocationUnits;
- __le64 CallerAvailableAllocationUnits;
- __le64 ActualAvailableAllocationUnits;
- __le32 SectorsPerAllocationUnit;
- __le32 BytesPerSector;
-} __packed;
-
-#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;
-
-/* File System Control Information */
-struct smb2_fs_control_info {
- __le64 FreeSpaceStartFiltering;
- __le64 FreeSpaceThreshold;
- __le64 FreeSpaceStopFiltering;
- __le64 DefaultQuotaThreshold;
- __le64 DefaultQuotaLimit;
- __le32 FileSystemControlFlags;
- __le32 Padding;
-} __packed;
-
/* volume info struct - see MS-FSCC 2.5.9 */
#define MAX_VOL_LABEL_LEN 32
struct smb3_fs_vol_info {
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 2/5] smb: move file_basic_info into common/fscc.h
2026-02-25 4:10 [PATCH v4 0/5] smb: move duplicate definitions into common header file, part 2 zhang.guodong
2026-02-25 4:10 ` [PATCH v4 1/5] smb: move some definitions from common/smb2pdu.h into common/fscc.h zhang.guodong
@ 2026-02-25 4:10 ` zhang.guodong
2026-02-25 4:10 ` [PATCH v4 3/5] smb: move filesystem_vol_info " zhang.guodong
` (2 subsequent siblings)
4 siblings, 0 replies; 15+ messages in thread
From: zhang.guodong @ 2026-02-25 4:10 UTC (permalink / raw)
To: smfrench, linkinjeon, chenxiaosong; +Cc: linux-cifs, ZhangGuoDong, ChenXiaoSong
From: ZhangGuoDong <zhangguodong@kylinos.cn>
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
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
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(-)
diff --git a/fs/smb/client/smb1pdu.h b/fs/smb/client/smb1pdu.h
index 97f7e1244a8b..7584e94d9b2b 100644
--- a/fs/smb/client/smb1pdu.h
+++ b/fs/smb/client/smb1pdu.h
@@ -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 */
diff --git a/fs/smb/common/fscc.h b/fs/smb/common/fscc.h
index 415cba02d1c9..076cbcffa26a 100644
--- a/fs/smb/common/fscc.h
+++ b/fs/smb/common/fscc.h
@@ -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;
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 95901a78951c..c787d9fd6dd2 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -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:
{
diff --git a/fs/smb/server/smb2pdu.h b/fs/smb/server/smb2pdu.h
index 257c6d26df26..9b3c4c9acb11 100644
--- a/fs/smb/server/smb2pdu.h
+++ b/fs/smb/server/smb2pdu.h
@@ -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[];
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 3/5] smb: move filesystem_vol_info into common/fscc.h
2026-02-25 4:10 [PATCH v4 0/5] smb: move duplicate definitions into common header file, part 2 zhang.guodong
2026-02-25 4:10 ` [PATCH v4 1/5] smb: move some definitions from common/smb2pdu.h into common/fscc.h zhang.guodong
2026-02-25 4:10 ` [PATCH v4 2/5] smb: move file_basic_info " zhang.guodong
@ 2026-02-25 4:10 ` zhang.guodong
2026-02-27 2:37 ` Namjae Jeon
2026-02-25 4:10 ` [PATCH v4 4/5] smb: update some doc references zhang.guodong
2026-02-25 4:11 ` [PATCH v4 5/5] smb: introduce struct file_posix_info zhang.guodong
4 siblings, 1 reply; 15+ messages in thread
From: zhang.guodong @ 2026-02-25 4:10 UTC (permalink / raw)
To: smfrench, linkinjeon, chenxiaosong
Cc: linux-cifs, ZhangGuoDong, ChenXiaoSong, Steve French
From: ZhangGuoDong <zhangguodong@kylinos.cn>
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.
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Reviewed-by: Steve French <stfrench@microsoft.com>
---
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(-)
diff --git a/fs/smb/client/cifs_debug.c b/fs/smb/client/cifs_debug.c
index 217444e3e6d0..8bb909a57edf 100644
--- a/fs/smb/client/cifs_debug.c
+++ b/fs/smb/client/cifs_debug.c
@@ -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) ||
diff --git a/fs/smb/client/cifs_ioctl.h b/fs/smb/client/cifs_ioctl.h
index 147496ac9f9f..b512d8af017f 100644
--- a/fs/smb/client/cifs_ioctl.h
+++ b/fs/smb/client/cifs_ioctl.h
@@ -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;
diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c
index 427558404aa5..93e9cfa042eb 100644
--- a/fs/smb/client/cifsfs.c
+++ b/fs/smb/client/cifsfs.c
@@ -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);
diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index 6f9b6c72962b..aa4462b0df25 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -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 */
diff --git a/fs/smb/client/fscache.c b/fs/smb/client/fscache.c
index 01424a5cdb99..9801b7fa58ac 100644
--- a/fs/smb/client/fscache.c
+++ b/fs/smb/client/fscache.c
@@ -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)
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index a2a96d817717..c7004b4eb87c 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -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;
diff --git a/fs/smb/common/fscc.h b/fs/smb/common/fscc.h
index 076cbcffa26a..b4ccddca9256 100644
--- a/fs/smb/common/fscc.h
+++ b/fs/smb/common/fscc.h
@@ -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;
diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
index 538e7a12ea93..85a4248d4f29 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -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;
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index c787d9fd6dd2..b5dcd9cff2e2 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -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;
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index ca7e3610d074..b090b56743c4 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -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
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 4/5] smb: update some doc references
2026-02-25 4:10 [PATCH v4 0/5] smb: move duplicate definitions into common header file, part 2 zhang.guodong
` (2 preceding siblings ...)
2026-02-25 4:10 ` [PATCH v4 3/5] smb: move filesystem_vol_info " zhang.guodong
@ 2026-02-25 4:10 ` zhang.guodong
2026-03-01 17:41 ` Steve French
2026-02-25 4:11 ` [PATCH v4 5/5] smb: introduce struct file_posix_info zhang.guodong
4 siblings, 1 reply; 15+ messages in thread
From: zhang.guodong @ 2026-02-25 4:10 UTC (permalink / raw)
To: smfrench, linkinjeon, chenxiaosong; +Cc: linux-cifs, ZhangGuoDong, ChenXiaoSong
From: ZhangGuoDong <zhangguodong@kylinos.cn>
To make it easier to locate the documentation during development.
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/smb2pdu.h | 7 +++++--
fs/smb/server/smb2pdu.h | 5 ++++-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
index 78bb99f29d38..30d70097fe2f 100644
--- a/fs/smb/client/smb2pdu.h
+++ b/fs/smb/client/smb2pdu.h
@@ -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;
diff --git a/fs/smb/server/smb2pdu.h b/fs/smb/server/smb2pdu.h
index 9b3c4c9acb11..e7cf573e59f0 100644
--- a/fs/smb/server/smb2pdu.h
+++ b/fs/smb/server/smb2pdu.h
@@ -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
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v4 5/5] smb: introduce struct file_posix_info
2026-02-25 4:10 [PATCH v4 0/5] smb: move duplicate definitions into common header file, part 2 zhang.guodong
` (3 preceding siblings ...)
2026-02-25 4:10 ` [PATCH v4 4/5] smb: update some doc references zhang.guodong
@ 2026-02-25 4:11 ` zhang.guodong
2026-02-27 4:37 ` Namjae Jeon
4 siblings, 1 reply; 15+ messages in thread
From: zhang.guodong @ 2026-02-25 4:11 UTC (permalink / raw)
To: smfrench, linkinjeon, chenxiaosong; +Cc: linux-cifs, ZhangGuoDong, ChenXiaoSong
From: ZhangGuoDong <zhangguodong@kylinos.cn>
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"
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
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(-)
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index 3e844c55ab8a..ebed32bf1c05 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -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) &&
diff --git a/fs/smb/client/readdir.c b/fs/smb/client/readdir.c
index be22bbc4a65a..6239d70e7984 100644
--- a/fs/smb/client/readdir.c
+++ b/fs/smb/client/readdir.c
@@ -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,
diff --git a/fs/smb/client/reparse.h b/fs/smb/client/reparse.h
index 0164dc47bdfd..57dccca0e9d4 100644
--- a/fs/smb/client/reparse.h
+++ b/fs/smb/client/reparse.h
@@ -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 {
diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
index 30d70097fe2f..74a332d9cbeb 100644
--- a/fs/smb/client/smb2pdu.h
+++ b/fs/smb/client/smb2pdu.h
@@ -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
diff --git a/fs/smb/common/fscc.h b/fs/smb/common/fscc.h
index b4ccddca9256..0d8c522f757a 100644
--- a/fs/smb/common/fscc.h
+++ b/fs/smb/common/fscc.h
@@ -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;
+ __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;
+ // 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 {
+ struct file_posix_info fpinfo;
+ u8 Sids[];
+ /*
+ * le32 filenamelength
+ * u8 filename[]
+ */
+} __packed;
+
+/* See POSIX-FSCC 2.3.2.1 */
typedef struct {
/* For undefined recommended transfer size return -1 in that field */
__le32 OptimalTransferSize; /* bsize on some os, iosize on other os */
diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
index 85a4248d4f29..9abfabb79dad 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -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;
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index b5dcd9cff2e2..460bf835ad40 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -4051,44 +4051,44 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level,
posix_info = (struct smb2_posix_info *)kstat;
posix_info->Ignored = 0;
- posix_info->CreationTime = cpu_to_le64(ksmbd_kstat->create_time);
+ posix_info->fpinfo.CreationTime = cpu_to_le64(ksmbd_kstat->create_time);
time = ksmbd_UnixTimeToNT(ksmbd_kstat->kstat->ctime);
- posix_info->ChangeTime = cpu_to_le64(time);
+ posix_info->fpinfo.ChangeTime = cpu_to_le64(time);
time = ksmbd_UnixTimeToNT(ksmbd_kstat->kstat->atime);
- posix_info->LastAccessTime = cpu_to_le64(time);
+ posix_info->fpinfo.LastAccessTime = cpu_to_le64(time);
time = ksmbd_UnixTimeToNT(ksmbd_kstat->kstat->mtime);
- posix_info->LastWriteTime = cpu_to_le64(time);
- posix_info->EndOfFile = cpu_to_le64(ksmbd_kstat->kstat->size);
- posix_info->AllocationSize = cpu_to_le64(ksmbd_kstat->kstat->blocks << 9);
- posix_info->DeviceId = cpu_to_le32(ksmbd_kstat->kstat->rdev);
- posix_info->HardLinks = cpu_to_le32(ksmbd_kstat->kstat->nlink);
- posix_info->Mode = cpu_to_le32(ksmbd_kstat->kstat->mode & 0777);
+ posix_info->fpinfo.LastWriteTime = cpu_to_le64(time);
+ posix_info->fpinfo.EndOfFile = cpu_to_le64(ksmbd_kstat->kstat->size);
+ posix_info->fpinfo.AllocationSize = cpu_to_le64(ksmbd_kstat->kstat->blocks << 9);
+ posix_info->fpinfo.DeviceId = cpu_to_le32(ksmbd_kstat->kstat->rdev);
+ posix_info->fpinfo.HardLinks = cpu_to_le32(ksmbd_kstat->kstat->nlink);
+ posix_info->fpinfo.Mode = cpu_to_le32(ksmbd_kstat->kstat->mode & 0777);
switch (ksmbd_kstat->kstat->mode & S_IFMT) {
case S_IFDIR:
- posix_info->Mode |= cpu_to_le32(POSIX_TYPE_DIR << POSIX_FILETYPE_SHIFT);
+ posix_info->fpinfo.Mode |= cpu_to_le32(POSIX_TYPE_DIR << POSIX_FILETYPE_SHIFT);
break;
case S_IFLNK:
- posix_info->Mode |= cpu_to_le32(POSIX_TYPE_SYMLINK << POSIX_FILETYPE_SHIFT);
+ posix_info->fpinfo.Mode |= cpu_to_le32(POSIX_TYPE_SYMLINK << POSIX_FILETYPE_SHIFT);
break;
case S_IFCHR:
- posix_info->Mode |= cpu_to_le32(POSIX_TYPE_CHARDEV << POSIX_FILETYPE_SHIFT);
+ posix_info->fpinfo.Mode |= cpu_to_le32(POSIX_TYPE_CHARDEV << POSIX_FILETYPE_SHIFT);
break;
case S_IFBLK:
- posix_info->Mode |= cpu_to_le32(POSIX_TYPE_BLKDEV << POSIX_FILETYPE_SHIFT);
+ posix_info->fpinfo.Mode |= cpu_to_le32(POSIX_TYPE_BLKDEV << POSIX_FILETYPE_SHIFT);
break;
case S_IFIFO:
- posix_info->Mode |= cpu_to_le32(POSIX_TYPE_FIFO << POSIX_FILETYPE_SHIFT);
+ posix_info->fpinfo.Mode |= cpu_to_le32(POSIX_TYPE_FIFO << POSIX_FILETYPE_SHIFT);
break;
case S_IFSOCK:
- posix_info->Mode |= cpu_to_le32(POSIX_TYPE_SOCKET << POSIX_FILETYPE_SHIFT);
+ posix_info->fpinfo.Mode |= cpu_to_le32(POSIX_TYPE_SOCKET << POSIX_FILETYPE_SHIFT);
}
- posix_info->Inode = cpu_to_le64(ksmbd_kstat->kstat->ino);
- posix_info->DosAttributes =
+ posix_info->fpinfo.Inode = cpu_to_le64(ksmbd_kstat->kstat->ino);
+ posix_info->fpinfo.DosAttributes =
S_ISDIR(ksmbd_kstat->kstat->mode) ?
FILE_ATTRIBUTE_DIRECTORY_LE : FILE_ATTRIBUTE_ARCHIVE_LE;
if (d_info->hide_dot_file && d_info->name[0] == '.')
- posix_info->DosAttributes |= FILE_ATTRIBUTE_HIDDEN_LE;
+ posix_info->fpinfo.DosAttributes |= FILE_ATTRIBUTE_HIDDEN_LE;
/*
* SidBuffer(32) contain two sids(Domain sid(16), UNIX group sid(16)).
* UNIX sid(16) = revision(1) + num_subauth(1) + authority(6) +
@@ -5276,45 +5276,45 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
return ret;
file_info = (struct smb311_posix_qinfo *)rsp->Buffer;
- file_info->CreationTime = cpu_to_le64(fp->create_time);
+ file_info->fpinfo.CreationTime = cpu_to_le64(fp->create_time);
time = ksmbd_UnixTimeToNT(stat.atime);
- file_info->LastAccessTime = cpu_to_le64(time);
+ file_info->fpinfo.LastAccessTime = cpu_to_le64(time);
time = ksmbd_UnixTimeToNT(stat.mtime);
- file_info->LastWriteTime = cpu_to_le64(time);
+ file_info->fpinfo.LastWriteTime = cpu_to_le64(time);
time = ksmbd_UnixTimeToNT(stat.ctime);
- file_info->ChangeTime = cpu_to_le64(time);
- file_info->DosAttributes = fp->f_ci->m_fattr;
- file_info->Inode = cpu_to_le64(stat.ino);
+ file_info->fpinfo.ChangeTime = cpu_to_le64(time);
+ file_info->fpinfo.DosAttributes = fp->f_ci->m_fattr;
+ file_info->fpinfo.Inode = cpu_to_le64(stat.ino);
if (ksmbd_stream_fd(fp) == false) {
- file_info->EndOfFile = cpu_to_le64(stat.size);
- file_info->AllocationSize = cpu_to_le64(stat.blocks << 9);
+ file_info->fpinfo.EndOfFile = cpu_to_le64(stat.size);
+ file_info->fpinfo.AllocationSize = cpu_to_le64(stat.blocks << 9);
} else {
- file_info->EndOfFile = cpu_to_le64(fp->stream.size);
- file_info->AllocationSize = cpu_to_le64(fp->stream.size);
+ file_info->fpinfo.EndOfFile = cpu_to_le64(fp->stream.size);
+ file_info->fpinfo.AllocationSize = cpu_to_le64(fp->stream.size);
}
- file_info->HardLinks = cpu_to_le32(stat.nlink);
- file_info->Mode = cpu_to_le32(stat.mode & 0777);
+ file_info->fpinfo.HardLinks = cpu_to_le32(stat.nlink);
+ file_info->fpinfo.Mode = cpu_to_le32(stat.mode & 0777);
switch (stat.mode & S_IFMT) {
case S_IFDIR:
- file_info->Mode |= cpu_to_le32(POSIX_TYPE_DIR << POSIX_FILETYPE_SHIFT);
+ file_info->fpinfo.Mode |= cpu_to_le32(POSIX_TYPE_DIR << POSIX_FILETYPE_SHIFT);
break;
case S_IFLNK:
- file_info->Mode |= cpu_to_le32(POSIX_TYPE_SYMLINK << POSIX_FILETYPE_SHIFT);
+ file_info->fpinfo.Mode |= cpu_to_le32(POSIX_TYPE_SYMLINK << POSIX_FILETYPE_SHIFT);
break;
case S_IFCHR:
- file_info->Mode |= cpu_to_le32(POSIX_TYPE_CHARDEV << POSIX_FILETYPE_SHIFT);
+ file_info->fpinfo.Mode |= cpu_to_le32(POSIX_TYPE_CHARDEV << POSIX_FILETYPE_SHIFT);
break;
case S_IFBLK:
- file_info->Mode |= cpu_to_le32(POSIX_TYPE_BLKDEV << POSIX_FILETYPE_SHIFT);
+ file_info->fpinfo.Mode |= cpu_to_le32(POSIX_TYPE_BLKDEV << POSIX_FILETYPE_SHIFT);
break;
case S_IFIFO:
- file_info->Mode |= cpu_to_le32(POSIX_TYPE_FIFO << POSIX_FILETYPE_SHIFT);
+ file_info->fpinfo.Mode |= cpu_to_le32(POSIX_TYPE_FIFO << POSIX_FILETYPE_SHIFT);
break;
case S_IFSOCK:
- file_info->Mode |= cpu_to_le32(POSIX_TYPE_SOCKET << POSIX_FILETYPE_SHIFT);
+ file_info->fpinfo.Mode |= cpu_to_le32(POSIX_TYPE_SOCKET << POSIX_FILETYPE_SHIFT);
}
- file_info->DeviceId = cpu_to_le32(stat.rdev);
+ file_info->fpinfo.DeviceId = cpu_to_le32(stat.rdev);
/*
* Sids(32) contain two sids(Domain sid(16), UNIX group sid(16)).
diff --git a/fs/smb/server/smb2pdu.h b/fs/smb/server/smb2pdu.h
index e7cf573e59f0..f05273f48bd0 100644
--- a/fs/smb/server/smb2pdu.h
+++ b/fs/smb/server/smb2pdu.h
@@ -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 */
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v4 3/5] smb: move filesystem_vol_info into common/fscc.h
2026-02-25 4:10 ` [PATCH v4 3/5] smb: move filesystem_vol_info " zhang.guodong
@ 2026-02-27 2:37 ` Namjae Jeon
2026-02-27 2:48 ` ZhangGuoDong
0 siblings, 1 reply; 15+ messages in thread
From: Namjae Jeon @ 2026-02-27 2:37 UTC (permalink / raw)
To: zhang.guodong
Cc: smfrench, chenxiaosong, linux-cifs, ZhangGuoDong, ChenXiaoSong,
Steve French
On Wed, Feb 25, 2026 at 1:12 PM <zhang.guodong@linux.dev> wrote:
>
> From: ZhangGuoDong <zhangguodong@kylinos.cn>
>
> 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
Why did you change vol_serial_number from u32 to __le32 ?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 3/5] smb: move filesystem_vol_info into common/fscc.h
2026-02-27 2:37 ` Namjae Jeon
@ 2026-02-27 2:48 ` ZhangGuoDong
0 siblings, 0 replies; 15+ messages in thread
From: ZhangGuoDong @ 2026-02-27 2:48 UTC (permalink / raw)
To: Namjae Jeon
Cc: smfrench, chenxiaosong, linux-cifs, ZhangGuoDong, ChenXiaoSong,
Steve French
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?
On 2026/2/27 10:37, Namjae Jeon wrote:
> Why did you change vol_serial_number from u32 to __le32 ?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 5/5] smb: introduce struct file_posix_info
2026-02-25 4:11 ` [PATCH v4 5/5] smb: introduce struct file_posix_info zhang.guodong
@ 2026-02-27 4:37 ` Namjae Jeon
2026-03-03 2:41 ` ZhangGuoDong
0 siblings, 1 reply; 15+ messages in thread
From: Namjae Jeon @ 2026-02-27 4:37 UTC (permalink / raw)
To: zhang.guodong
Cc: smfrench, chenxiaosong, linux-cifs, ZhangGuoDong, ChenXiaoSong
It doesn't seem to have been updated as I said.
> diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
> index 30d70097fe2f..74a332d9cbeb 100644
> --- a/fs/smb/client/smb2pdu.h
> +++ b/fs/smb/client/smb2pdu.h
> @@ -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
Please remove these comments included filename and move it to /common.
> diff --git a/fs/smb/common/fscc.h b/fs/smb/common/fscc.h
> index b4ccddca9256..0d8c522f757a 100644
> --- a/fs/smb/common/fscc.h
> +++ b/fs/smb/common/fscc.h
> @@ -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;
> + __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.
> + // 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 ?
> + struct file_posix_info fpinfo;
> + u8 Sids[];
> + /*
> + * le32 filenamelength
> + * u8 filename[]
> + */
> +} __packed;
> diff --git a/fs/smb/server/smb2pdu.h b/fs/smb/server/smb2pdu.h
> index e7cf573e59f0..f05273f48bd0 100644
> --- a/fs/smb/server/smb2pdu.h
> +++ b/fs/smb/server/smb2pdu.h
> @@ -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;
It should be replaced with smb2_posix_info in common.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 4/5] smb: update some doc references
2026-02-25 4:10 ` [PATCH v4 4/5] smb: update some doc references zhang.guodong
@ 2026-03-01 17:41 ` Steve French
0 siblings, 0 replies; 15+ messages in thread
From: Steve French @ 2026-03-01 17:41 UTC (permalink / raw)
To: zhang.guodong
Cc: linkinjeon, chenxiaosong, linux-cifs, ZhangGuoDong, ChenXiaoSong
added to cifs-2.6.git for-next
On Tue, Feb 24, 2026 at 10:12 PM <zhang.guodong@linux.dev> wrote:
>
> From: ZhangGuoDong <zhangguodong@kylinos.cn>
>
> To make it easier to locate the documentation during development.
>
> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
> Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> ---
> fs/smb/client/smb2pdu.h | 7 +++++--
> fs/smb/server/smb2pdu.h | 5 ++++-
> 2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
> index 78bb99f29d38..30d70097fe2f 100644
> --- a/fs/smb/client/smb2pdu.h
> +++ b/fs/smb/client/smb2pdu.h
> @@ -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;
> diff --git a/fs/smb/server/smb2pdu.h b/fs/smb/server/smb2pdu.h
> index 9b3c4c9acb11..e7cf573e59f0 100644
> --- a/fs/smb/server/smb2pdu.h
> +++ b/fs/smb/server/smb2pdu.h
> @@ -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
>
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 5/5] smb: introduce struct file_posix_info
2026-02-27 4:37 ` Namjae Jeon
@ 2026-03-03 2:41 ` ZhangGuoDong
2026-03-03 3:00 ` ZhangGuoDong
0 siblings, 1 reply; 15+ messages in thread
From: ZhangGuoDong @ 2026-03-03 2:41 UTC (permalink / raw)
To: Namjae Jeon
Cc: smfrench, chenxiaosong, linux-cifs, ZhangGuoDong, ChenXiaoSong
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?
在 2026/2/27 12:37, Namjae Jeon 写道:
> You need to add Sids[] flex array here.
>> + // var sized owner SID
>> + // var sized group SID
>> + /* end of POSIX Create Context Response */
>> + // le32 filenamelength
>> + // u8 filename[]
>> +} __packed;
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 5/5] smb: introduce struct file_posix_info
2026-03-03 2:41 ` ZhangGuoDong
@ 2026-03-03 3:00 ` ZhangGuoDong
2026-03-03 7:31 ` ChenXiaoSong
0 siblings, 1 reply; 15+ messages in thread
From: ZhangGuoDong @ 2026-03-03 3:00 UTC (permalink / raw)
To: Namjae Jeon
Cc: smfrench, chenxiaosong, linux-cifs, ZhangGuoDong, ChenXiaoSong
And we cannot use `SidBuffer[32]` because the size of `SidBuffer[]` on
the client side is not necessarily 32.
在 2026/3/3 10:41, 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 has `filenamelength` and
> `filename[]` after it. And `filename[]` is also a flexible array member.
>
> Do you have any suggestions for this?
>
> 在 2026/2/27 12:37, Namjae Jeon 写道:
>> You need to add Sids[] flex array here.
>>> + // var sized owner SID
>>> + // var sized group SID
>>> + /* end of POSIX Create Context Response */
>>> + // le32 filenamelength
>>> + // u8 filename[]
>>> +} __packed;
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 5/5] smb: introduce struct file_posix_info
2026-03-03 3:00 ` ZhangGuoDong
@ 2026-03-03 7:31 ` ChenXiaoSong
2026-03-03 8:58 ` ChenXiaoSong
0 siblings, 1 reply; 15+ messages in thread
From: ChenXiaoSong @ 2026-03-03 7:31 UTC (permalink / raw)
To: ZhangGuoDong, Namjae Jeon
Cc: smfrench, linux-cifs, ZhangGuoDong, ChenXiaoSong
How about merging the two flexible array members and naming it
`sids_and_name[]`?
在 2026/3/3 11:00, ZhangGuoDong 写道:
> And we cannot use `SidBuffer[32]` because the size of `SidBuffer[]` on
> the client side is not necessarily 32.
>
> 在 2026/3/3 10:41, 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 has `filenamelength`
>> and `filename[]` after it. And `filename[]` is also a flexible array
>> member.
>>
>> Do you have any suggestions for this?
>>
>> 在 2026/2/27 12:37, Namjae Jeon 写道:
>>> You need to add Sids[] flex array here.
>>>> + // var sized owner SID
>>>> + // var sized group SID
>>>> + /* end of POSIX Create Context Response */
>>>> + // le32 filenamelength
>>>> + // u8 filename[]
>>>> +} __packed;
>>
>
--
Thanks,
ChenXiaoSong <chenxiaosong@chenxiaosong.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 5/5] smb: introduce struct file_posix_info
2026-03-03 7:31 ` ChenXiaoSong
@ 2026-03-03 8:58 ` ChenXiaoSong
2026-03-03 9:41 ` ChenXiaoSong
0 siblings, 1 reply; 15+ messages in thread
From: ChenXiaoSong @ 2026-03-03 8:58 UTC (permalink / raw)
To: ZhangGuoDong, Namjae Jeon, smfrench
Cc: linux-cifs, ZhangGuoDong, ChenXiaoSong
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 <chenxiaosong@chenxiaosong.com>
在 2026/3/3 15:31, ChenXiaoSong 写道:
> How about merging the two flexible array members and naming it
> `sids_and_name[]`?
>
> 在 2026/3/3 11:00, ZhangGuoDong 写道:
>> And we cannot use `SidBuffer[32]` because the size of `SidBuffer[]` on
>> the client side is not necessarily 32.
>>
>> 在 2026/3/3 10:41, 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 has `filenamelength`
>>> and `filename[]` after it. And `filename[]` is also a flexible array
>>> member.
>>>
>>> Do you have any suggestions for this?
>>>
>>> 在 2026/2/27 12:37, Namjae Jeon 写道:
>>>> You need to add Sids[] flex array here.
>>>>> + // var sized owner SID
>>>>> + // var sized group SID
>>>>> + /* end of POSIX Create Context Response */
>>>>> + // le32 filenamelength
>>>>> + // u8 filename[]
>>>>> +} __packed;
>>>
>>
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v4 5/5] smb: introduce struct file_posix_info
2026-03-03 8:58 ` ChenXiaoSong
@ 2026-03-03 9:41 ` ChenXiaoSong
0 siblings, 0 replies; 15+ messages in thread
From: ChenXiaoSong @ 2026-03-03 9:41 UTC (permalink / raw)
To: ZhangGuoDong, Namjae Jeon, smfrench
Cc: linux-cifs, ZhangGuoDong, ChenXiaoSong
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 <chenxiaosong@chenxiaosong.com>
在 2026/3/3 16:58, 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.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2026-03-03 9:41 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-25 4:10 [PATCH v4 0/5] smb: move duplicate definitions into common header file, part 2 zhang.guodong
2026-02-25 4:10 ` [PATCH v4 1/5] smb: move some definitions from common/smb2pdu.h into common/fscc.h zhang.guodong
2026-02-25 4:10 ` [PATCH v4 2/5] smb: move file_basic_info " zhang.guodong
2026-02-25 4:10 ` [PATCH v4 3/5] smb: move filesystem_vol_info " zhang.guodong
2026-02-27 2:37 ` Namjae Jeon
2026-02-27 2:48 ` ZhangGuoDong
2026-02-25 4:10 ` [PATCH v4 4/5] smb: update some doc references zhang.guodong
2026-03-01 17:41 ` Steve French
2026-02-25 4:11 ` [PATCH v4 5/5] smb: introduce struct file_posix_info zhang.guodong
2026-02-27 4:37 ` Namjae Jeon
2026-03-03 2:41 ` ZhangGuoDong
2026-03-03 3:00 ` ZhangGuoDong
2026-03-03 7:31 ` ChenXiaoSong
2026-03-03 8:58 ` ChenXiaoSong
2026-03-03 9:41 ` ChenXiaoSong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox