public inbox for linux-cifs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/7] smb: fix some bugs, move duplicate definitions into common header file, part 2
@ 2026-03-03 15:13 zhang.guodong
  2026-03-03 15:13 ` [PATCH v5 1/7] smb/client: fix buffer size for smb311_posix_qinfo in smb2_compound_op() zhang.guodong
                   ` (7 more replies)
  0 siblings, 8 replies; 18+ messages in thread
From: zhang.guodong @ 2026-03-03 15:13 UTC (permalink / raw)
  To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, chenxiaosong
  Cc: linux-cifs

From: ZhangGuoDong <zhangguodong@kylinos.cn>

v4->v5:
  - Add patch #01 #02 #03
  - Patch #06: keep vol_serial_number as u32 in smb_mnt_fs_info and cifs_tcon
  - Patch #07:
    - Add new flexible array member `sids_and_name[]` to file_posix_info
    - smb311_posix_qinfo -> file_posix_info

v4: https://lore.kernel.org/linux-cifs/20260225041100.707468-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

The following patches from v4 have already been merged into cifs-2.6.git for-next:
  - smb: update some doc references

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 (7):
  smb/client: fix buffer size for smb311_posix_qinfo in
    smb2_compound_op()
  smb/client: fix buffer size for smb311_posix_qinfo in
    SMB311_posix_query_info()
  smb/client: remove unused SMB311_posix_query_info()
  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: introduce struct file_posix_info

 fs/smb/client/cifsglob.h   |   2 +-
 fs/smb/client/inode.c      |   2 +-
 fs/smb/client/readdir.c    |  28 +--
 fs/smb/client/reparse.h    |   2 +-
 fs/smb/client/smb1pdu.h    |   9 -
 fs/smb/client/smb2inode.c  |   4 +-
 fs/smb/client/smb2pdu.c    |  26 +--
 fs/smb/client/smb2pdu.h    |  21 +--
 fs/smb/client/smb2proto.h  |   3 -
 fs/smb/common/fscc.h       | 371 ++++++++++++++++++++++++++++++++++++-
 fs/smb/common/smb2pdu.h    | 343 ----------------------------------
 fs/smb/server/smb2pdu.c    |  65 +++----
 fs/smb/server/smb2pdu.h    |  30 +--
 fs/smb/server/smb_common.h |   8 -
 14 files changed, 428 insertions(+), 486 deletions(-)

-- 
2.52.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v5 1/7] smb/client: fix buffer size for smb311_posix_qinfo in smb2_compound_op()
  2026-03-03 15:13 [PATCH v5 0/7] smb: fix some bugs, move duplicate definitions into common header file, part 2 zhang.guodong
@ 2026-03-03 15:13 ` zhang.guodong
  2026-03-03 23:58   ` Steve French
  2026-03-04  0:06   ` Steve French
  2026-03-03 15:13 ` [PATCH v5 2/7] smb/client: fix buffer size for smb311_posix_qinfo in SMB311_posix_query_info() zhang.guodong
                   ` (6 subsequent siblings)
  7 siblings, 2 replies; 18+ messages in thread
From: zhang.guodong @ 2026-03-03 15:13 UTC (permalink / raw)
  To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, chenxiaosong
  Cc: linux-cifs

From: ZhangGuoDong <zhangguodong@kylinos.cn>

Use `sizeof(struct smb311_posix_qinfo)` instead of sizeof its pointer,
so the allocated buffer matches the actual struct size.

Fixes: 6a5f6592a0b6 ("SMB311: Add support for query info using posix extensions (level 100)")
Reported-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/client/smb2inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/smb/client/smb2inode.c b/fs/smb/client/smb2inode.c
index 195a38fd61e8..1c4663ed7e69 100644
--- a/fs/smb/client/smb2inode.c
+++ b/fs/smb/client/smb2inode.c
@@ -325,7 +325,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
 							  cfile->fid.volatile_fid,
 							  SMB_FIND_FILE_POSIX_INFO,
 							  SMB2_O_INFO_FILE, 0,
-							  sizeof(struct smb311_posix_qinfo *) +
+							  sizeof(struct smb311_posix_qinfo) +
 							  (PATH_MAX * 2) +
 							  (sizeof(struct smb_sid) * 2), 0, NULL);
 			} else {
@@ -335,7 +335,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
 							  COMPOUND_FID,
 							  SMB_FIND_FILE_POSIX_INFO,
 							  SMB2_O_INFO_FILE, 0,
-							  sizeof(struct smb311_posix_qinfo *) +
+							  sizeof(struct smb311_posix_qinfo) +
 							  (PATH_MAX * 2) +
 							  (sizeof(struct smb_sid) * 2), 0, NULL);
 			}
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v5 2/7] smb/client: fix buffer size for smb311_posix_qinfo in SMB311_posix_query_info()
  2026-03-03 15:13 [PATCH v5 0/7] smb: fix some bugs, move duplicate definitions into common header file, part 2 zhang.guodong
  2026-03-03 15:13 ` [PATCH v5 1/7] smb/client: fix buffer size for smb311_posix_qinfo in smb2_compound_op() zhang.guodong
