summaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-01-30 11:58:21 +0000
committerRoy Marples <roy@marples.name>2008-01-30 11:58:21 +0000
commitc1d18354c6a5061490f9ca892b7872d5f11e153f (patch)
treec982695a6f9e53476e1affecbe29c8c8ff985563 /sh
parente675b2e00579618c54064c4ac80e221c7531f280 (diff)
downloadopenrc-c1d18354c6a5061490f9ca892b7872d5f11e153f.tar.gz
openrc-c1d18354c6a5061490f9ca892b7872d5f11e153f.tar.bz2
openrc-c1d18354c6a5061490f9ca892b7872d5f11e153f.tar.xz
Fix unmounting shared and bind mounts, Gentoo bug #207611.
Diffstat (limited to 'sh')
-rw-r--r--sh/rc-mount.sh28
1 files changed, 15 insertions, 13 deletions
diff --git a/sh/rc-mount.sh b/sh/rc-mount.sh
index 56a8f78..81d677a 100644
--- a/sh/rc-mount.sh
+++ b/sh/rc-mount.sh
@@ -18,16 +18,12 @@ do_unmount()
shift
mountinfo "$@" | while read mnt; do
+ # Unmounting a shared mount can unmount other mounts, so
+ # we need to check the mount is still valid
+ mountinfo --quiet "${mnt}" || continue
+
case "${cmd}" in
umount*)
- # If we're using the mount (probably /usr) then don't unmount us
- local pids="$(fuser ${f_opts} "${mnt}" 2>/dev/null)"
- case " ${pids} " in
- *" $$ "*)
- ewarn "We are using ${mnt}, not unmounting"
- continue
- ;;
- esac
ebegin "Unmounting ${mnt}"
;;
*)
@@ -40,13 +36,18 @@ do_unmount()
# Don't kill if it's us (/ and possibly /usr)
local pids="$(fuser ${f_opts} "${mnt}" 2>/dev/null)"
case " ${pids} " in
- *" $$ "*) retry=0;;
- " ") eend 1 "in use but fuser finds nothing"; retry=0;;
+ *" $$ "*)
+ eend 1 "failed because we are using" \
+ "${mnt}"
+ retry=0;;
+ " ")
+ eend 1 "in use but fuser finds nothing"
+ retry=0;;
*)
local sig="KILL"
[ ${retry} -gt 0 ] && sig="TERM"
- fuser ${f_kill}${sig} -k ${f_opts} "${mnt}" \
- >/dev/null 2>&1
+ fuser ${f_kill}${sig} -k ${f_opts} \
+ "${mnt}" >/dev/null 2>&1
sleep 1
retry=$((${retry} - 1))
;;
@@ -56,7 +57,8 @@ do_unmount()
if [ ${retry} -le 0 ]; then
case "${cmd}" in
umount*)
- LC_ALL=C ${cmd} -f "${mnt}" || retry=-999
+ LC_ALL=C ${cmd} -f "${mnt}" \
+ || retry=-999
;;
*)
retry=-999