130 lines
7.9 KiB
Diff
130 lines
7.9 KiB
Diff
From 51f04ae1074b115f486aaaf0a3feb72d0bf90130 Mon Sep 17 00:00:00 2001
|
|
From: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
|
|
Date: Fri, 24 Dec 2021 13:23:29 +0300
|
|
Subject: [PATCH 204/245] compel: add open_tree syscall
|
|
|
|
Will use this for cross mount namespace bindmounts.
|
|
|
|
Note: don't need separate kdat for mount-v2, as MOVE_MOUNT_SET_GROUP
|
|
were added much later than open_tree and all related fixups.
|
|
|
|
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
|
|
---
|
|
.../arch/arm/plugins/std/syscalls/syscall.def | 1 +
|
|
.../mips/plugins/std/syscalls/syscall_64.tbl | 1 +
|
|
.../plugins/std/syscalls/syscall-ppc64.tbl | 1 +
|
|
.../plugins/std/syscalls/syscall-s390.tbl | 1 +
|
|
.../x86/plugins/std/syscalls/syscall_32.tbl | 1 +
|
|
.../x86/plugins/std/syscalls/syscall_64.tbl | 1 +
|
|
criu/include/mount-v2.h | 24 +++++++++++++++++++
|
|
7 files changed, 30 insertions(+)
|
|
|
|
diff --git a/compel/arch/arm/plugins/std/syscalls/syscall.def b/compel/arch/arm/plugins/std/syscalls/syscall.def
|
|
index 6b9cd8b8e..a422b4905 100644
|
|
--- a/compel/arch/arm/plugins/std/syscalls/syscall.def
|
|
+++ b/compel/arch/arm/plugins/std/syscalls/syscall.def
|
|
@@ -112,6 +112,7 @@ userfaultfd 282 388 (int flags)
|
|
fallocate 47 352 (int fd, int mode, loff_t offset, loff_t len)
|
|
cacheflush ! 983042 (void *start, void *end, int flags)
|
|
ppoll 73 336 (struct pollfd *fds, unsigned int nfds, const struct timespec *tmo, const sigset_t *sigmask, size_t sigsetsize)
|
|
+open_tree 428 428 (int dirfd, const char *pathname, unsigned int flags)
|
|
move_mount 429 429 (int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, int flags)
|
|
fsopen 430 430 (char *fsname, unsigned int flags)
|
|
fsconfig 431 431 (int fd, unsigned int cmd, const char *key, const char *value, int aux)
|
|
diff --git a/compel/arch/mips/plugins/std/syscalls/syscall_64.tbl b/compel/arch/mips/plugins/std/syscalls/syscall_64.tbl
|
|
index 430df1824..745782285 100644
|
|
--- a/compel/arch/mips/plugins/std/syscalls/syscall_64.tbl
|
|
+++ b/compel/arch/mips/plugins/std/syscalls/syscall_64.tbl
|
|
@@ -109,6 +109,7 @@ __NR_memfd_create 5314 sys_memfd_create (const char *name, unsigned int flags)
|
|
__NR_userfaultfd 5317 sys_userfaultfd (int flags)
|
|
|
|
##TODO for kernel
|
|
+__NR_open_tree 5428 sys_open_tree (int dirfd, const char *pathname, unsigned int flags)
|
|
__NR_move_mount 5429 sys_move_mount (int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, int flags)
|
|
__NR_fsopen 5430 sys_fsopen (char *fsname, unsigned int flags)
|
|
__NR_fsconfig 5431 sys_fsconfig (int fd, unsigned int cmd, const char *key, const char *value, int aux)
|
|
diff --git a/compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl b/compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl
|
|
index 138eec2af..0eceebe22 100644
|
|
--- a/compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl
|
|
+++ b/compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl
|
|
@@ -108,6 +108,7 @@ __NR_gettimeofday 78 sys_gettimeofday (struct timeval *tv, struct timezone *tz)
|
|
__NR_preadv 320 sys_preadv_raw (int fd, struct iovec *iov, unsigned long nr, unsigned long pos_l, unsigned long pos_h)
|
|
__NR_userfaultfd 364 sys_userfaultfd (int flags)
|
|
__NR_ppoll 281 sys_ppoll (struct pollfd *fds, unsigned int nfds, const struct timespec *tmo, const sigset_t *sigmask, size_t sigsetsize)
|
|
+__NR_open_tree 428 sys_open_tree (int dirfd, const char *pathname, unsigned int flags)
|
|
__NR_move_mount 429 sys_move_mount (int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, int flags)
|
|
__NR_fsopen 430 sys_fsopen (char *fsname, unsigned int flags)
|
|
__NR_fsconfig 431 sys_fsconfig (int fd, unsigned int cmd, const char *key, const char *value, int aux)
|
|
diff --git a/compel/arch/s390/plugins/std/syscalls/syscall-s390.tbl b/compel/arch/s390/plugins/std/syscalls/syscall-s390.tbl
|
|
index ae54afa17..93a8f34d3 100644
|
|
--- a/compel/arch/s390/plugins/std/syscalls/syscall-s390.tbl
|
|
+++ b/compel/arch/s390/plugins/std/syscalls/syscall-s390.tbl
|
|
@@ -108,6 +108,7 @@ __NR_userfaultfd 355 sys_userfaultfd (int flags)
|
|
__NR_preadv 328 sys_preadv_raw (int fd, struct iovec *iov, unsigned long nr, unsigned long pos_l, unsigned long pos_h)
|
|
__NR_gettimeofday 78 sys_gettimeofday (struct timeval *tv, struct timezone *tz)
|
|
__NR_ppoll 302 sys_ppoll (struct pollfd *fds, unsigned int nfds, const struct timespec *tmo, const sigset_t *sigmask, size_t sigsetsize)
|
|
+__NR_open_tree 428 sys_open_tree (int dirfd, const char *pathname, unsigned int flags)
|
|
__NR_move_mount 429 sys_move_mount (int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, int flags)
|
|
__NR_fsopen 430 sys_fsopen (char *fsname, unsigned int flags)
|
|
__NR_fsconfig 431 sys_fsconfig (int fd, unsigned int cmd, const char *key, const char *value, int aux)
|
|
diff --git a/compel/arch/x86/plugins/std/syscalls/syscall_32.tbl b/compel/arch/x86/plugins/std/syscalls/syscall_32.tbl
|
|
index e4133f8f9..14d2e0581 100644
|
|
--- a/compel/arch/x86/plugins/std/syscalls/syscall_32.tbl
|
|
+++ b/compel/arch/x86/plugins/std/syscalls/syscall_32.tbl
|
|
@@ -96,6 +96,7 @@ __NR_seccomp 354 sys_seccomp (unsigned int op, unsigned int flags, const char
|
|
__NR_memfd_create 356 sys_memfd_create (const char *name, unsigned int flags)
|
|
__NR_userfaultfd 374 sys_userfaultfd (int flags)
|
|
__NR_ppoll 309 sys_ppoll (struct pollfd *fds, unsigned int nfds, const struct timespec *tmo, const sigset_t *sigmask, size_t sigsetsize)
|
|
+__NR_open_tree 428 sys_open_tree (int dirfd, const char *pathname, unsigned int flags)
|
|
__NR_move_mount 429 sys_move_mount (int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, int flags)
|
|
__NR_fsopen 430 sys_fsopen (char *fsname, unsigned int flags)
|
|
__NR_fsconfig 431 sys_fsconfig (int fd, unsigned int cmd, const char *key, const char *value, int aux)
|
|
diff --git a/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl b/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl
|
|
index 4c9461473..2f690f48f 100644
|
|
--- a/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl
|
|
+++ b/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl
|
|
@@ -107,6 +107,7 @@ __NR_kcmp 312 sys_kcmp (pid_t pid1, pid_t pid2, int type, unsigned long idx1
|
|
__NR_memfd_create 319 sys_memfd_create (const char *name, unsigned int flags)
|
|
__NR_userfaultfd 323 sys_userfaultfd (int flags)
|
|
__NR_ppoll 271 sys_ppoll (struct pollfd *fds, unsigned int nfds, const struct timespec *tmo, const sigset_t *sigmask, size_t sigsetsize)
|
|
+__NR_open_tree 428 sys_open_tree (int dirfd, const char *pathname, unsigned int flags)
|
|
__NR_move_mount 429 sys_move_mount (int from_dfd, const char *from_pathname, int to_dfd, const char *to_pathname, int flags)
|
|
__NR_fsopen 430 sys_fsopen (char *fsname, unsigned int flags)
|
|
__NR_fsconfig 431 sys_fsconfig (int fd, unsigned int cmd, const char *key, const char *value, int aux)
|
|
diff --git a/criu/include/mount-v2.h b/criu/include/mount-v2.h
|
|
index 8a4e46b1a..396ed9594 100644
|
|
--- a/criu/include/mount-v2.h
|
|
+++ b/criu/include/mount-v2.h
|
|
@@ -21,4 +21,28 @@ static inline int sys_move_mount(int from_dirfd, const char *from_pathname, int
|
|
return syscall(__NR_move_mount, from_dirfd, from_pathname, to_dirfd, to_pathname, flags);
|
|
}
|
|
|
|
+#ifndef OPEN_TREE_CLONE
|
|
+#define OPEN_TREE_CLONE 1 /* Clone the target tree and attach the clone */
|
|
+#endif
|
|
+#ifndef OPEN_TREE_CLOEXEC
|
|
+#define OPEN_TREE_CLOEXEC O_CLOEXEC /* Close the file on execve() */
|
|
+#endif
|
|
+#ifndef AT_SYMLINK_NOFOLLOW
|
|
+#define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links. */
|
|
+#endif
|
|
+#ifndef AT_NO_AUTOMOUNT
|
|
+#define AT_NO_AUTOMOUNT 0x800 /* Suppress terminal automount traversal */
|
|
+#endif
|
|
+#ifndef AT_EMPTY_PATH
|
|
+#define AT_EMPTY_PATH 0x1000 /* Allow empty relative pathname */
|
|
+#endif
|
|
+#ifndef AT_RECURSIVE
|
|
+#define AT_RECURSIVE 0x8000 /* Apply to the entire subtree */
|
|
+#endif
|
|
+
|
|
+static inline int sys_open_tree(int dfd, const char *filename, unsigned int flags)
|
|
+{
|
|
+ return syscall(__NR_open_tree, dfd, filename, flags);
|
|
+}
|
|
+
|
|
#endif /* __CR_MOUNT_V2_H__ */
|
|
--
|
|
2.35.1
|
|
|