@ 2026-03-03 15:13 ` zhang.guodong
  2026-03-04  0:05   ` Steve French
  2026-03-03 15:13 ` [PATCH v5 3/7] smb/client: remove unused SMB311_posix_query_info() zhang.guodong
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 18+ messages in thread
From: zhang.guodong @ 2026-03-03 15:13 UTC (permalink / raw)
  To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, chenxiaosong
  Cc: linux-cifs

From: ZhangGuoDong <zhangguodong@kylinos.cn>

SMB311_posix_query_info() is currently unused, but it may still be used in
some stable versions, so these changes are submitted as a separate patch.

Use `sizeof(struct smb311_posix_qinfo)` instead of sizeof its pointer,
so the allocated buffer matches the actual struct size.

Fixes: b1bc1874b885 ("smb311: Add support for SMB311 query info (non-compounded)")
Reported-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/client/smb2pdu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 04e361ed2356..8a1fcc097606 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -3996,7 +3996,7 @@ SMB311_posix_query_info(const unsigned int xid, struct cifs_tcon *tcon,
 			u64 persistent_fid, u64 volatile_fid,
 			struct smb311_posix_qinfo *data, u32 *plen)
 {
-	size_t output_len = sizeof(struct smb311_posix_qinfo *) +
+	size_t output_len = sizeof(struct smb311_posix_qinfo) +
 			(sizeof(struct smb_sid) * 2) + (PATH_MAX * 2);
 	*plen = 0;
 
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v5 3/7] smb/client: remove unused SMB311_posix_query_info()
  2026-03-03 15:13 [PATCH v5 0/7] smb: fix some bugs, move duplicate definitions into common header file, part 2 zhang.guodong
  2026-03-03 15:13 ` [PATCH v5 1/7] smb/client: fix buffer size for smb311_posix_qinfo in smb2_compound_op() zhang.guodong
  2026-03-03 15:13 ` [PATCH v5 2/7] smb/client: fix buffer size for smb311_posix_qinfo in SMB311_posix_query_info() zhang.guodong
@ 2026-03-03 15:13 ` zhang.guodong
  2026-03-04  0:05   ` Steve French
  2026-03-03 15:13 ` [PATCH v5 4/7] smb: move some definitions from common/smb2pdu.h into common/fscc.h zhang.guodong
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 18+ messages in thread
From: zhang.guodong @ 2026-03-03 15:13 UTC (permalink / raw)
  To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, chenxiaosong
  Cc: linux-cifs

From: ZhangGuoDong <zhangguodong@kylinos.cn>

It is currently unused, as now we are doing compounding instead
(see smb2_query_path_info()).

Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/client/smb2pdu.c   | 18 ------------------
 fs/smb/client/smb2proto.h |  3 ---
 2 files changed, 21 deletions(-)

diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 8a1fcc097606..c43ca74e8704 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -3989,24 +3989,6 @@ int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
 			  NULL);
 }
 
-#if 0
-/* currently unused, as now we are doing compounding instead (see smb311_posix_query_path_info) */
-int
-SMB311_posix_query_info(const unsigned int xid, struct cifs_tcon *tcon,
-			u64 persistent_fid, u64 volatile_fid,
-			struct smb311_posix_qinfo *data, u32 *plen)
-{
-	size_t output_len = sizeof(struct smb311_posix_qinfo) +
-			(sizeof(struct smb_sid) * 2) + (PATH_MAX * 2);
-	*plen = 0;
-
-	return query_info(xid, tcon, persistent_fid, volatile_fid,
-			  SMB_FIND_FILE_POSIX_INFO, SMB2_O_INFO_FILE, 0,
-			  output_len, sizeof(struct smb311_posix_qinfo), (void **)&data, plen);
-	/* Note caller must free "data" (passed in above). It may be allocated in query_info call */
-}
-#endif
-
 int
 SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
 	       u64 persistent_fid, u64 volatile_fid,
diff --git a/fs/smb/client/smb2proto.h b/fs/smb/client/smb2proto.h
index 881e42cf66ce..230bb1e9f4e1 100644
--- a/fs/smb/client/smb2proto.h
+++ b/fs/smb/client/smb2proto.h
@@ -167,9 +167,6 @@ int SMB2_flush_init(const unsigned int xid, struct smb_rqst *rqst,
 		    struct cifs_tcon *tcon, struct TCP_Server_Info *server,
 		    u64 persistent_fid, u64 volatile_fid);
 void SMB2_flush_free(struct smb_rqst *rqst);
