[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260107153443.64794-4-john@groves.net>
Date: Wed, 7 Jan 2026 09:34:42 -0600
From: John Groves <John@...ves.net>
To: John Groves <John@...ves.net>,
Miklos Szeredi <miklos@...redi.hu>,
Dan Williams <dan.j.williams@...el.com>,
Bernd Schubert <bschubert@....com>,
Alison Schofield <alison.schofield@...el.com>
Cc: John Groves <jgroves@...ron.com>,
Jonathan Corbet <corbet@....net>,
Vishal Verma <vishal.l.verma@...el.com>,
Dave Jiang <dave.jiang@...el.com>,
Matthew Wilcox <willy@...radead.org>,
Jan Kara <jack@...e.cz>,
Alexander Viro <viro@...iv.linux.org.uk>,
David Hildenbrand <david@...nel.org>,
Christian Brauner <brauner@...nel.org>,
"Darrick J . Wong" <djwong@...nel.org>,
Randy Dunlap <rdunlap@...radead.org>,
Jeff Layton <jlayton@...nel.org>,
Amir Goldstein <amir73il@...il.com>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Stefan Hajnoczi <shajnocz@...hat.com>,
Joanne Koong <joannelkoong@...il.com>,
Josef Bacik <josef@...icpanda.com>,
Bagas Sanjaya <bagasdotme@...il.com>,
Chen Linxuan <chenlinxuan@...ontech.com>,
James Morse <james.morse@....com>,
Fuad Tabba <tabba@...gle.com>,
Sean Christopherson <seanjc@...gle.com>,
Shivank Garg <shivankg@....com>,
Ackerley Tng <ackerleytng@...gle.com>,
Gregory Price <gourry@...rry.net>,
Aravind Ramesh <arramesh@...ron.com>,
Ajay Joshi <ajayjoshi@...ron.com>,
venkataravis@...ron.com,
linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org,
nvdimm@...ts.linux.dev,
linux-cxl@...r.kernel.org,
linux-fsdevel@...r.kernel.org,
John Groves <john@...ves.net>
Subject: [PATCH V3 3/4] fuse: add API to set kernel mount options
Add fuse_add_kernel_mount_opt() to allow libfuse callers to pass
additional mount options directly to the kernel. This enables
filesystem-specific kernel mount options that aren't exposed through
the standard libfuse mount option parsing.
For example, famfs uses this to set the "shadow=" mount option
for shadow file system mounts.
API addition:
int fuse_add_kernel_mount_opt(struct fuse_session *se, const char *mount_opt)
Signed-off-by: John Groves <john@...ves.net>
---
include/fuse_lowlevel.h | 10 ++++++++++
lib/fuse_i.h | 1 +
lib/fuse_lowlevel.c | 5 +++++
lib/fuse_versionscript | 1 +
lib/mount.c | 8 ++++++++
5 files changed, 25 insertions(+)
diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h
index 016f831..d2bbcca 100644
--- a/include/fuse_lowlevel.h
+++ b/include/fuse_lowlevel.h
@@ -2195,6 +2195,16 @@ static inline int fuse_session_custom_io(struct fuse_session *se,
}
#endif
+/**
+ * Allow a libfuse caller to directly add kernel mount opts
+ *
+ * @param se session object
+ * @param mount_opt the option to add
+ *
+ * @return 0 on success, -1 on failure
+ */
+int fuse_add_kernel_mount_opt(struct fuse_session *se, const char *mount_opt);
+
/**
* Mount a FUSE file system.
*
diff --git a/lib/fuse_i.h b/lib/fuse_i.h
index 65d2f68..41285d2 100644
--- a/lib/fuse_i.h
+++ b/lib/fuse_i.h
@@ -220,6 +220,7 @@ void destroy_mount_opts(struct mount_opts *mo);
void fuse_mount_version(void);
unsigned get_max_read(struct mount_opts *o);
void fuse_kern_unmount(const char *mountpoint, int fd);
+int __fuse_add_kernel_mount_opt(struct fuse_session *se, const char *mount_opt);
int fuse_kern_mount(const char *mountpoint, struct mount_opts *mo);
int fuse_send_reply_iov_nofree(fuse_req_t req, int error, struct iovec *iov,
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
index 0cde3d4..413e7c3 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -4349,6 +4349,11 @@ int fuse_session_custom_io_30(struct fuse_session *se,
offsetof(struct fuse_custom_io, clone_fd), fd);
}
+int fuse_add_kernel_mount_opt(struct fuse_session *se, const char *mount_opt)
+{
+ return __fuse_add_kernel_mount_opt(se, mount_opt);
+}
+
int fuse_session_mount(struct fuse_session *se, const char *_mountpoint)
{
int fd;
diff --git a/lib/fuse_versionscript b/lib/fuse_versionscript
index f9562b6..536569a 100644
--- a/lib/fuse_versionscript
+++ b/lib/fuse_versionscript
@@ -220,6 +220,7 @@ FUSE_3.18 {
fuse_reply_statx;
fuse_fs_statx;
+ fuse_add_kernel_mount_opt;
} FUSE_3.17;
FUSE_3.19 {
diff --git a/lib/mount.c b/lib/mount.c
index 7a856c1..e6c2305 100644
--- a/lib/mount.c
+++ b/lib/mount.c
@@ -674,6 +674,14 @@ void destroy_mount_opts(struct mount_opts *mo)
free(mo);
}
+int __fuse_add_kernel_mount_opt(struct fuse_session *se, const char *mount_opt)
+{
+ if (!se->mo)
+ return -1;
+ if (!mount_opt)
+ return -1;
+ return fuse_opt_add_opt(&se->mo->kernel_opts, mount_opt);
+}
int fuse_kern_mount(const char *mountpoint, struct mount_opts *mo)
{
--
2.49.0
Powered by blists - more mailing lists