From b30f4928376b71bd44021a951115e848e925d198 Mon Sep 17 00:00:00 2001 From: Enrico Scholz Date: Wed, 10 Mar 2004 05:33:39 +0000 Subject: [PATCH] added support for 'fstab.local' files git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@1204 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- util-vserver/scripts/vserver.functions | 64 +++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/util-vserver/scripts/vserver.functions b/util-vserver/scripts/vserver.functions index d666cbc..83215c9 100644 --- a/util-vserver/scripts/vserver.functions +++ b/util-vserver/scripts/vserver.functions @@ -494,6 +494,15 @@ function generateOptions _generateChcontextOptions "$1" } +function _mountVserverInternal +{ + local fstab="$1" + test -e "$fstab" || return 0 + shift + + "$@" $_SECURE_MOUNT -a --chroot "$vdir" --fstab "$fstab" +} + function mountVserver { local cfgdir=$1 @@ -501,7 +510,8 @@ function mountVserver local vdir=$1/vdir local mtab_src - test -e "$cfgdir"/fstab || return 0 + test -e "$cfgdir"/fstab -o \ + -e "$cfgdir"/fstab.local || return 0 findObject -r mtab_src "$vdir"/apps/init/mtab "$CONFDIR"/.defaults/init/mtab "$PKGLIBDEFAULTDIR"/mtab /dev/null @@ -513,36 +523,50 @@ function mountVserver test -z "$NAMESPACE_CLEANUP" || isAvoidNamespace "$cfgdir" || \ $_VNAMESPACE --cleanup - - $_CHBIND "${CHBIND_OPTS[@]}" \ - $_SECURE_MOUNT -a --chroot "$vdir" --fstab "$cfgdir"/fstab + + _mountVserverInternal "$cfgdir"/fstab $_CHBIND "${CHBIND_OPTS[@]}" + _mountVserverInternal "$cfgdir"/fstab.local isAvoidNamespace "$cfgdir" || \ $_SECURE_MOUNT --rbind -n "$vdir" "/" } +function _umountVserverInternal +{ + local fstab="$1" + test -e "$fstab" || return 0 + shift + + tac "$fstab" | { + is_ok=1 + while read src dst tmp; do + test "$tmp" || continue + case x"$src" in + (x\#*) continue;; + esac + + + "$@" $_EXEC_CD "$dst" $_UMOUNT -lfn . || is_ok= + done + test "$is_ok" + } +} + function umountVserver { local cfgdir=$1 local vdir=$1/vdir + local is_ok=1 - is_ok=1 - - isAvoidNamespace "$cfgdir" || return 0 - test -e "$cfgdir"/fstab || return 0 - test "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$cfgdir" + isAvoidNamespace "$cfgdir" || return 0 + test -e "$cfgdir"/fstab -o \ + -e "$cfgdir"/fstab.local || return 0 + test "$_HAVE_CHBIND_OPTIONS" || _generateChbindOptions "$cfgdir" - pushd "$vdir/" >/dev/null - tac "$cfgdir"/fstab | while read src dst tmp; do - test "$tmp" || continue - case x"$src" in - (x\#*) continue;; - esac - - $_CHBIND "${CHBIND_OPTS[@]}" $_EXEC_CD "$dst" \ - $_UMOUNT -lfn . || is_ok= - done - popd >/dev/null + pushd "$vdir/" >/dev/null || return 1 + _umountVserverInternal "$cfgdir"/fstab.local || is_ok= + _umountVserverInternal "$cfgdir"/fstab $_CHBIND "${CHBIND_OPTS[@]}" || is_ok= + popd >/dev/null || return 1 test "$is_ok" } -- 1.8.1.5