]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
raw_syscalls: add lxc_raw_getpid()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sun, 30 Sep 2018 18:05:17 +0000 (20:05 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 30 Sep 2018 18:20:16 +0000 (20:20 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/Makefile.am
src/lxc/af_unix.c
src/lxc/cmd/lxc_init.c
src/lxc/cmd/lxc_monitord.c
src/lxc/lsm/apparmor.c
src/lxc/lxccontainer.c
src/lxc/namespace.h
src/lxc/network.c
src/lxc/raw_syscalls.h
src/lxc/utils.h

index 1fdd91cfcf0f25febab0c408631248a075c823ce..85b56cee24b3dbf3e8f23f5536455e1c2b43142f 100644 (file)
@@ -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 \
index 648c7d2a8d87f3ecd45f06d65984fb05cbcd44e3..02f32c4542bcb62ae0f3e0f0e6e206cedc7ae037 100644 (file)
@@ -37,6 +37,7 @@
 
 #include "config.h"
 #include "log.h"
+#include "raw_syscalls.h"
 #include "utils.h"
 
 #ifndef HAVE_STRLCPY
index b6c7ca3d568da9861ab53fb53f44b9131fe9488f..c643419ea0fc53fc0cd55f801f1f2c0adb4448ec 100644 (file)
@@ -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 */
index 466bc6f20686fb749616e103af7d0a73cd565645..13158d7b2c07c649e00c9baa692684ca69c56955 100644 (file)
@@ -49,6 +49,7 @@
 #include "log.h"
 #include "mainloop.h"
 #include "monitor.h"
+#include "raw_syscalls.h"
 #include "utils.h"
 
 #define CLIENTFDS_CHUNK 64
index 8c833ce75408ef7593fb9c55ac6c4d25040dab40..cc5391ab017f917f7869453f22234397eb850a5a 100644 (file)
@@ -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);
index 0d9276492086c944a8c9adc64557a353d66192ba..b4cb4c0ad13348bfa317c504d3a0d0db6502385e 100644 (file)
@@ -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"
index be2bf8b7133281abd58cb6dd486152ec96b11c2a..ab583da76aa554c868c128e95e413ef7cd0d15ca 100644 (file)
@@ -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
index 20ab21ae644037f6b4d5a895800acaea60e6e55a..3ed35afd4d352e64aae0a7bb5033bbd2448fe2d0 100644 (file)
@@ -56,6 +56,7 @@
 #include "macro.h"
 #include "network.h"
 #include "nl.h"
+#include "raw_syscalls.h"
 #include "utils.h"
 
 #ifndef HAVE_STRLCPY
index 9ce0b71452d427e6bca8f285006f4d95ce230259..513089649a03eb2620ffb787f42f446111b11dbe 100644 (file)
@@ -27,6 +27,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/syscall.h>
+#include <unistd.h>
 
 /*
  * 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 */
index 6d10dbf5facbed2d2e5bf6c09517516138daf95b..6e53f71a1e37a6de97b6bb473899129124113206 100644 (file)
@@ -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