[CRIU] [PATCH 2/4] prctl: kerndat -- Add kerndat_prctl_may_use_mm_map helper
Cyrill Gorcunov
gorcunov at openvz.org
Fri Oct 10 04:09:36 PDT 2014
It tests if new prctl interface is present in the kernel
and will be used on restore and check procedures.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
include/kerndat.h | 2 ++
kerndat.c | 18 ++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/include/kerndat.h b/include/kerndat.h
index 6b9947fbddd0..cef33e26de48 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);
+extern int kerndat_prctl_may_use_mm_map(void);
+
#endif /* __CR_KERNDAT_H__ */
diff --git a/kerndat.c b/kerndat.c
index 3c87f6ceb34f..a42a7ca66c9d 100644
--- a/kerndat.c
+++ b/kerndat.c
@@ -4,6 +4,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mman.h>
+#include <sys/prctl.h>
#include <errno.h>
#include "log.h"
@@ -13,6 +14,7 @@
#include "mem.h"
#include "compiler.h"
#include "sysctl.h"
+#include "prctl.h"
#include "asm/types.h"
#include "cr_options.h"
#include "util.h"
@@ -220,6 +222,22 @@ int get_last_cap(void)
return sysctl_op(req, CTL_READ);
}
+int kerndat_prctl_may_use_mm_map(void)
+{
+ static int prctl_may_use_mm_map = -1;
+
+ if (prctl_may_use_mm_map == -1) {
+ unsigned int size = 0;
+
+ if (!prctl(PR_SET_MM, PR_SET_MM_MAP_SIZE, (unsigned long)&size, 0, 0))
+ prctl_may_use_mm_map = (size <= sizeof(struct prctl_mm_map)) ? 1 : 0;
+ else
+ prctl_may_use_mm_map = 0;
+ }
+
+ return prctl_may_use_mm_map;
+}
+
int kerndat_init(void)
{
int ret;
--
1.9.3
More information about the CRIU
mailing list