From: Enrico Scholz Date: Tue, 10 Feb 2004 14:22:41 +0000 (+0000) Subject: implemented CLONE_NS and --rbind mounting X-Git-Tag: VERSION_0_10~685 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1171042cfba2870d05f6dcc771f6331fb5c9ad78;p=util-vserver.git implemented CLONE_NS and --rbind mounting git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@870 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/scripts/vserver b/util-vserver/scripts/vserver index 74709cc..a2a1278 100755 --- a/util-vserver/scripts/vserver +++ b/util-vserver/scripts/vserver @@ -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) diff --git a/util-vserver/scripts/vserver.functions b/util-vserver/scripts/vserver.functions index a9159f4..94f59e4 100644 --- a/util-vserver/scripts/vserver.functions +++ b/util-vserver/scripts/vserver.functions @@ -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 diff --git a/util-vserver/scripts/vserver.start b/util-vserver/scripts/vserver.start index 96d3a16..b66e054 100644 --- a/util-vserver/scripts/vserver.start +++ b/util-vserver/scripts/vserver.start @@ -28,7 +28,6 @@ enableInterfaces "$VSERVER_DIR" mountVserver "$VSERVER_DIR" prepareInit "$VSERVER_DIR" - cd "$VSERVER_DIR"/vdir/ execScriptlets "$VSERVER_DIR" "$VSERVER_NAME" pre-start