Quoting Dwight Engen (dwight.en...@oracle.com): > This fixes the build of lxccontainer.c on systems that have __NR_setns > but not HAVE_SETNS. > > Signed-off-by: Dwight Engen <dwight.en...@oracle.com>
Acked-by: Serge E. Hallyn <serge.hal...@ubuntu.com> > --- > src/lxc/attach.c | 34 +--------------------------------- > src/lxc/bdev.c | 15 +-------------- > src/lxc/lxccontainer.c | 17 +---------------- > src/lxc/parse.c | 8 +------- > src/lxc/utils.h | 37 +++++++++++++++++++++++++++++++++++++ > 5 files changed, 41 insertions(+), 70 deletions(-) > > diff --git a/src/lxc/attach.c b/src/lxc/attach.c > index a33d24f..5061b93 100644 > --- a/src/lxc/attach.c > +++ b/src/lxc/attach.c > @@ -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)); > diff --git a/src/lxc/bdev.c b/src/lxc/bdev.c > index fcde16b..a0ce5f5 100644 > --- a/src/lxc/bdev.c > +++ b/src/lxc/bdev.c > @@ -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 > diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c > index b2e5e36..1c0b7b2 100644 > --- a/src/lxc/lxccontainer.c > +++ b/src/lxc/lxccontainer.c > @@ -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 > diff --git a/src/lxc/parse.c b/src/lxc/parse.c > index 4504ec2..6c2ed5a 100644 > --- a/src/lxc/parse.c > +++ b/src/lxc/parse.c > @@ -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. > diff --git a/src/lxc/utils.h b/src/lxc/utils.h > index d1242b1..fbfe5d3 100644 > --- a/src/lxc/utils.h > +++ b/src/lxc/utils.h > @@ -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. > -- > 1.7.1 > > > ------------------------------------------------------------------------------ > Try New Relic Now & We'll Send You this Cool Shirt > New Relic is the only SaaS-based application performance monitoring service > that delivers powerful full stack analytics. Optimize and monitor your > browser, app, & servers with just a few lines of code. Try New Relic > and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may > _______________________________________________ > Lxc-devel mailing list > Lxc-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/lxc-devel ------------------------------------------------------------------------------ Try New Relic Now & We'll Send You this Cool Shirt New Relic is the only SaaS-based application performance monitoring service that delivers powerful full stack analytics. Optimize and monitor your browser, app, & servers with just a few lines of code. Try New Relic and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may _______________________________________________ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel