From: zhang.guodong@linux.dev
To: smfrench@gmail.com, linkinjeon@kernel.org, pc@manguebit.org,
ronniesahlberg@gmail.com, sprasad@microsoft.com, tom@talpey.com,
bharathsm@microsoft.com, senozhatsky@chromium.org,
dhowells@redhat.com, chenxiaosong@kylinos.cn,
chenxiaosong.chenxiaosong@linux.dev
Cc: linux-cifs@vger.kernel.org, ZhangGuoDong <zhangguodong@kylinos.cn>
Subject: [PATCH v3 4/5] smb: introduce struct create_posix_ctxt_rsp
Date: Mon, 16 Feb 2026 08:20:17 +0000 [thread overview]
Message-ID: <20260216082018.156695-5-zhang.guodong@linux.dev> (raw)
In-Reply-To: <20260216082018.156695-1-zhang.guodong@linux.dev>
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)
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 | 17 +++++++++++++++++
fs/smb/server/oplock.c | 8 ++++----
fs/smb/server/smb2pdu.h | 6 ++----
5 files changed, 30 insertions(+), 16 deletions(-)
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 7f3edf42b9c3..f8825160355d 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -2362,9 +2362,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);
@@ -2383,7 +2383,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 85a4248d4f29..5dd4ab245453 100644
--- a/fs/smb/common/smb2pdu.h
+++ b/fs/smb/common/smb2pdu.h
@@ -1775,4 +1775,21 @@ struct smb2_lease_ack {
#define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \
| READ_CONTROL | SYNCHRONIZE)
+/*
+ * [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 a5967ac46604..171758ed94b2 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 9b3c4c9acb11..dc6a81c64fd5 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.52.0
next prev parent reply other threads:[~2026-02-16 8:21 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-16 8:20 [PATCH v3 0/5] smb: move duplicate definitions into common header file, part 2 zhang.guodong
2026-02-16 8:20 ` [PATCH v3 1/5] smb: move smb3_fs_vol_info into common/fscc.h zhang.guodong
2026-02-16 16:05 ` kernel test robot
2026-02-16 8:20 ` [PATCH v3 2/5] smb: move some definitions from common/smb2pdu.h " zhang.guodong
2026-02-16 8:20 ` [PATCH v3 3/5] smb: move file_basic_info " zhang.guodong
2026-02-16 8:20 ` zhang.guodong [this message]
2026-02-16 18:22 ` [PATCH v3 4/5] smb: introduce struct create_posix_ctxt_rsp kernel test robot
2026-02-17 14:20 ` ZhangGuoDong
[not found] ` <CAH2r5muK5WrHkJsJ=Rix7ceFFZNzpQkUZSaSsHi8PMXVpw88pw@mail.gmail.com>
[not found] ` <b840459a-8a31-46e7-817a-3b80e9ed1353@linux.dev>
[not found] ` <CAH2r5muScb7NmeJa1BNwAt8Qzb7WmwVfvskZ=9LEV6WWyO5HyQ@mail.gmail.com>
[not found] ` <d6149e9f-9607-4379-a74d-c4bbe12fef00@linux.dev>
2026-02-19 8:16 ` ChenXiaoSong
2026-02-19 13:14 ` ChenXiaoSong
2026-02-16 8:20 ` [PATCH v3 5/5] smb: introduce struct file_posix_info zhang.guodong
2026-02-20 1:27 ` [PATCH v3 0/5] smb: move duplicate definitions into common header file, part 2 Namjae Jeon
2026-02-20 10:54 ` ZhangGuoDong
2026-02-22 7:39 ` ChenXiaoSong
2026-02-22 15:26 ` ChenXiaoSong
2026-02-22 15:42 ` ChenXiaoSong
2026-02-25 3:14 ` ZhangGuoDong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260216082018.156695-5-zhang.guodong@linux.dev \
--to=zhang.guodong@linux.dev \
--cc=bharathsm@microsoft.com \
--cc=chenxiaosong.chenxiaosong@linux.dev \
--cc=chenxiaosong@kylinos.cn \
--cc=dhowells@redhat.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=pc@manguebit.org \
--cc=ronniesahlberg@gmail.com \
--cc=senozhatsky@chromium.org \
--cc=smfrench@gmail.com \
--cc=sprasad@microsoft.com \
--cc=tom@talpey.com \
--cc=zhangguodong@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox