mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-08-01 14:30:53 +00:00
syscall: add memfd_create() (v3)
v2: Follow the kerndat style that "features" are described just by global boolean variables. v3: give NULL as a name to get EFAULT if memfd_create is supported Signed-off-by: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
caa64d974d
commit
de71c48079
4 changed files with 26 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -24,4 +24,6 @@ extern u64 zero_page_pfn;
|
|||
struct stat;
|
||||
extern struct stat *kerndat_get_devpts_stat(void);
|
||||
|
||||
extern bool memfd_is_supported;
|
||||
|
||||
#endif /* __CR_KERNDAT_H__ */
|
||||
|
|
|
|||
22
kerndat.c
22
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"
|
||||
|
|
@ -220,6 +221,25 @@ int get_last_cap(void)
|
|||
return sysctl_op(req, CTL_READ);
|
||||
}
|
||||
|
||||
bool memfd_is_supported;
|
||||
static bool kerndat_has_memfd_create(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = sys_memfd_create(NULL, 0);
|
||||
|
||||
if (ret == -ENOSYS)
|
||||
memfd_is_supported = false;
|
||||
else if (ret == -EFAULT)
|
||||
memfd_is_supported = true;
|
||||
else {
|
||||
pr_err("Unexpected error %d from memfd_create(NULL, 0)\n", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kerndat_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
|
@ -231,6 +251,8 @@ int kerndat_init(void)
|
|||
ret = init_zero_page_pfn();
|
||||
if (!ret)
|
||||
ret = get_last_cap();
|
||||
if (!ret)
|
||||
ret = kerndat_has_memfd_create();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue