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@groves.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