From 3b794314149e40afaf3c456285e1e529747b6560 Mon Sep 17 00:00:00 2001 From: Holger Schurig Date: Thu, 20 Feb 2014 14:39:13 +0100 Subject: [PATCH] build-sys: Add setns() functions if not in the C library. Debian Stable is still using glibc 2.13, which doesn't provide the setns(). So we detect this and provide a tiny wrapper that issues the setns syscall towards the kernel. --- configure.ac | 5 +++-- src/shared/missing.h | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 05ee098d2..18df6d86e 100644 --- a/configure.ac +++ b/configure.ac @@ -241,10 +241,11 @@ LIBS="$save_LIBS" AC_CHECK_FUNCS([fanotify_init fanotify_mark]) AC_CHECK_FUNCS([__secure_getenv secure_getenv]) -AC_CHECK_DECLS([gettid, pivot_root, name_to_handle_at], [], [], [[#include +AC_CHECK_DECLS([gettid, pivot_root, name_to_handle_at, setns], [], [], [[#include #include #include -#include ]]) +#include +#include ]]) # This makes sure pkg.m4 is available. m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-config]) diff --git a/src/shared/missing.h b/src/shared/missing.h index 2661285a2..3142306e3 100644 --- a/src/shared/missing.h +++ b/src/shared/missing.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -353,3 +354,19 @@ static inline int name_to_handle_at(int fd, const char *name, struct file_handle #endif #endif + +#ifndef __NR_setns +# if defined(__x86_64__) +# define __NR_setns 308 +# elif defined(__i386__) +# define __NR_setns 346 +# else +# error "__NR_setns is not defined" +# endif +#endif + +#if !HAVE_DECL_SETNS +static inline int setns(int fd, int nstype) { + return syscall(__NR_setns, fd, nstype); +} +#endif -- 2.30.2