#include "caps.h"
#include "config.h"
#include "apparmor.h"
+#include "utils.h"
lxc_log_define(lxc_attach, lxc);
-/* Define setns() if missing from the C library */
-#ifndef HAVE_SETNS
-static int setns(int fd, int nstype)
-{
-#ifdef __NR_setns
-return syscall(__NR_setns, fd, nstype);
-#else
-errno = ENOSYS;
-return -1;
-#endif
-}
-#endif
-
-/* Define unshare() if missing from the C library */
-#ifndef HAVE_UNSHARE
-static int unshare(int flags)
-{
-#ifdef __NR_unshare
-return syscall(__NR_unshare, flags);
-#else
-errno = ENOSYS;
-return -1;
-#endif
-}
-#endif
-
-/* Define getline() if missing from the C library */
-#ifndef HAVE_GETLINE
-#ifdef HAVE_FGETLN
-#include <../include/getline.h>
-#endif
-#endif
-
struct lxc_proc_context_info *lxc_proc_get_context_info(pid_t pid)
{
struct lxc_proc_context_info *info = calloc(1, sizeof(*info));
#include "utils.h"
#include "namespace.h"
#include "parse.h"
+#include "utils.h"
lxc_log_define(bdev, lxc);
-/* Define unshare() if missing from the C library */
-/* this is also in attach.c and lxccontainer.c: commonize it in utils.c */
-#ifndef HAVE_UNSHARE
-static int unshare(int flags)
-{
-#ifdef __NR_unshare
-return syscall(__NR_unshare, flags);
-#else
-errno = ENOSYS;
-return -1;
-#endif
-}
-#endif
-
static int do_rsync(const char *src, const char *dest)
{
// call out to rsync
#include "version.h"
#include "log.h"
#include "bdev.h"
+#include "utils.h"
#include <lxc/utils.h>
#include <lxc/monitor.h>
#include <sched.h>
static pthread_mutex_t thread_mutex = PTHREAD_MUTEX_INITIALIZER;
-/* Define unshare() if missing from the C library */
-/* this is also in attach.c and lxccontainer.c: commonize it in utils.c */
-#ifndef HAVE_UNSHARE
-static int unshare(int flags)
-{
-#ifdef __NR_unshare
- return syscall(__NR_unshare, flags);
-#else
- errno = ENOSYS;
- return -1;
-#endif
-}
-#else
-int unshare(int);
-#endif
-
lxc_log_define(lxc_container, lxc);
/* LOCKING
#include "parse.h"
#include "config.h"
+#include "utils.h"
#include <lxc/log.h>
-/* Define getline() if missing from the C library */
-#ifndef HAVE_GETLINE
-#ifdef HAVE_FGETLN
-#include <../include/getline.h>
-#endif
-#endif
-
/* Workaround for the broken signature of alphasort() in bionic.
This was fixed upstream in 40e467ec668b59be25491bd44bf348a884d6a68d so the
workaround can probably be dropped with the next version of the Android NDK.
#ifndef _utils_h
#define _utils_h
+#include <errno.h>
#include <sys/types.h>
+#include "config.h"
extern int lxc_setup_fs(void);
extern int get_u16(unsigned short *val, const char *arg, int base);
extern const char *default_zfs_root(void);
extern const char *default_lvm_vg(void);
+/* Define getline() if missing from the C library */
+#ifndef HAVE_GETLINE
+#ifdef HAVE_FGETLN
+#include <../include/getline.h>
+#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);
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+}
+#endif
+
+/* Define unshare() if missing from the C library */
+#ifndef HAVE_UNSHARE
+static inline int unshare(int flags)
+{
+#ifdef __NR_unshare
+ return syscall(__NR_unshare, flags);
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+}
+#else
+int unshare(int);
+#endif
+
/**
* BUILD_BUG_ON - break compile if a condition is true.
* @condition: the condition which the compiler should know is false.