mirror of
https://github.com/libfuse/libfuse.git
synced 2026-07-07 14:47:41 +08:00
Move 'struct mount_flags' to util.h
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> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
This commit is contained in:
@@ -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_ */
|
||||
|
||||
-39
@@ -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(const struct mount_opts *o)
|
||||
{
|
||||
return o->max_read;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "util.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#include "fuse_mount_compat.h"
|
||||
|
||||
#include <sys/wait.h>
|
||||
|
||||
+2
-2
@@ -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_ */
|
||||
|
||||
+52
-1
@@ -34,9 +34,60 @@
|
||||
#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 */
|
||||
|
||||
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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -756,40 +756,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;
|
||||
|
||||
Reference in New Issue
Block a user