Comment 8 for bug 151579

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

Still not working. The issue is due to the use of umount -f -d. The previous patch basically skipped the mountpoints (as opposed to skipping devices). But umount -f -d also affects the underlying devices (e.g. in bindmounts). The proposed solutions skips the mountpoints listed at the top of /proc/mounts (as before) and for the rest it changes the flags whenever the affected device is in the top of /proc/mounts.

--- /etc/init.d/umountfs 2007-10-04 12:17:31.000000000 +0100
+++ umountfs 2008-01-25 11:14:42.770493000 +0000
@@ -60,18 +60,20 @@

 do_stop () {
  exec 9<&0 </proc/mounts
-
+ PROTECTED_MOUNTS="$(sed -n '0,/^\/[^ ]* \/ /p' /proc/mounts)"
+ PROTECTED_MTPTS=""
  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)
+ case "$FSTYPE" in
+ proc|procfs|linprocfs|devfs|sysfs|usbfs|usbdevfs|devpts|securityfs)
    continue
    ;;
     tmpfs)
@@ -81,12 +83,15 @@
    ;;
     *)
    REG_MTPTS="$REG_MTPTS $MTPT"
+ if echo "$PROTECTED_MOUNTS" | grep -qs "^$DEV "; then
+ PROTECTED_MTPTS="$PROTECTED_MTPTS $MTPT "
+ fi
    ;;
   esac
  done

  exec 0<&9 9<&-
-
+
  #
  # Make sure tmpfs file systems are umounted before turning off
  # swap, to avoid running out of memory if the tmpfs filesystems
@@ -140,19 +145,31 @@
   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 $?
+ for MTPT in $REG_MTPTS; do
+ log_action_begin_msg "Unmounting local filesystem $MTPT"
+ if echo "PROTECTED_MTPTS" | grep -qs " $MTPT "; then
+ umount -r $MTPT
+ else
+ umount -f -r -d $MTPT
+ fi
+ log_action_end_msg $?
+ done
   else
- log_action_msg "Will now unmount local filesystems"
- umount -f -v -r -d $REG_MTPTS
- ES=$?
- if [ "$ES" = 0 ]
- then
- log_success_msg "Done unmounting local filesystems."
- else
- log_failure_msg "Unmounting local filesystems failed with error code ${ES}."
- fi
+ for MTPT in $REG_MTPTS; do
+ log_action_begin_msg "Will now unmount local filesystem $MTPT"
+ if echo "PROTECTED_MTPTS" | grep -qs " $MTPT "; then
+ umount -r -v $MTPT
+ else
+ umount -f -r -d -v $MTPT
+ fi
+ 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
+ done
   fi
  fi
 }