aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjunchao yuan <junchao.yuan@amlogic.com>2023-04-11 10:31:33 +0800
committerAlessio Balsini <balsini@google.com>2023-05-05 13:58:21 +0100
commit80ca6e69c367deb14593b53d63ca295c42113589 (patch)
treeb8a028ba0edfd4c6c2b4141a3a1b039a7d363e99
parente227ec84976de7482eea3ae09a2404cbe59bbe99 (diff)
downloadlibfuse-80ca6e69c367deb14593b53d63ca295c42113589.tar.gz
libfuse: add setxattr functionandroid-u-beta-2-gpl
Add the upstream setxattr functionality to libfuse. This is a rework of the upstream commit: 681a0c11, and doesn't add any out-of-tree functionality. PD#SWPL-114538 Test: ohm, m, CtsScopedStorageDeviceOnlyTest Bug: 254164657 Change-Id: Iefaa6682729600f8804b454bb14f9d1611c6d7a7 Signed-off-by: junchao yuan <junchao.yuan@amlogic.com>
-rw-r--r--include/fuse_common.h7
-rw-r--r--lib/fuse_lowlevel.c10
2 files changed, 16 insertions, 1 deletions
diff --git a/include/fuse_common.h b/include/fuse_common.h
index d6fa3e2..efaf754 100644
--- a/include/fuse_common.h
+++ b/include/fuse_common.h
@@ -400,6 +400,13 @@ struct fuse_loop_config {
#define FUSE_CAP_EXPLICIT_INVAL_DATA (1 << 25)
/**
+ * Indicates that an extended 'struct fuse_setxattr' is used by the kernel
+ * side - extra_flags are passed, which are used (as of now by acl) processing.
+ * For example FUSE_SETXATTR_ACL_KILL_SGID might be set.
+ */
+#define FUSE_CAP_SETXATTR_EXT (1 << 27)
+
+/**
* Indicates support for passthrough mode access for read/write operations.
*
* If this flag is set in the `capable` field of the `fuse_conn_info`
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
index 964462f..51cd412 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -1677,10 +1677,14 @@ static void do_statfs(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
static void do_setxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
{
+ struct fuse_session *se = req->se;
+ unsigned int xattr_ext = !!(se->conn.want & FUSE_CAP_SETXATTR_EXT);
struct fuse_setxattr_in *arg = (struct fuse_setxattr_in *) inarg;
- char *name = PARAM(arg);
+ char *name = xattr_ext ? PARAM(arg) :
+ (char *)arg + FUSE_COMPAT_SETXATTR_IN_SIZE;
char *value = name + strlen(name) + 1;
+ /* XXX:The API should be extended to support extra_flags/setxattr_flags */
if (req->se->op.setxattr)
req->se->op.setxattr(req, nodeid, name, value, arg->size,
arg->flags);
@@ -2089,6 +2093,8 @@ void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
se->conn.capable |= FUSE_CAP_NO_OPENDIR_SUPPORT;
if (arg->flags & FUSE_EXPLICIT_INVAL_DATA)
se->conn.capable |= FUSE_CAP_EXPLICIT_INVAL_DATA;
+ if (arg->flags & FUSE_SETXATTR_EXT)
+ se->conn.capable |= FUSE_CAP_SETXATTR_EXT;
if (!(arg->flags & FUSE_MAX_PAGES)) {
size_t max_bufsize =
FUSE_DEFAULT_MAX_PAGES_PER_REQ * getpagesize()
@@ -2226,6 +2232,8 @@ void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
outarg.flags |= FUSE_CACHE_SYMLINKS;
if (se->conn.want & FUSE_CAP_EXPLICIT_INVAL_DATA)
outarg.flags |= FUSE_EXPLICIT_INVAL_DATA;
+ if (se->conn.want & FUSE_CAP_SETXATTR_EXT)
+ outarg.flags |= FUSE_SETXATTR_EXT;
outarg.max_readahead = se->conn.max_readahead;
outarg.max_write = se->conn.max_write;
if (se->conn.proto_minor >= 13) {