linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/13 smb: move duplicate definitions into common header file, part 2
@ 2025-12-09  1:10 chenxiaosong.chenxiaosong
  2025-12-09  1:10 ` [PATCH 01/13] smb: add documentation references for smb2 change notify definitions chenxiaosong.chenxiaosong
                   ` (13 more replies)
  0 siblings, 14 replies; 21+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-09  1:10 UTC (permalink / raw)
  To: sfrench, smfrench, linkinjeon, linkinjeon
  Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
	ChenXiaoSong

From: ChenXiaoSong <chenxiaosong@kylinos.cn>

I'm currently working on implementing the SMB2 change notify feature in
ksmbd, and noticed several duplicated definitions that exist on both client
and server. Maybe we can clean these up first.

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:
https://lore.kernel.org/linux-cifs/20251117112838.473051-1-chenxiaosong.chenxiaosong@linux.dev/

ChenXiaoSong (7):
  smb: add documentation references for smb2 change notify definitions
  smb: move notify completion filter flags into common/smb2pdu.h
  smb: move SMB2 Notify Action Flags into common/smb2pdu.h
  smb: move file_notify_information to common/fscc.h
  smb: move File Attributes definitions into common/fscc.h
  smb: update struct duplicate_extents_to_file_ex
  smb/server: add comment to FileSystemName of
    FileFsAttributeInformation

ZhangGuoDong (6):
  smb: move smb3_fs_vol_info into common/fscc.h
  smb: move some definitions from common/smb2pdu.h into common/fscc.h
  smb/client: remove DeviceType Flags and Device Characteristics
    definitions
  smb: introduce struct create_posix_ctxt_rsp
  smb: introduce struct file_posix_info
  smb: move some SMB1 definitions into common/smb1pdu.h

 fs/smb/client/cifspdu.h    |  67 +-----
 fs/smb/client/inode.c      |  22 +-
 fs/smb/client/readdir.c    |  28 +--
 fs/smb/client/reparse.h    |   4 +-
 fs/smb/client/smb2pdu.c    |   9 +-
 fs/smb/client/smb2pdu.h    |  21 +-
 fs/smb/common/fscc.h       | 419 ++++++++++++++++++++++++++++++++++-
 fs/smb/common/smb1pdu.h    |  59 +++++
 fs/smb/common/smb2pdu.h    | 433 ++-----------------------------------
 fs/smb/common/smbglob.h    |   2 -
 fs/smb/server/oplock.c     |   8 +-
 fs/smb/server/smb2pdu.c    |  91 ++++----
 fs/smb/server/smb2pdu.h    |  27 +--
 fs/smb/server/smb_common.h |   9 +-
 14 files changed, 589 insertions(+), 610 deletions(-)
 create mode 100644 fs/smb/common/smb1pdu.h

-- 
2.43.0


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

