diff options
author | Dmitry Chagin <dchagin@FreeBSD.org> | 2023-01-28 10:20:27 +0000 |
---|---|---|
committer | Dmitry Chagin <dchagin@FreeBSD.org> | 2023-02-06 19:06:29 +0000 |
commit | ef4f2cca6085e79f4610897dbc62c489f1976a9c (patch) | |
tree | 494f9f3205e5c2fd21c919864fc203d4282dad17 | |
parent | 3e60d3d3c4b3e9690c0f1a77fa163e3d07c9b245 (diff) | |
download | src-ef4f2cca6085e79f4610897dbc62c489f1976a9c.tar.gz src-ef4f2cca6085e79f4610897dbc62c489f1976a9c.zip |
linux(4): Convert mount exported flags for statfs system calls.
MFC after: 1 week
(cherry picked from commit 9922bccbc9c4effb02b99391088d0405f9c0f75e)
-rw-r--r-- | sys/compat/linux/linux.h | 15 | ||||
-rw-r--r-- | sys/compat/linux/linux_stats.c | 25 |
2 files changed, 38 insertions, 2 deletions
diff --git a/sys/compat/linux/linux.h b/sys/compat/linux/linux.h index 6400de4cb228..40e563014fde 100644 --- a/sys/compat/linux/linux.h +++ b/sys/compat/linux/linux.h @@ -264,6 +264,21 @@ struct l_statx { uint64_t __spare2[13]; }; +/* + * statfs f_flags + */ +#define LINUX_ST_RDONLY 0x0001 +#define LINUX_ST_NOSUID 0x0002 +#define LINUX_ST_NODEV 0x0004 /* No native analogue */ +#define LINUX_ST_NOEXEC 0x0008 +#define LINUX_ST_SYNCHRONOUS 0x0010 +#define LINUX_ST_VALID 0x0020 +#define LINUX_ST_MANDLOCK 0x0040 /* No native analogue */ +#define LINUX_ST_NOATIME 0x0400 +#define LINUX_ST_NODIRATIME 0x0800 /* No native analogue */ +#define LINUX_ST_RELATIME 0x1000 /* No native analogue */ +#define LINUX_ST_NOSYMFOLLOW 0x2000 + #define lower_32_bits(n) ((uint32_t)((n) & 0xffffffff)) #ifdef KTRACE diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c index 63a5c37e1acf..a1cc2bb7bf8b 100644 --- a/sys/compat/linux/linux_stats.c +++ b/sys/compat/linux/linux_stats.c @@ -411,6 +411,27 @@ bsd_to_linux_ftype(const char *fstypename) } static int +bsd_to_linux_mnt_flags(int f_flags) +{ + int flags = LINUX_ST_VALID; + + if (f_flags & MNT_RDONLY) + flags |= LINUX_ST_RDONLY; + if (f_flags & MNT_NOEXEC) + flags |= LINUX_ST_NOEXEC; + if (f_flags & MNT_NOSUID) + flags |= LINUX_ST_NOSUID; + if (f_flags & MNT_NOATIME) + flags |= LINUX_ST_NOATIME; + if (f_flags & MNT_NOSYMFOLLOW) + flags |= LINUX_ST_NOSYMFOLLOW; + if (f_flags & MNT_SYNCHRONOUS) + flags |= LINUX_ST_SYNCHRONOUS; + + return (flags); +} + +static int bsd_to_linux_statfs(struct statfs *bsd_statfs, struct l_statfs *linux_statfs) { @@ -433,7 +454,7 @@ bsd_to_linux_statfs(struct statfs *bsd_statfs, struct l_statfs *linux_statfs) linux_statfs->f_fsid.val[1] = bsd_statfs->f_fsid.val[1]; linux_statfs->f_namelen = MAXNAMLEN; linux_statfs->f_frsize = bsd_statfs->f_bsize; - linux_statfs->f_flags = 0; + linux_statfs->f_flags = bsd_to_linux_mnt_flags(bsd_statfs->f_flags); memset(linux_statfs->f_spare, 0, sizeof(linux_statfs->f_spare)); return (0); @@ -480,7 +501,7 @@ bsd_to_linux_statfs64(struct statfs *bsd_statfs, struct l_statfs64 *linux_statfs linux_statfs->f_fsid.val[1] = bsd_statfs->f_fsid.val[1]; linux_statfs->f_namelen = MAXNAMLEN; linux_statfs->f_frsize = bsd_statfs->f_bsize; - linux_statfs->f_flags = 0; + linux_statfs->f_flags = bsd_to_linux_mnt_flags(bsd_statfs->f_flags); memset(linux_statfs->f_spare, 0, sizeof(linux_statfs->f_spare)); } |