[CRIU] [PATCH 1/3] syscall: add memfd_create()

Andrey Vagin avagin at openvz.org
Fri Oct 10 09:39:21 PDT 2014


Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 arch/arm/syscall.def        |  1 +
 arch/x86/syscall-x86-64.def |  1 +
 include/kerndat.h           |  2 ++
 kerndat.c                   | 18 ++++++++++++++++++
 4 files changed, 22 insertions(+)

diff --git a/arch/arm/syscall.def b/arch/arm/syscall.def
index 02eaa65..3b2d1ed 100644
--- a/arch/arm/syscall.def
+++ b/arch/arm/syscall.def
@@ -96,3 +96,4 @@ kcmp				272	378	(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned
 openat				56	322	(int dirfd, const char *pathname, int flags, mode_t mode)
 mkdirat				34	323	(int dirfd, const char *pathname, mode_t mode)
 unlinkat			35	328	(int dirfd, const char *pathname, int flags)
+memfd_create			279	385	(const char *name, unsigned int flags)
diff --git a/arch/x86/syscall-x86-64.def b/arch/x86/syscall-x86-64.def
index 5d31337..c780c40 100644
--- a/arch/x86/syscall-x86-64.def
+++ b/arch/x86/syscall-x86-64.def
@@ -96,3 +96,4 @@ __NR_prlimit64		302		sys_prlimit64		(pid_t pid, unsigned int resource, const str
 __NR_open_by_handle_at	304		sys_open_by_handle_at	(int mountdirfd, struct file_handle *handle, int flags)
 __NR_setns		308		sys_setns		(int fd, int nstype)
 __NR_kcmp		312		sys_kcmp		(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2)
+__NR_memfd_create	319		sys_memfd_create	(const char *name, unsigned int flags)
diff --git a/include/kerndat.h b/include/kerndat.h
index 6b9947f..62f25e6 100644
--- a/include/kerndat.h
+++ b/include/kerndat.h
@@ -24,4 +24,6 @@ extern u64 zero_page_pfn;
 struct stat;
 extern struct stat *kerndat_get_devpts_stat(void);
 
+bool kerndat_has_memfd_create(void);
+
 #endif /* __CR_KERNDAT_H__ */
diff --git a/kerndat.c b/kerndat.c
index 3c87f6c..8ee5707 100644
--- a/kerndat.c
+++ b/kerndat.c
@@ -13,6 +13,7 @@
 #include "mem.h"
 #include "compiler.h"
 #include "sysctl.h"
+#include "syscall.h"
 #include "asm/types.h"
 #include "cr_options.h"
 #include "util.h"
@@ -232,6 +233,8 @@ int kerndat_init(void)
 	if (!ret)
 		ret = get_last_cap();
 
+	kerndat_has_memfd_create();
+
 	return ret;
 }
 
@@ -251,3 +254,18 @@ int kerndat_init_rst(void)
 
 	return ret;
 }
+
+bool kerndat_has_memfd_create(void)
+{
+	static int supported = -1;
+	int ret;
+
+	if (supported != -1)
+		return !!supported;
+
+	ret = sys_memfd_create(NULL, 0);
+	supported = (ret != -ENOSYS);
+
+	return !!supported;
+}
+
-- 
1.9.3



More information about the CRIU mailing list