From c1d18354c6a5061490f9ca892b7872d5f11e153f Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Wed, 30 Jan 2008 11:58:21 +0000 Subject: Fix unmounting shared and bind mounts, Gentoo bug #207611. --- sh/rc-mount.sh | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'sh') diff --git a/sh/rc-mount.sh b/sh/rc-mount.sh index 56a8f789..81d677ad 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 -- cgit v1.2.3