* [PATCH 01/13] smb: add documentation references for smb2 change notify definitions
  2025-12-09  1:10 [PATCH 00/13 smb: move duplicate definitions into common header file, part 2 chenxiaosong.chenxiaosong
@ 2025-12-09  1:10 ` chenxiaosong.chenxiaosong
  2025-12-09  1:10 ` [PATCH 02/13] smb: move notify completion filter flags into common/smb2pdu.h chenxiaosong.chenxiaosong
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-09  1:10 UTC (permalink / raw)
  To: sfrench, smfrench, linkinjeon, linkinjeon
  Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
	ChenXiaoSong

From: ChenXiaoSong <chenxiaosong@kylinos.cn>

To make it easier to locate the documentation during development.

Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/client/cifspdu.h | 5 ++++-
 fs/smb/common/smb2pdu.h | 7 ++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index 49f35cb3cf2e..31c33e20b8ac 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -1381,7 +1381,10 @@ typedef struct smb_com_transaction_change_notify_rsp {
 #define FILE_ACTION_REMOVED_STREAM	0x00000007
 #define FILE_ACTION_MODIFIED_STREAM	0x00000008
 
-/* response contains array of the following structures */
+/*
+ * response contains array of the following structures
+ * See MS-FSCC 2.7.1
+ */
 struct file_notify_information {
 	__le32 NextEntryOffset;
 	__le32 Action;
diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
index f38c5739a9d2..7b954b607165 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -1002,7 +1002,10 @@ struct smb2_set_info_rsp {
 #define FILE_NOTIFY_CHANGE_STREAM_SIZE		0x00000400
 #define FILE_NOTIFY_CHANGE_STREAM_WRITE		0x00000800
 
-/* SMB2 Notify Action Flags */
+/*
+ * 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
@@ -1013,6 +1016,7 @@ struct smb2_set_info_rsp {
 #define FILE_ACTION_MODIFIED_STREAM             0x00000008
 #define FILE_ACTION_REMOVED_BY_DELETE           0x00000009
 
+/* See MS-SMB2 2.2.35 */
 struct smb2_change_notify_req {
 	struct smb2_hdr hdr;
 	__le16	StructureSize;
@@ -1024,6 +1028,7 @@ struct smb2_change_notify_req {
 	__u32	Reserved;
 } __packed;
 
+/* See MS-SMB2 2.2.36 */
 struct smb2_change_notify_rsp {
 	struct smb2_hdr hdr;
 	__le16	StructureSize;  /* Must be 9 */
-- 
2.43.0


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

* [PATCH 02/13] smb: move notify completion filter flags into common/smb2pdu.h
  2025-12-09  1:10 [PATCH 00/13 smb: move duplicate definitions into common header file, part 2 chenxiaosong.chenxiaosong
  2025-12-09  1:10 ` [PATCH 01/13] smb: add documentation references for smb2 change notify definitions chenxiaosong.chenxiaosong
@ 2025-12-09  1:10 ` chenxiaosong.chenxiaosong
  2025-12-09  1:10 ` [PATCH 03/13] smb: move SMB2 Notify Action Flags " chenxiaosong.chenxiaosong
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-09  1:10 UTC (permalink / raw)
  To: sfrench, smfrench, linkinjeon, linkinjeon
  Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
	ChenXiaoSong

From: ChenXiaoSong <chenxiaosong@kylinos.cn>

Some of these definitions are already in common/smb2pdu.h, remove the
duplicate client side definitions, and move FILE_NOTIFY_CHANGE_NAME to
common header file.

Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/client/cifspdu.h | 14 --------------
 fs/smb/common/smb2pdu.h |  1 +
 2 files changed, 1 insertion(+), 14 deletions(-)

diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index 31c33e20b8ac..4315a06d296b 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -1357,20 +1357,6 @@ typedef struct smb_com_transaction_change_notify_rsp {
 	__u16 ByteCount;
 	/* __u8 Pad[3]; */
 } __packed TRANSACT_CHANGE_NOTIFY_RSP;
-/* Completion Filter flags for Notify */
-#define FILE_NOTIFY_CHANGE_FILE_NAME    0x00000001
-#define FILE_NOTIFY_CHANGE_DIR_NAME     0x00000002
-#define FILE_NOTIFY_CHANGE_NAME         0x00000003
-#define FILE_NOTIFY_CHANGE_ATTRIBUTES   0x00000004
-#define FILE_NOTIFY_CHANGE_SIZE         0x00000008
-#define FILE_NOTIFY_CHANGE_LAST_WRITE   0x00000010
-#define FILE_NOTIFY_CHANGE_LAST_ACCESS  0x00000020
-#define FILE_NOTIFY_CHANGE_CREATION     0x00000040
-#define FILE_NOTIFY_CHANGE_EA           0x00000080
-#define FILE_NOTIFY_CHANGE_SECURITY     0x00000100
-#define FILE_NOTIFY_CHANGE_STREAM_NAME  0x00000200
-#define FILE_NOTIFY_CHANGE_STREAM_SIZE  0x00000400
-#define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
 
 #define FILE_ACTION_ADDED		0x00000001
 #define FILE_ACTION_REMOVED		0x00000002
diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
index 7b954b607165..0565385d735a 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -991,6 +991,7 @@ struct smb2_set_info_rsp {
 /* notify completion filter flags. See MS-FSCC 2.6 and MS-SMB2 2.2.35 */
 #define FILE_NOTIFY_CHANGE_FILE_NAME		0x00000001
 #define FILE_NOTIFY_CHANGE_DIR_NAME		0x00000002
+#define FILE_NOTIFY_CHANGE_NAME			0x00000003
 #define FILE_NOTIFY_CHANGE_ATTRIBUTES		0x00000004
 #define FILE_NOTIFY_CHANGE_SIZE			0x00000008
 #define FILE_NOTIFY_CHANGE_LAST_WRITE		0x00000010
-- 
2.43.0


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

* [PATCH 03/13] smb: move SMB2 Notify Action Flags into common/smb2pdu.h
  2025-12-09  1:10 [PATCH 00/13 smb: move duplicate definitions into common header file, part 2 chenxiaosong.chenxiaosong
  2025-12-09  1:10 ` [PATCH 01/13] smb: add documentation references for smb2 change notify definitions chenxiaosong.chenxiaosong
  2025-12-09  1:10 ` [PATCH 02/13] smb: move notify completion filter flags into common/smb2pdu.h chenxiaosong.chenxiaosong
@ 2025-12-09  1:10 ` chenxiaosong.chenxiaosong
  2025-12-09  1:10 ` [PATCH 04/13] smb: move file_notify_information to common/fscc.h chenxiaosong.chenxiaosong
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-09  1:10 UTC (permalink / raw)
  To: sfrench, smfrench, linkinjeon, linkinjeon
  Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
	ChenXiaoSong

From: ChenXiaoSong <chenxiaosong@kylinos.cn>

Some of these definitions are already in common/smb2pdu.h. Remove the
duplicate client side definitions, and add all SMB2 Notify Action Flags to
common header file.

Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/client/cifspdu.h | 9 ---------
 fs/smb/common/smb2pdu.h | 2 ++
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index 4315a06d296b..8f0547d1fe0e 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -1358,15 +1358,6 @@ typedef struct smb_com_transaction_change_notify_rsp {
 	/* __u8 Pad[3]; */
 } __packed TRANSACT_CHANGE_NOTIFY_RSP;
 
-#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
-
 /*
  * 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 0565385d735a..ddb0609bc186 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -1016,6 +1016,8 @@ struct smb2_set_info_rsp {
 #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 {
-- 
2.43.0


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

* [PATCH 04/13] smb: move file_notify_information to common/fscc.h
  2025-12-09  1:10 [PATCH 00/13 smb: move duplicate definitions into common header file, part 2 chenxiaosong.chenxiaosong
                   ` (2 preceding siblings ...)
  2025-12-09  1:10 ` [PATCH 03/13] smb: move SMB2 Notify Action Flags " chenxiaosong.chenxiaosong
@ 2025-12-09  1:10 ` chenxiaosong.chenxiaosong
  2025-12-09  1:10 ` [PATCH 05/13] smb: move File Attributes definitions into common/fscc.h chenxiaosong.chenxiaosong
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-09  1:10 UTC (permalink / raw)
  To: sfrench, smfrench, linkinjeon, linkinjeon
  Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
	ChenXiaoSong

From: ChenXiaoSong <chenxiaosong@kylinos.cn>

This struct definition is specified in MS-FSCC, and KSMBD will also use it,
so move it into common header file.

Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/client/cifspdu.h | 11 -----------
 fs/smb/common/fscc.h    | 11 +++++++++++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index 8f0547d1fe0e..e10392eb80e7 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -1358,17 +1358,6 @@ typedef struct smb_com_transaction_change_notify_rsp {
 	/* __u8 Pad[3]; */
 } __packed TRANSACT_CHANGE_NOTIFY_RSP;
 
-/*
- * response contains array of the following structures
- * See MS-FSCC 2.7.1
- */
-struct file_notify_information {
-	__le32 NextEntryOffset;
-	__le32 Action;
-	__le32 FileNameLength;
-	__u8  FileName[];
-} __packed;
-
 struct cifs_quota_data {
 	__u32	rsrvd1;  /* 0 */
 	__u32	sid_size;
diff --git a/fs/smb/common/fscc.h b/fs/smb/common/fscc.h
index 35dbacdbb902..b8e7bb5ddfdd 100644
--- a/fs/smb/common/fscc.h
+++ b/fs/smb/common/fscc.h
@@ -144,6 +144,17 @@ typedef struct {
 	__le32 DeviceCharacteristics;
 } __packed FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */
 
+/*
+ * Response contains array of the following structures
+ * See MS-FSCC 2.7.1
+ */
+struct file_notify_information {
+	__le32 NextEntryOffset;
+	__le32 Action;
+	__le32 FileNameLength;
+	__u8  FileName[];
+} __packed;
+
 /*
  * See POSIX Extensions to MS-FSCC 2.3.2.1
  * Link: https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/fscc_posix_extensions.md
-- 
2.43.0


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

* [PATCH 05/13] smb: move File Attributes definitions into common/fscc.h
  2025-12-09  1:10 [PATCH 00/13 smb: move duplicate definitions into common header file, part 2 chenxiaosong.chenxiaosong
                   ` (3 preceding siblings ...)
  2025-12-09  1:10 ` [PATCH 04/13] smb: move file_notify_information to common/fscc.h chenxiaosong.chenxiaosong
@ 2025-12-09  1:10 ` chenxiaosong.chenxiaosong
  2025-12-09  1:10 ` [PATCH 06/13] smb: update struct duplicate_extents_to_file_ex chenxiaosong.chenxiaosong
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-09  1:10 UTC (permalink / raw)
  To: sfrench, smfrench, linkinjeon, linkinjeon
  Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
	ChenXiaoSong

From: ChenXiaoSong <chenxiaosong@kylinos.cn>

These definitions are specified in MS-FSCC 2.6, so move them into fscc.h.

Modify the following places:

  - FILE_ATTRIBUTE__MASK -> FILE_ATTRIBUTE_MASK
  - cpu_to_le32(constant) -> cpu_to_le32(MACRO DEFINITION)

Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/common/fscc.h    | 38 ++++++++++++++++++++++++++++++++++++++
 fs/smb/common/smb2pdu.h | 35 -----------------------------------
 2 files changed, 38 insertions(+), 35 deletions(-)

diff --git a/fs/smb/common/fscc.h b/fs/smb/common/fscc.h
index b8e7bb5ddfdd..5bf6c82e27f7 100644
--- a/fs/smb/common/fscc.h
+++ b/fs/smb/common/fscc.h
@@ -144,6 +144,44 @@ typedef struct {
 	__le32 DeviceCharacteristics;
 } __packed FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */
 
+/*
+ * File Attributes
+ * See MS-FSCC 2.6
+ */
+#define FILE_ATTRIBUTE_READONLY			0x00000001
+#define FILE_ATTRIBUTE_HIDDEN			0x00000002
+#define FILE_ATTRIBUTE_SYSTEM			0x00000004
+#define FILE_ATTRIBUTE_DIRECTORY		0x00000010
+#define FILE_ATTRIBUTE_ARCHIVE			0x00000020
+#define FILE_ATTRIBUTE_NORMAL			0x00000080
+#define FILE_ATTRIBUTE_TEMPORARY		0x00000100
+#define FILE_ATTRIBUTE_SPARSE_FILE		0x00000200
+#define FILE_ATTRIBUTE_REPARSE_POINT		0x00000400
+#define FILE_ATTRIBUTE_COMPRESSED		0x00000800
+#define FILE_ATTRIBUTE_OFFLINE			0x00001000
+#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED	0x00002000
+#define FILE_ATTRIBUTE_ENCRYPTED		0x00004000
+#define FILE_ATTRIBUTE_INTEGRITY_STREAM		0x00008000
+#define FILE_ATTRIBUTE_NO_SCRUB_DATA		0x00020000
+#define FILE_ATTRIBUTE_MASK			0x00007FB7
+
+#define FILE_ATTRIBUTE_READONLY_LE		cpu_to_le32(FILE_ATTRIBUTE_READONLY)
+#define FILE_ATTRIBUTE_HIDDEN_LE		cpu_to_le32(FILE_ATTRIBUTE_HIDDEN)
+#define FILE_ATTRIBUTE_SYSTEM_LE		cpu_to_le32(FILE_ATTRIBUTE_SYSTEM)
+#define FILE_ATTRIBUTE_DIRECTORY_LE		cpu_to_le32(FILE_ATTRIBUTE_DIRECTORY)
+#define FILE_ATTRIBUTE_ARCHIVE_LE		cpu_to_le32(FILE_ATTRIBUTE_ARCHIVE)
+#define FILE_ATTRIBUTE_NORMAL_LE		cpu_to_le32(FILE_ATTRIBUTE_NORMAL)
+#define FILE_ATTRIBUTE_TEMPORARY_LE		cpu_to_le32(FILE_ATTRIBUTE_TEMPORARY)
+#define FILE_ATTRIBUTE_SPARSE_FILE_LE		cpu_to_le32(FILE_ATTRIBUTE_SPARSE_FILE)
+#define FILE_ATTRIBUTE_REPARSE_POINT_LE		cpu_to_le32(FILE_ATTRIBUTE_REPARSE_POINT)
+#define FILE_ATTRIBUTE_COMPRESSED_LE		cpu_to_le32(FILE_ATTRIBUTE_COMPRESSED)
+#define FILE_ATTRIBUTE_OFFLINE_LE		cpu_to_le32(FILE_ATTRIBUTE_OFFLINE)
+#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED_LE	cpu_to_le32(FILE_ATTRIBUTE_NOT_CONTENT_INDEXED)
+#define FILE_ATTRIBUTE_ENCRYPTED_LE		cpu_to_le32(FILE_ATTRIBUTE_ENCRYPTED)
+#define FILE_ATTRIBUTE_INTEGRITY_STREAM_LE	cpu_to_le32(FILE_ATTRIBUTE_INTEGRITY_STREAM)
+#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)
+
 /*
  * 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 ddb0609bc186..87a92cd00282 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -1072,41 +1072,6 @@ struct smb2_server_client_notification {
 #define IL_IMPERSONATION	cpu_to_le32(0x00000002)
 #define IL_DELEGATE		cpu_to_le32(0x00000003)
 
-/* File Attributes */
-#define FILE_ATTRIBUTE_READONLY			0x00000001
-#define FILE_ATTRIBUTE_HIDDEN			0x00000002
-#define FILE_ATTRIBUTE_SYSTEM			0x00000004
-#define FILE_ATTRIBUTE_DIRECTORY		0x00000010
-#define FILE_ATTRIBUTE_ARCHIVE			0x00000020
-#define FILE_ATTRIBUTE_NORMAL			0x00000080
-#define FILE_ATTRIBUTE_TEMPORARY		0x00000100
-#define FILE_ATTRIBUTE_SPARSE_FILE		0x00000200
-#define FILE_ATTRIBUTE_REPARSE_POINT		0x00000400
-#define FILE_ATTRIBUTE_COMPRESSED		0x00000800
-#define FILE_ATTRIBUTE_OFFLINE			0x00001000
-#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED	0x00002000
-#define FILE_ATTRIBUTE_ENCRYPTED		0x00004000
-#define FILE_ATTRIBUTE_INTEGRITY_STREAM		0x00008000
-#define FILE_ATTRIBUTE_NO_SCRUB_DATA		0x00020000
-#define FILE_ATTRIBUTE__MASK			0x00007FB7
-
-#define FILE_ATTRIBUTE_READONLY_LE              cpu_to_le32(0x00000001)
-#define FILE_ATTRIBUTE_HIDDEN_LE		cpu_to_le32(0x00000002)
-#define FILE_ATTRIBUTE_SYSTEM_LE		cpu_to_le32(0x00000004)
-#define FILE_ATTRIBUTE_DIRECTORY_LE		cpu_to_le32(0x00000010)
-#define FILE_ATTRIBUTE_ARCHIVE_LE		cpu_to_le32(0x00000020)
-#define FILE_ATTRIBUTE_NORMAL_LE		cpu_to_le32(0x00000080)
-#define FILE_ATTRIBUTE_TEMPORARY_LE		cpu_to_le32(0x00000100)
-#define FILE_ATTRIBUTE_SPARSE_FILE_LE		cpu_to_le32(0x00000200)
-#define FILE_ATTRIBUTE_REPARSE_POINT_LE		cpu_to_le32(0x00000400)
-#define FILE_ATTRIBUTE_COMPRESSED_LE		cpu_to_le32(0x00000800)
-#define FILE_ATTRIBUTE_OFFLINE_LE		cpu_to_le32(0x00001000)
-#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED_LE	cpu_to_le32(0x00002000)
-#define FILE_ATTRIBUTE_ENCRYPTED_LE		cpu_to_le32(0x00004000)
-#define FILE_ATTRIBUTE_INTEGRITY_STREAM_LE	cpu_to_le32(0x00008000)
-#define FILE_ATTRIBUTE_NO_SCRUB_DATA_LE		cpu_to_le32(0x00020000)
-#define FILE_ATTRIBUTE_MASK_LE			cpu_to_le32(0x00007FB7)
-
 /* Desired Access Flags */
 #define FILE_READ_DATA_LE		cpu_to_le32(0x00000001)
 #define FILE_LIST_DIRECTORY_LE		cpu_to_le32(0x00000001)
-- 
2.43.0


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

* [PATCH 06/13] smb: update struct duplicate_extents_to_file_ex
  2025-12-09  1:10 [PATCH 00/13 smb: move duplicate definitions into common header file, part 2 chenxiaosong.chenxiaosong
                   ` (4 preceding siblings ...)
  2025-12-09  1:10 ` [PATCH 05/13] smb: move File Attributes definitions into common/fscc.h chenxiaosong.chenxiaosong
@ 2025-12-09  1:10 ` chenxiaosong.chenxiaosong
  2025-12-09  1:10 ` [PATCH 07/13] smb/server: add comment to FileSystemName of FileFsAttributeInformation chenxiaosong.chenxiaosong
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-09  1:10 UTC (permalink / raw)
  To: sfrench, smfrench, linkinjeon, linkinjeon
  Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
	ChenXiaoSong

From: ChenXiaoSong <chenxiaosong@kylinos.cn>

Add the missing field to the structure (see MS-FSCC 2.3.9.2), and correct
the section number in the documentation reference.

Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/common/smb2pdu.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
index 87a92cd00282..5d6ca221d4b6 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -1510,9 +1510,10 @@ struct duplicate_extents_to_file {
 	__le64 ByteCount;  /* Bytes to be copied */
 } __packed;
 
-/* See MS-FSCC 2.3.8 */
+/* See MS-FSCC 2.3.9 */
 #define DUPLICATE_EXTENTS_DATA_EX_SOURCE_ATOMIC	0x00000001
 struct duplicate_extents_to_file_ex {
+	__u64 StructureSize; /* MUST be set to 0x30 */
 	__u64 PersistentFileHandle; /* source file handle, opaque endianness */
 	__u64 VolatileFileHandle;
 	__le64 SourceFileOffset;
-- 
2.43.0


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

* [PATCH 07/13] smb/server: add comment to FileSystemName of FileFsAttributeInformation
  2025-12-09  1:10 [PATCH 00/13 smb: move duplicate definitions into common header file, part 2 chenxiaosong.chenxiaosong
                   ` (5 preceding siblings ...)
  2025-12-09  1:10 ` [PATCH 06/13] smb: update struct duplicate_extents_to_file_ex chenxiaosong.chenxiaosong
@ 2025-12-09  1:10 ` chenxiaosong.chenxiaosong
  2025-12-09  1:10 ` [PATCH 08/13] smb: move smb3_fs_vol_info into common/fscc.h chenxiaosong.chenxiaosong
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-09  1:10 UTC (permalink / raw)
  To: sfrench, smfrench, linkinjeon, linkinjeon
  Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
	ChenXiaoSong

From: ChenXiaoSong <chenxiaosong@kylinos.cn>

Explained why FileSystemName is always set to "NTFS".

Link: https://github.com/namjaejeon/ksmbd/commit/84392651b0b740d2f59bcacd3b4cfff8ae0051a0
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/server/smb2pdu.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 7ea6144c692c..ddd031ad7689 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -5497,6 +5497,13 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
 			info->Attributes |= cpu_to_le32(FILE_NAMED_STREAMS);
 
 		info->MaxPathNameComponentLength = cpu_to_le32(stfs.f_namelen);
+		/*
+		 * some application(potableapp) can not run on ksmbd share
+		 * because only NTFS handle security setting on windows.
+		 * So Although local fs(EXT4 or F2fs, etc) is not NTFS,
+		 * ksmbd should show share as NTFS. Later, If needed, we can add
+		 * fs type(s) parameter to change fs type user wanted.
+		 */
 		len = smbConvertToUTF16((__le16 *)info->FileSystemName,
 					"NTFS", PATH_MAX, conn->local_nls, 0);
 		len = len * 2;
-- 
2.43.0


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

* [PATCH 08/13] smb: move smb3_fs_vol_info into common/fscc.h
  2025-12-09  1:10 [PATCH 00/13 smb: move duplicate definitions into common header file, part 2 chenxiaosong.chenxiaosong
                   ` (6 preceding siblings ...)
  2025-12-09  1:10 ` [PATCH 07/13] smb/server: add comment to FileSystemName of FileFsAttributeInformation chenxiaosong.chenxiaosong
@ 2025-12-09  1:10 ` chenxiaosong.chenxiaosong
  2025-12-09  1:10 ` [PATCH 09/13] smb: move some definitions from common/smb2pdu.h " chenxiaosong.chenxiaosong
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-09  1:10 UTC (permalink / raw)
  To: sfrench, smfrench, linkinjeon, linkinjeon
  Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
	ZhangGuoDong, ChenXiaoSong

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:

  - filesystem_vol_info -> smb3_fs_vol_info
  - SerialNumber -> VolumeSerialNumber
  - VolumeLabelSize -> VolumeLabelLength

Then move it into common header file.

Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
---
 fs/smb/common/fscc.h       | 11 +++++++++++
 fs/smb/common/smb2pdu.h    | 11 -----------
 fs/smb/server/smb2pdu.c    | 10 +++++-----
 fs/smb/server/smb_common.h |  8 --------
 4 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/fs/smb/common/fscc.h b/fs/smb/common/fscc.h
index 5bf6c82e27f7..bd1e0824ac4a 100644
--- a/fs/smb/common/fscc.h
+++ b/fs/smb/common/fscc.h
@@ -138,6 +138,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 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-FSCC 2.5.10 */
 typedef struct {
 	__le32 DeviceType;
diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
index 5d6ca221d4b6..a4804674aaba 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -1938,17 +1938,6 @@ struct smb2_fs_control_info {
 	__le32 Padding;
 } __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 ddd031ad7689..4faa44fa9875 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -5514,11 +5514,11 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
 	}
 	case FS_VOLUME_INFORMATION:
 	{
-		struct filesystem_vol_info *info;
+		struct smb3_fs_vol_info *info;
 		size_t sz;
 		unsigned int serial_crc = 0;
 
-		info = (struct filesystem_vol_info *)(rsp->Buffer);
+		info = (struct smb3_fs_vol_info *)(rsp->Buffer);
 		info->VolumeCreationTime = 0;
 		serial_crc = crc32_le(serial_crc, share->name,
 				      strlen(share->name));
@@ -5527,14 +5527,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;
-		sz = sizeof(struct filesystem_vol_info) + len;
+		sz = sizeof(struct smb3_fs_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 2baf4aa330eb..b8da31cdbfd1 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.43.0


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

* [PATCH 09/13] smb: move some definitions from common/smb2pdu.h into common/fscc.h
  2025-12-09  1:10 [PATCH 00/13 smb: move duplicate definitions into common header file, part 2 chenxiaosong.chenxiaosong
                   ` (7 preceding siblings ...)
  2025-12-09  1:10 ` [PATCH 08/13] smb: move smb3_fs_vol_info into common/fscc.h chenxiaosong.chenxiaosong
@ 2025-12-09  1:10 ` chenxiaosong.chenxiaosong
  2025-12-09  1:10 ` [PATCH 10/13] smb/client: remove DeviceType Flags and Device Characteristics definitions chenxiaosong.chenxiaosong
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-09  1:10 UTC (permalink / raw)
  To: sfrench, smfrench, linkinjeon, linkinjeon
  Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
	ZhangGuoDong, ChenXiaoSong

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.

Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
---
 fs/smb/common/fscc.h    | 316 ++++++++++++++++++++++++++++++++++++++++
 fs/smb/common/smb2pdu.h | 307 --------------------------------------
 2 files changed, 316 insertions(+), 307 deletions(-)

diff --git a/fs/smb/common/fscc.h b/fs/smb/common/fscc.h
index bd1e0824ac4a..0129246d1d78 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 {
+	__u64 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;
+
+/* 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,46 @@ 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;
@@ -193,6 +493,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 a4804674aaba..72f2cfc47da8 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -1003,22 +1003,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;
@@ -1495,105 +1479,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 {
-	__u64 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
@@ -1602,72 +1487,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];
@@ -1787,84 +1606,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;
@@ -1890,54 +1631,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;
-
 /* See MS-SMB2 2.2.23 through 2.2.25 */
 struct smb2_oplock_break {
 	struct smb2_hdr hdr;
-- 
2.43.0


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

* [PATCH 10/13] smb/client: remove DeviceType Flags and Device Characteristics definitions
  2025-12-09  1:10 [PATCH 00/13 smb: move duplicate definitions into common header file, part 2 chenxiaosong.chenxiaosong
                   ` (8 preceding siblings ...)
  2025-12-09  1:10 ` [PATCH 09/13] smb: move some definitions from common/smb2pdu.h " chenxiaosong.chenxiaosong
@ 2025-12-09  1:10 ` chenxiaosong.chenxiaosong
  2025-12-09  1:10 ` [PATCH 11/13] smb: introduce struct create_posix_ctxt_rsp chenxiaosong.chenxiaosong
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 21+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-09  1:10 UTC (permalink / raw)
  To: sfrench, smfrench, linkinjeon, linkinjeon
  Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
	ZhangGuoDong, ChenXiaoSong

From: ZhangGuoDong <zhangguodong@kylinos.cn>

These definitions are already in common/smb2pdu.h, so remove the duplicated
ones from the client.

Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
---
 fs/smb/client/cifspdu.h | 34 ----------------------------------
 1 file changed, 34 deletions(-)

diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index e10392eb80e7..758ea29769da 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -2003,40 +2003,6 @@ typedef struct {
 
 #define CIFS_POSIX_EXTENSIONS           0x00000010 /* support for new QFSInfo */
 
-/* DeviceType Flags */
-#define FILE_DEVICE_CD_ROM              0x00000002
-#define FILE_DEVICE_CD_ROM_FILE_SYSTEM  0x00000003
-#define FILE_DEVICE_DFS                 0x00000006
-#define FILE_DEVICE_DISK                0x00000007
-#define FILE_DEVICE_DISK_FILE_SYSTEM    0x00000008
-#define FILE_DEVICE_FILE_SYSTEM         0x00000009
-#define FILE_DEVICE_NAMED_PIPE          0x00000011
-#define FILE_DEVICE_NETWORK             0x00000012
-#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
-#define FILE_DEVICE_NULL                0x00000015
-#define FILE_DEVICE_PARALLEL_PORT       0x00000016
-#define FILE_DEVICE_PRINTER             0x00000018
-#define FILE_DEVICE_SERIAL_PORT         0x0000001b
-#define FILE_DEVICE_STREAMS             0x0000001e
-#define FILE_DEVICE_TAPE                0x0000001f
-#define FILE_DEVICE_TAPE_FILE_SYSTEM    0x00000020
-#define FILE_DEVICE_VIRTUAL_DISK        0x00000024
-#define FILE_DEVICE_NETWORK_REDIRECTOR  0x00000028
-
-/* Device Characteristics */
-#define FILE_REMOVABLE_MEDIA			0x00000001
-#define FILE_READ_ONLY_DEVICE			0x00000002
-#define FILE_FLOPPY_DISKETTE			0x00000004
-#define FILE_WRITE_ONCE_MEDIA			0x00000008
-#define FILE_REMOTE_DEVICE			0x00000010
-#define FILE_DEVICE_IS_MOUNTED			0x00000020
-#define FILE_VIRTUAL_VOLUME			0x00000040
-#define FILE_DEVICE_SECURE_OPEN			0x00000100
-#define FILE_CHARACTERISTIC_TS_DEVICE		0x00001000
-#define FILE_CHARACTERISTIC_WEBDAV_DEVICE	0x00002000
-#define FILE_PORTABLE_DEVICE			0x00004000
-#define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL 0x00020000
-
 /******************************************************************************/
 /* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
 /******************************************************************************/
-- 
2.43.0


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

* [PATCH 11/13] smb: introduce struct create_posix_ctxt_rsp
  2025-12-09  1:10 [PATCH 00/13 smb: move duplicate definitions into common header file, part 2 chenxiaosong.chenxiaosong
                   ` (9 preceding siblings ...)
  2025-12-09  1:10 ` [PATCH 10/13] smb/client: remove DeviceType Flags and Device Characteristics definitions chenxiaosong.chenxiaosong
@ 2025-12-09  1:10 ` chenxiaosong.chenxiaosong
  2025-12-09 23:45   ` Namjae Jeon
  2025-12-09  1:10 ` [PATCH 12/13] smb: introduce struct file_posix_info chenxiaosong.chenxiaosong
                   ` (2 subsequent siblings)
  13 siblings, 1 reply; 21+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-09  1:10 UTC (permalink / raw)
  To: sfrench, smfrench, linkinjeon, linkinjeon
  Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
	ZhangGuoDong, ChenXiaoSong

From: ZhangGuoDong <zhangguodong@kylinos.cn>

Modify the following places:

  - introduce new struct create_posix_ctxt_rsp
  - some fields in "struct create_posix_rsp" -> "struct create_posix_ctxt_rsp"
  - create_posix_rsp_buf(): offsetof(..., nlink) -> offsetof(..., ctxt_rsp)

Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
---
 fs/smb/client/smb2pdu.c |  9 +++++----
 fs/smb/client/smb2pdu.h |  6 ++----
 fs/smb/common/smb2pdu.h | 18 ++++++++++++++++++
 fs/smb/server/oplock.c  |  8 ++++----
 fs/smb/server/smb2pdu.h |  6 ++----
 5 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index ef2c6ac500f7..ec0f83db5591 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -2298,9 +2298,9 @@ parse_posix_ctxt(struct create_context *cc, struct smb2_file_all_info *info,
 
 	memset(posix, 0, sizeof(*posix));
 
-	posix->nlink = le32_to_cpu(*(__le32 *)(beg + 0));
-	posix->reparse_tag = le32_to_cpu(*(__le32 *)(beg + 4));
-	posix->mode = le32_to_cpu(*(__le32 *)(beg + 8));
+	posix->ctxt_rsp.nlink = le32_to_cpu(*(__le32 *)(beg + 0));
+	posix->ctxt_rsp.reparse_tag = le32_to_cpu(*(__le32 *)(beg + 4));
+	posix->ctxt_rsp.mode = le32_to_cpu(*(__le32 *)(beg + 8));
 
 	sid = beg + 12;
 	sid_len = posix_info_sid_size(sid, end);
@@ -2319,7 +2319,8 @@ parse_posix_ctxt(struct create_context *cc, struct smb2_file_all_info *info,
 	memcpy(&posix->group, sid, sid_len);
 
 	cifs_dbg(FYI, "nlink=%d mode=%o reparse_tag=%x\n",
-		 posix->nlink, posix->mode, posix->reparse_tag);
+		 posix->ctxt_rsp.nlink, posix->ctxt_rsp.mode,
+		 posix->ctxt_rsp.reparse_tag);
 }
 
 int smb2_parse_contexts(struct TCP_Server_Info *server,
diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
index 78bb99f29d38..4928fb620233 100644
--- a/fs/smb/client/smb2pdu.h
+++ b/fs/smb/client/smb2pdu.h
@@ -251,11 +251,9 @@ 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 */
 struct create_posix_rsp {
-	u32 nlink;
-	u32 reparse_tag;
-	u32 mode;
+	struct create_posix_ctxt_rsp ctxt_rsp;
 	struct smb_sid owner; /* var-sized on the wire */
 	struct smb_sid group; /* var-sized on the wire */
 } __packed;
diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
index 72f2cfc47da8..698ab9d7d16b 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -1814,4 +1814,22 @@ typedef struct smb_negotiate_req {
 	unsigned char DialectsArray[];
 } __packed SMB_NEGOTIATE_REQ;
 
+
+/*
+ * [POSIX-SMB2] SMB3 POSIX Extensions
+ * Link: https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/smb3_posix_extensions.md
+ */
+
+/*
+ * SMB2_CREATE_POSIX_CONTEXT Response
+ * See POSIX-SMB2 2.2.14.2.16
+ */
+struct create_posix_ctxt_rsp {
+	__le32 nlink;
+	__le32 reparse_tag;
+	__le32 mode;
+	// var sized owner SID
+	// var sized group SID
+} __packed;
+
 #endif				/* _COMMON_SMB2PDU_H */
diff --git a/fs/smb/server/oplock.c b/fs/smb/server/oplock.c
index 1f07ebf431d7..8658402ff893 100644
--- a/fs/smb/server/oplock.c
+++ b/fs/smb/server/oplock.c
@@ -1703,7 +1703,7 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp)
 	buf = (struct create_posix_rsp *)cc;
 	memset(buf, 0, sizeof(struct create_posix_rsp));
 	buf->ccontext.DataOffset = cpu_to_le16(offsetof
-			(struct create_posix_rsp, nlink));
+			(struct create_posix_rsp, ctxt_rsp));
 	/*
 	 * DataLength = nlink(4) + reparse_tag(4) + mode(4) +
 	 * domain sid(28) + unix group sid(16).
@@ -1730,9 +1730,9 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp)
 	buf->Name[14] = 0xCD;
 	buf->Name[15] = 0x7C;
 
-	buf->nlink = cpu_to_le32(inode->i_nlink);
-	buf->reparse_tag = cpu_to_le32(fp->volatile_id);
-	buf->mode = cpu_to_le32(inode->i_mode & 0777);
+	buf->ctxt_rsp.nlink = cpu_to_le32(inode->i_nlink);
+	buf->ctxt_rsp.reparse_tag = cpu_to_le32(fp->volatile_id);
+	buf->ctxt_rsp.mode = cpu_to_le32(inode->i_mode & 0777);
 	/*
 	 * SidBuffer(44) contain two sids(Domain sid(28), UNIX group sid(16)).
 	 * Domain sid(28) = revision(1) + num_subauth(1) + authority(6) +
diff --git a/fs/smb/server/smb2pdu.h b/fs/smb/server/smb2pdu.h
index 66cdc8e4a648..09311a9eb1de 100644
--- a/fs/smb/server/smb2pdu.h
+++ b/fs/smb/server/smb2pdu.h
@@ -83,13 +83,11 @@ 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 */
 struct create_posix_rsp {
 	struct create_context_hdr ccontext;
 	__u8    Name[16];
-	__le32 nlink;
-	__le32 reparse_tag;
-	__le32 mode;
+	struct create_posix_ctxt_rsp ctxt_rsp;
 	/* SidBuffer contain two sids(Domain sid(28), UNIX group sid(16)) */
 	u8 SidBuffer[44];
 } __packed;
-- 
2.43.0


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

* [PATCH 12/13] smb: introduce struct file_posix_info
  2025-12-09  1:10 [PATCH 00/13 smb: move duplicate definitions into common header file, part 2 chenxiaosong.chenxiaosong
                   ` (10 preceding siblings ...)
  2025-12-09  1:10 ` [PATCH 11/13] smb: introduce struct create_posix_ctxt_rsp chenxiaosong.chenxiaosong
@ 2025-12-09  1:10 ` chenxiaosong.chenxiaosong
  2025-12-09  1:10 ` [PATCH 13/13] smb: move some SMB1 definitions into common/smb1pdu.h chenxiaosong.chenxiaosong
  2025-12-10  4:34 ` [PATCH 00/13 smb: move duplicate definitions into common header file, part 2 ChenXiaoSong
  13 siblings, 0 replies; 21+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-09  1:10 UTC (permalink / raw)
  To: sfrench, smfrench, linkinjeon, linkinjeon
  Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
	ZhangGuoDong, ChenXiaoSong

From: ZhangGuoDong <zhangguodong@kylinos.cn>

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"

Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@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 400e4fbd450f..b51870981719 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -841,16 +841,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;
@@ -861,11 +861,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 7ff728503ed1..835f69e4b2de 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);
@@ -516,7 +516,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 19caab2fd11e..fd7f14908075 100644
--- a/fs/smb/client/reparse.h
+++ b/fs/smb/client/reparse.h
@@ -105,10 +105,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 4928fb620233..07ba081750fb 100644
--- a/fs/smb/client/smb2pdu.h
+++ b/fs/smb/client/smb2pdu.h
@@ -269,20 +269,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 0129246d1d78..b0ec6ff1081f 100644
--- a/fs/smb/common/fscc.h
+++ b/fs/smb/common/fscc.h
@@ -521,9 +521,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 698ab9d7d16b..2d68bd24f3bd 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -1606,31 +1606,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 4faa44fa9875..a4f6de350df8 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -4036,44 +4036,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) +
@@ -5259,45 +5259,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 09311a9eb1de..11737e1ac864 100644
--- a/fs/smb/server/smb2pdu.h
+++ b/fs/smb/server/smb2pdu.h
@@ -285,30 +285,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.43.0


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

* [PATCH 13/13] smb: move some SMB1 definitions into common/smb1pdu.h
  2025-12-09  1:10 [PATCH 00/13 smb: move duplicate definitions into common header file, part 2 chenxiaosong.chenxiaosong
                   ` (11 preceding siblings ...)
  2025-12-09  1:10 ` [PATCH 12/13] smb: introduce struct file_posix_info chenxiaosong.chenxiaosong
@ 2025-12-09  1:10 ` chenxiaosong.chenxiaosong
  2025-12-09  2:52   ` Steve French
  2025-12-10  4:34 ` [PATCH 00/13 smb: move duplicate definitions into common header file, part 2 ChenXiaoSong
  13 siblings, 1 reply; 21+ messages in thread
From: chenxiaosong.chenxiaosong @ 2025-12-09  1:10 UTC (permalink / raw)
  To: sfrench, smfrench, linkinjeon, linkinjeon
  Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01,
	ZhangGuoDong, ChenXiaoSong

From: ZhangGuoDong <zhangguodong@kylinos.cn>

These definitions are only used by SMB1, so move them into the new
common/smb1pdu.h.

Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
---
 fs/smb/client/cifspdu.h    |  2 +-
 fs/smb/common/smb1pdu.h    | 59 ++++++++++++++++++++++++++++++++++++++
 fs/smb/common/smb2pdu.h    | 44 ----------------------------
 fs/smb/common/smbglob.h    |  2 --
 fs/smb/server/smb_common.h |  1 +
 5 files changed, 61 insertions(+), 47 deletions(-)
 create mode 100644 fs/smb/common/smb1pdu.h

diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
index 758ea29769da..bf6329cb4fd4 100644
--- a/fs/smb/client/cifspdu.h
+++ b/fs/smb/client/cifspdu.h
@@ -12,7 +12,7 @@
 #include <net/sock.h>
 #include <linux/unaligned.h>
 #include "../common/smbfsctl.h"
-#include "../common/smb2pdu.h"
+#include "../common/smb1pdu.h"
 
 #define CIFS_PROT   0
 #define POSIX_PROT  (CIFS_PROT+1)
diff --git a/fs/smb/common/smb1pdu.h b/fs/smb/common/smb1pdu.h
new file mode 100644
index 000000000000..11797471b2eb
--- /dev/null
+++ b/fs/smb/common/smb1pdu.h
@@ -0,0 +1,59 @@
+/* SPDX-License-Identifier: LGPL-2.1 */
+/*
+ *
+ *   Copyright (c) International Business Machines  Corp., 2002,2009
+ *                 2018 Samsung Electronics Co., Ltd.
+ *   Author(s): Steve French (sfrench@us.ibm.com)
+ *              Namjae Jeon (linkinjeon@kernel.org)
+ *
+ */
+
+#ifndef _COMMON_SMB1_PDU_H
+#define _COMMON_SMB1_PDU_H
+
+#define SMB1_PROTO_NUMBER		cpu_to_le32(0x424d53ff)
+
+/*
+ * See MS-CIFS 2.2.3.1
+ *     MS-SMB 2.2.3.1
+ */
+struct smb_hdr {
+	__be32 smb_buf_length;	/* BB length is only two (rarely three) bytes,
+		with one or two byte "type" preceding it that will be
+		zero - we could mask the type byte off */
+	__u8 Protocol[4];
+	__u8 Command;
+	union {
+		struct {
+			__u8 ErrorClass;
+			__u8 Reserved;
+			__le16 Error;
+		} __packed DosError;
+		__le32 CifsError;
+	} __packed Status;
+	__u8 Flags;
+	__le16 Flags2;		/* note: le */
+	__le16 PidHigh;
+	union {
+		struct {
+			__le32 SequenceNumber;  /* le */
+			__u32 Reserved; /* zero */
+		} __packed Sequence;
+		__u8 SecuritySignature[8];	/* le */
+	} __packed Signature;
+	__u8 pad[2];
+	__u16 Tid;
+	__le16 Pid;
+	__u16 Uid;
+	__le16 Mid;
+	__u8 WordCount;
+} __packed;
+
+/* See MS-CIFS 2.2.4.52.1 */
+typedef struct smb_negotiate_req {
+	struct smb_hdr hdr;	/* wct = 0 */
+	__le16 ByteCount;
+	unsigned char DialectsArray[];
+} __packed SMB_NEGOTIATE_REQ;
+
+#endif /* _COMMON_SMB1_PDU_H */
diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
index 2d68bd24f3bd..098f147680c5 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -1642,42 +1642,6 @@ struct smb2_lease_ack {
 	__le64 LeaseDuration;
 } __packed;
 
-/*
- * See MS-CIFS 2.2.3.1
- *     MS-SMB 2.2.3.1
- */
-struct smb_hdr {
-	__be32 smb_buf_length;	/* BB length is only two (rarely three) bytes,
-		with one or two byte "type" preceding it that will be
-		zero - we could mask the type byte off */
-	__u8 Protocol[4];
-	__u8 Command;
-	union {
-		struct {
-			__u8 ErrorClass;
-			__u8 Reserved;
-			__le16 Error;
-		} __packed DosError;
-		__le32 CifsError;
-	} __packed Status;
-	__u8 Flags;
-	__le16 Flags2;		/* note: le */
-	__le16 PidHigh;
-	union {
-		struct {
-			__le32 SequenceNumber;  /* le */
-			__u32 Reserved; /* zero */
-		} __packed Sequence;
-		__u8 SecuritySignature[8];	/* le */
-	} __packed Signature;
-	__u8 pad[2];
-	__u16 Tid;
-	__le16 Pid;
-	__u16 Uid;
-	__le16 Mid;
-	__u8 WordCount;
-} __packed;
-
 #define OP_BREAK_STRUCT_SIZE_20		24
 #define OP_BREAK_STRUCT_SIZE_21		36
 
@@ -1782,14 +1746,6 @@ struct smb_hdr {
 #define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \
 				| READ_CONTROL | SYNCHRONIZE)
 
-/* See MS-CIFS 2.2.4.52.1 */
-typedef struct smb_negotiate_req {
-	struct smb_hdr hdr;	/* wct = 0 */
-	__le16 ByteCount;
-	unsigned char DialectsArray[];
-} __packed SMB_NEGOTIATE_REQ;
-
-
 /*
  * [POSIX-SMB2] SMB3 POSIX Extensions
  * Link: https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/smb3_posix_extensions.md
diff --git a/fs/smb/common/smbglob.h b/fs/smb/common/smbglob.h
index 7853b5771128..353dc4f0971a 100644
--- a/fs/smb/common/smbglob.h
+++ b/fs/smb/common/smbglob.h
@@ -11,8 +11,6 @@
 #ifndef _COMMON_SMB_GLOB_H
 #define _COMMON_SMB_GLOB_H
 
-#define SMB1_PROTO_NUMBER		cpu_to_le32(0x424d53ff)
-
 struct smb_version_values {
 	char		*version_string;
 	__u16		protocol_id;
diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
index b8da31cdbfd1..f47ce4a6719c 100644
--- a/fs/smb/server/smb_common.h
+++ b/fs/smb/server/smb_common.h
@@ -11,6 +11,7 @@
 #include "glob.h"
 #include "nterr.h"
 #include "../common/smbglob.h"
+#include "../common/smb1pdu.h"
 #include "../common/smb2pdu.h"
 #include "../common/fscc.h"
 #include "smb2pdu.h"
-- 
2.43.0


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

* Re: [PATCH 13/13] smb: move some SMB1 definitions into common/smb1pdu.h
  2025-12-09  1:10 ` [PATCH 13/13] smb: move some SMB1 definitions into common/smb1pdu.h chenxiaosong.chenxiaosong
@ 2025-12-09  2:52   ` Steve French
  2025-12-09  2:56     ` ChenXiaoSong
  0 siblings, 1 reply; 21+ messages in thread
From: Steve French @ 2025-12-09  2:52 UTC (permalink / raw)
  To: chenxiaosong.chenxiaosong
  Cc: sfrench, linkinjeon, linkinjeon, linux-cifs, linux-kernel,
	liuzhengyuan, huhai, liuyun01, ZhangGuoDong, ChenXiaoSong

One option to consider is moving smb1 definitions into a client only
(fs/smb/client) header since ksmbd doesn't use SMB1 technically they
aren't 'common'

Did you find ksmbd server cases where it depends on any of these?

On Mon, Dec 8, 2025 at 7:12 PM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>
> From: ZhangGuoDong <zhangguodong@kylinos.cn>
>
> These definitions are only used by SMB1, so move them into the new
> common/smb1pdu.h.
>
> Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
> ---
>  fs/smb/client/cifspdu.h    |  2 +-
>  fs/smb/common/smb1pdu.h    | 59 ++++++++++++++++++++++++++++++++++++++
>  fs/smb/common/smb2pdu.h    | 44 ----------------------------
>  fs/smb/common/smbglob.h    |  2 --
>  fs/smb/server/smb_common.h |  1 +
>  5 files changed, 61 insertions(+), 47 deletions(-)
>  create mode 100644 fs/smb/common/smb1pdu.h
>
> diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
> index 758ea29769da..bf6329cb4fd4 100644
> --- a/fs/smb/client/cifspdu.h
> +++ b/fs/smb/client/cifspdu.h
> @@ -12,7 +12,7 @@
>  #include <net/sock.h>
>  #include <linux/unaligned.h>
>  #include "../common/smbfsctl.h"
> -#include "../common/smb2pdu.h"
> +#include "../common/smb1pdu.h"
>
>  #define CIFS_PROT   0
>  #define POSIX_PROT  (CIFS_PROT+1)
> diff --git a/fs/smb/common/smb1pdu.h b/fs/smb/common/smb1pdu.h
> new file mode 100644
> index 000000000000..11797471b2eb
> --- /dev/null
> +++ b/fs/smb/common/smb1pdu.h
> @@ -0,0 +1,59 @@
> +/* SPDX-License-Identifier: LGPL-2.1 */
> +/*
> + *
> + *   Copyright (c) International Business Machines  Corp., 2002,2009
> + *                 2018 Samsung Electronics Co., Ltd.
> + *   Author(s): Steve French (sfrench@us.ibm.com)
> + *              Namjae Jeon (linkinjeon@kernel.org)
> + *
> + */
> +
> +#ifndef _COMMON_SMB1_PDU_H
> +#define _COMMON_SMB1_PDU_H
> +
> +#define SMB1_PROTO_NUMBER              cpu_to_le32(0x424d53ff)
> +
> +/*
> + * See MS-CIFS 2.2.3.1
> + *     MS-SMB 2.2.3.1
> + */
> +struct smb_hdr {
> +       __be32 smb_buf_length;  /* BB length is only two (rarely three) bytes,
> +               with one or two byte "type" preceding it that will be
> +               zero - we could mask the type byte off */
> +       __u8 Protocol[4];
> +       __u8 Command;
> +       union {
> +               struct {
> +                       __u8 ErrorClass;
> +                       __u8 Reserved;
> +                       __le16 Error;
> +               } __packed DosError;
> +               __le32 CifsError;
> +       } __packed Status;
> +       __u8 Flags;
> +       __le16 Flags2;          /* note: le */
> +       __le16 PidHigh;
> +       union {
> +               struct {
> +                       __le32 SequenceNumber;  /* le */
> +                       __u32 Reserved; /* zero */
> +               } __packed Sequence;
> +               __u8 SecuritySignature[8];      /* le */
> +       } __packed Signature;
> +       __u8 pad[2];
> +       __u16 Tid;
> +       __le16 Pid;
> +       __u16 Uid;
> +       __le16 Mid;
> +       __u8 WordCount;
> +} __packed;
> +
> +/* See MS-CIFS 2.2.4.52.1 */
> +typedef struct smb_negotiate_req {
> +       struct smb_hdr hdr;     /* wct = 0 */
> +       __le16 ByteCount;
> +       unsigned char DialectsArray[];
> +} __packed SMB_NEGOTIATE_REQ;
> +
> +#endif /* _COMMON_SMB1_PDU_H */
> diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
> index 2d68bd24f3bd..098f147680c5 100644
> --- a/fs/smb/common/smb2pdu.h
> +++ b/fs/smb/common/smb2pdu.h
> @@ -1642,42 +1642,6 @@ struct smb2_lease_ack {
>         __le64 LeaseDuration;
>  } __packed;
>
> -/*
> - * See MS-CIFS 2.2.3.1
> - *     MS-SMB 2.2.3.1
> - */
> -struct smb_hdr {
> -       __be32 smb_buf_length;  /* BB length is only two (rarely three) bytes,
> -               with one or two byte "type" preceding it that will be
> -               zero - we could mask the type byte off */
> -       __u8 Protocol[4];
> -       __u8 Command;
> -       union {
> -               struct {
> -                       __u8 ErrorClass;
> -                       __u8 Reserved;
> -                       __le16 Error;
> -               } __packed DosError;
> -               __le32 CifsError;
> -       } __packed Status;
> -       __u8 Flags;
> -       __le16 Flags2;          /* note: le */
> -       __le16 PidHigh;
> -       union {
> -               struct {
> -                       __le32 SequenceNumber;  /* le */
> -                       __u32 Reserved; /* zero */
> -               } __packed Sequence;
> -               __u8 SecuritySignature[8];      /* le */
> -       } __packed Signature;
> -       __u8 pad[2];
> -       __u16 Tid;
> -       __le16 Pid;
> -       __u16 Uid;
> -       __le16 Mid;
> -       __u8 WordCount;
> -} __packed;
> -
>  #define OP_BREAK_STRUCT_SIZE_20                24
>  #define OP_BREAK_STRUCT_SIZE_21                36
>
> @@ -1782,14 +1746,6 @@ struct smb_hdr {
>  #define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \
>                                 | READ_CONTROL | SYNCHRONIZE)
>
> -/* See MS-CIFS 2.2.4.52.1 */
> -typedef struct smb_negotiate_req {
> -       struct smb_hdr hdr;     /* wct = 0 */
> -       __le16 ByteCount;
> -       unsigned char DialectsArray[];
> -} __packed SMB_NEGOTIATE_REQ;
> -
> -
>  /*
>   * [POSIX-SMB2] SMB3 POSIX Extensions
>   * Link: https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/smb3_posix_extensions.md
> diff --git a/fs/smb/common/smbglob.h b/fs/smb/common/smbglob.h
> index 7853b5771128..353dc4f0971a 100644
> --- a/fs/smb/common/smbglob.h
> +++ b/fs/smb/common/smbglob.h
> @@ -11,8 +11,6 @@
>  #ifndef _COMMON_SMB_GLOB_H
>  #define _COMMON_SMB_GLOB_H
>
> -#define SMB1_PROTO_NUMBER              cpu_to_le32(0x424d53ff)
> -
>  struct smb_version_values {
>         char            *version_string;
>         __u16           protocol_id;
> diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
> index b8da31cdbfd1..f47ce4a6719c 100644
> --- a/fs/smb/server/smb_common.h
> +++ b/fs/smb/server/smb_common.h
> @@ -11,6 +11,7 @@
>  #include "glob.h"
>  #include "nterr.h"
>  #include "../common/smbglob.h"
> +#include "../common/smb1pdu.h"
>  #include "../common/smb2pdu.h"
>  #include "../common/fscc.h"
>  #include "smb2pdu.h"
> --
> 2.43.0
>


-- 
Thanks,

Steve

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

* Re: [PATCH 13/13] smb: move some SMB1 definitions into common/smb1pdu.h
  2025-12-09  2:52   ` Steve French
@ 2025-12-09  2:56     ` ChenXiaoSong
  0 siblings, 0 replies; 21+ messages in thread
From: ChenXiaoSong @ 2025-12-09  2:56 UTC (permalink / raw)
  To: Steve French
  Cc: sfrench, linkinjeon, linkinjeon, linux-cifs, linux-kernel,
	liuzhengyuan, huhai, liuyun01, ZhangGuoDong, ChenXiaoSong

ksmbd only implements SMB_COM_NEGOTIATE. Please refer to the 
init_smb1_rsp_hdr() function

Thanks,
ChenXiaoSong.

On 12/9/25 10:52, Steve French wrote:
> One option to consider is moving smb1 definitions into a client only
> (fs/smb/client) header since ksmbd doesn't use SMB1 technically they
> aren't 'common'
> 
> Did you find ksmbd server cases where it depends on any of these?
> 
> On Mon, Dec 8, 2025 at 7:12 PM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>>
>> From: ZhangGuoDong <zhangguodong@kylinos.cn>
>>
>> These definitions are only used by SMB1, so move them into the new
>> common/smb1pdu.h.
>>
>> Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
>> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
>> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
>> ---
>>   fs/smb/client/cifspdu.h    |  2 +-
>>   fs/smb/common/smb1pdu.h    | 59 ++++++++++++++++++++++++++++++++++++++
>>   fs/smb/common/smb2pdu.h    | 44 ----------------------------
>>   fs/smb/common/smbglob.h    |  2 --
>>   fs/smb/server/smb_common.h |  1 +
>>   5 files changed, 61 insertions(+), 47 deletions(-)
>>   create mode 100644 fs/smb/common/smb1pdu.h
>>
>> diff --git a/fs/smb/client/cifspdu.h b/fs/smb/client/cifspdu.h
>> index 758ea29769da..bf6329cb4fd4 100644
>> --- a/fs/smb/client/cifspdu.h
>> +++ b/fs/smb/client/cifspdu.h
>> @@ -12,7 +12,7 @@
>>   #include <net/sock.h>
>>   #include <linux/unaligned.h>
>>   #include "../common/smbfsctl.h"
>> -#include "../common/smb2pdu.h"
>> +#include "../common/smb1pdu.h"
>>
>>   #define CIFS_PROT   0
>>   #define POSIX_PROT  (CIFS_PROT+1)
>> diff --git a/fs/smb/common/smb1pdu.h b/fs/smb/common/smb1pdu.h
>> new file mode 100644
>> index 000000000000..11797471b2eb
>> --- /dev/null
>> +++ b/fs/smb/common/smb1pdu.h
>> @@ -0,0 +1,59 @@
>> +/* SPDX-License-Identifier: LGPL-2.1 */
>> +/*
>> + *
>> + *   Copyright (c) International Business Machines  Corp., 2002,2009
>> + *                 2018 Samsung Electronics Co., Ltd.
>> + *   Author(s): Steve French (sfrench@us.ibm.com)
>> + *              Namjae Jeon (linkinjeon@kernel.org)
>> + *
>> + */
>> +
>> +#ifndef _COMMON_SMB1_PDU_H
>> +#define _COMMON_SMB1_PDU_H
>> +
>> +#define SMB1_PROTO_NUMBER              cpu_to_le32(0x424d53ff)
>> +
>> +/*
>> + * See MS-CIFS 2.2.3.1
>> + *     MS-SMB 2.2.3.1
>> + */
>> +struct smb_hdr {
>> +       __be32 smb_buf_length;  /* BB length is only two (rarely three) bytes,
>> +               with one or two byte "type" preceding it that will be
>> +               zero - we could mask the type byte off */
>> +       __u8 Protocol[4];
>> +       __u8 Command;
>> +       union {
>> +               struct {
>> +                       __u8 ErrorClass;
>> +                       __u8 Reserved;
>> +                       __le16 Error;
>> +               } __packed DosError;
>> +               __le32 CifsError;
>> +       } __packed Status;
>> +       __u8 Flags;
>> +       __le16 Flags2;          /* note: le */
>> +       __le16 PidHigh;
>> +       union {
>> +               struct {
>> +                       __le32 SequenceNumber;  /* le */
>> +                       __u32 Reserved; /* zero */
>> +               } __packed Sequence;
>> +               __u8 SecuritySignature[8];      /* le */
>> +       } __packed Signature;
>> +       __u8 pad[2];
>> +       __u16 Tid;
>> +       __le16 Pid;
>> +       __u16 Uid;
>> +       __le16 Mid;
>> +       __u8 WordCount;
>> +} __packed;
>> +
>> +/* See MS-CIFS 2.2.4.52.1 */
>> +typedef struct smb_negotiate_req {
>> +       struct smb_hdr hdr;     /* wct = 0 */
>> +       __le16 ByteCount;
>> +       unsigned char DialectsArray[];
>> +} __packed SMB_NEGOTIATE_REQ;
>> +
>> +#endif /* _COMMON_SMB1_PDU_H */
>> diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
>> index 2d68bd24f3bd..098f147680c5 100644
>> --- a/fs/smb/common/smb2pdu.h
>> +++ b/fs/smb/common/smb2pdu.h
>> @@ -1642,42 +1642,6 @@ struct smb2_lease_ack {
>>          __le64 LeaseDuration;
>>   } __packed;
>>
>> -/*
>> - * See MS-CIFS 2.2.3.1
>> - *     MS-SMB 2.2.3.1
>> - */
>> -struct smb_hdr {
>> -       __be32 smb_buf_length;  /* BB length is only two (rarely three) bytes,
>> -               with one or two byte "type" preceding it that will be
>> -               zero - we could mask the type byte off */
>> -       __u8 Protocol[4];
>> -       __u8 Command;
>> -       union {
>> -               struct {
>> -                       __u8 ErrorClass;
>> -                       __u8 Reserved;
>> -                       __le16 Error;
>> -               } __packed DosError;
>> -               __le32 CifsError;
>> -       } __packed Status;
>> -       __u8 Flags;
>> -       __le16 Flags2;          /* note: le */
>> -       __le16 PidHigh;
>> -       union {
>> -               struct {
>> -                       __le32 SequenceNumber;  /* le */
>> -                       __u32 Reserved; /* zero */
>> -               } __packed Sequence;
>> -               __u8 SecuritySignature[8];      /* le */
>> -       } __packed Signature;
>> -       __u8 pad[2];
>> -       __u16 Tid;
>> -       __le16 Pid;
>> -       __u16 Uid;
>> -       __le16 Mid;
>> -       __u8 WordCount;
>> -} __packed;
>> -
>>   #define OP_BREAK_STRUCT_SIZE_20                24
>>   #define OP_BREAK_STRUCT_SIZE_21                36
>>
>> @@ -1782,14 +1746,6 @@ struct smb_hdr {
>>   #define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \
>>                                  | READ_CONTROL | SYNCHRONIZE)
>>
>> -/* See MS-CIFS 2.2.4.52.1 */
>> -typedef struct smb_negotiate_req {
>> -       struct smb_hdr hdr;     /* wct = 0 */
>> -       __le16 ByteCount;
>> -       unsigned char DialectsArray[];
>> -} __packed SMB_NEGOTIATE_REQ;
>> -
>> -
>>   /*
>>    * [POSIX-SMB2] SMB3 POSIX Extensions
>>    * Link: https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/smb3_posix_extensions.md
>> diff --git a/fs/smb/common/smbglob.h b/fs/smb/common/smbglob.h
>> index 7853b5771128..353dc4f0971a 100644
>> --- a/fs/smb/common/smbglob.h
>> +++ b/fs/smb/common/smbglob.h
>> @@ -11,8 +11,6 @@
>>   #ifndef _COMMON_SMB_GLOB_H
>>   #define _COMMON_SMB_GLOB_H
>>
>> -#define SMB1_PROTO_NUMBER              cpu_to_le32(0x424d53ff)
>> -
>>   struct smb_version_values {
>>          char            *version_string;
>>          __u16           protocol_id;
>> diff --git a/fs/smb/server/smb_common.h b/fs/smb/server/smb_common.h
>> index b8da31cdbfd1..f47ce4a6719c 100644
>> --- a/fs/smb/server/smb_common.h
>> +++ b/fs/smb/server/smb_common.h
>> @@ -11,6 +11,7 @@
>>   #include "glob.h"
>>   #include "nterr.h"
>>   #include "../common/smbglob.h"
>> +#include "../common/smb1pdu.h"
>>   #include "../common/smb2pdu.h"
>>   #include "../common/fscc.h"
>>   #include "smb2pdu.h"
>> --
>> 2.43.0
>>
> 
> 


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

* Re: [PATCH 11/13] smb: introduce struct create_posix_ctxt_rsp
  2025-12-09  1:10 ` [PATCH 11/13] smb: introduce struct create_posix_ctxt_rsp chenxiaosong.chenxiaosong
@ 2025-12-09 23:45   ` Namjae Jeon
  2025-12-10  0:12     ` ChenXiaoSong
  0 siblings, 1 reply; 21+ messages in thread
From: Namjae Jeon @ 2025-12-09 23:45 UTC (permalink / raw)
  To: chenxiaosong.chenxiaosong
  Cc: sfrench, smfrench, linkinjeon, linux-cifs, linux-kernel,
	liuzhengyuan, huhai, liuyun01, ZhangGuoDong, ChenXiaoSong

On Tue, Dec 9, 2025 at 10:12 AM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>
> From: ZhangGuoDong <zhangguodong@kylinos.cn>
>
> Modify the following places:
>
>   - introduce new struct create_posix_ctxt_rsp
>   - some fields in "struct create_posix_rsp" -> "struct create_posix_ctxt_rsp"
>   - create_posix_rsp_buf(): offsetof(..., nlink) -> offsetof(..., ctxt_rsp)
I don't know why we need to add a new create_posix_ctxt_rsp struct.
>
> Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
> ---
>  fs/smb/client/smb2pdu.c |  9 +++++----
>  fs/smb/client/smb2pdu.h |  6 ++----
>  fs/smb/common/smb2pdu.h | 18 ++++++++++++++++++
>  fs/smb/server/oplock.c  |  8 ++++----
>  fs/smb/server/smb2pdu.h |  6 ++----
>  5 files changed, 31 insertions(+), 16 deletions(-)
>
> diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
> index ef2c6ac500f7..ec0f83db5591 100644
> --- a/fs/smb/client/smb2pdu.c
> +++ b/fs/smb/client/smb2pdu.c
> @@ -2298,9 +2298,9 @@ parse_posix_ctxt(struct create_context *cc, struct smb2_file_all_info *info,
>
>         memset(posix, 0, sizeof(*posix));
>
> -       posix->nlink = le32_to_cpu(*(__le32 *)(beg + 0));
> -       posix->reparse_tag = le32_to_cpu(*(__le32 *)(beg + 4));
> -       posix->mode = le32_to_cpu(*(__le32 *)(beg + 8));
> +       posix->ctxt_rsp.nlink = le32_to_cpu(*(__le32 *)(beg + 0));
> +       posix->ctxt_rsp.reparse_tag = le32_to_cpu(*(__le32 *)(beg + 4));
> +       posix->ctxt_rsp.mode = le32_to_cpu(*(__le32 *)(beg + 8));
>
>         sid = beg + 12;
>         sid_len = posix_info_sid_size(sid, end);
> @@ -2319,7 +2319,8 @@ parse_posix_ctxt(struct create_context *cc, struct smb2_file_all_info *info,
>         memcpy(&posix->group, sid, sid_len);
>
>         cifs_dbg(FYI, "nlink=%d mode=%o reparse_tag=%x\n",
> -                posix->nlink, posix->mode, posix->reparse_tag);
> +                posix->ctxt_rsp.nlink, posix->ctxt_rsp.mode,
> +                posix->ctxt_rsp.reparse_tag);
>  }
>
>  int smb2_parse_contexts(struct TCP_Server_Info *server,
> diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
> index 78bb99f29d38..4928fb620233 100644
> --- a/fs/smb/client/smb2pdu.h
> +++ b/fs/smb/client/smb2pdu.h
> @@ -251,11 +251,9 @@ 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 */
>  struct create_posix_rsp {
> -       u32 nlink;
> -       u32 reparse_tag;
> -       u32 mode;
> +       struct create_posix_ctxt_rsp ctxt_rsp;
>         struct smb_sid owner; /* var-sized on the wire */
>         struct smb_sid group; /* var-sized on the wire */
>  } __packed;
> diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
> index 72f2cfc47da8..698ab9d7d16b 100644
> --- a/fs/smb/common/smb2pdu.h
> +++ b/fs/smb/common/smb2pdu.h
> @@ -1814,4 +1814,22 @@ typedef struct smb_negotiate_req {
>         unsigned char DialectsArray[];
>  } __packed SMB_NEGOTIATE_REQ;
>
> +
> +/*
> + * [POSIX-SMB2] SMB3 POSIX Extensions
> + * Link: https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/smb3_posix_extensions.md
> + */
> +
> +/*
> + * SMB2_CREATE_POSIX_CONTEXT Response
> + * See POSIX-SMB2 2.2.14.2.16
> + */
> +struct create_posix_ctxt_rsp {
> +       __le32 nlink;
> +       __le32 reparse_tag;
> +       __le32 mode;
> +       // var sized owner SID
> +       // var sized group SID
> +} __packed;
> +
>  #endif                         /* _COMMON_SMB2PDU_H */
> diff --git a/fs/smb/server/oplock.c b/fs/smb/server/oplock.c
> index 1f07ebf431d7..8658402ff893 100644
> --- a/fs/smb/server/oplock.c
> +++ b/fs/smb/server/oplock.c
> @@ -1703,7 +1703,7 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp)
>         buf = (struct create_posix_rsp *)cc;
>         memset(buf, 0, sizeof(struct create_posix_rsp));
>         buf->ccontext.DataOffset = cpu_to_le16(offsetof
> -                       (struct create_posix_rsp, nlink));
> +                       (struct create_posix_rsp, ctxt_rsp));
>         /*
>          * DataLength = nlink(4) + reparse_tag(4) + mode(4) +
>          * domain sid(28) + unix group sid(16).
> @@ -1730,9 +1730,9 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp)
>         buf->Name[14] = 0xCD;
>         buf->Name[15] = 0x7C;
>
> -       buf->nlink = cpu_to_le32(inode->i_nlink);
> -       buf->reparse_tag = cpu_to_le32(fp->volatile_id);
> -       buf->mode = cpu_to_le32(inode->i_mode & 0777);
> +       buf->ctxt_rsp.nlink = cpu_to_le32(inode->i_nlink);
> +       buf->ctxt_rsp.reparse_tag = cpu_to_le32(fp->volatile_id);
> +       buf->ctxt_rsp.mode = cpu_to_le32(inode->i_mode & 0777);
>         /*
>          * SidBuffer(44) contain two sids(Domain sid(28), UNIX group sid(16)).
>          * Domain sid(28) = revision(1) + num_subauth(1) + authority(6) +
> diff --git a/fs/smb/server/smb2pdu.h b/fs/smb/server/smb2pdu.h
> index 66cdc8e4a648..09311a9eb1de 100644
> --- a/fs/smb/server/smb2pdu.h
> +++ b/fs/smb/server/smb2pdu.h
> @@ -83,13 +83,11 @@ 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 */
>  struct create_posix_rsp {
>         struct create_context_hdr ccontext;
>         __u8    Name[16];
> -       __le32 nlink;
> -       __le32 reparse_tag;
> -       __le32 mode;
> +       struct create_posix_ctxt_rsp ctxt_rsp;
>         /* SidBuffer contain two sids(Domain sid(28), UNIX group sid(16)) */
>         u8 SidBuffer[44];
>  } __packed;
> --
> 2.43.0
>

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

* Re: [PATCH 11/13] smb: introduce struct create_posix_ctxt_rsp
  2025-12-09 23:45   ` Namjae Jeon
@ 2025-12-10  0:12     ` ChenXiaoSong
  2025-12-10  0:31       ` Namjae Jeon
  0 siblings, 1 reply; 21+ messages in thread
From: ChenXiaoSong @ 2025-12-10  0:12 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: sfrench, smfrench, linkinjeon, linux-cifs, linux-kernel,
	liuzhengyuan, huhai, liuyun01, ZhangGuoDong, ChenXiaoSong

Hi Namjae,

The `create_posix_rsp` structures on the client and server sides differ, 
but they share a common part, and only this common part is defined in 
POSIX‑SMB2 2.2.14.2.16.

/*
  * [POSIX-SMB2] SMB3 POSIX Extensions
  * Link: 
https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/smb3_posix_extensions.md
  */

Thanks,
ChenXiaoSong.

On 12/10/25 7:45 AM, Namjae Jeon wrote:
> On Tue, Dec 9, 2025 at 10:12 AM <chenxiaosong.chenxiaosong@linux.dev> wrote:
>>
>> From: ZhangGuoDong <zhangguodong@kylinos.cn>
>>
>> Modify the following places:
>>
>>    - introduce new struct create_posix_ctxt_rsp
>>    - some fields in "struct create_posix_rsp" -> "struct create_posix_ctxt_rsp"
>>    - create_posix_rsp_buf(): offsetof(..., nlink) -> offsetof(..., ctxt_rsp)
> I don't know why we need to add a new create_posix_ctxt_rsp struct.
>>
>> Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
>> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
>> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
>> ---
>>   fs/smb/client/smb2pdu.c |  9 +++++----
>>   fs/smb/client/smb2pdu.h |  6 ++----
>>   fs/smb/common/smb2pdu.h | 18 ++++++++++++++++++
>>   fs/smb/server/oplock.c  |  8 ++++----
>>   fs/smb/server/smb2pdu.h |  6 ++----
>>   5 files changed, 31 insertions(+), 16 deletions(-)
>>
>> diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
>> index ef2c6ac500f7..ec0f83db5591 100644
>> --- a/fs/smb/client/smb2pdu.c
>> +++ b/fs/smb/client/smb2pdu.c
>> @@ -2298,9 +2298,9 @@ parse_posix_ctxt(struct create_context *cc, struct smb2_file_all_info *info,
>>
>>          memset(posix, 0, sizeof(*posix));
>>
>> -       posix->nlink = le32_to_cpu(*(__le32 *)(beg + 0));
>> -       posix->reparse_tag = le32_to_cpu(*(__le32 *)(beg + 4));
>> -       posix->mode = le32_to_cpu(*(__le32 *)(beg + 8));
>> +       posix->ctxt_rsp.nlink = le32_to_cpu(*(__le32 *)(beg + 0));
>> +       posix->ctxt_rsp.reparse_tag = le32_to_cpu(*(__le32 *)(beg + 4));
>> +       posix->ctxt_rsp.mode = le32_to_cpu(*(__le32 *)(beg + 8));
>>
>>          sid = beg + 12;
>>          sid_len = posix_info_sid_size(sid, end);
>> @@ -2319,7 +2319,8 @@ parse_posix_ctxt(struct create_context *cc, struct smb2_file_all_info *info,
>>          memcpy(&posix->group, sid, sid_len);
>>
>>          cifs_dbg(FYI, "nlink=%d mode=%o reparse_tag=%x\n",
>> -                posix->nlink, posix->mode, posix->reparse_tag);
>> +                posix->ctxt_rsp.nlink, posix->ctxt_rsp.mode,
>> +                posix->ctxt_rsp.reparse_tag);
>>   }
>>
>>   int smb2_parse_contexts(struct TCP_Server_Info *server,
>> diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
>> index 78bb99f29d38..4928fb620233 100644
>> --- a/fs/smb/client/smb2pdu.h
>> +++ b/fs/smb/client/smb2pdu.h
>> @@ -251,11 +251,9 @@ 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 */
>>   struct create_posix_rsp {
>> -       u32 nlink;
>> -       u32 reparse_tag;
>> -       u32 mode;
>> +       struct create_posix_ctxt_rsp ctxt_rsp;
>>          struct smb_sid owner; /* var-sized on the wire */
>>          struct smb_sid group; /* var-sized on the wire */
>>   } __packed;
>> diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
>> index 72f2cfc47da8..698ab9d7d16b 100644
>> --- a/fs/smb/common/smb2pdu.h
>> +++ b/fs/smb/common/smb2pdu.h
>> @@ -1814,4 +1814,22 @@ typedef struct smb_negotiate_req {
>>          unsigned char DialectsArray[];
>>   } __packed SMB_NEGOTIATE_REQ;
>>
>> +
>> +/*
>> + * [POSIX-SMB2] SMB3 POSIX Extensions
>> + * Link: https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/smb3_posix_extensions.md
>> + */
>> +
>> +/*
>> + * SMB2_CREATE_POSIX_CONTEXT Response
>> + * See POSIX-SMB2 2.2.14.2.16
>> + */
>> +struct create_posix_ctxt_rsp {
>> +       __le32 nlink;
>> +       __le32 reparse_tag;
>> +       __le32 mode;
>> +       // var sized owner SID
>> +       // var sized group SID
>> +} __packed;
>> +
>>   #endif                         /* _COMMON_SMB2PDU_H */
>> diff --git a/fs/smb/server/oplock.c b/fs/smb/server/oplock.c
>> index 1f07ebf431d7..8658402ff893 100644
>> --- a/fs/smb/server/oplock.c
>> +++ b/fs/smb/server/oplock.c
>> @@ -1703,7 +1703,7 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp)
>>          buf = (struct create_posix_rsp *)cc;
>>          memset(buf, 0, sizeof(struct create_posix_rsp));
>>          buf->ccontext.DataOffset = cpu_to_le16(offsetof
>> -                       (struct create_posix_rsp, nlink));
>> +                       (struct create_posix_rsp, ctxt_rsp));
>>          /*
>>           * DataLength = nlink(4) + reparse_tag(4) + mode(4) +
>>           * domain sid(28) + unix group sid(16).
>> @@ -1730,9 +1730,9 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp)
>>          buf->Name[14] = 0xCD;
>>          buf->Name[15] = 0x7C;
>>
>> -       buf->nlink = cpu_to_le32(inode->i_nlink);
>> -       buf->reparse_tag = cpu_to_le32(fp->volatile_id);
>> -       buf->mode = cpu_to_le32(inode->i_mode & 0777);
>> +       buf->ctxt_rsp.nlink = cpu_to_le32(inode->i_nlink);
>> +       buf->ctxt_rsp.reparse_tag = cpu_to_le32(fp->volatile_id);
>> +       buf->ctxt_rsp.mode = cpu_to_le32(inode->i_mode & 0777);
>>          /*
>>           * SidBuffer(44) contain two sids(Domain sid(28), UNIX group sid(16)).
>>           * Domain sid(28) = revision(1) + num_subauth(1) + authority(6) +
>> diff --git a/fs/smb/server/smb2pdu.h b/fs/smb/server/smb2pdu.h
>> index 66cdc8e4a648..09311a9eb1de 100644
>> --- a/fs/smb/server/smb2pdu.h
>> +++ b/fs/smb/server/smb2pdu.h
>> @@ -83,13 +83,11 @@ 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 */
>>   struct create_posix_rsp {
>>          struct create_context_hdr ccontext;
>>          __u8    Name[16];
>> -       __le32 nlink;
>> -       __le32 reparse_tag;
>> -       __le32 mode;
>> +       struct create_posix_ctxt_rsp ctxt_rsp;
>>          /* SidBuffer contain two sids(Domain sid(28), UNIX group sid(16)) */
>>          u8 SidBuffer[44];
>>   } __packed;
>> --
>> 2.43.0
>>


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

* Re: [PATCH 11/13] smb: introduce struct create_posix_ctxt_rsp
  2025-12-10  0:12     ` ChenXiaoSong
@ 2025-12-10  0:31       ` Namjae Jeon
  2025-12-10  0:37         ` ChenXiaoSong
  0 siblings, 1 reply; 21+ messages in thread
From: Namjae Jeon @ 2025-12-10  0:31 UTC (permalink / raw)
  To: ChenXiaoSong
  Cc: sfrench, smfrench, linkinjeon, linux-cifs, linux-kernel,
	liuzhengyuan, huhai, liuyun01, ZhangGuoDong, ChenXiaoSong

On Wed, Dec 10, 2025 at 9:13 AM ChenXiaoSong
<chenxiaosong.chenxiaosong@linux.dev> wrote:
>
> Hi Namjae,
>
> The `create_posix_rsp` structures on the client and server sides differ,
> but they share a common part, and only this common part is defined in
> POSIX‑SMB2 2.2.14.2.16.
I agree with moving create_posix_rsp struct to common, but doing it
partially feels forced and unnatural.
>
> /*
>   * [POSIX-SMB2] SMB3 POSIX Extensions
>   * Link:
> https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/smb3_posix_extensions.md
>   */
>
> Thanks,
> ChenXiaoSong.
>
> On 12/10/25 7:45 AM, Namjae Jeon wrote:
> > On Tue, Dec 9, 2025 at 10:12 AM <chenxiaosong.chenxiaosong@linux.dev> wrote:
> >>
> >> From: ZhangGuoDong <zhangguodong@kylinos.cn>
> >>
> >> Modify the following places:
> >>
> >>    - introduce new struct create_posix_ctxt_rsp
> >>    - some fields in "struct create_posix_rsp" -> "struct create_posix_ctxt_rsp"
> >>    - create_posix_rsp_buf(): offsetof(..., nlink) -> offsetof(..., ctxt_rsp)
> > I don't know why we need to add a new create_posix_ctxt_rsp struct.
> >>
> >> Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> >> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> >> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
> >> ---
> >>   fs/smb/client/smb2pdu.c |  9 +++++----
> >>   fs/smb/client/smb2pdu.h |  6 ++----
> >>   fs/smb/common/smb2pdu.h | 18 ++++++++++++++++++
> >>   fs/smb/server/oplock.c  |  8 ++++----
> >>   fs/smb/server/smb2pdu.h |  6 ++----
> >>   5 files changed, 31 insertions(+), 16 deletions(-)
> >>
> >> diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
> >> index ef2c6ac500f7..ec0f83db5591 100644
> >> --- a/fs/smb/client/smb2pdu.c
> >> +++ b/fs/smb/client/smb2pdu.c
> >> @@ -2298,9 +2298,9 @@ parse_posix_ctxt(struct create_context *cc, struct smb2_file_all_info *info,
> >>
> >>          memset(posix, 0, sizeof(*posix));
> >>
> >> -       posix->nlink = le32_to_cpu(*(__le32 *)(beg + 0));
> >> -       posix->reparse_tag = le32_to_cpu(*(__le32 *)(beg + 4));
> >> -       posix->mode = le32_to_cpu(*(__le32 *)(beg + 8));
> >> +       posix->ctxt_rsp.nlink = le32_to_cpu(*(__le32 *)(beg + 0));
> >> +       posix->ctxt_rsp.reparse_tag = le32_to_cpu(*(__le32 *)(beg + 4));
> >> +       posix->ctxt_rsp.mode = le32_to_cpu(*(__le32 *)(beg + 8));
> >>
> >>          sid = beg + 12;
> >>          sid_len = posix_info_sid_size(sid, end);
> >> @@ -2319,7 +2319,8 @@ parse_posix_ctxt(struct create_context *cc, struct smb2_file_all_info *info,
> >>          memcpy(&posix->group, sid, sid_len);
> >>
> >>          cifs_dbg(FYI, "nlink=%d mode=%o reparse_tag=%x\n",
> >> -                posix->nlink, posix->mode, posix->reparse_tag);
> >> +                posix->ctxt_rsp.nlink, posix->ctxt_rsp.mode,
> >> +                posix->ctxt_rsp.reparse_tag);
> >>   }
> >>
> >>   int smb2_parse_contexts(struct TCP_Server_Info *server,
> >> diff --git a/fs/smb/client/smb2pdu.h b/fs/smb/client/smb2pdu.h
> >> index 78bb99f29d38..4928fb620233 100644
> >> --- a/fs/smb/client/smb2pdu.h
> >> +++ b/fs/smb/client/smb2pdu.h
> >> @@ -251,11 +251,9 @@ 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 */
> >>   struct create_posix_rsp {
> >> -       u32 nlink;
> >> -       u32 reparse_tag;
> >> -       u32 mode;
> >> +       struct create_posix_ctxt_rsp ctxt_rsp;
> >>          struct smb_sid owner; /* var-sized on the wire */
> >>          struct smb_sid group; /* var-sized on the wire */
> >>   } __packed;
> >> diff --git a/fs/smb/common/smb2pdu.h b/fs/smb/common/smb2pdu.h
> >> index 72f2cfc47da8..698ab9d7d16b 100644
> >> --- a/fs/smb/common/smb2pdu.h
> >> +++ b/fs/smb/common/smb2pdu.h
> >> @@ -1814,4 +1814,22 @@ typedef struct smb_negotiate_req {
> >>          unsigned char DialectsArray[];
> >>   } __packed SMB_NEGOTIATE_REQ;
> >>
> >> +
> >> +/*
> >> + * [POSIX-SMB2] SMB3 POSIX Extensions
> >> + * Link: https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/smb3_posix_extensions.md
> >> + */
> >> +
> >> +/*
> >> + * SMB2_CREATE_POSIX_CONTEXT Response
> >> + * See POSIX-SMB2 2.2.14.2.16
> >> + */
> >> +struct create_posix_ctxt_rsp {
> >> +       __le32 nlink;
> >> +       __le32 reparse_tag;
> >> +       __le32 mode;
> >> +       // var sized owner SID
> >> +       // var sized group SID
> >> +} __packed;
> >> +
> >>   #endif                         /* _COMMON_SMB2PDU_H */
> >> diff --git a/fs/smb/server/oplock.c b/fs/smb/server/oplock.c
> >> index 1f07ebf431d7..8658402ff893 100644
> >> --- a/fs/smb/server/oplock.c
> >> +++ b/fs/smb/server/oplock.c
> >> @@ -1703,7 +1703,7 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp)
> >>          buf = (struct create_posix_rsp *)cc;
> >>          memset(buf, 0, sizeof(struct create_posix_rsp));
> >>          buf->ccontext.DataOffset = cpu_to_le16(offsetof
> >> -                       (struct create_posix_rsp, nlink));
> >> +                       (struct create_posix_rsp, ctxt_rsp));
> >>          /*
> >>           * DataLength = nlink(4) + reparse_tag(4) + mode(4) +
> >>           * domain sid(28) + unix group sid(16).
> >> @@ -1730,9 +1730,9 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp)
> >>          buf->Name[14] = 0xCD;
> >>          buf->Name[15] = 0x7C;
> >>
> >> -       buf->nlink = cpu_to_le32(inode->i_nlink);
> >> -       buf->reparse_tag = cpu_to_le32(fp->volatile_id);
> >> -       buf->mode = cpu_to_le32(inode->i_mode & 0777);
> >> +       buf->ctxt_rsp.nlink = cpu_to_le32(inode->i_nlink);
> >> +       buf->ctxt_rsp.reparse_tag = cpu_to_le32(fp->volatile_id);
> >> +       buf->ctxt_rsp.mode = cpu_to_le32(inode->i_mode & 0777);
> >>          /*
> >>           * SidBuffer(44) contain two sids(Domain sid(28), UNIX group sid(16)).
> >>           * Domain sid(28) = revision(1) + num_subauth(1) + authority(6) +
> >> diff --git a/fs/smb/server/smb2pdu.h b/fs/smb/server/smb2pdu.h
> >> index 66cdc8e4a648..09311a9eb1de 100644
> >> --- a/fs/smb/server/smb2pdu.h
> >> +++ b/fs/smb/server/smb2pdu.h
> >> @@ -83,13 +83,11 @@ 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 */
> >>   struct create_posix_rsp {
> >>          struct create_context_hdr ccontext;
> >>          __u8    Name[16];
> >> -       __le32 nlink;
> >> -       __le32 reparse_tag;
> >> -       __le32 mode;
> >> +       struct create_posix_ctxt_rsp ctxt_rsp;
> >>          /* SidBuffer contain two sids(Domain sid(28), UNIX group sid(16)) */
> >>          u8 SidBuffer[44];
> >>   } __packed;
> >> --
> >> 2.43.0
> >>
>

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

* Re: [PATCH 11/13] smb: introduce struct create_posix_ctxt_rsp
  2025-12-10  0:31       ` Namjae Jeon
@ 2025-12-10  0:37         ` ChenXiaoSong
  0 siblings, 0 replies; 21+ messages in thread
From: ChenXiaoSong @ 2025-12-10  0:37 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: sfrench, smfrench, linkinjeon, linux-cifs, linux-kernel,
	liuzhengyuan, huhai, liuyun01, ZhangGuoDong

Hi Namjae,

In the POSIX-SMB2 2.2.14.2.16 documentation, the OwnerSID and GroupSID 
fields in this structure are flexible members, and how these two SIDs 
are defined depends on where the structure is used.

https://gitlab.com/samba-team/smb3-posix-spec/-/blob/master/smb3_posix_extensions.md#2214216-smb2_create_posix_context-response

Thanks,
ChenXiaoSong.

On 12/10/25 8:31 AM, Namjae Jeon wrote:
> On Wed, Dec 10, 2025 at 9:13 AM ChenXiaoSong
> <chenxiaosong.chenxiaosong@linux.dev> wrote:
>> Hi Namjae,
>>
>> The `create_posix_rsp` structures on the client and server sides differ,
>> but they share a common part, and only this common part is defined in
>> POSIX‑SMB2 2.2.14.2.16.
> I agree with moving create_posix_rsp struct to common, but doing it
> partially feels forced and unnatural.


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

* Re: [PATCH 00/13 smb: move duplicate definitions into common header file, part 2
  2025-12-09  1:10 [PATCH 00/13 smb: move duplicate definitions into common header file, part 2 chenxiaosong.chenxiaosong
                   ` (12 preceding siblings ...)
  2025-12-09  1:10 ` [PATCH 13/13] smb: move some SMB1 definitions into common/smb1pdu.h chenxiaosong.chenxiaosong
@ 2025-12-10  4:34 ` ChenXiaoSong
  13 siblings, 0 replies; 21+ messages in thread
From: ChenXiaoSong @ 2025-12-10  4:34 UTC (permalink / raw)
  To: sfrench, smfrench, linkinjeon, linkinjeon
  Cc: linux-cifs, linux-kernel, liuzhengyuan, huhai, liuyun01

Hi Steve and Namjae,

I have tested all patches using KUnit tests, xfstests, and smbtorture, 
and no additional test failures were observed. The detailed test results 
can be found in: https://chenxiaosong.com/en/smb-test-20251210.html

For more detailed information about the patches to be reviewed, please 
see the link: https://chenxiaosong.com/en/smb-patch.html

Thanks,
ChenXiaoSong.

On 12/9/25 09:10, chenxiaosong.chenxiaosong@linux.dev wrote:
> From: ChenXiaoSong <chenxiaosong@kylinos.cn>
> 
> I'm currently working on implementing the SMB2 change notify feature in
> ksmbd, and noticed several duplicated definitions that exist on both client
> and server. Maybe we can clean these up first.
> 
> 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:
> https://lore.kernel.org/linux-cifs/20251117112838.473051-1-chenxiaosong.chenxiaosong@linux.dev/
> 
> ChenXiaoSong (7):
>    smb: add documentation references for smb2 change notify definitions
>    smb: move notify completion filter flags into common/smb2pdu.h
>    smb: move SMB2 Notify Action Flags into common/smb2pdu.h
>    smb: move file_notify_information to common/fscc.h
>    smb: move File Attributes definitions into common/fscc.h
>    smb: update struct duplicate_extents_to_file_ex
>    smb/server: add comment to FileSystemName of
>      FileFsAttributeInformation
> 
> ZhangGuoDong (6):
>    smb: move smb3_fs_vol_info into common/fscc.h
>    smb: move some definitions from common/smb2pdu.h into common/fscc.h
>    smb/client: remove DeviceType Flags and Device Characteristics
>      definitions
>    smb: introduce struct create_posix_ctxt_rsp
>    smb: introduce struct file_posix_info
>    smb: move some SMB1 definitions into common/smb1pdu.h
> 
>   fs/smb/client/cifspdu.h    |  67 +-----
>   fs/smb/client/inode.c      |  22 +-
>   fs/smb/client/readdir.c    |  28 +--
>   fs/smb/client/reparse.h    |   4 +-
>   fs/smb/client/smb2pdu.c    |   9 +-
>   fs/smb/client/smb2pdu.h    |  21 +-
>   fs/smb/common/fscc.h       | 419 ++++++++++++++++++++++++++++++++++-
>   fs/smb/common/smb1pdu.h    |  59 +++++
>   fs/smb/common/smb2pdu.h    | 433 ++-----------------------------------
>   fs/smb/common/smbglob.h    |   2 -
>   fs/smb/server/oplock.c     |   8 +-
>   fs/smb/server/smb2pdu.c    |  91 ++++----
>   fs/smb/server/smb2pdu.h    |  27 +--
>   fs/smb/server/smb_common.h |   9 +-
>   14 files changed, 589 insertions(+), 610 deletions(-)
>   create mode 100644 fs/smb/common/smb1pdu.h
> 


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

end of thread, other threads:[~2025-12-10  4:34 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-09  1:10 [PATCH 00/13 smb: move duplicate definitions into common header file, part 2 chenxiaosong.chenxiaosong
2025-12-09  1:10 ` [PATCH 01/13] smb: add documentation references for smb2 change notify definitions chenxiaosong.chenxiaosong
2025-12-09  1:10 ` [PATCH 02/13] smb: move notify completion filter flags into common/smb2pdu.h chenxiaosong.chenxiaosong
2025-12-09  1:10 ` [PATCH 03/13] smb: move SMB2 Notify Action Flags " chenxiaosong.chenxiaosong
2025-12-09  1:10 ` [PATCH 04/13] smb: move file_notify_information to common/fscc.h chenxiaosong.chenxiaosong
2025-12-09  1:10 ` [PATCH 05/13] smb: move File Attributes definitions into common/fscc.h chenxiaosong.chenxiaosong
2025-12-09  1:10 ` [PATCH 06/13] smb: update struct duplicate_extents_to_file_ex chenxiaosong.chenxiaosong
2025-12-09  1:10 ` [PATCH 07/13] smb/server: add comment to FileSystemName of FileFsAttributeInformation chenxiaosong.chenxiaosong
2025-12-09  1:10 ` [PATCH 08/13] smb: move smb3_fs_vol_info into common/fscc.h chenxiaosong.chenxiaosong
2025-12-09  1:10 ` [PATCH 09/13] smb: move some definitions from common/smb2pdu.h " chenxiaosong.chenxiaosong
2025-12-09  1:10 ` [PATCH 10/13] smb/client: remove DeviceType Flags and Device Characteristics definitions chenxiaosong.chenxiaosong
2025-12-09  1:10 ` [PATCH 11/13] smb: introduce struct create_posix_ctxt_rsp chenxiaosong.chenxiaosong
2025-12-09 23:45   ` Namjae Jeon
2025-12-10  0:12     ` ChenXiaoSong
2025-12-10  0:31       ` Namjae Jeon
2025-12-10  0:37         ` ChenXiaoSong
2025-12-09  1:10 ` [PATCH 12/13] smb: introduce struct file_posix_info chenxiaosong.chenxiaosong
2025-12-09  1:10 ` [PATCH 13/13] smb: move some SMB1 definitions into common/smb1pdu.h chenxiaosong.chenxiaosong
2025-12-09  2:52   ` Steve French
2025-12-09  2:56     ` ChenXiaoSong
2025-12-10  4:34 ` [PATCH 00/13 smb: move duplicate definitions into common header file, part 2 ChenXiaoSong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).