]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
generate setns syscall number
authorClement Calmels <clement.calmels@fr.ibm.com>
Thu, 20 Jan 2011 09:59:33 +0000 (10:59 +0100)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Tue, 1 Feb 2011 11:54:17 +0000 (12:54 +0100)
Signed-off-by: Clement Calmels <clement.calmels@fr.ibm.com>
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
config/linux.m4 [new file with mode: 0644]
configure.ac
src/lxc/Makefile.am
src/lxc/namespace.c

diff --git a/config/linux.m4 b/config/linux.m4
new file mode 100644 (file)
index 0000000..338f393
--- /dev/null
@@ -0,0 +1,73 @@
+AC_DEFUN([AC_LINUX],
+[
+       AC_LINUX_DIR()
+       AC_LINUX_SRCARCH()
+])
+
+AC_DEFUN([AS_TRY_LINUX_DIR],
+       [AC_MSG_CHECKING(for Linux in $1)
+
+       if test -f "$1/Makefile" ; then
+               result=yes
+               $2
+       else
+               result="not found"
+               $3
+       fi
+
+       AC_MSG_RESULT($result)
+])
+
+AC_DEFUN([AC_LINUX_DIR],
+[
+       AC_ARG_WITH([linuxdir],
+               [AC_HELP_STRING([--with-linuxdir=DIR],
+                       [specify path to Linux source directory])],
+               [LINUX_DIR="${withval}"],
+               [LINUX_DIR=default])
+
+       dnl if specified, use the specified one
+       if test "${LINUX_DIR}" != "default" ; then
+               AS_TRY_LINUX_DIR([${LINUX_DIR}], , AC_MSG_ERROR([Linux dir not found]) )
+       fi
+
+       dnl if not specified, first try with previously set LINUX_KERNEL_RELEASE
+       if test "${LINUX_DIR}" = "default" ; then
+               dir="/lib/modules/$LINUX_KERNEL_RELEASE/build";
+               AS_TRY_LINUX_DIR([${dir}], [LINUX_DIR=${dir}], )
+       fi
+
+       dnl next try using the kernel source dir
+       if test "${LINUX_DIR}" = "default" ; then
+               dir="/usr/src/linux-$LINUX_KERNEL_RELEASE";
+               AS_TRY_LINUX_DIR([${dir}], [LINUX_DIR=${dir}], )
+       fi
+
+       dnl then try a common default of /usr/src/linux
+       if test "${LINUX_DIR}" = "default" ; then
+               dir="/usr/src/linux";
+               AS_TRY_LINUX_DIR([${dir}], [LINUX_DIR=${dir}], )
+       fi
+
+       dnl if still nothing found, fail
+       if test "${LINUX_DIR}" = "default" ; then
+               AC_MSG_WARN([Linux source directory not found])
+       fi
+
+       AC_SUBST(LINUX_DIR)
+])
+
+AC_DEFUN([AC_LINUX_SRCARCH],[
+       AC_MSG_CHECKING(for linux SRCARCH)
+
+       case "${host}" in
+       i[[3456]]86-*) LINUX_SRCARCH=x86;;
+       x86_64-*) LINUX_SRCARCH=x86;;
+       powerpc*-*) LINUX_SRCARCH=powerpc;;
+       s390*-*) LINUX_SRCARCH=s390;;
+       *) AC_MSG_ERROR([architecture ${host} not supported]);;
+       esac
+
+       AC_MSG_RESULT(${LINUX_SRCARCH})
+       AC_SUBST(LINUX_SRCARCH)
+])
index 74565f43310c370e20eaf2352f134e708f3daa7d..da83fa14f9c73e5cbf056350670acd55bc98d6f5 100644 (file)
@@ -91,6 +91,8 @@ AC_CHECK_HEADERS([sys/signalfd.h])
 
 AC_PROG_GCC_TRADITIONAL
 
+AC_LINUX
+
 if test "x$GCC" = "xyes"; then
   CFLAGS="$CFLAGS -Wall"
 fi
index d2ee4d90a2c35c2a6043f6c05ae9e1a4e732e78b..df3d4ddc159811ee1a2a95b32e8e1f8ce240e595 100644 (file)
@@ -11,7 +11,8 @@ pkginclude_HEADERS = \
                conf.h \
                list.h \
                log.h \
-               state.h
+               state.h \
+               setns.h
 
 sodir=$(libdir)
 # use PROGRAMS to avoid complains from automake
@@ -120,3 +121,14 @@ install-exec-local: install-soPROGRAMS
 
 uninstall-local:
        $(RM) $(DESTDIR)$(libdir)/liblxc.so*
+
+namespace.c: setns.h
+
+setns.h:
+       -$(CC) $(CPPFLAGS) -M -MT$@ $(LINUX_DIR)/arch/$(LINUX_SRCARCH)/include/asm/unistd.h >setns.P
+       -$(CPP) $(CPPFLAGS) -dM $(LINUX_DIR)/arch/$(LINUX_SRCARCH)/include/asm/unistd.h |grep setns > $@
+
+clean-local:
+       $(RM) setns.h setns.P
+
+-include setns.P
index 3a6db795b96a02b4008410729393f5df6a965b6d..27b53b0bf5e2b97c25566ab4ec47207476ef4da7 100644 (file)
 #include "namespace.h"
 #include "log.h"
 
-#ifndef __NR_setns
-#  if __i386__
-#    define __NR_setns 338
-#  elif __x86_64__
-#    define __NR_setns 300
-#  elif __powerpc__
-#    define __NR_setns 323
-#  elif __s390__
-#    define __NR_setns 332
-#  else
-#    warning "architecture not supported for setns"
-#  endif
-#endif
+#include "setns.h"
 
 lxc_log_define(lxc_namespace, lxc);