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 --- 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 /* 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 - -#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 +#include #include "fuse_mount_compat.h" #include 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 + 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 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__) -#define umount2(mnt, flags) unmount(mnt, ((flags) == 2) ? MNT_FORCE : 0) +#include +#ifdef __NetBSD__ +#include #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 */ +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 #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