diff options
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | kexec/kexec.c | 11 |
2 files changed, 14 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 352eefee..602de79b 100644 --- a/configure.ac +++ b/configure.ac @@ -208,6 +208,9 @@ if test "$ac_cv_lib_xenctrl_xc_kexec_load" = yes ; then AC_MSG_NOTICE([The kexec_status call is not available])) fi +dnl Check if libc has the memfd_create() syscall wrapper +AC_CHECK_FUNCS([memfd_create]) + dnl ---Sanity checks if test "$CC" = "no"; then AC_MSG_ERROR([cc not found]); fi if test "$CPP" = "no"; then AC_MSG_ERROR([cpp not found]); fi diff --git a/kexec/kexec.c b/kexec/kexec.c index fdb4c984..08edfca2 100644 --- a/kexec/kexec.c +++ b/kexec/kexec.c @@ -31,6 +31,10 @@ #include <sys/mount.h> #include <sys/types.h> #include <sys/stat.h> +#ifndef HAVE_MEMFD_CREATE +#include <linux/memfd.h> +#include <sys/syscall.h> +#endif #include <sys/reboot.h> #include <sys/mman.h> #include <unistd.h> @@ -640,6 +644,13 @@ char *slurp_decompress_file(const char *filename, off_t *r_size) return kernel_buf; } +#ifndef HAVE_MEMFD_CREATE +static int memfd_create(const char *name, unsigned int flags) +{ + return syscall(SYS_memfd_create, name, flags); +} +#endif + static int copybuf_memfd(const char *kernel_buf, size_t size) { int fd, count; |