From: Enrico Scholz Date: Sun, 3 Jul 2005 13:18:34 +0000 (+0000) Subject: check whether filesystem is mounted readonly; if so, execute X-Git-Tag: version_0_30_210~162 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98fd27aafc3e20c42c3eed3d061edd3c0dc92c1e;p=util-vserver.git check whether filesystem is mounted readonly; if so, execute $_SECURE_MOUNT with the '-n' argument git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2119 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/scripts/vserver.functions b/util-vserver/scripts/vserver.functions index 5d1372d..a2a56a7 100644 --- a/util-vserver/scripts/vserver.functions +++ b/util-vserver/scripts/vserver.functions @@ -670,11 +670,17 @@ function generateOptions function _mountVserverInternal { local fstab="$1" + local xflag= + test -e "$fstab" || return 0 shift pushd "$vdir" >/dev/null - "$@" $_SECURE_MOUNT -a --chroot --fstab "$fstab" --rootfs no + # check whether / is mounted readonly or whether there is special + # magic regarding the mtab file; when etc/mtab can not be touched, + # add the '-n' flag to mount + test -w etc -o -w etc/mtab || xflag=-n + "$@" $_SECURE_MOUNT -a $xflag --chroot --fstab "$fstab" --rootfs no popd >/dev/null } @@ -683,10 +689,15 @@ function mountRootFS local cfgdir=$1 local vdir=$1/vdir local fstab="$cfgdir"/fstab + local xflag= test -e "$fstab" || return 0 pushd "$vdir" >/dev/null - $_SECURE_MOUNT -a --chroot --fstab "$fstab" --rootfs only -n + # check whether / is mounted readonly or whether there is special + # magic regarding the mtab file; when etc/mtab can not be touched, + # add the '-n' flag to mount + test -w etc -o -w etc/mtab || xflag=-n + $_SECURE_MOUNT -a $xflag --chroot --fstab "$fstab" --rootfs only -n popd >/dev/null }