From 3bd074fd404b4863d811d0a50e9ef484523c6b57 Mon Sep 17 00:00:00 2001 From: Miloslav Trmac Date: Mon, 8 May 2006 23:54:06 +0000 Subject: Fix handling of mount points with white space (#186713): - src/fstab-decode.c, src/fstab-decode.8: New files. - src/Makefile: Build and install fstab-decode. - initscripts.spec: Add fstab-decode to %files - rc.d/init.d/functions (fstab_decode_str): New function. (__umount_loop, __umount_loopback_loop): Factor out from copy&pasted copies. (action): Fix command quoting. - rc.d/rc.sysinit: Correctly quote and decode mount points. - rc.d/init.d/halt: Use __umount_* and fstab-decode. (action): Rename from runcmd. Fix command quoting. - rc.d/init.d/netfs: Use __umount_*. --- rc.d/init.d/netfs | 79 ++++++++++--------------------------------------------- 1 file changed, 14 insertions(+), 65 deletions(-) (limited to 'rc.d/init.d/netfs') diff --git a/rc.d/init.d/netfs b/rc.d/init.d/netfs index faab107e..59693d11 100755 --- a/rc.d/init.d/netfs +++ b/rc.d/init.d/netfs @@ -89,71 +89,20 @@ case "$1" in ;; stop) # Unmount loopback stuff first - remaining=`LC_ALL=C awk '$1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts` - devremaining=`LC_ALL=C awk '$1 ~ /^\/dev\/loop/ && $2 != "/" {print $1}' /proc/mounts` - [ -n "$remaining" ] && { - sig= - retry=3 - while [ -n "$remaining" -a "$retry" -gt 0 ] - do - if [ "$retry" -lt 3 ]; then - action $"Unmounting loopback filesystems (retry):" umount $remaining - else - action $"Unmounting loopback filesystems: " umount $remaining - fi - for dev in $devremaining ; do - losetup $dev >/dev/null 2>&1 && \ - action $"Detaching loopback device $dev: " losetup -d $dev - done - remaining=`LC_ALL=C awk '$1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts` - devremaining=`LC_ALL=C awk '$1 ~ /^\/dev\/loop/ && $2 != "/" {print $1}' /proc/mounts` - [ -z "$remaining" ] && break - /sbin/fuser -k -m $sig $remaining >/dev/null - sleep 5 - retry=$(($retry -1)) - sig=-9 - done - } - [ -n "$NETDEVMTAB" ] && { - sig= - retry=3 - remaining=`LC_ALL=C awk '!/^#/ && $4 ~ /_netdev/ && $2 != "/" {print $2}' /etc/mtab` - while [ -n "$remaining" -a "$retry" -gt 0 ] - do - if [ "$retry" -lt 3 ]; then - action $"Unmounting network block filesystems (retry): " umount -a -O _netdev - else - action $"Unmounting network block filesystems: " umount -a -O _netdev - fi - sleep 2 - remaining=`LC_ALL=C awk '!/^#/ && $4 ~ /_netdev/ && $2 != "/" {print $2}' /etc/mtab` - [ -z "$remaining" ] && break - /sbin/fuser -k -m $sig $remaining >/dev/null - sleep 5 - retry=$(($retry - 1)) - sig=-9 - done - } - [ -n "$NFSMTAB" ] && { - sig= - retry=3 - remaining=`LC_ALL=C awk '$3 ~ /^nfs/ && $2 != "/" {print $2}' /proc/mounts` - while [ -n "$remaining" -a "$retry" -gt 0 ] - do - if [ "$retry" -lt 3 ]; then - action $"Unmounting NFS filesystems (retry): " umount -f -l $remaining - else - action $"Unmounting NFS filesystems: " umount -f -l $remaining - fi - sleep 2 - remaining=`LC_ALL=C awk '$3 ~ /^nfs/ && $2 != "/" {print $2}' /proc/mounts` - [ -z "$remaining" ] && break - /sbin/fuser -k -m $sig $remaining >/dev/null - sleep 5 - retry=$(($retry - 1)) - sig=-9 - done - } + __umount_loopback_loop + if [ -n "$NETDEVMTAB" ]; then + __umount_loop '$4 ~ /_netdev/ && $2 != "/" {print $2}' \ + /etc/mtab \ + $"Unmounting network block filesystems: " \ + $"Unmounting network block filesystems (retry): " + fi + if [ -n "$NFSMTAB" ]; then + __umount_loop '$3 ~ /^nfs/ && $2 != "/" {print $2}' \ + /proc/mounts \ + $"Unmounting NFS filesystems: " \ + $"Unmounting NFS filesystems (retry): " \ + "-f -l" + fi [ -n "$SMBMTAB" ] && action $"Unmounting SMB filesystems: " umount -a -t smbfs [ -n "$CIFSMTAB" ] && action $"Unmounting CIFS filesystems: " umount -a -t cifs [ -n "$NCPMTAB" ] && action $"Unmounting NCP filesystems: " umount -a -t ncpfs -- cgit v1.2.1