-int SMB311_posix_query_info(const unsigned int xid, struct cifs_tcon *tcon,
-			    u64 persistent_fid, u64 volatile_fid,
-			    struct smb311_posix_qinfo *data, u32 *plen);
 int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
 		    u64 persistent_fid, u64 volatile_fid,
 		    struct smb2_file_all_info *data);
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v5 4/7] smb: move some definitions from common/smb2pdu.h into common/fscc.h
  2026-03-03 15:13 [PATCH v5 0/7] smb: fix some bugs, move duplicate definitions into common header file, part 2 zhang.guodong
                   ` (2 preceding siblings ...)
  2026-03-03 15:13 ` [PATCH v5 3/7] smb/client: remove unused SMB311_posix_query_info() zhang.guodong
@ 2026-03-03 15:13 ` zhang.guodong
  2026-03-03 15:13 ` [PATCH v5 5/7] smb: move file_basic_info " zhang.guodong
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 18+ messages in thread
From: zhang.guodong @ 2026-03-03 15:13 UTC (permalink / raw)
  To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, chenxiaosong
  Cc: linux-cifs

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.52.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v5 5/7] smb: move file_basic_info into common/fscc.h
  2026-03-03 15:13 [PATCH v5 0/7] smb: fix some bugs, move duplicate definitions into common header file, part 2 zhang.guodong
                   ` (3 preceding siblings ...)
  2026-03-03 15:13 ` [PATCH v5 4/7] smb: move some definitions from common/smb2pdu.h into common/fscc.h zhang.guodong
@ 2026-03-03 15:13 ` zhang.guodong
  2026-03-03 15:13 ` [PATCH v5 6/7] smb: move filesystem_vol_info " zhang.guodong
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 18+ messages in thread
From: zhang.guodong @ 2026-03-03 15:13 UTC (permalink / raw)
  To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, chenxiaosong
  Cc: linux-cifs

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 743c629fe7ec..5126394337bc 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -4839,7 +4839,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;
@@ -4855,7 +4855,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);
@@ -4864,9 +4864,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;
 }
 
@@ -6137,7 +6137,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;
@@ -6419,10 +6419,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 8b6eafb70dca..e7cf573e59f0 100644
--- a/fs/smb/server/smb2pdu.h
+++ b/fs/smb/server/smb2pdu.h
@@ -186,15 +186,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.52.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v5 6/7] smb: move filesystem_vol_info into common/fscc.h
  2026-03-03 15:13 [PATCH v5 0/7] smb: fix some bugs, move duplicate definitions into common header file, part 2 zhang.guodong
                   ` (4 preceding siblings ...)
  2026-03-03 15:13 ` [PATCH v5 5/7] smb: move file_basic_info " zhang.guodong
@ 2026-03-03 15:13 ` zhang.guodong
  2026-03-03 15:13 ` [PATCH v5 7/7] smb: introduce struct file_posix_info zhang.guodong
  2026-03-10  0:57 ` [PATCH v5 0/7] smb: fix some bugs, move duplicate definitions into common header file, part 2 Namjae Jeon
  7 siblings, 0 replies; 18+ messages in thread
From: zhang.guodong @ 2026-03-03 15:13 UTC (permalink / raw)
  To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, chenxiaosong
  Cc: linux-cifs

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

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/smb2pdu.c    |  8 ++++----
 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 --------
 5 files changed, 18 insertions(+), 25 deletions(-)

diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index c43ca74e8704..1c917f80f19d 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -6144,8 +6144,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;
@@ -6200,9 +6200,9 @@ 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_serial_number = le32_to_cpu(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 5126394337bc..f73ea4d1db8f 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -5545,13 +5545,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.52.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v5 7/7] smb: introduce struct file_posix_info
  2026-03-03 15:13 [PATCH v5 0/7] smb: fix some bugs, move duplicate definitions into common header file, part 2 zhang.guodong
                   ` (5 preceding siblings ...)
  2026-03-03 15:13 ` [PATCH v5 6/7] smb: move filesystem_vol_info " zhang.guodong
@ 2026-03-03 15:13 ` zhang.guodong
  2026-03-10  1:02   ` Namjae Jeon
  2026-03-10  0:57 ` [PATCH v5 0/7] smb: fix some bugs, move duplicate definitions into common header file, part 2 Namjae Jeon
  7 siblings, 1 reply; 18+ messages in thread
From: zhang.guodong @ 2026-03-03 15:13 UTC (permalink / raw)
  To: smfrench, linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, chenxiaosong
  Cc: linux-cifs

From: ZhangGuoDong <zhangguodong@kylinos.cn>

Extract the common part of struct smb311_posix_qinfo/file_posix_info
into a new struct.

