Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Feb 2023 19:07:40 GMT
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: ef4f2cca6085 - stable/13 - linux(4): Convert mount exported flags for statfs system calls.
Message-ID:  <202302061907.316J7eFj076782@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=ef4f2cca6085e79f4610897dbc62c489f1976a9c

commit ef4f2cca6085e79f4610897dbc62c489f1976a9c
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-01-28 10:20:27 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-02-06 19:06:29 +0000

    linux(4): Convert mount exported flags for statfs system calls.
    
    MFC after:              1 week
    
    (cherry picked from commit 9922bccbc9c4effb02b99391088d0405f9c0f75e)
---
 sys/compat/linux/linux.h       | 15 +++++++++++++++
 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
@@ -410,6 +410,27 @@ bsd_to_linux_ftype(const char *fstypename)
 	return (0L);
 }
 
+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));
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202302061907.316J7eFj076782>