The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/2291
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === When HAVE_SETNS is unset the tool_utils.c can't be build because it can't find setns(). The inline setns() is defined in lxc/utils.h but isn't defined in lxc/tools/tool_utils.h. The patch fixes it. Another minor patch fixes headers in lxc/tools to use their own defines to disable double including ( __LXC_TOOLS_UTILS_H).
From 9051c53ee8a8b0a16d5d37853f3b977fc6ce9cd8 Mon Sep 17 00:00:00 2001 From: Serj Kalichev <[email protected]> Date: Thu, 26 Apr 2018 13:44:20 +0300 Subject: [PATCH 1/2] Headers in src/tools dir use their own defines to disable double includes --- src/lxc/tools/arguments.h | 6 +++--- src/lxc/tools/tool_list.h | 6 +++--- src/lxc/tools/tool_utils.h | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lxc/tools/arguments.h b/src/lxc/tools/arguments.h index 15941bcc3..e4cf8fc0a 100644 --- a/src/lxc/tools/arguments.h +++ b/src/lxc/tools/arguments.h @@ -22,8 +22,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef __LXC_ARGUMENTS_H -#define __LXC_ARGUMENTS_H +#ifndef __LXC_TOOLS_ARGUMENTS_H +#define __LXC_TOOLS_ARGUMENTS_H #include <getopt.h> #include <stdbool.h> @@ -177,4 +177,4 @@ extern int lxc_arguments_str_to_int(struct lxc_arguments *args, extern bool lxc_setup_shared_ns(struct lxc_arguments *args, struct lxc_container *c); -#endif /* __LXC_ARGUMENTS_H */ +#endif /* __LXC_TOOLS_ARGUMENTS_H */ diff --git a/src/lxc/tools/tool_list.h b/src/lxc/tools/tool_list.h index 9858081ab..1dd82d28e 100644 --- a/src/lxc/tools/tool_list.h +++ b/src/lxc/tools/tool_list.h @@ -21,8 +21,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef __LXC_LIST_H -#define __LXC_LIST_H +#ifndef __LXC_TOOLS_LIST_H +#define __LXC_TOOLS_LIST_H #include <stdio.h> @@ -164,4 +164,4 @@ static inline size_t lxc_list_len(struct lxc_list *list) return i; } -#endif /* __LXC_LIST_H */ +#endif /* __LXC_TOOLS_LIST_H */ diff --git a/src/lxc/tools/tool_utils.h b/src/lxc/tools/tool_utils.h index 25f2dfd61..3e8fa93a2 100644 --- a/src/lxc/tools/tool_utils.h +++ b/src/lxc/tools/tool_utils.h @@ -17,8 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef __LXC_UTILS_H -#define __LXC_UTILS_H +#ifndef __LXC_TOOLS_UTILS_H +#define __LXC_TOOLS_UTILS_H /* Properly support loop devices on 32bit systems. */ #define _FILE_OFFSET_BITS 64 @@ -201,4 +201,4 @@ int clone(int (*fn)(void *), void *child_stack, extern pid_t lxc_clone(int (*fn)(void *), void *arg, int flags); -#endif /* __LXC_UTILS_H */ +#endif /* __LXC_TOOLS_UTILS_H */ From 6c4bec671b158b9e7a5177f572266928339097aa Mon Sep 17 00:00:00 2001 From: Serj Kalichev <[email protected]> Date: Thu, 26 Apr 2018 13:50:57 +0300 Subject: [PATCH 2/2] Add inline setns() function to tool_utils.h. Without it tool_utils.c can't be build when HAVE_SETNS is unset. --- src/lxc/tools/tool_utils.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/lxc/tools/tool_utils.h b/src/lxc/tools/tool_utils.h index 3e8fa93a2..0aae00e05 100644 --- a/src/lxc/tools/tool_utils.h +++ b/src/lxc/tools/tool_utils.h @@ -109,6 +109,37 @@ extern signed long lxc_config_parse_arch(const char *arch); extern int lxc_namespace_2_cloneflag(const char *namespace); extern int lxc_fill_namespace_flags(char *flaglist, int *flags); +#if !defined(__NR_setns) && !defined(__NR_set_ns) + #if defined(__x86_64__) + #define __NR_setns 308 + #elif defined(__i386__) + #define __NR_setns 346 + #elif defined(__arm__) + #define __NR_setns 375 + #elif defined(__aarch64__) + #define __NR_setns 375 + #elif defined(__powerpc__) + #define __NR_setns 350 + #elif defined(__s390__) + #define __NR_setns 339 + #endif +#endif + +/* Define setns() if missing from the C library */ +#ifndef HAVE_SETNS +static inline int setns(int fd, int nstype) +{ +#ifdef __NR_setns + return syscall(__NR_setns, fd, nstype); +#elif defined(__NR_set_ns) + return syscall(__NR_set_ns, fd, nstype); +#else + errno = ENOSYS; + return -1; +#endif +} +#endif + #if HAVE_LIBCAP #include <sys/capability.h>
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