Modify the following places:

  - introduce new struct file_posix_info
  - smb311_posix_qinfo -> file_posix_info
  - remove struct smb311_posix_qinfo
  - 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/cifsglob.h  |  2 +-
 fs/smb/client/inode.c     |  2 +-
 fs/smb/client/readdir.c   | 28 ++++++++++++------------
 fs/smb/client/reparse.h   |  2 +-
 fs/smb/client/smb2inode.c |  4 ++--
 fs/smb/client/smb2pdu.h   | 21 +-----------------
 fs/smb/common/fscc.h      | 35 ++++++++++++++++++++++++++++-
 fs/smb/common/smb2pdu.h   | 25 ---------------------
 fs/smb/server/smb2pdu.c   | 46 +++++++++++++++++++--------------------
 fs/smb/server/smb2pdu.h   | 21 +-----------------
 10 files changed, 78 insertions(+), 108 deletions(-)

diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index 6f9b6c72962b..f49e76feb527 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -270,7 +270,7 @@ struct cifs_open_info_data {
 	struct smb_sid posix_group;
 	union {
 		struct smb2_file_all_info fi;
-		struct smb311_posix_qinfo posix_fi;
+		struct file_posix_info posix_fi;
 	};
 };
 
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index 3e844c55ab8a..11c5eeaa64fd 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -835,7 +835,7 @@ static void smb311_posix_info_to_fattr(struct cifs_fattr *fattr,
 				       struct cifs_open_info_data *data,
 				       struct super_block *sb)
 {
-	struct smb311_posix_qinfo *info = &data->posix_fi;
+	struct file_posix_info *info = &data->posix_fi;
 	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
 	struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
 
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..674a4686c035 100644
--- a/fs/smb/client/reparse.h
+++ b/fs/smb/client/reparse.h
@@ -104,7 +104,7 @@ static inline bool cifs_open_data_reparse(struct cifs_open_info_data *data)
 	bool ret;
 
 	if (data->contains_posix_file_info) {
-		struct smb311_posix_qinfo *fi = &data->posix_fi;
+		struct file_posix_info *fi = &data->posix_fi;
 
 		attrs = le32_to_cpu(fi->DosAttributes);
 		if (data->reparse_point) {
diff --git a/fs/smb/client/smb2inode.c b/fs/smb/client/smb2inode.c
index 1c4663ed7e69..119a9ac2e6eb 100644
--- a/fs/smb/client/smb2inode.c
+++ b/fs/smb/client/smb2inode.c
@@ -325,7 +325,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
 							  cfile->fid.volatile_fid,
 							  SMB_FIND_FILE_POSIX_INFO,
 							  SMB2_O_INFO_FILE, 0,
-							  sizeof(struct smb311_posix_qinfo) +
+							  sizeof(struct file_posix_info) +
 							  (PATH_MAX * 2) +
 							  (sizeof(struct smb_sid) * 2), 0, NULL);
 			} else {
@@ -335,7 +335,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
 							  COMPOUND_FID,
 							  SMB_FIND_FILE_POSIX_INFO,
 							  SMB2_O_INFO_FILE, 0,
-							  sizeof(struct smb311_posix_qinfo) +
+							  sizeof(struct file_posix_info) +
 							  (PATH_MAX * 2) +
 							  (sizeof(struct smb_sid) * 2), 0, NULL);
 			}
diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
index 30d70097fe2f..912017461f5f 100644
--- a/fs/smb/client/smb2pdu.h
+++ b/fs/smb/client/smb2pdu.h
@@ -274,26 +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;
-	/*
-	 * var sized owner SID
-	 * var sized group SID
-	 * le32 filenamelength
-	 * u8  filename[]
-	 */
+	struct file_posix_info fpinfo;
 } __packed;
 
 /*
diff --git a/fs/smb/common/fscc.h b/fs/smb/common/fscc.h
index b4ccddca9256..da8f2ba0996c 100644
--- a/fs/smb/common/fscc.h
+++ b/fs/smb/common/fscc.h
@@ -537,9 +537,42 @@ 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.
+ * Level 100 query info
+ * 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[]
+	u8 sids_and_name[];
+} __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 f73ea4d1db8f..cf1475fae918 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -4052,44 +4052,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) +
@@ -5261,14 +5261,14 @@ static int get_file_attribute_tag_info(struct smb2_query_info_rsp *rsp,
 static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
 				struct ksmbd_file *fp, void *rsp_org)
 {
-	struct smb311_posix_qinfo *file_info;
+	struct file_posix_info *file_info;
 	struct inode *inode = file_inode(fp->filp);
 	struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
 	vfsuid_t vfsuid = i_uid_into_vfsuid(idmap, inode);
 	vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode);
 	struct kstat stat;
 	u64 time;
-	int out_buf_len = sizeof(struct smb311_posix_qinfo) + 32;
+	int out_buf_len = sizeof(struct file_posix_info) + 32;
 	int ret;
 
 	ret = vfs_getattr(&fp->filp->f_path, &stat, STATX_BASIC_STATS,
@@ -5276,7 +5276,7 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
 	if (ret)
 		return ret;
 
-	file_info = (struct smb311_posix_qinfo *)rsp->Buffer;
+	file_info = (struct file_posix_info *)rsp->Buffer;
 	file_info->CreationTime = cpu_to_le64(fp->create_time);
 	time = ksmbd_UnixTimeToNT(stat.atime);
 	file_info->LastAccessTime = cpu_to_le64(time);
@@ -5323,9 +5323,9 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
 	 *		  sub_auth(4 * 1(num_subauth)) + RID(4).
 	 */
 	id_to_sid(from_kuid_munged(&init_user_ns, vfsuid_into_kuid(vfsuid)),
-		  SIDUNIX_USER, (struct smb_sid *)&file_info->Sids[0]);
+		  SIDUNIX_USER, (struct smb_sid *)&file_info->sids_and_name[0]);
 	id_to_sid(from_kgid_munged(&init_user_ns, vfsgid_into_kgid(vfsgid)),
-		  SIDUNIX_GROUP, (struct smb_sid *)&file_info->Sids[16]);
+		  SIDUNIX_GROUP, (struct smb_sid *)&file_info->sids_and_name[16]);
 
 	rsp->OutputBufferLength = cpu_to_le32(out_buf_len);
 
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.52.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH v5 1/7] smb/client: fix buffer size for smb311_posix_qinfo in smb2_compound_op()
  2026-03-03 15:13 ` [PATCH v5 1/7] smb/client: fix buffer size for smb311_posix_qinfo in smb2_compound_op() zhang.guodong
@ 2026-03-03 23:58   ` Steve French
  2026-03-04  0:07     ` ZhangGuoDong
  2026-03-04  0:06   ` Steve French
  1 sibling, 1 reply; 18+ messages in thread
From: Steve French @ 2026-03-03 23:58 UTC (permalink / raw)
  To: zhang.guodong
  Cc: linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, chenxiaosong, linux-cifs

Good catch - were you able to repro a crash or other bug when running
without the patch?

On Tue, Mar 3, 2026 at 9:14 AM <zhang.guodong@linux.dev> wrote:
>
> From: ZhangGuoDong <zhangguodong@kylinos.cn>
>
> Use `sizeof(struct smb311_posix_qinfo)` instead of sizeof its pointer,
> so the allocated buffer matches the actual struct size.
>
> Fixes: 6a5f6592a0b6 ("SMB311: Add support for query info using posix extensions (level 100)")
> Reported-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
> Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> ---
>  fs/smb/client/smb2inode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/smb/client/smb2inode.c b/fs/smb/client/smb2inode.c
> index 195a38fd61e8..1c4663ed7e69 100644
> --- a/fs/smb/client/smb2inode.c
> +++ b/fs/smb/client/smb2inode.c
> @@ -325,7 +325,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
>                                                           cfile->fid.volatile_fid,
>                                                           SMB_FIND_FILE_POSIX_INFO,
>                                                           SMB2_O_INFO_FILE, 0,
> -                                                         sizeof(struct smb311_posix_qinfo *) +
> +                                                         sizeof(struct smb311_posix_qinfo) +
>                                                           (PATH_MAX * 2) +
>                                                           (sizeof(struct smb_sid) * 2), 0, NULL);
>                         } else {
> @@ -335,7 +335,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
>                                                           COMPOUND_FID,
>                                                           SMB_FIND_FILE_POSIX_INFO,
>                                                           SMB2_O_INFO_FILE, 0,
> -                                                         sizeof(struct smb311_posix_qinfo *) +
> +                                                         sizeof(struct smb311_posix_qinfo) +
>                                                           (PATH_MAX * 2) +
>                                                           (sizeof(struct smb_sid) * 2), 0, NULL);
>                         }
> --
> 2.52.0
>


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v5 3/7] smb/client: remove unused SMB311_posix_query_info()
  2026-03-03 15:13 ` [PATCH v5 3/7] smb/client: remove unused SMB311_posix_query_info() zhang.guodong
@ 2026-03-04  0:05   ` Steve French
  0 siblings, 0 replies; 18+ messages in thread
From: Steve French @ 2026-03-04  0:05 UTC (permalink / raw)
  To: zhang.guodong
  Cc: linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, chenxiaosong, linux-cifs

merged into cifs-2.6.git for-next pending more testing

