Comment 9 for bug 151579

Revision history for this message
Agostino Russo (ago) wrote :

In fact only the -f flag is problematic. See new patch which is a bit less invasive

--- /etc/init.d/umountfs 2007-10-04 12:25:08.000000000 +0100
+++ umountfs 2008-01-26 07:20:48.000000000 +0000
@@ -60,18 +60,20 @@

 do_stop () {
  exec 9<&0 </proc/mounts
-
+ PROTECTED_MOUNTS="$(sed -n '0,/^\/[^ ]* \/ /p' /proc/mounts)"
+ WEAK_MTPTS="" #be gentle, don't use force
  REG_MTPTS=""
  TMPFS_MTPTS=""
  while read DEV MTPT FSTYPE REST
  do
+ echo "$PROTECTED_MOUNTS" | grep -qs "^$DEV $MTPT " && continue
   case "$MTPT" in
     /|/proc|/dev|/.dev|/dev/pts|/dev/shm|/proc/*|/sys|/var/run|/var/lock)
    continue
    ;;
   esac
   case "$FSTYPE" in
- proc|procfs|linprocfs|devfs|sysfs|usbfs|usbdevfs|devpts)
+ proc|procfs|linprocfs|devfs|sysfs|usbfs|usbdevfs|devpts|securityfs)
    continue
    ;;
     tmpfs)
@@ -81,6 +83,9 @@
    ;;
     *)
    REG_MTPTS="$REG_MTPTS $MTPT"
+ if echo "$PROTECTED_MOUNTS" | grep -qs "^$DEV "; then
+ WEAK_MTPTS="$WEAK_MTPTS $MTPT "
+ fi
    ;;
   esac
  done
@@ -138,22 +143,29 @@
  if [ "$REG_MTPTS" ]
  then
   REG_MTPTS="$(pioodl $REG_MTPTS)"
- if [ "$VERBOSE" = no ]
- then
- log_action_begin_msg "Unmounting local filesystems"
- umount -f -r -d $REG_MTPTS
- log_action_end_msg $?
- else
- log_action_msg "Will now unmount local filesystems"
- umount -f -v -r -d $REG_MTPTS
- ES=$?
- if [ "$ES" = 0 ]
+ for MTPT in $REG_MTPTS; do
+ if echo "$WEAK_MTPTS" | grep -qs " $MTPT "; then
+ FORCE=""
+ else
+ FORCE="-f"
+ fi
+ if [ "$VERBOSE" = no ]
    then
- log_success_msg "Done unmounting local filesystems."
+ log_action_begin_msg "Unmounting local filesystem $MTPT"
+ umount $FORCE -r -d $MTPT
+ log_action_end_msg $?
    else
- log_failure_msg "Unmounting local filesystems failed with error code ${ES}."
+ log_action_msg "Will now unmount local filesystem $MTPT"
+ umount $FORCE -v -r -d $MTPT
+ ES=$?
+ if [ "$ES" = 0 ]
+ then
+ log_success_msg "Done unmounting local filesystem $MTPT."
+ else
+ log_failure_msg "Unmounting local filesystem $MTPT failed with error code ${ES}."
+ fi
    fi
- fi
+ done
  fi
 }