[CRIU] [PATCH 01/10] syscalls: Introduce sys_kcmp syscall

Cyrill Gorcunov gorcunov at openvz.org
Fri Feb 24 18:24:22 EST 2012


Though we can use libc's syscall() wrapper
I would prefer to have own implementation
in case if we will need it in non-libc bindable
code.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 include/syscall-codes.h |    1 +
 include/syscall.h       |    6 ++++++
 include/types.h         |   13 +++++++++++++
 3 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/include/syscall-codes.h b/include/syscall-codes.h
index 2a470c6..7951771 100644
--- a/include/syscall-codes.h
+++ b/include/syscall-codes.h
@@ -51,6 +51,7 @@
 #define __NR_restart_syscall	219
 #define __NR_msync		227
 #define __NR_setns		308
+#define __NR_kcmp		312
 
 #else /* CONFIG_X86_64 */
 # error x86-32 bit mode not yet implemented
diff --git a/include/syscall.h b/include/syscall.h
index f759587..a2b1a9e 100644
--- a/include/syscall.h
+++ b/include/syscall.h
@@ -391,6 +391,12 @@ static void sys_set_tid_address(int *tid_addr) {
 	syscall1(__NR_set_tid_address, (long) tid_addr);
 }
 
+static long always_inline
+sys_kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2)
+{
+	return syscall5(__NR_kcmp, (long)pid1, (long)pid2, (long)type, idx1, idx2);
+}
+
 #ifndef CLONE_NEWUTS
 #define CLONE_NEWUTS	0x04000000
 #endif
diff --git a/include/types.h b/include/types.h
index 63799cf..0f87b4b 100644
--- a/include/types.h
+++ b/include/types.h
@@ -182,4 +182,17 @@ typedef struct {
 # define PAGE_SIZE	4096
 #endif
 
+/* For sys_kcmp */
+enum kcmp_type {
+	KCMP_FILE,
+	KCMP_VM,
+	KCMP_FILES,
+	KCMP_FS,
+	KCMP_SIGHAND,
+	KCMP_IO,
+	KCMP_SYSVSEM,
+
+	KCMP_TYPES,
+};
+
 #endif /* CR_TYPES_H_ */
-- 
1.7.7.6



More information about the CRIU mailing list