From: Bernd Schubert This is preparation work for the new mount API, which goes into its own file. Signed-off-by: Bernd Schubert --- lib/mount.c | 59 ++++++++--------------------------------------------- lib/mount_i_linux.h | 35 ++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 52 deletions(-) diff --git a/lib/mount.c b/lib/mount.c index fe353e2cc4579adb47473cac5db7d1bae2defb2c..b3ee9ba4c0a74c1d0d55f916e7046e064f8468b0 100644 --- a/lib/mount.c +++ b/lib/mount.c @@ -34,16 +34,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 - #define umount2(mnt, flags) unmount(mnt, (flags == 2) ? MNT_FORCE : 0) #endif @@ -51,10 +41,6 @@ #define FUSE_COMMFD_ENV "_FUSE_COMMFD" #define FUSE_COMMFD2_ENV "_FUSE_COMMFD2" -#ifndef MS_DIRSYNC -#define MS_DIRSYNC 128 -#endif - enum { KEY_KERN_FLAG, KEY_KERN_OPT, @@ -154,35 +140,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}, -#ifndef __NetBSD__ - {"dirsync", MS_DIRSYNC, 1}, -#endif - {NULL, 0, 0} -}; - unsigned int get_max_read(struct mount_opts *o) { return o->max_read; @@ -192,13 +149,13 @@ static void set_mount_flag(const char *s, int *flags) { int i; - for (i = 0; mount_flags[i].opt != NULL; i++) { - const char *opt = mount_flags[i].opt; + for (i = 0; fuse_mount_flags[i].opt != NULL; i++) { + const char *opt = fuse_mount_flags[i].opt; if (strcmp(opt, s) == 0) { - if (mount_flags[i].on) - *flags |= mount_flags[i].flag; + if (fuse_mount_flags[i].on) + *flags |= fuse_mount_flags[i].flag; else - *flags &= ~mount_flags[i].flag; + *flags &= ~fuse_mount_flags[i].flag; return; } } @@ -645,9 +602,9 @@ static int get_mnt_flag_opts(char **mnt_optsp, int flags) if (!(flags & MS_RDONLY) && fuse_opt_add_opt(mnt_optsp, "rw") == -1) return -1; - for (i = 0; mount_flags[i].opt != NULL; i++) { - if (mount_flags[i].on && (flags & mount_flags[i].flag) && - fuse_opt_add_opt(mnt_optsp, mount_flags[i].opt) == -1) + for (i = 0; fuse_mount_flags[i].opt != NULL; i++) { + if (fuse_mount_flags[i].on && (flags & fuse_mount_flags[i].flag) && + fuse_opt_add_opt(mnt_optsp, fuse_mount_flags[i].opt) == -1) return -1; } return 0; diff --git a/lib/mount_i_linux.h b/lib/mount_i_linux.h index abcd1b08012feedef6b4c8961b55ac847a27496a..c0de6228fce5a4d9070cc246ec76222b66de56fb 100644 --- a/lib/mount_i_linux.h +++ b/lib/mount_i_linux.h @@ -10,7 +10,8 @@ #ifndef FUSE_MOUNT_I_H_ #define FUSE_MOUNT_I_H_ -/* Forward declaration for fuse_args */ +#include + struct fuse_args; /* Mount options structure */ @@ -28,5 +29,37 @@ struct mount_opts { unsigned int max_read; }; +/* Mount flags mapping structure */ +struct mount_flags { + const char *opt; + unsigned long flag; + int on; +}; + +/* Mount flags table */ +static const struct mount_flags fuse_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}, +#ifndef __NetBSD__ + {"dirsync", MS_DIRSYNC, 1}, +#endif + {NULL, 0, 0} +}; + + #endif /* FUSE_MOUNT_I_H_ */ -- 2.43.0