|
|
Message-ID: <aiQCS0GzEEu__wSH@igalia.com>
Date: Sat, 6 Jun 2026 12:19:39 +0100
From: Luis Henriques <luis@...lia.com>
To: musl@...ts.openwall.com
Cc: Rich Felker <dalias@...c.org>
Subject: [PATCH v2] Add new Linux mount API wrappers
Add the wrappers for the set of syscalls used by the Linux new mount API.
These syscalls are:
- open_tree
- move_mount
- fsopen
- fsconfig
- fsmount
- fspick
All these syscalls were merged into the Linux kernel 5.2.
Signed-off-by: Luis Henriques <luis@...lia.com>
---
Hi!
As suggested by Rich, I'm resending this set of wrappers as a single patch.
Also, I moved all the code into a new file fsopen.c instead of mount.c.
The filename matches the filename where half of these syscalls are in the
kernel tree (the other half are in namespace.c).
Cheers,
--
Luis
include/sys/mount.h | 52 +++++++++++++++++++++++++++++++++++++++++++++
src/linux/fsopen.c | 32 ++++++++++++++++++++++++++++
2 files changed, 84 insertions(+)
create mode 100644 src/linux/fsopen.c
diff --git a/include/sys/mount.h b/include/sys/mount.h
index 09bd6e9dfeff..6d25d17ea7a6 100644
--- a/include/sys/mount.h
+++ b/include/sys/mount.h
@@ -64,10 +64,62 @@ extern "C" {
#define MNT_EXPIRE 4
#define UMOUNT_NOFOLLOW 8
+#define OPEN_TREE_CLONE 1
+#define OPEN_TREE_CLOEXEC O_CLOEXEC
+
+#define MOVE_MOUNT_F_SYMLINKS 0x00000001
+#define MOVE_MOUNT_F_AUTOMOUNTS 0x00000002
+#define MOVE_MOUNT_F_EMPTY_PATH 0x00000004
+#define MOVE_MOUNT_T_SYMLINKS 0x00000010
+#define MOVE_MOUNT_T_AUTOMOUNTS 0x00000020
+#define MOVE_MOUNT_T_EMPTY_PATH 0x00000040
+#define MOVE_MOUNT_SET_GROUP 0x00000100
+#define MOVE_MOUNT_BENEATH 0x00000200
+
+#define FSOPEN_CLOEXEC 0x00000001
+
+enum fsconfig_command {
+ 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_CMD_CREATE_EXCL = 8,
+};
+
+#define FSMOUNT_CLOEXEC 0x00000001
+
+#define MOUNT_ATTR_RDONLY 0x00000001
+#define MOUNT_ATTR_NOSUID 0x00000002
+#define MOUNT_ATTR_NODEV 0x00000004
+#define MOUNT_ATTR_NOEXEC 0x00000008
+#define MOUNT_ATTR__ATIME 0x00000070
+#define MOUNT_ATTR_RELATIME 0x00000000
+#define MOUNT_ATTR_NOATIME 0x00000010
+#define MOUNT_ATTR_STRICTATIME 0x00000020
+#define MOUNT_ATTR_NODIRATIME 0x00000080
+#define MOUNT_ATTR_IDMAP 0x00100000
+#define MOUNT_ATTR_NOSYMFOLLOW 0x00200000
+
+#define FSPICK_CLOEXEC 0x00000001
+#define FSPICK_SYMLINK_NOFOLLOW 0x00000002
+#define FSPICK_NO_AUTOMOUNT 0x00000004
+#define FSPICK_EMPTY_PATH 0x00000008
+
int mount(const char *, const char *, const char *, unsigned long, const void *);
int umount(const char *);
int umount2(const char *, int);
+int open_tree(int, const char *, unsigned int);
+int move_mount(int, const char *, int, const char *, unsigned int);
+int fsopen(const char *, unsigned int);
+int fsconfig(int, unsigned int, const char *, const void *, int);
+int fsmount(int, unsigned int, unsigned int);
+int fspick(int, const char *, unsigned int);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/linux/fsopen.c b/src/linux/fsopen.c
new file mode 100644
index 000000000000..ba6acb7cb17e
--- /dev/null
+++ b/src/linux/fsopen.c
@@ -0,0 +1,32 @@
+#include <sys/mount.h>
+#include "syscall.h"
+
+int open_tree(int dirfd, const char *path, unsigned int flags)
+{
+ return syscall(SYS_open_tree, dirfd, path, flags);
+}
+
+int move_mount(int from_dirfd, const char *from_path, int to_dirfd, const char *to_path, unsigned int flags)
+{
+ return syscall(SYS_move_mount, from_dirfd, from_path, to_dirfd, to_path, flags);
+}
+
+int fsopen(const char *fsname, unsigned int flags)
+{
+ return syscall(SYS_fsopen, fsname, flags);
+}
+
+int fsconfig(int fd, unsigned int cmd, const char *key, const void * value, int aux)
+{
+ return syscall(SYS_fsconfig, fd, cmd, key, value, aux);
+}
+
+int fsmount(int fsfd, unsigned int flags, unsigned int attr_flags)
+{
+ return syscall(SYS_fsmount, fsfd, flags, attr_flags);
+}
+
+int fspick(int dirfd, const char *path, unsigned int flags)
+{
+ return syscall(SYS_fspick, dirfd, path, flags);
+}
Cheers,
--
Luis
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.