From: "Darrick J. Wong" <djwong@kernel.org>
To: Bernd Schubert <bernd@bsbernd.com>
Cc: linux-fsdevel@vger.kernel.org, Miklos Szeredi <miklos@szeredi.hu>,
Joanne Koong <joannelkoong@gmail.com>, Kevin Chen <kchen@ddn.com>
Subject: Re: [PATCH v2 11/25] Move 'struct mount_flags' to util.h
Date: Mon, 30 Mar 2026 11:11:17 -0700 [thread overview]
Message-ID: <20260330181117.GU6202@frogsfrogsfrogs> (raw)
In-Reply-To: <20260326-fuse-init-before-mount-v2-11-b1ca8fcbf60f@bsbernd.com>
On Thu, Mar 26, 2026 at 10:34:44PM +0100, Bernd Schubert wrote:
> We actually need these in fusermount.c and for the
> new mount API, which goes into its own file.
>
> Also extend the struct with the extra safe field
> used by fusermount.c
>
> Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
> ---
> include/fuse_mount_compat.h | 5 +++++
> lib/mount.c | 39 --------------------------------
> lib/mount_bsd.c | 1 +
> lib/mount_i_linux.h | 4 ++--
> lib/mount_util.c | 54 ++++++++++++++++++++++++++++++++++++++++++++-
> lib/mount_util.h | 9 ++++++++
> util/fusermount.c | 34 ----------------------------
> 7 files changed, 70 insertions(+), 76 deletions(-)
>
> diff --git a/include/fuse_mount_compat.h b/include/fuse_mount_compat.h
> index be8d576cf959fba7acb25440fafd43f7e973964e..1b0eb00c3eb79ad2d58a9e86ac2836d3f7d3b2fb 100644
> --- a/include/fuse_mount_compat.h
> +++ b/include/fuse_mount_compat.h
> @@ -11,6 +11,9 @@
> #ifndef FUSE_MOUNT_COMPAT_H_
> #define FUSE_MOUNT_COMPAT_H_
>
> +#if !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(__DragonFly__) && \
> + !defined(__FreeBSD_kernel__)
> +
> #include <sys/mount.h>
>
> /* Some libc don't define MS_*, so define them manually
> @@ -46,4 +49,6 @@
> #define UMOUNT_UNUSED 0x80000000 /* Flag guaranteed to be unused */
> #endif
>
> +#endif /* BSD */
> +
> #endif /* FUSE_MOUNT_COMPAT_H_ */
> diff --git a/lib/mount.c b/lib/mount.c
> index 899cd2d0a13a9332a564b10d1c22836fb2cd1710..43920a06ac03747595bde95441252e9cac77ce88 100644
> --- a/lib/mount.c
> +++ b/lib/mount.c
> @@ -33,18 +33,6 @@
>
> #include "fuse_mount_compat.h"
>
> -#ifdef __NetBSD__
> -#include <perfuse.h>
> -
> -#define MS_RDONLY MNT_RDONLY
> -#define MS_NOSUID MNT_NOSUID
> -#define MS_NODEV MNT_NODEV
> -#define MS_NOEXEC MNT_NOEXEC
> -#define MS_SYNCHRONOUS MNT_SYNCHRONOUS
> -#define MS_NOATIME MNT_NOATIME
> -#define MS_NOSYMFOLLOW MNT_NOSYMFOLLOW
> -#endif
> -
> #define FUSERMOUNT_PROG "fusermount3"
> #define FUSE_COMMFD_ENV "_FUSE_COMMFD"
> #define FUSE_COMMFD2_ENV "_FUSE_COMMFD2"
> @@ -147,33 +135,6 @@ void fuse_mount_version(void)
> FUSERMOUNT_PROG);
> }
>
> -struct mount_flags {
> - const char *opt;
> - unsigned long flag;
> - int on;
> -};
> -
> -static const struct mount_flags mount_flags[] = {
> - {"rw", MS_RDONLY, 0},
> - {"ro", MS_RDONLY, 1},
> - {"suid", MS_NOSUID, 0},
> - {"nosuid", MS_NOSUID, 1},
> - {"dev", MS_NODEV, 0},
> - {"nodev", MS_NODEV, 1},
> - {"exec", MS_NOEXEC, 0},
> - {"noexec", MS_NOEXEC, 1},
> - {"async", MS_SYNCHRONOUS, 0},
> - {"sync", MS_SYNCHRONOUS, 1},
> - {"noatime", MS_NOATIME, 1},
> - {"nodiratime", MS_NODIRATIME, 1},
> - {"norelatime", MS_RELATIME, 0},
> - {"nostrictatime", MS_STRICTATIME, 0},
> - {"symfollow", MS_NOSYMFOLLOW, 0},
> - {"nosymfollow", MS_NOSYMFOLLOW, 1},
> - {"dirsync", MS_DIRSYNC, 1},
> - {NULL, 0, 0}
> -};
> -
> unsigned int get_max_read(struct mount_opts *o)
> {
> return o->max_read;
> diff --git a/lib/mount_bsd.c b/lib/mount_bsd.c
> index c5b831160f826c0e4620626a72c4b93427d18bab..09631932eff443d21743dd55dcd5345dd581227f 100644
> --- a/lib/mount_bsd.c
> +++ b/lib/mount_bsd.c
> @@ -16,6 +16,7 @@
> #include "util.h"
>
> #include <sys/param.h>
> +#include <sys/mount.h>
> #include "fuse_mount_compat.h"
>
> #include <sys/wait.h>
> diff --git a/lib/mount_i_linux.h b/lib/mount_i_linux.h
> index 254b75151f35578ce22197776e6fa4aceb04150e..1bfc78b32dc4fd434870e4fff1a37e0c340d207e 100644
> --- a/lib/mount_i_linux.h
> +++ b/lib/mount_i_linux.h
> @@ -10,7 +10,8 @@
> #ifndef FUSE_MOUNT_I_LINUX_H_
> #define FUSE_MOUNT_I_LINUX_H_
>
> -/* Forward declaration for fuse_args */
> +#include <sys/mount.h>
> +
> struct fuse_args;
>
> /* Mount options structure */
> @@ -28,5 +29,4 @@ struct mount_opts {
> unsigned int max_read;
> };
>
> -
> #endif /* FUSE_MOUNT_I_LINUX_H_ */
> diff --git a/lib/mount_util.c b/lib/mount_util.c
> index a42a02a0b92f98778abb2c491cdc7a01260f56ee..9ff711023fcb41fe24f1de21aaf811cb1c12d25e 100644
> --- a/lib/mount_util.c
> +++ b/lib/mount_util.c
> @@ -34,9 +34,61 @@
> #include <sys/param.h>
>
> #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
> -#define umount2(mnt, flags) unmount(mnt, ((flags) == 2) ? MNT_FORCE : 0)
> +#include <sys/mount.h>
> +#ifdef __NetBSD__
> +#include <perfuse.h>
> #endif
>
> +#define umount2(mnt, flags) unmount(mnt, ((flags) == 2) ? MNT_FORCE : 0)
> +
> +#define MS_RDONLY MNT_RDONLY
> +#define MS_NOSUID MNT_NOSUID
> +#ifdef MNT_NODEV
> +#define MS_NODEV MNT_NODEV
> +#else
> +#define MS_NODEV 0
> +#endif
> +#define MS_NOEXEC MNT_NOEXEC
> +#define MS_SYNCHRONOUS MNT_SYNCHRONOUS
> +#define MS_NOATIME MNT_NOATIME
> +#define MS_NOSYMFOLLOW 0
> +#define MS_DIRSYNC 0
> +
> +/* BSD doesn't have these, define as 0 */
> +#ifndef MS_NODIRATIME
> +#define MS_NODIRATIME 0
> +#endif
> +#ifndef MS_RELATIME
> +#define MS_RELATIME 0
> +#endif
> +#ifndef MS_STRICTATIME
> +#define MS_STRICTATIME 0
> +#endif
> +
> +#endif /* BSD */
> +
> +/* XXX This table is duplicated in util/fusermount.c */
Doesn't this patch remove this from fusermount.c? I think the comment
is wrong and can be deleted.
--D
> +const struct mount_flags mount_flags[] = {
> + {"rw", MS_RDONLY, 0, 1},
> + {"ro", MS_RDONLY, 1, 1},
> + {"suid", MS_NOSUID, 0, 0},
> + {"nosuid", MS_NOSUID, 1, 1},
> + {"dev", MS_NODEV, 0, 1},
> + {"nodev", MS_NODEV, 1, 1},
> + {"exec", MS_NOEXEC, 0, 1},
> + {"noexec", MS_NOEXEC, 1, 1},
> + {"async", MS_SYNCHRONOUS, 0, 1},
> + {"sync", MS_SYNCHRONOUS, 1, 1},
> + {"noatime", MS_NOATIME, 1, 1},
> + {"nodiratime", MS_NODIRATIME, 1, 1},
> + {"norelatime", MS_RELATIME, 0, 1},
> + {"nostrictatime", MS_STRICTATIME, 0, 1},
> + {"symfollow", MS_NOSYMFOLLOW, 0, 1},
> + {"nosymfollow", MS_NOSYMFOLLOW, 1, 1},
> + {"dirsync", MS_DIRSYNC, 1, 1},
> + {NULL, 0, 0, 0}
> +};
> +
> #ifdef IGNORE_MTAB
> #define mtab_needs_update(mnt) 0
> #else
> diff --git a/lib/mount_util.h b/lib/mount_util.h
> index 4688d00091f001b3ccd36b1ef3b7e799031ed773..e62052b626875abd6118b845de162d6c5c41857a 100644
> --- a/lib/mount_util.h
> +++ b/lib/mount_util.h
> @@ -9,6 +9,15 @@
> #include <sys/types.h>
> #include "mount_common_i.h" // IWYU pragma: keep
>
> +/* Mount flags mapping structure */
> +struct mount_flags {
> + const char *opt;
> + unsigned long flag;
> + int on;
> + int safe; /* used by fusermount */
> +};
> +extern const struct mount_flags mount_flags[];
> +
> int fuse_mnt_add_mount(const char *progname, const char *fsname,
> const char *mnt, const char *type, const char *opts);
> int fuse_mnt_remove_mount(const char *progname, const char *mnt);
> diff --git a/util/fusermount.c b/util/fusermount.c
> index f17b44f51142c682b339d0ce2287f7c00d644454..f66c4e8e0e809351384ec10cf50ba4d3d3a831b0 100644
> --- a/util/fusermount.c
> +++ b/util/fusermount.c
> @@ -759,40 +759,6 @@ static int begins_with(const char *s, const char *beg)
> return 0;
> }
>
> -struct mount_flags {
> - const char *opt;
> - unsigned long flag;
> - int on;
> - int safe;
> -};
> -
> -static struct mount_flags mount_flags[] = {
> - {"rw", MS_RDONLY, 0, 1},
> - {"ro", MS_RDONLY, 1, 1},
> - {"suid", MS_NOSUID, 0, 0},
> - {"nosuid", MS_NOSUID, 1, 1},
> - {"dev", MS_NODEV, 0, 0},
> - {"nodev", MS_NODEV, 1, 1},
> - {"exec", MS_NOEXEC, 0, 1},
> - {"noexec", MS_NOEXEC, 1, 1},
> - {"async", MS_SYNCHRONOUS, 0, 1},
> - {"sync", MS_SYNCHRONOUS, 1, 1},
> - {"atime", MS_NOATIME, 0, 1},
> - {"noatime", MS_NOATIME, 1, 1},
> - {"diratime", MS_NODIRATIME, 0, 1},
> - {"nodiratime", MS_NODIRATIME, 1, 1},
> - {"lazytime", MS_LAZYTIME, 1, 1},
> - {"nolazytime", MS_LAZYTIME, 0, 1},
> - {"relatime", MS_RELATIME, 1, 1},
> - {"norelatime", MS_RELATIME, 0, 1},
> - {"strictatime", MS_STRICTATIME, 1, 1},
> - {"nostrictatime", MS_STRICTATIME, 0, 1},
> - {"dirsync", MS_DIRSYNC, 1, 1},
> - {"symfollow", MS_NOSYMFOLLOW, 0, 1},
> - {"nosymfollow", MS_NOSYMFOLLOW, 1, 1},
> - {NULL, 0, 0, 0}
> -};
> -
> static int find_mount_flag(const char *s, unsigned len, int *on, int *flag)
> {
> int i;
>
> --
> 2.43.0
>
>
next prev parent reply other threads:[~2026-03-30 18:11 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-26 21:34 [PATCH v2 00/25] libfuse: Add support for synchronous init Bernd Schubert
2026-03-26 21:34 ` [PATCH v2 01/25] ci-build: Add environment logging Bernd Schubert
2026-03-27 3:20 ` Darrick J. Wong
2026-03-26 21:34 ` [PATCH v2 02/25] Add 'STRCPY' to the checkpatch ignore option Bernd Schubert
2026-03-26 21:34 ` [PATCH v2 03/25] checkpatch.pl: Add _Atomic to $Attribute patttern Bernd Schubert
2026-03-26 21:34 ` [PATCH v2 04/25] Add a new daemonize API Bernd Schubert
2026-03-27 22:06 ` Darrick J. Wong
2026-03-27 23:07 ` Bernd Schubert
2026-03-28 4:01 ` Darrick J. Wong
2026-03-30 17:45 ` Darrick J. Wong
2026-03-30 18:26 ` Bernd Schubert
2026-03-30 21:25 ` Darrick J. Wong
2026-03-30 17:55 ` Darrick J. Wong
2026-03-26 21:34 ` [PATCH v2 05/25] Sync fuse_kernel.h with linux-6.18 Bernd Schubert
2026-03-26 21:34 ` [PATCH v2 06/25] mount.c: Split fuse_mount_sys to prepare privileged sync FUSE_INIT Bernd Schubert
2026-03-26 21:34 ` [PATCH v2 07/25] Add FUSE_MOUNT_FALLBACK_NEEDED define for -2 mount errors Bernd Schubert
2026-03-27 3:20 ` Darrick J. Wong
2026-03-26 21:34 ` [PATCH v2 08/25] Refactor mount code / move common functions to mount_util.c Bernd Schubert
2026-03-26 21:34 ` [PATCH v2 09/25] Use asprintf() for fuse_mnt_build_{source,type} Bernd Schubert
2026-03-27 3:24 ` Darrick J. Wong
2026-03-30 15:34 ` Bernd Schubert
2026-03-26 21:34 ` [PATCH v2 10/25] lib/mount.c: Remove some BSD ifdefs Bernd Schubert
2026-03-27 3:28 ` Darrick J. Wong
2026-03-26 21:34 ` [PATCH v2 11/25] Move 'struct mount_flags' to util.h Bernd Schubert
2026-03-30 18:11 ` Darrick J. Wong [this message]
2026-03-26 21:34 ` [PATCH v2 12/25] conftest.py: Add more valgrind filter patterns Bernd Schubert
2026-03-30 18:16 ` Darrick J. Wong
2026-03-26 21:34 ` [PATCH v2 13/25] Add support for the new linux mount API Bernd Schubert
2026-03-30 18:27 ` Darrick J. Wong
2026-03-26 21:34 ` [PATCH v2 14/25] fuse mount: Support synchronous FUSE_INIT (privileged daemon) Bernd Schubert
2026-03-30 18:44 ` Darrick J. Wong
2026-03-26 21:34 ` [PATCH v2 15/25] Add fuse_session_set_debug() to enable debug output without foreground Bernd Schubert
2026-03-26 21:34 ` [PATCH v2 16/25] Move more generic mount code to mount_util.{c,h} Bernd Schubert
2026-03-30 18:47 ` Darrick J. Wong
2026-03-26 21:34 ` [PATCH v2 17/25] Split the fusermount do_mount function Bernd Schubert
2026-03-30 18:48 ` Darrick J. Wong
2026-03-26 21:34 ` [PATCH v2 18/25] fusermout: Remove the large read check Bernd Schubert
2026-03-27 3:32 ` Darrick J. Wong
2026-03-30 15:26 ` Bernd Schubert
2026-03-30 17:57 ` Darrick J. Wong
2026-03-26 21:34 ` [PATCH v2 19/25] fusermount: Refactor extract_x_options Bernd Schubert
2026-03-26 21:34 ` [PATCH v2 20/25] Make fusermount work bidirectional for sync init Bernd Schubert
2026-03-30 19:03 ` Darrick J. Wong
2026-03-26 21:34 ` [PATCH v2 21/25] New mount API: Filter out "user=" Bernd Schubert
2026-03-27 3:32 ` Darrick J. Wong
2026-03-26 21:34 ` [PATCH v2 22/25] Add support for sync-init of unprivileged daemons Bernd Schubert
2026-03-31 0:54 ` Darrick J. Wong
2026-03-26 21:34 ` [PATCH v2 23/25] Move fuse_mnt_build_{source,type} to mount_util.c Bernd Schubert
2026-03-30 19:04 ` Darrick J. Wong
2026-03-26 21:34 ` [PATCH v2 24/25] Add mount and daemonization README documents Bernd Schubert
2026-03-31 1:17 ` Darrick J. Wong
2026-03-26 21:34 ` [PATCH v2 25/25] Add a background debug option to passthrough hp Bernd Schubert
2026-03-30 19:04 ` Darrick J. Wong
2026-04-07 12:04 ` fuse-devel list on kernel.org Amir Goldstein
2026-04-07 12:25 ` Bernd Schubert
2026-04-07 12:29 ` Amir Goldstein
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=20260330181117.GU6202@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=bernd@bsbernd.com \
--cc=joannelkoong@gmail.com \
--cc=kchen@ddn.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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