From 74b1df2e84e836a1710561f52075d51f20cd5c78 Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 23 Feb 2024 22:56:49 -0800 Subject: Passthrough options starting with "x-" to mtab (#894) This implements #651, tested with bindfs. "x-*" options are comments meant to be interpreted by userspace. #651 is about some 3rd party mount options like 'x-gvfs-notrash'. This also removes the test if /etc/mtab is a symlink. This test was added in commit 5f28cd15ab43c741f6d116be4d3a9aa5d82ab385 and the corresponding ChangeLog entry in this commit points to mount issues for read-only mtab. However, in all recent Linux distributions /etc/mtab is a symlink to /proc/self/mounts and never writable. In fact, util-linux 2.39 (libmount) entirely removed support for a writable mtab. At least since util-linux 2.19 (10-Feb-2011) /run/mount/utab is used as replacement for userspace mount entries.. --- lib/mount.c | 6 ++++++ lib/mount_util.c | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/mount.c b/lib/mount.c index d71e6fc..f98a8bb 100644 --- a/lib/mount.c +++ b/lib/mount.c @@ -209,6 +209,12 @@ static int fuse_mount_opt_proc(void *data, const char *arg, int key, case KEY_MTAB_OPT: return fuse_opt_add_opt(&mo->mtab_opts, arg); + + /* Third party options like 'x-gvfs-notrash' */ + case FUSE_OPT_KEY_OPT: + return (strncmp("x-", arg, 2) == 0) ? + fuse_opt_add_opt(&mo->mtab_opts, arg) : + 1; } /* Pass through unknown options */ diff --git a/lib/mount_util.c b/lib/mount_util.c index 8027a2e..dd32276 100644 --- a/lib/mount_util.c +++ b/lib/mount_util.c @@ -54,7 +54,6 @@ static int mtab_needs_update(const char *mnt) * Skip mtab update if /etc/mtab: * * - doesn't exist, - * - is a symlink, * - is on a read-only filesystem. */ res = lstat(_PATH_MOUNTED, &stbuf); @@ -65,9 +64,6 @@ static int mtab_needs_update(const char *mnt) uid_t ruid; int err; - if (S_ISLNK(stbuf.st_mode)) - return 0; - ruid = getuid(); if (ruid != 0) setreuid(0, -1); -- cgit v1.2.3