On Tue, Mar 3, 2026 at 9:14 AM <zhang.guodong@linux.dev> wrote:
>
> From: ZhangGuoDong <zhangguodong@kylinos.cn>
>
> It is currently unused, as now we are doing compounding instead
> (see smb2_query_path_info()).
>
> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
> Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> ---
>  fs/smb/client/smb2pdu.c   | 18 ------------------
>  fs/smb/client/smb2proto.h |  3 ---
>  2 files changed, 21 deletions(-)
>
> diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
> index 8a1fcc097606..c43ca74e8704 100644
> --- a/fs/smb/client/smb2pdu.c
> +++ b/fs/smb/client/smb2pdu.c
> @@ -3989,24 +3989,6 @@ int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
>                           NULL);
>  }
>
> -#if 0
> -/* currently unused, as now we are doing compounding instead (see smb311_posix_query_path_info) */
> -int
> -SMB311_posix_query_info(const unsigned int xid, struct cifs_tcon *tcon,
> -                       u64 persistent_fid, u64 volatile_fid,
> -                       struct smb311_posix_qinfo *data, u32 *plen)
> -{
> -       size_t output_len = sizeof(struct smb311_posix_qinfo) +
> -                       (sizeof(struct smb_sid) * 2) + (PATH_MAX * 2);
> -       *plen = 0;
> -
> -       return query_info(xid, tcon, persistent_fid, volatile_fid,
> -                         SMB_FIND_FILE_POSIX_INFO, SMB2_O_INFO_FILE, 0,
> -                         output_len, sizeof(struct smb311_posix_qinfo), (void **)&data, plen);
> -       /* Note caller must free "data" (passed in above). It may be allocated in query_info call */
> -}
> -#endif
> -
>  int
>  SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
>                u64 persistent_fid, u64 volatile_fid,
> diff --git a/fs/smb/client/smb2proto.h b/fs/smb/client/smb2proto.h
> index 881e42cf66ce..230bb1e9f4e1 100644
> --- a/fs/smb/client/smb2proto.h
> +++ b/fs/smb/client/smb2proto.h
> @@ -167,9 +167,6 @@ int SMB2_flush_init(const unsigned int xid, struct smb_rqst *rqst,
>                     struct cifs_tcon *tcon, struct TCP_Server_Info *server,
>                     u64 persistent_fid, u64 volatile_fid);
>  void SMB2_flush_free(struct smb_rqst *rqst);
> -int SMB311_posix_query_info(const unsigned int xid, struct cifs_tcon *tcon,
> -                           u64 persistent_fid, u64 volatile_fid,
> -                           struct smb311_posix_qinfo *data, u32 *plen);
>  int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
>                     u64 persistent_fid, u64 volatile_fid,
>                     struct smb2_file_all_info *data);
> --
> 2.52.0
>


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v5 2/7] smb/client: fix buffer size for smb311_posix_qinfo in SMB311_posix_query_info()
  2026-03-03 15:13 ` [PATCH v5 2/7] smb/client: fix buffer size for smb311_posix_qinfo in SMB311_posix_query_info() zhang.guodong
@ 2026-03-04  0:05   ` Steve French
  0 siblings, 0 replies; 18+ messages in thread
From: Steve French @ 2026-03-04  0:05 UTC (permalink / raw)
  To: zhang.guodong
  Cc: linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, chenxiaosong, linux-cifs

merged into cifs-2.6.git for-next pending more testing

On Tue, Mar 3, 2026 at 9:14 AM <zhang.guodong@linux.dev> wrote:
>
> From: ZhangGuoDong <zhangguodong@kylinos.cn>
>
> SMB311_posix_query_info() is currently unused, but it may still be used in
> some stable versions, so these changes are submitted as a separate patch.
>
> Use `sizeof(struct smb311_posix_qinfo)` instead of sizeof its pointer,
> so the allocated buffer matches the actual struct size.
>
> Fixes: b1bc1874b885 ("smb311: Add support for SMB311 query info (non-compounded)")
> Reported-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
> Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> ---
>  fs/smb/client/smb2pdu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
> index 04e361ed2356..8a1fcc097606 100644
> --- a/fs/smb/client/smb2pdu.c
> +++ b/fs/smb/client/smb2pdu.c
> @@ -3996,7 +3996,7 @@ SMB311_posix_query_info(const unsigned int xid, struct cifs_tcon *tcon,
>                         u64 persistent_fid, u64 volatile_fid,
>                         struct smb311_posix_qinfo *data, u32 *plen)
>  {
> -       size_t output_len = sizeof(struct smb311_posix_qinfo *) +
> +       size_t output_len = sizeof(struct smb311_posix_qinfo) +
>                         (sizeof(struct smb_sid) * 2) + (PATH_MAX * 2);
>         *plen = 0;
>
> --
> 2.52.0
>


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v5 1/7] smb/client: fix buffer size for smb311_posix_qinfo in smb2_compound_op()
  2026-03-03 15:13 ` [PATCH v5 1/7] smb/client: fix buffer size for smb311_posix_qinfo in smb2_compound_op() zhang.guodong
  2026-03-03 23:58   ` Steve French
