mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-25 07:41:19 +00:00
consolidate missing C library functions into utils.h
This fixes the build of lxccontainer.c on systems that have __NR_setns but not HAVE_SETNS. Signed-off-by: Dwight Engen <dwight.engen@oracle.com> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
ad5f151515
commit
6a44839f59
@ -46,42 +46,10 @@
|
||||
#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));
|
||||
|
@ -44,23 +44,10 @@
|
||||
#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
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "version.h"
|
||||
#include "log.h"
|
||||
#include "bdev.h"
|
||||
#include "utils.h"
|
||||
#include <lxc/utils.h>
|
||||
#include <lxc/monitor.h>
|
||||
#include <sched.h>
|
||||
@ -44,22 +45,6 @@
|
||||
|
||||
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
|
||||
|
@ -30,15 +30,9 @@
|
||||
|
||||
#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.
|
||||
|
@ -23,7 +23,9 @@
|
||||
#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);
|
||||
@ -36,6 +38,41 @@ extern const char *default_lxc_path(void);
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user