diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am index 1fdd91cfc..85b56cee2 100644 --- a/src/lxc/Makefile.am +++ b/src/lxc/Makefile.am @@ -342,13 +342,16 @@ if ENABLE_COMMANDS # Binaries shipping with liblxc init_lxc_SOURCES = cmd/lxc_init.c \ initutils.c initutils.h \ + raw_syscalls.c raw_syscalls.h \ string_utils.c string_utils.h -lxc_monitord_SOURCES = cmd/lxc_monitord.c +lxc_monitord_SOURCES = cmd/lxc_monitord.c \ + raw_syscalls.c raw_syscalls.h lxc_user_nic_SOURCES = cmd/lxc_user_nic.c \ ../include/netns_ifaddrs.c ../include/netns_ifaddrs.h \ log.c log.h \ namespace.c namespace.h \ network.c network.h \ + raw_syscalls.c raw_syscalls.h \ parse.c parse.h lxc_usernsexec_SOURCES = cmd/lxc_usernsexec.c \ conf.c conf.h \ diff --git a/src/lxc/af_unix.c b/src/lxc/af_unix.c index 648c7d2a8..02f32c454 100644 --- a/src/lxc/af_unix.c +++ b/src/lxc/af_unix.c @@ -37,6 +37,7 @@ #include "config.h" #include "log.h" +#include "raw_syscalls.h" #include "utils.h" #ifndef HAVE_STRLCPY diff --git a/src/lxc/cmd/lxc_init.c b/src/lxc/cmd/lxc_init.c index b6c7ca3d5..c643419ea 100644 --- a/src/lxc/cmd/lxc_init.c +++ b/src/lxc/cmd/lxc_init.c @@ -46,8 +46,8 @@ #include "error.h" #include "initutils.h" #include "log.h" -#include "namespace.h" #include "parse.h" +#include "raw_syscalls.h" #include "string_utils.h" /* option keys for long only options */ diff --git a/src/lxc/cmd/lxc_monitord.c b/src/lxc/cmd/lxc_monitord.c index 466bc6f20..13158d7b2 100644 --- a/src/lxc/cmd/lxc_monitord.c +++ b/src/lxc/cmd/lxc_monitord.c @@ -49,6 +49,7 @@ #include "log.h" #include "mainloop.h" #include "monitor.h" +#include "raw_syscalls.h" #include "utils.h" #define CLIENTFDS_CHUNK 64 diff --git a/src/lxc/lsm/apparmor.c b/src/lxc/lsm/apparmor.c index 8c833ce75..cc5391ab0 100644 --- a/src/lxc/lsm/apparmor.c +++ b/src/lxc/lsm/apparmor.c @@ -37,6 +37,7 @@ #include "log.h" #include "lsm.h" #include "parse.h" +#include "raw_syscalls.h" #include "utils.h" lxc_log_define(apparmor, lsm); diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 0d9276492..b4cb4c0ad 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -65,6 +65,7 @@ #include "namespace.h" #include "network.h" #include "parse.h" +#include "raw_syscalls.h" #include "start.h" #include "state.h" #include "storage.h" diff --git a/src/lxc/namespace.h b/src/lxc/namespace.h index be2bf8b71..ab583da76 100644 --- a/src/lxc/namespace.h +++ b/src/lxc/namespace.h @@ -140,13 +140,4 @@ extern int lxc_namespace_2_ns_idx(const char *namespace); extern int lxc_namespace_2_std_identifiers(char *namespaces); extern int lxc_fill_namespace_flags(char *flaglist, int *flags); -/** - * Because of older glibc's pid cache (up to 2.25) whenever clone() is called - * the child must must retrieve it's own pid via lxc_raw_getpid(). - */ -static inline pid_t lxc_raw_getpid(void) -{ - return (pid_t) syscall(SYS_getpid); -} - #endif diff --git a/src/lxc/network.c b/src/lxc/network.c index 20ab21ae6..3ed35afd4 100644 --- a/src/lxc/network.c +++ b/src/lxc/network.c @@ -56,6 +56,7 @@ #include "macro.h" #include "network.h" #include "nl.h" +#include "raw_syscalls.h" #include "utils.h" #ifndef HAVE_STRLCPY diff --git a/src/lxc/raw_syscalls.h b/src/lxc/raw_syscalls.h index 9ce0b7145..513089649 100644 --- a/src/lxc/raw_syscalls.h +++ b/src/lxc/raw_syscalls.h @@ -27,6 +27,7 @@ #include #include #include +#include /* * lxc_raw_clone() - create a new process @@ -73,4 +74,13 @@ extern pid_t lxc_raw_clone_cb(int (*fn)(void *), void *args, unsigned long flags extern int lxc_raw_execveat(int dirfd, const char *pathname, char *const argv[], char *const envp[], int flags); +/* + * Because of older glibc's pid cache (up to 2.25) whenever clone() is called + * the child must must retrieve it's own pid via lxc_raw_getpid(). + */ +static inline pid_t lxc_raw_getpid(void) +{ + return (pid_t)syscall(SYS_getpid); +} + #endif /* __LXC_RAW_SYSCALL_H */ diff --git a/src/lxc/utils.h b/src/lxc/utils.h index 6d10dbf5f..6e53f71a1 100644 --- a/src/lxc/utils.h +++ b/src/lxc/utils.h @@ -40,6 +40,7 @@ #include "file_utils.h" #include "initutils.h" #include "macro.h" +#include "raw_syscalls.h" #include "string_utils.h" #ifdef HAVE_LINUX_MEMFD_H