@ 2026-03-04  0:06   ` Steve French
  1 sibling, 0 replies; 18+ messages in thread
From: Steve French @ 2026-03-04  0:06 UTC (permalink / raw)
  To: zhang.guodong
  Cc: linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, chenxiaosong, linux-cifs

merged into cifs-2.6.git for-next pending more testing

On Tue, Mar 3, 2026 at 9:14 AM <zhang.guodong@linux.dev> wrote:
>
> From: ZhangGuoDong <zhangguodong@kylinos.cn>
>
> Use `sizeof(struct smb311_posix_qinfo)` instead of sizeof its pointer,
> so the allocated buffer matches the actual struct size.
>
> Fixes: 6a5f6592a0b6 ("SMB311: Add support for query info using posix extensions (level 100)")
> Reported-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
> Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> ---
>  fs/smb/client/smb2inode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/smb/client/smb2inode.c b/fs/smb/client/smb2inode.c
> index 195a38fd61e8..1c4663ed7e69 100644
> --- a/fs/smb/client/smb2inode.c
> +++ b/fs/smb/client/smb2inode.c
> @@ -325,7 +325,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
>                                                           cfile->fid.volatile_fid,
>                                                           SMB_FIND_FILE_POSIX_INFO,
>                                                           SMB2_O_INFO_FILE, 0,
> -                                                         sizeof(struct smb311_posix_qinfo *) +
> +                                                         sizeof(struct smb311_posix_qinfo) +
>                                                           (PATH_MAX * 2) +
>                                                           (sizeof(struct smb_sid) * 2), 0, NULL);
>                         } else {
> @@ -335,7 +335,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
>                                                           COMPOUND_FID,
>                                                           SMB_FIND_FILE_POSIX_INFO,
>                                                           SMB2_O_INFO_FILE, 0,
> -                                                         sizeof(struct smb311_posix_qinfo *) +
> +                                                         sizeof(struct smb311_posix_qinfo) +
>                                                           (PATH_MAX * 2) +
>                                                           (sizeof(struct smb_sid) * 2), 0, NULL);
>                         }
> --
> 2.52.0
>


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v5 1/7] smb/client: fix buffer size for smb311_posix_qinfo in smb2_compound_op()
  2026-03-03 23:58   ` Steve French
@ 2026-03-04  0:07     ` ZhangGuoDong
  0 siblings, 0 replies; 18+ messages in thread
From: ZhangGuoDong @ 2026-03-04  0:07 UTC (permalink / raw)
  To: Steve French
  Cc: linkinjeon, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, chenxiaosong, linux-cifs

I will try to test it, but this is a very obvious bug.

On 2026/3/4 07:58, Steve French wrote:
> Good catch - were you able to repro a crash or other bug when running
> without the patch?

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v5 0/7] smb: fix some bugs, move duplicate definitions into common header file, part 2
  2026-03-03 15:13 [PATCH v5 0/7] smb: fix some bugs, move duplicate definitions into common header file, part 2 zhang.guodong
                   ` (6 preceding siblings ...)
  2026-03-03 15:13 ` [PATCH v5 7/7] smb: introduce struct file_posix_info zhang.guodong
@ 2026-03-10  0:57 ` Namjae Jeon
  7 siblings, 0 replies; 18+ messages in thread
From: Namjae Jeon @ 2026-03-10  0:57 UTC (permalink / raw)
  To: zhang.guodong
  Cc: smfrench, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, chenxiaosong, linux-cifs

On Wed, Mar 4, 2026 at 12:14 AM <zhang.guodong@linux.dev> wrote:
>
> From: ZhangGuoDong <zhangguodong@kylinos.cn>
>
> v4->v5:
>   - Add patch #01 #02 #03
>   - Patch #06: keep vol_serial_number as u32 in smb_mnt_fs_info and cifs_tcon
>   - Patch #07:
>     - Add new flexible array member `sids_and_name[]` to file_posix_info
>     - smb311_posix_qinfo -> file_posix_info
>
> v4: https://lore.kernel.org/linux-cifs/20260225041100.707468-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
>
> The following patches from v4 have already been merged into cifs-2.6.git for-next:
>   - smb: update some doc references
>
> 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 (7):
>   smb/client: fix buffer size for smb311_posix_qinfo in
>     smb2_compound_op()
>   smb/client: fix buffer size for smb311_posix_qinfo in
>     SMB311_posix_query_info()
>   smb/client: remove unused SMB311_posix_query_info()
>   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: introduce struct file_posix_info
Applied 0004~0006 patches to #ksmbd-for-next-next.
Thanks!

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v5 7/7] smb: introduce struct file_posix_info
  2026-03-03 15:13 ` [PATCH v5 7/7] smb: introduce struct file_posix_info zhang.guodong
@ 2026-03-10  1:02   ` Namjae Jeon
  2026-03-10  1:17     ` ZhangGuoDong
  0 siblings, 1 reply; 18+ messages in thread
From: Namjae Jeon @ 2026-03-10  1:02 UTC (permalink / raw)
  To: zhang.guodong
  Cc: smfrench, pc, ronniesahlberg, sprasad, tom, bharathsm,
	senozhatsky, dhowells, chenxiaosong, chenxiaosong, linux-cifs

> 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[];
These 3 fields should be removed and use flex array in struct file_posix_info.
And why can't smb2_posix_info move to /smb/common?
> -       /*
> -        * var sized owner SID
> -        * var sized group SID
> -        * le32 filenamelength
> -        * u8  filename[]
> -        */
>  } __packed;
>
>  /* functions */
> --
> 2.52.0
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v5 7/7] smb: introduce struct file_posix_info
  2026-03-10  1:02   ` Namjae Jeon
