From: "Pali Rohár" <pali@kernel.org>
To: Steve French <sfrench@samba.org>,
Paulo Alcantara <pc@manguebit.com>,
Ronnie Sahlberg <ronniesahlberg@gmail.com>
Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/4] cifs: Add a new xattr system.reparse for querying repase point from SMB server
Date: Sun, 22 Dec 2024 16:43:38 +0100 [thread overview]
Message-ID: <20241222154340.24104-3-pali@kernel.org> (raw)
In-Reply-To: <20241222154340.24104-1-pali@kernel.org>
Currently SMB client fetches and parses only few reparse point types,
those which directly maps to Linux file types.
This change introduce a new xattr system.reparse which allows userspace
application to query reparse point buffer and then let application to parse
and handle it as needed.
Currently only get xattr is implemented. Setting new reparse point,
changing it or deleting via set xattr is not implemented yet.
Signed-off-by: Pali Rohár <pali@kernel.org>
---
fs/smb/client/xattr.c | 46 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/fs/smb/client/xattr.c b/fs/smb/client/xattr.c
index b88fa04f5792..7fb7662afaea 100644
--- a/fs/smb/client/xattr.c
+++ b/fs/smb/client/xattr.c
@@ -39,7 +39,10 @@
#define SMB3_XATTR_CREATETIME "smb3.creationtime" /* user.smb3.creationtime */
/* BB need to add server (Samba e.g) support for security and trusted prefix */
+#define SMB_XATTR_REPARSE "system.reparse"
+
enum { XATTR_USER, XATTR_CIFS_ACL, XATTR_ACL_ACCESS, XATTR_ACL_DEFAULT,
+ XATTR_REPARSE,
XATTR_CIFS_NTSD_SACL, XATTR_CIFS_NTSD_OWNER,
XATTR_CIFS_NTSD, XATTR_CIFS_NTSD_FULL };
@@ -162,6 +165,11 @@ static int cifs_xattr_set(const struct xattr_handler *handler,
}
break;
+ case XATTR_REPARSE:
+ /* TODO: Implementing setting, changing and deleting reparse point */
+ rc = -EOPNOTSUPP;
+ break;
+
case XATTR_CIFS_ACL:
case XATTR_CIFS_NTSD_SACL:
case XATTR_CIFS_NTSD_OWNER:
@@ -319,6 +327,36 @@ static int cifs_xattr_get(const struct xattr_handler *handler,
full_path, name, value, size, cifs_sb);
break;
+ case XATTR_REPARSE: {
+ struct reparse_data_buffer *reparse_buf;
+ int rsp_buftype = CIFS_NO_BUFFER;
+ struct kvec rsp_iov = {};
+ u32 reparse_len;
+ u32 tag;
+
+ if (!pTcon->ses->server->ops->query_reparse_point)
+ goto out;
+
+ rc = pTcon->ses->server->ops->query_reparse_point(xid, pTcon,
+ cifs_sb, full_path, &tag, &rsp_iov, &rsp_buftype);
+ if (rc)
+ goto out;
+
+ reparse_buf = pTcon->ses->server->ops->get_reparse_point_buffer(&rsp_iov,
+ &reparse_len);
+
+ if (value) {
+ if (reparse_len > size)
+ reparse_len = -ERANGE;
+ else
+ memcpy(value, reparse_buf, reparse_len);
+ }
+ rc = reparse_len;
+
+ free_rsp_buf(rsp_buftype, rsp_iov.iov_base);
+ break;
+ }
+
case XATTR_CIFS_ACL:
case XATTR_CIFS_NTSD_SACL:
case XATTR_CIFS_NTSD_OWNER:
@@ -448,6 +486,13 @@ static const struct xattr_handler cifs_os2_xattr_handler = {
.set = cifs_xattr_set,
};
+static const struct xattr_handler cifs_reparse_xattr_handler = {
+ .name = SMB_XATTR_REPARSE,
+ .flags = XATTR_REPARSE,
+ .get = cifs_xattr_get,
+ .set = cifs_xattr_set,
+};
+
static const struct xattr_handler cifs_cifs_acl_xattr_handler = {
.name = CIFS_XATTR_CIFS_ACL,
.flags = XATTR_CIFS_ACL,
@@ -525,6 +570,7 @@ static const struct xattr_handler smb3_ntsd_full_xattr_handler = {
const struct xattr_handler * const cifs_xattr_handlers[] = {
&cifs_user_xattr_handler,
&cifs_os2_xattr_handler,
+ &cifs_reparse_xattr_handler,
&cifs_cifs_acl_xattr_handler,
&smb3_acl_xattr_handler, /* alias for above since avoiding "cifs" */
&smb3_ntsd_sacl_xattr_handler,
--
2.20.1
next prev parent reply other threads:[~2024-12-22 15:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-22 15:43 [PATCH 0/4] cifs: Add support for querying reparse points from userspace Pali Rohár
2024-12-22 15:43 ` [PATCH 1/4] cifs: Split parse_reparse_point callback to functions: get buffer and parse buffer Pali Rohár
2024-12-22 15:43 ` Pali Rohár [this message]
2024-12-22 15:43 ` [PATCH 3/4] cifs: Change translation of STATUS_NOT_A_REPARSE_POINT to -ENODATA Pali Rohár
2024-12-22 15:43 ` [PATCH 4/4] cifs: Check if server supports reparse points before using them Pali Rohár
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=20241222154340.24104-3-pali@kernel.org \
--to=pali@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pc@manguebit.com \
--cc=ronniesahlberg@gmail.com \
--cc=sfrench@samba.org \
/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