[RFC PATCH v3 2/8] fuse: export extend_arg() and factor out fuse_ext_size()

Luis Henriques
2026-02-25T11:25:17Z

Export (and rename) extend_arg() and fuse_ext_size() as these functions
are useful for using extension headers in other places.

Signed-off-by: Luis Henriques <luis@igalia.com>
---
fs/fuse/dir.c | 9 ++-------
fs/fuse/fuse_i.h | 7 +++++++
2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index e3000affff88..f5eacea44896 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -713,7 +713,7 @@ static int get_security_context(struct dentry *entry, umode_t mode,
return err;
}

-static void *extend_arg(struct fuse_in_arg *buf, u32 bytes)
+void *fuse_extend_arg(struct fuse_in_arg *buf, u32 bytes)
{
void *p;
u32 newlen = buf->size + bytes;
@@ -733,11 +733,6 @@ static void *extend_arg(struct fuse_in_arg *buf, u32 bytes)
return p + newlen - bytes;
}

-static u32 fuse_ext_size(size_t size)
-{
- return FUSE_REC_ALIGN(sizeof(struct fuse_ext_header) + size);
-}
-
/*
* This adds just a single supplementary group that matches the parent's group.
*/
@@ -758,7 +753,7 @@ static int get_create_supp_group(struct mnt_idmap *idmap,
!vfsgid_in_group_p(vfsgid))
return 0;

- xh = extend_arg(ext, sg_len);
+ xh = fuse_extend_arg(ext, sg_len);
if (!xh)
return -ENOMEM;

diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 6178a012f36c..135027efec7a 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1410,6 +1410,13 @@ int fuse_valid_type(int m);

bool fuse_invalid_attr(struct fuse_attr *attr);

+void *fuse_extend_arg(struct fuse_in_arg *buf, u32 bytes);
+
+static inline u32 fuse_ext_size(size_t size)
+{
+ return FUSE_REC_ALIGN(sizeof(struct fuse_ext_header) + size);
+}
+
/**
* Is current process allowed to perform filesystem operation?
*/