From: "Darrick J. Wong" <djwong@kernel.org>
To: bschubert@ddn.com
Cc: linux-fsdevel@vger.kernel.org, bernd@bsbernd.com,
miklos@szeredi.hu, neal@gompa.dev, joannelkoong@gmail.com
Subject: Re: [PATCH 05/17] mount_service: update mtab after a successful mount
Date: Tue, 7 Apr 2026 16:42:47 -0700 [thread overview]
Message-ID: <20260407234247.GP6202@frogsfrogsfrogs> (raw)
In-Reply-To: <177457463206.1008428.3710251281230290878.stgit@frogsfrogsfrogs>
On Thu, Mar 26, 2026 at 06:26:04PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> Update "mtab" so that non-kernel mount options (e.g. "x-fubar=XXX") are
> recorded somewhere so that userspace utilities can pick that up. Note
> that this likely is not the venerable /etc/mtab, which has been a
> symlink to procfs for years. On a modern system, these non-kernel
> options end up /run/mount/utab.
>
> But that's not a detail that libfuse has to worry about directly; it's
> really just calling mount -f(ake) to make the changes it wants. Old
> hats may remember the use of mount -f to update /etc/mtab after mounting
> the root filesystem.
>
> Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
> ---
> include/fuse_service_priv.h | 1 +
> lib/mount_common_i.h | 1 +
> lib/fuse_service.c | 15 ++++++++++++++
> lib/mount.c | 7 ++++++
> util/mount_service.c | 47 +++++++++++++++++++++++++++++++++++++++++++
> 5 files changed, 71 insertions(+)
>
>
> diff --git a/include/fuse_service_priv.h b/include/fuse_service_priv.h
> index d1fdd6221b5268..17002249d6a02e 100644
> --- a/include/fuse_service_priv.h
> +++ b/include/fuse_service_priv.h
> @@ -36,6 +36,7 @@ struct fuse_service_memfd_argv {
> #define FUSE_SERVICE_MNTPT_CMD 0x4d4e5450 /* MNTP */
> #define FUSE_SERVICE_MOUNT_CMD 0x444f4954 /* DOIT */
> #define FUSE_SERVICE_BYE_CMD 0x42594545 /* BYEE */
> +#define FUSE_SERVICE_MTABOPTS_CMD 0x4d544142 /* MTAB */
>
> /* mount.service sends replies to the fuse server */
> #define FUSE_SERVICE_OPEN_REPLY 0x46494c45 /* FILE */
> diff --git a/lib/mount_common_i.h b/lib/mount_common_i.h
> index 631dff3e6f8aaf..541cdebae4f47a 100644
> --- a/lib/mount_common_i.h
> +++ b/lib/mount_common_i.h
> @@ -15,6 +15,7 @@ struct mount_opts;
> char *fuse_mnt_build_source(const struct mount_opts *mo);
> char *fuse_mnt_build_type(const struct mount_opts *mo);
> char *fuse_mnt_kernel_opts(const struct mount_opts *mo);
> +char *fuse_mnt_mtab_opts(const struct mount_opts *mo);
> unsigned int fuse_mnt_flags(const struct mount_opts *mo);
>
>
> diff --git a/lib/fuse_service.c b/lib/fuse_service.c
> index 795453693da09b..8076a8b2737574 100644
> --- a/lib/fuse_service.c
> +++ b/lib/fuse_service.c
> @@ -804,6 +804,7 @@ int fuse_service_session_mount(struct fuse_service *sf, struct fuse_session *se,
> char *fstype = fuse_mnt_build_type(se->mo);
> char *source = fuse_mnt_build_source(se->mo);
> char *mntopts = fuse_mnt_kernel_opts(se->mo);
> + char *mtabopts = fuse_mnt_mtab_opts(se->mo);
> char path[32];
> int ret;
> int error;
> @@ -871,6 +872,19 @@ int fuse_service_session_mount(struct fuse_service *sf, struct fuse_session *se,
> }
> }
>
> + if (mtabopts) {
> + ret = send_string(sf, FUSE_SERVICE_MTABOPTS_CMD, mtabopts,
> + &error);
> + if (ret)
> + goto out_strings;
> + if (error) {
> + fuse_log(FUSE_LOG_ERR, "fuse: service fs mtab options: %s\n",
> + strerror(error));
> + ret = -error;
> + goto out_strings;
> + }
> + }
> +
> ret = send_mount(sf, fuse_mnt_flags(se->mo), expected_fmt, &error);
> if (ret)
> goto out_strings;
> @@ -889,6 +903,7 @@ int fuse_service_session_mount(struct fuse_service *sf, struct fuse_session *se,
> opts->foreground = 1;
>
> out_strings:
> + free(mtabopts);
> free(mntopts);
> free(source);
> free(fstype);
> diff --git a/lib/mount.c b/lib/mount.c
> index 2018172ae570f0..ce8f58450827ce 100644
> --- a/lib/mount.c
> +++ b/lib/mount.c
> @@ -758,6 +758,13 @@ char *fuse_mnt_kernel_opts(const struct mount_opts *mo)
> return NULL;
> }
>
> +char *fuse_mnt_mtab_opts(const struct mount_opts *mo)
> +{
> + if (mo->mtab_opts)
> + return strdup(mo->mtab_opts);
> + return NULL;
> +}
> +
> unsigned int fuse_mnt_flags(const struct mount_opts *mo)
> {
> return mo->flags;
> diff --git a/util/mount_service.c b/util/mount_service.c
> index 4a2c1111b66b91..2e541f67277ee5 100644
> --- a/util/mount_service.c
> +++ b/util/mount_service.c
> @@ -54,6 +54,9 @@ struct mount_service {
> /* mount options */
> char *mntopts;
>
> + /* mtab options */
> + char *mtabopts;
> +
> /* socket fd */
> int sockfd;
>
> @@ -842,6 +845,30 @@ static int mount_service_handle_mntopts_cmd(struct mount_service *mo,
> return mount_service_send_reply(mo, 0);
> }
>
> +static int mount_service_handle_mtabopts_cmd(struct mount_service *mo,
> + const struct fuse_service_packet *p)
> +{
> + struct fuse_service_string_command *oc =
> + container_of(p, struct fuse_service_string_command, p);
> +
> + if (mo->mtabopts) {
> + fprintf(stderr, "%s: mtab options respecified!\n",
> + mo->msgtag);
> + return mount_service_send_reply(mo, EINVAL);
> + }
> +
> + mo->mtabopts = strdup(oc->value);
> + if (!mo->mtabopts) {
> + int error = errno;
> +
> + fprintf(stderr, "%s: alloc mtab options string: %s\n",
> + mo->msgtag, strerror(error));
> + return mount_service_send_reply(mo, error);
> + }
> +
> + return mount_service_send_reply(mo, 0);
> +}
> +
> static int mount_service_handle_mountpoint_cmd(struct mount_service *mo,
> const struct fuse_service_packet *p)
> {
> @@ -973,6 +1000,14 @@ static int mount_service_regular_mount(struct mount_service *mo,
> return mount_service_send_reply(mo, error);
> }
>
> + /*
> + * The mount succeeded, so we send a positive reply even if the mtab
> + * update fails.
> + */
> + if (mo->mtabopts)
> + fuse_mnt_add_mount(mo->msgtag, mo->source, mo->mountpoint,
> + mo->fstype, mo->mtabopts);
Codex complains that we need to preserve the non-mtab mount options in
mtab for legacy systems where /etc/mtab isn't a symlink to
/proc/self/mounts. I don't think it really matters here because that's
been the case for many years, and you can't mount -o remount a fuse
server anyway.
The primary benefit of the mtab updating code (which seems only to
manage /run/mount/utab these days, btw) is to provide a place to park
x-foo options for userspace programs to pick them up.
--D
next prev parent reply other threads:[~2026-04-07 23:42 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-27 1:24 [PATCHSET v3] libfuse: run fuse servers as a contained service Darrick J. Wong
2026-03-27 1:25 ` [PATCH 01/17] Refactor mount code / move common functions to mount_util.c Darrick J. Wong
2026-03-27 1:25 ` [PATCH 02/17] mount_service: add systemd/inetd socket service mounting helper Darrick J. Wong
2026-03-30 20:44 ` Bernd Schubert
2026-03-30 21:37 ` Darrick J. Wong
2026-04-07 23:39 ` Darrick J. Wong
2026-03-27 1:25 ` [PATCH 03/17] mount_service: create high level fuse helpers Darrick J. Wong
2026-03-30 19:37 ` Bernd Schubert
2026-03-30 20:30 ` Darrick J. Wong
2026-03-30 20:51 ` Bernd Schubert
2026-03-30 21:09 ` Darrick J. Wong
2026-03-27 1:25 ` [PATCH 04/17] mount_service: use the new mount api for the mount service Darrick J. Wong
2026-03-30 21:06 ` Bernd Schubert
2026-03-30 21:18 ` Darrick J. Wong
2026-03-30 21:40 ` Bernd Schubert
2026-03-30 21:47 ` Darrick J. Wong
2026-03-27 1:26 ` [PATCH 05/17] mount_service: update mtab after a successful mount Darrick J. Wong
2026-04-07 23:42 ` Darrick J. Wong [this message]
2026-03-27 1:26 ` [PATCH 06/17] util: hoist the fuse.conf parsing code Darrick J. Wong
2026-04-07 23:40 ` Darrick J. Wong
2026-03-27 1:26 ` [PATCH 07/17] util: fix checkpatch complaints in fuser_conf.[ch] Darrick J. Wong
2026-03-27 1:26 ` [PATCH 08/17] mount_service: read fuse.conf to enable allow_other for unprivileged mounts Darrick J. Wong
2026-03-27 1:27 ` [PATCH 09/17] util: hoist the other non-root user limits Darrick J. Wong
2026-03-27 1:27 ` [PATCH 10/17] util: fix more checkpatch complaints in fuser_conf.[ch] Darrick J. Wong
2026-03-27 1:27 ` [PATCH 11/17] mount_service: use over the other non-root user checks Darrick J. Wong
2026-04-07 23:47 ` Darrick J. Wong
2026-03-27 1:27 ` [PATCH 12/17] mount.fuse3: integrate systemd service startup Darrick J. Wong
2026-04-07 23:56 ` Darrick J. Wong
2026-03-27 1:28 ` [PATCH 13/17] mount_service: allow installation as a setuid program Darrick J. Wong
2026-03-27 1:28 ` [PATCH 14/17] example/service_ll: create a sample systemd service fuse server Darrick J. Wong
2026-04-08 0:09 ` Darrick J. Wong
2026-03-27 1:28 ` [PATCH 15/17] example/service: create a sample systemd service for a high-level " Darrick J. Wong
2026-03-27 1:28 ` [PATCH 16/17] example/hello_ll: port to single-file common code Darrick J. Wong
2026-03-27 1:29 ` [PATCH 17/17] nullfs: support fuse systemd service mode Darrick J. Wong
2026-04-08 0:11 ` Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260407234247.GP6202@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=bernd@bsbernd.com \
--cc=bschubert@ddn.com \
--cc=joannelkoong@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=neal@gompa.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox