implemented CLONE_NS and --rbind mounting
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Tue, 10 Feb 2004 14:22:41 +0000 (14:22 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Tue, 10 Feb 2004 14:22:41 +0000 (14:22 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@870 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/scripts/vserver
util-vserver/scripts/vserver.functions
util-vserver/scripts/vserver.start

index 74709cc..a2a1278 100755 (executable)
@@ -112,25 +112,29 @@ function restart()
 
 set +e
 
-tmp=$(getopt -o +sv --long help,debug,version,sync,verbose,silent -n "$0" -- "$@") || exit 1
+OPTIONS_ORIG=( "$@" )
+tmp=$(getopt -o +sv --long nonamespace,--nonamespace,help,debug,version,sync,verbose,silent -n "$0" -- "$@") || exit 1
 eval set -- "$tmp"
 
 OPTION_FORCE_SYNC=
 OPTION_VERBOSE=
 OPTION_SILENT=
 OPTION_DEBUG=
+OPTION_NONAMESPACE=
 
 while true; do
     case "$1" in
        --help)         showHelp $0 ;;
        --version)      showVersion ;;
-       --debug)        OPTION_DEBUG=$1; set -x; shift;;
-       -v|--verbose)   OPTION_VERBOSE=$1;    shift;;
-       -s|--sync)      OPTION_FORCE_SYNC=$1; shift;;
-       --silent)       OPTION_SILENT=$1;     shift;;
+       --debug)        OPTION_DEBUG=$1; set -x;;
+       -v|--verbose)   OPTION_VERBOSE=$1;;
+       -s|--sync)      OPTION_FORCE_SYNC=$1;;
+       --silent)       OPTION_SILENT=$1;;
+       ----nonamespace)OPTION_NONAMESPACE=$1;;
        --)             shift; break;;
        *)              echo $"vserver: internal error; arg=='$1'"; exit 1;;
     esac
+    shift
 done
 
 OPTION_ALL=( $OPTION_SILENT $OPTION_VERBOSE $OPTION_DEBUG )
@@ -174,6 +178,9 @@ else
     VSERVER_NAME=$(basename "$VSERVER_DIR")
 fi
 
+test "$2" != start -o -e "$VSERVER_DIR"/nonamespace -o "$OPTION_NONAMESPACE" || \
+    exec $_NEW_NAMESPACE "$0" ----nonamespace "${OPTIONS_ORIG[@]}"
+
 . $PKGLIBDIR/vserver.functions
 case "$2" in
     start|stop)
index a9159f4..94f59e4 100644 (file)
@@ -439,6 +439,7 @@ function generateOptions
 function mountVserver
 {
     local cfgdir=$1
+    local ns_opt=$2
     local vdir=$1/vdir
     local mtab_src
 
@@ -453,6 +454,9 @@ function mountVserver
     test "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$cfgdir"
     $_CHBIND "${CHBIND_OPTS[@]}" \
        $_SECURE_MOUNT -a --chroot "$vdir" --fstab "$cfgdir"/fstab
+
+    test -e "$cfgdir"/nonamespace || \
+       $_SECURE_MOUNT --rbind -n "$vdir" "/"
 }
 
 function umountVserver
@@ -462,8 +466,9 @@ function umountVserver
 
     is_ok=1
 
-    test -e "$cfgdir"/fstab || return 0
-    test "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$cfgdir"
+    test -e "$cfgdir"/nonamespace || return 0
+    test -e "$cfgdir"/fstab       || return 0
+    test "$_HAVE_CHBIND_OPTIONS"  || _generateChbindOptions "$cfgdir"
     
     pushd "$vdir/" >/dev/null
     tac "$cfgdir"/fstab | while read src dst tmp; do
index 96d3a16..b66e054 100644 (file)
@@ -28,7 +28,6 @@ enableInterfaces "$VSERVER_DIR"
 mountVserver "$VSERVER_DIR"
 prepareInit  "$VSERVER_DIR"
 
-
 cd "$VSERVER_DIR"/vdir/
 execScriptlets   "$VSERVER_DIR" "$VSERVER_NAME" pre-start