@ 2026-03-10  1:17     ` ZhangGuoDong
  2026-03-10  1:25       ` Namjae Jeon
  0 siblings, 1 reply; 18+ messages in thread
From: ZhangGuoDong @ 2026-03-10  1:17 UTC (permalink / raw)
  To: Namjae Jeon; +Cc: smfrench, chenxiaosong, chenxiaosong, linux-cifs

Hi Namjae,

The client cannot use `SidBuffer[32]` because the size of `SidBuffer[]` 
on the client side is not necessarily 32.

在 2026/3/10 09:02, Namjae Jeon 写道:
>>          /* SidBuffer contain two sids (UNIX user sid(16), UNIX group sid(16)) */
>>          u8 SidBuffer[32];
>>          __le32 name_len;
>>          u8 name[];
> These 3 fields should be removed and use flex array in struct file_posix_info.
> And why can't smb2_posix_info move to /smb/common?


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v5 7/7] smb: introduce struct file_posix_info
  2026-03-10  1:17     ` ZhangGuoDong
@ 2026-03-10  1:25       ` Namjae Jeon
  2026-03-10  1:31         ` ZhangGuoDong
  0 siblings, 1 reply; 18+ messages in thread
From: Namjae Jeon @ 2026-03-10  1:25 UTC (permalink / raw)
  To: ZhangGuoDong; +Cc: smfrench, chenxiaosong, chenxiaosong, linux-cifs

On Tue, Mar 10, 2026 at 10:18 AM ZhangGuoDong <zhang.guodong@linux.dev> wrote:
>
> Hi Namjae,
>
> The client cannot use `SidBuffer[32]` because the size of `SidBuffer[]`
> on the client side is not necessarily 32.
I know, We need to change ksmbd to use flex arrays.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v5 7/7] smb: introduce struct file_posix_info
  2026-03-10  1:25       ` Namjae Jeon
@ 2026-03-10  1:31         ` ZhangGuoDong
  0 siblings, 0 replies; 18+ messages in thread
From: ZhangGuoDong @ 2026-03-10  1:31 UTC (permalink / raw)
  To: Namjae Jeon; +Cc: smfrench, chenxiaosong, chenxiaosong, linux-cifs

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/3/10 09:25, Namjae Jeon 写道:
> I know, We need to change ksmbd to use flex arrays.


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2026-03-10  1:31 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-03 15:13 [PATCH v5 0/7] smb: fix some bugs, move duplicate definitions into common header file, part 2 zhang.guodong
2026-03-03 15:13 ` [PATCH v5 1/7] smb/client: fix buffer size for smb311_posix_qinfo in smb2_compound_op() zhang.guodong
2026-03-03 23:58   ` Steve French
2026-03-04  0:07     ` ZhangGuoDong
2026-03-04  0:06   ` Steve French
2026-03-03 15:13 ` [PATCH v5 2/7] smb/client: fix buffer size for smb311_posix_qinfo in SMB311_posix_query_info() zhang.guodong
2026-03-04  0:05   ` Steve French
2026-03-03 15:13 ` [PATCH v5 3/7] smb/client: remove unused SMB311_posix_query_info() zhang.guodong
2026-03-04  0:05   ` Steve French
2026-03-03 15:13 ` [PATCH v5 4/7] smb: move some definitions from common/smb2pdu.h into common/fscc.h zhang.guodong
2026-03-03 15:13 ` [PATCH v5 5/7] smb: move file_basic_info " zhang.guodong
2026-03-03 15:13 ` [PATCH v5 6/7] smb: move filesystem_vol_info " zhang.guodong
2026-03-03 15:13 ` [PATCH v5 7/7] smb: introduce struct file_posix_info zhang.guodong
2026-03-10  1:02   ` Namjae Jeon
2026-03-10  1:17     ` ZhangGuoDong
2026-03-10  1:25       ` Namjae Jeon
2026-03-10  1:31         ` ZhangGuoDong
2026-03-10  0:57 ` [PATCH v5 0/7] smb: fix some bugs, move duplicate definitions into common header file, part 2 Namjae Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox