From: Christian Brauner Date: Wed, 3 Oct 2018 11:03:30 +0000 (+0200) Subject: syscall_wrappers: move unshare() X-Git-Tag: lxc-3.1.0~65^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8f764b6bc74eefa31fe7e029cc7ce09f1f09471;p=thirdparty%2Flxc.git syscall_wrappers: move unshare() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am index 208a485e1..5a0ae9dd4 100644 --- a/src/lxc/Makefile.am +++ b/src/lxc/Makefile.am @@ -369,6 +369,7 @@ lxc_usernsexec_SOURCES = cmd/lxc_usernsexec.c \ macro.h \ file_utils.c file_utils.h \ string_utils.c string_utils.h \ + syscall_wrappers.h \ utils.c utils.h endif diff --git a/src/lxc/cmd/lxc_usernsexec.c b/src/lxc/cmd/lxc_usernsexec.c index 7475e7506..10557dd51 100644 --- a/src/lxc/cmd/lxc_usernsexec.c +++ b/src/lxc/cmd/lxc_usernsexec.c @@ -49,6 +49,7 @@ #include "macro.h" #include "file_utils.h" #include "string_utils.h" +#include "syscall_wrappers.h" #include "utils.h" extern int lxc_log_fd; diff --git a/src/lxc/criu.c b/src/lxc/criu.c index 66470a016..dcf6d5cf6 100644 --- a/src/lxc/criu.c +++ b/src/lxc/criu.c @@ -45,6 +45,7 @@ #include "lxclock.h" #include "network.h" #include "storage.h" +#include "syscall_wrappers.h" #include "utils.h" #if IS_BIONIC diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index b4cb4c0ad..bfd3c85a1 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -73,6 +73,7 @@ #include "storage/overlay.h" #include "storage_utils.h" #include "sync.h" +#include "syscall_wrappers.h" #include "terminal.h" #include "utils.h" #include "version.h" diff --git a/src/lxc/storage/rsync.c b/src/lxc/storage/rsync.c index e3ade30a0..fa4e59cc3 100644 --- a/src/lxc/storage/rsync.c +++ b/src/lxc/storage/rsync.c @@ -38,6 +38,7 @@ #include "log.h" #include "rsync.h" #include "storage.h" +#include "syscall_wrappers.h" #include "utils.h" lxc_log_define(rsync, lxc); diff --git a/src/lxc/storage/storage_utils.c b/src/lxc/storage/storage_utils.c index 36a62a11e..9efc939b1 100644 --- a/src/lxc/storage/storage_utils.c +++ b/src/lxc/storage/storage_utils.c @@ -48,6 +48,7 @@ #include "parse.h" #include "storage.h" #include "storage_utils.h" +#include "syscall_wrappers.h" #include "utils.h" #ifndef HAVE_STRLCPY diff --git a/src/lxc/syscall_wrappers.h b/src/lxc/syscall_wrappers.h index c2cebe6a8..8661ceb4f 100644 --- a/src/lxc/syscall_wrappers.h +++ b/src/lxc/syscall_wrappers.h @@ -155,4 +155,19 @@ static inline int setns(int fd, int nstype) } #endif +/* Define unshare() if missing from the C library */ +#ifndef HAVE_UNSHARE +static inline int unshare(int flags) +{ +#ifdef __NR_unshare + return syscall(__NR_unshare, flags); +#else + errno = ENOSYS; + return -1; +#endif +} +#else +extern int unshare(int); +#endif + #endif /* __LXC_SYSCALL_WRAPPER_H */ diff --git a/src/lxc/utils.h b/src/lxc/utils.h index ee3875e58..5f16eaedb 100644 --- a/src/lxc/utils.h +++ b/src/lxc/utils.h @@ -56,21 +56,6 @@ extern char *get_rundir(void); #endif #endif -/* Define unshare() if missing from the C library */ -#ifndef HAVE_UNSHARE -static inline int unshare(int flags) -{ -#ifdef __NR_unshare - return syscall(__NR_unshare, flags); -#else - errno = ENOSYS; - return -1; -#endif -} -#else -extern int unshare(int); -#endif - /* Define signalfd() if missing from the C library */ #ifdef HAVE_SYS_SIGNALFD_H # include