summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@strace.io>2021-02-06 08:00:00 +0000
committerDmitry V. Levin <ldv@strace.io>2021-02-06 08:00:00 +0000
commit354147b07ec2db6b466c51d4bc363d651bb6d2bb (patch)
tree229678d30c63de7807697094e4ea55724f073749
parent3f275ddea360b4d2d321abdb45e8043769fde79f (diff)
downloadstrace-354147b07ec2db6b466c51d4bc363d651bb6d2bb.tar.gz
Switch to use bundled <linux/mount.h>
* bundled/linux/include/uapi/linux/mount.h: New file, copied from * bundled/Makefile.am (EXTRA_DIST): Add it. * configure.ac (AC_CHECK_HEADERS): Remove linux/mount.h. * src/fsconfig.c: Include <linux/mount.h> unconditionally. * src/fsmount.c: Likewise. * src/fsopen.c: Likewise. * src/fspick.c: Likewise. * src/move_mount.c: Likewise. * src/open_tree.c: Likewise. Include "xlat/open_mode_flags.h" in XLAT_MACROS_ONLY mode instead of <fcntl.h>. to make sure O_CLOEXEC is properly defined. * src/xlat/fsconfig_cmds.in: Add #unconditional, remove fallback definitions. * src/xlat/fsmount_flags.in: Likewise. * src/xlat/fsopen_flags.in: Likewise. * src/xlat/fspick_flags.in: Likewise. * src/xlat/mount_attr_flags.in: Likewise. * src/xlat/move_mount_flags.in: Likewise. * src/xlat/open_tree_flags.in (OPEN_TREE_CLOEXEC): Define unconditionally. * tests/fsconfig.c: Include <linux/mount.h> instead of "xlat/fsconfig_cmds.h".
-rw-r--r--bundled/Makefile.am1
-rw-r--r--bundled/linux/include/uapi/linux/mount.h121
-rw-r--r--configure.ac1
-rw-r--r--src/fsconfig.c4
-rw-r--r--src/fsmount.c4
-rw-r--r--src/fsopen.c4
-rw-r--r--src/fspick.c4
-rw-r--r--src/move_mount.c4
-rw-r--r--src/open_tree.c8
-rw-r--r--src/xlat/fsconfig_cmds.in17
-rw-r--r--src/xlat/fsmount_flags.in3
-rw-r--r--src/xlat/fsopen_flags.in3
-rw-r--r--src/xlat/fspick_flags.in9
-rw-r--r--src/xlat/mount_attr_flags.in15
-rw-r--r--src/xlat/move_mount_flags.in13
-rw-r--r--src/xlat/open_tree_flags.in2
-rw-r--r--tests/fsconfig.c5
17 files changed, 165 insertions, 53 deletions
diff --git a/bundled/Makefile.am b/bundled/Makefile.am
index 7f1009852..f885b067c 100644
--- a/bundled/Makefile.am
+++ b/bundled/Makefile.am
@@ -14,6 +14,7 @@ EXTRA_DIST = \
linux/include/uapi/linux/gpio.h \
linux/include/uapi/linux/inet_diag.h \
linux/include/uapi/linux/loop.h \
+ linux/include/uapi/linux/mount.h \
linux/include/uapi/linux/netlink_diag.h \
linux/include/uapi/linux/openat2.h \
linux/include/uapi/linux/packet_diag.h \
diff --git a/bundled/linux/include/uapi/linux/mount.h b/bundled/linux/include/uapi/linux/mount.h
new file mode 100644
index 000000000..13247dafe
--- /dev/null
+++ b/bundled/linux/include/uapi/linux/mount.h
@@ -0,0 +1,121 @@
+#ifndef _LINUX_MOUNT_H
+#define _LINUX_MOUNT_H
+
+/*
+ * These are the fs-independent mount-flags: up to 32 flags are supported
+ *
+ * Usage of these is restricted within the kernel to core mount(2) code and
+ * callers of sys_mount() only. Filesystems should be using the SB_*
+ * equivalent instead.
+ */
+#define MS_RDONLY 1 /* Mount read-only */
+#define MS_NOSUID 2 /* Ignore suid and sgid bits */
+#define MS_NODEV 4 /* Disallow access to device special files */
+#define MS_NOEXEC 8 /* Disallow program execution */
+#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
+#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
+#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
+#define MS_DIRSYNC 128 /* Directory modifications are synchronous */
+#define MS_NOSYMFOLLOW 256 /* Do not follow symlinks */
+#define MS_NOATIME 1024 /* Do not update access times. */
+#define MS_NODIRATIME 2048 /* Do not update directory access times */
+#define MS_BIND 4096
+#define MS_MOVE 8192
+#define MS_REC 16384
+#define MS_VERBOSE 32768 /* War is peace. Verbosity is silence.
+ MS_VERBOSE is deprecated. */
+#define MS_SILENT 32768
+#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
+#define MS_UNBINDABLE (1<<17) /* change to unbindable */
+#define MS_PRIVATE (1<<18) /* change to private */
+#define MS_SLAVE (1<<19) /* change to slave */
+#define MS_SHARED (1<<20) /* change to shared */
+#define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
+#define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
+#define MS_I_VERSION (1<<23) /* Update inode I_version field */
+#define MS_STRICTATIME (1<<24) /* Always perform atime updates */
+#define MS_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */
+
+/* These sb flags are internal to the kernel */
+#define MS_SUBMOUNT (1<<26)
+#define MS_NOREMOTELOCK (1<<27)
+#define MS_NOSEC (1<<28)
+#define MS_BORN (1<<29)
+#define MS_ACTIVE (1<<30)
+#define MS_NOUSER (1<<31)
+
+/*
+ * Superblock flags that can be altered by MS_REMOUNT
+ */
+#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION|\
+ MS_LAZYTIME)
+
+/*
+ * Old magic mount flag and mask
+ */
+#define MS_MGC_VAL 0xC0ED0000
+#define MS_MGC_MSK 0xffff0000
+
+/*
+ * open_tree() flags.
+ */
+#define OPEN_TREE_CLONE 1 /* Clone the target tree and attach the clone */
+#define OPEN_TREE_CLOEXEC O_CLOEXEC /* Close the file on execve() */
+
+/*
+ * move_mount() flags.
+ */
+#define MOVE_MOUNT_F_SYMLINKS 0x00000001 /* Follow symlinks on from path */
+#define MOVE_MOUNT_F_AUTOMOUNTS 0x00000002 /* Follow automounts on from path */
+#define MOVE_MOUNT_F_EMPTY_PATH 0x00000004 /* Empty from path permitted */
+#define MOVE_MOUNT_T_SYMLINKS 0x00000010 /* Follow symlinks on to path */
+#define MOVE_MOUNT_T_AUTOMOUNTS 0x00000020 /* Follow automounts on to path */
+#define MOVE_MOUNT_T_EMPTY_PATH 0x00000040 /* Empty to path permitted */
+#define MOVE_MOUNT__MASK 0x00000077
+
+/*
+ * fsopen() flags.
+ */
+#define FSOPEN_CLOEXEC 0x00000001
+
+/*
+ * fspick() flags.
+ */
+#define FSPICK_CLOEXEC 0x00000001
+#define FSPICK_SYMLINK_NOFOLLOW 0x00000002
+#define FSPICK_NO_AUTOMOUNT 0x00000004
+#define FSPICK_EMPTY_PATH 0x00000008
+
+/*
+ * The type of fsconfig() call made.
+ */
+enum fsconfig_command {
+ FSCONFIG_SET_FLAG = 0, /* Set parameter, supplying no value */
+ FSCONFIG_SET_STRING = 1, /* Set parameter, supplying a string value */
+ FSCONFIG_SET_BINARY = 2, /* Set parameter, supplying a binary blob value */
+ FSCONFIG_SET_PATH = 3, /* Set parameter, supplying an object by path */
+ FSCONFIG_SET_PATH_EMPTY = 4, /* Set parameter, supplying an object by (empty) path */
+ FSCONFIG_SET_FD = 5, /* Set parameter, supplying an object by fd */
+ FSCONFIG_CMD_CREATE = 6, /* Invoke superblock creation */
+ FSCONFIG_CMD_RECONFIGURE = 7, /* Invoke superblock reconfiguration */
+};
+
+/*
+ * fsmount() flags.
+ */
+#define FSMOUNT_CLOEXEC 0x00000001
+
+/*
+ * Mount attributes.
+ */
+#define MOUNT_ATTR_RDONLY 0x00000001 /* Mount read-only */
+#define MOUNT_ATTR_NOSUID 0x00000002 /* Ignore suid and sgid bits */
+#define MOUNT_ATTR_NODEV 0x00000004 /* Disallow access to device special files */
+#define MOUNT_ATTR_NOEXEC 0x00000008 /* Disallow program execution */
+#define MOUNT_ATTR__ATIME 0x00000070 /* Setting on how atime should be updated */
+#define MOUNT_ATTR_RELATIME 0x00000000 /* - Update atime relative to mtime/ctime. */
+#define MOUNT_ATTR_NOATIME 0x00000010 /* - Do not update access times. */
+#define MOUNT_ATTR_STRICTATIME 0x00000020 /* - Always perform atime updates */
+#define MOUNT_ATTR_NODIRATIME 0x00000080 /* Do not update directory access times */
+
+#endif /* _LINUX_MOUNT_H */
diff --git a/configure.ac b/configure.ac
index 32ae74ed3..1253c813a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -449,7 +449,6 @@ AC_CHECK_HEADERS(m4_normalize([
linux/kvm.h
linux/memfd.h
linux/mmtimer.h
- linux/mount.h
linux/mqueue.h
linux/netfilter/ipset/ip_set.h
linux/netfilter/nf_tables.h
diff --git a/src/fsconfig.c b/src/fsconfig.c
index 6134155ca..dba3778cf 100644
--- a/src/fsconfig.c
+++ b/src/fsconfig.c
@@ -6,9 +6,7 @@
*/
#include "defs.h"
-#ifdef HAVE_LINUX_MOUNT_H
-# include <linux/mount.h>
-#endif
+#include <linux/mount.h>
#include "xlat/fsconfig_cmds.h"
SYS_FUNC(fsconfig)
diff --git a/src/fsmount.c b/src/fsmount.c
index 5922421c2..ff7a4afd1 100644
--- a/src/fsmount.c
+++ b/src/fsmount.c
@@ -6,9 +6,7 @@
*/
#include "defs.h"
-#ifdef HAVE_LINUX_MOUNT_H
-# include <linux/mount.h>
-#endif
+#include <linux/mount.h>
#include "xlat/fsmount_flags.h"
#include "xlat/mount_attr_flags.h"
diff --git a/src/fsopen.c b/src/fsopen.c
index 293bbfa52..515c693e6 100644
--- a/src/fsopen.c
+++ b/src/fsopen.c
@@ -6,9 +6,7 @@
*/
#include "defs.h"
-#ifdef HAVE_LINUX_MOUNT_H
-# include <linux/mount.h>
-#endif
+#include <linux/mount.h>
#include "xlat/fsopen_flags.h"
SYS_FUNC(fsopen)
diff --git a/src/fspick.c b/src/fspick.c
index 1d9b43d70..8595b5def 100644
--- a/src/fspick.c
+++ b/src/fspick.c
@@ -6,9 +6,7 @@
*/
#include "defs.h"
-#ifdef HAVE_LINUX_MOUNT_H
-# include <linux/mount.h>
-#endif
+#include <linux/mount.h>
#include "xlat/fspick_flags.h"
SYS_FUNC(fspick)
diff --git a/src/move_mount.c b/src/move_mount.c
index dd67b3f42..365d18880 100644
--- a/src/move_mount.c
+++ b/src/move_mount.c
@@ -6,9 +6,7 @@
*/
#include "defs.h"
-#ifdef HAVE_LINUX_MOUNT_H
-# include <linux/mount.h>
-#endif
+#include <linux/mount.h>
#include "xlat/move_mount_flags.h"
SYS_FUNC(move_mount)
diff --git a/src/open_tree.c b/src/open_tree.c
index 8f16fc95e..5dc2a9d1e 100644
--- a/src/open_tree.c
+++ b/src/open_tree.c
@@ -6,10 +6,10 @@
*/
#include "defs.h"
-#include <fcntl.h>
-#ifdef HAVE_LINUX_MOUNT_H
-# include <linux/mount.h>
-#endif
+#include <linux/mount.h>
+#define XLAT_MACROS_ONLY
+# include "xlat/open_mode_flags.h"
+#undef XLAT_MACROS_ONLY
#include "xlat/open_tree_flags.h"
SYS_FUNC(open_tree)
diff --git a/src/xlat/fsconfig_cmds.in b/src/xlat/fsconfig_cmds.in
index be33679be..012f0c80b 100644
--- a/src/xlat/fsconfig_cmds.in
+++ b/src/xlat/fsconfig_cmds.in
@@ -1,9 +1,10 @@
+#unconditional
#value_indexed
-FSCONFIG_SET_FLAG 0
-FSCONFIG_SET_STRING 1
-FSCONFIG_SET_BINARY 2
-FSCONFIG_SET_PATH 3
-FSCONFIG_SET_PATH_EMPTY 4
-FSCONFIG_SET_FD 5
-FSCONFIG_CMD_CREATE 6
-FSCONFIG_CMD_RECONFIGURE 7
+FSCONFIG_SET_FLAG
+FSCONFIG_SET_STRING
+FSCONFIG_SET_BINARY
+FSCONFIG_SET_PATH
+FSCONFIG_SET_PATH_EMPTY
+FSCONFIG_SET_FD
+FSCONFIG_CMD_CREATE
+FSCONFIG_CMD_RECONFIGURE
diff --git a/src/xlat/fsmount_flags.in b/src/xlat/fsmount_flags.in
index 8a3b95e4e..bc14fda5b 100644
--- a/src/xlat/fsmount_flags.in
+++ b/src/xlat/fsmount_flags.in
@@ -1 +1,2 @@
-FSMOUNT_CLOEXEC 1
+#unconditional
+FSMOUNT_CLOEXEC
diff --git a/src/xlat/fsopen_flags.in b/src/xlat/fsopen_flags.in
index ce01ddf0e..47513151b 100644
--- a/src/xlat/fsopen_flags.in
+++ b/src/xlat/fsopen_flags.in
@@ -1 +1,2 @@
-FSOPEN_CLOEXEC 1
+#unconditional
+FSOPEN_CLOEXEC
diff --git a/src/xlat/fspick_flags.in b/src/xlat/fspick_flags.in
index 52ed0350e..1b0d16556 100644
--- a/src/xlat/fspick_flags.in
+++ b/src/xlat/fspick_flags.in
@@ -1,4 +1,5 @@
-FSPICK_CLOEXEC 0x01
-FSPICK_SYMLINK_NOFOLLOW 0x02
-FSPICK_NO_AUTOMOUNT 0x04
-FSPICK_EMPTY_PATH 0x08
+#unconditional
+FSPICK_CLOEXEC
+FSPICK_SYMLINK_NOFOLLOW
+FSPICK_NO_AUTOMOUNT
+FSPICK_EMPTY_PATH
diff --git a/src/xlat/mount_attr_flags.in b/src/xlat/mount_attr_flags.in
index f6356c193..1366350f8 100644
--- a/src/xlat/mount_attr_flags.in
+++ b/src/xlat/mount_attr_flags.in
@@ -1,7 +1,8 @@
-MOUNT_ATTR_RDONLY 0x01
-MOUNT_ATTR_NOSUID 0x02
-MOUNT_ATTR_NODEV 0x04
-MOUNT_ATTR_NOEXEC 0x08
-MOUNT_ATTR_NOATIME 0x10
-MOUNT_ATTR_STRICTATIME 0x20
-MOUNT_ATTR_NODIRATIME 0x80
+#unconditional
+MOUNT_ATTR_RDONLY
+MOUNT_ATTR_NOSUID
+MOUNT_ATTR_NODEV
+MOUNT_ATTR_NOEXEC
+MOUNT_ATTR_NOATIME
+MOUNT_ATTR_STRICTATIME
+MOUNT_ATTR_NODIRATIME
diff --git a/src/xlat/move_mount_flags.in b/src/xlat/move_mount_flags.in
index 441387c44..7bea629ba 100644
--- a/src/xlat/move_mount_flags.in
+++ b/src/xlat/move_mount_flags.in
@@ -1,6 +1,7 @@
-MOVE_MOUNT_F_SYMLINKS 0x01
-MOVE_MOUNT_F_AUTOMOUNTS 0x02
-MOVE_MOUNT_F_EMPTY_PATH 0x04
-MOVE_MOUNT_T_SYMLINKS 0x10
-MOVE_MOUNT_T_AUTOMOUNTS 0x20
-MOVE_MOUNT_T_EMPTY_PATH 0x40
+#unconditional
+MOVE_MOUNT_F_SYMLINKS
+MOVE_MOUNT_F_AUTOMOUNTS
+MOVE_MOUNT_F_EMPTY_PATH
+MOVE_MOUNT_T_SYMLINKS
+MOVE_MOUNT_T_AUTOMOUNTS
+MOVE_MOUNT_T_EMPTY_PATH
diff --git a/src/xlat/open_tree_flags.in b/src/xlat/open_tree_flags.in
index 3080dc083..990f1149f 100644
--- a/src/xlat/open_tree_flags.in
+++ b/src/xlat/open_tree_flags.in
@@ -1,7 +1,5 @@
OPEN_TREE_CLONE 1
-#if defined OPEN_TREE_CLOEXEC || defined O_CLOEXEC
OPEN_TREE_CLOEXEC O_CLOEXEC
-#endif
AT_SYMLINK_NOFOLLOW 0x100
AT_REMOVEDIR 0x200
AT_SYMLINK_FOLLOW 0x400
diff --git a/tests/fsconfig.c b/tests/fsconfig.c
index 652d620bb..95f728c30 100644
--- a/tests/fsconfig.c
+++ b/tests/fsconfig.c
@@ -17,10 +17,7 @@
# include <stdio.h>
# include <stdint.h>
# include <unistd.h>
-
-# define XLAT_MACROS_ONLY
-# include "xlat/fsconfig_cmds.h"
-# undef XLAT_MACROS_ONLY
+# include <linux/mount.h>
static const char *errstr;