From 6b3d24d716b065d4269f327f95d53ead576a47d7 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Sun, 30 Sep 2018 12:41:34 +0200 Subject: [PATCH] syscall_wrappers: add pivot_root() Signed-off-by: Christian Brauner --- src/lxc/conf.c | 16 +--------------- src/lxc/syscall_wrappers.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 8e98f7ee4..01c1e3f5d 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -74,6 +74,7 @@ #include "start.h" #include "storage.h" #include "storage/overlay.h" +#include "syscall_wrappers.h" #include "terminal.h" #include "utils.h" @@ -124,21 +125,6 @@ thread_local struct lxc_conf *current_config; struct lxc_conf *current_config; #endif -/* Define pivot_root() if missing from the C library */ -#ifndef HAVE_PIVOT_ROOT -static int pivot_root(const char *new_root, const char *put_old) -{ -#ifdef __NR_pivot_root - return syscall(__NR_pivot_root, new_root, put_old); -#else - errno = ENOSYS; - return -1; -#endif -} -#else -extern int pivot_root(const char *new_root, const char *put_old); -#endif - char *lxchook_names[NUM_LXC_HOOKS] = { "pre-start", "pre-mount", diff --git a/src/lxc/syscall_wrappers.h b/src/lxc/syscall_wrappers.h index 4692cea59..a6c7694d9 100644 --- a/src/lxc/syscall_wrappers.h +++ b/src/lxc/syscall_wrappers.h @@ -48,4 +48,18 @@ static inline long __keyctl(int cmd, unsigned long arg2, unsigned long arg3, #define keyctl __keyctl #endif +#if !HAVE_PIVOT_ROOT +static int pivot_root(const char *new_root, const char *put_old) +{ +#ifdef __NR_pivot_root + return syscall(__NR_pivot_root, new_root, put_old); +#else + errno = ENOSYS; + return -1; +#endif +} +#else +extern int pivot_root(const char *new_root, const char *put_old); +#endif + #endif /* __LXC_SYSCALL_WRAPPER_H */