[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ipcop-svn
Subject:    [Ipcop-svn] SF.net SVN: ipcop:[2236] ipcop/trunk/src/rc.d/rc.halt
From:       owes () users ! sourceforge ! net
Date:       2008-12-28 16:16:47
Message-ID: E1LGyJr-0003uL-Gc () dn4whf1 ! ch3 ! sourceforge ! com
[Download RAW message or body]

Revision: 2236
          http://ipcop.svn.sourceforge.net/ipcop/?rev=2236&view=rev
Author:   owes
Date:     2008-12-28 16:16:47 +0000 (Sun, 28 Dec 2008)

Log Message:
-----------
Use magic & voodoo from Debian S40umountfs to umount all FS and avoid the message \
about /dev still busy. This should also take care of proper umount order for \
additional user mounts.

Modified Paths:
--------------
    ipcop/trunk/src/rc.d/rc.halt

Modified: ipcop/trunk/src/rc.d/rc.halt
===================================================================
--- ipcop/trunk/src/rc.d/rc.halt	2008-12-28 14:53:25 UTC (rev 2235)
+++ ipcop/trunk/src/rc.d/rc.halt	2008-12-28 16:16:47 UTC (rev 2236)
@@ -3,6 +3,52 @@
 # $Id$
 #
 
+
+# From Debian S40umountfs, to umount mountpoints with large names first
+# 
+#
+# Print in order of decreasing length
+#
+# Algorithm: Find and print longest argument, then call self
+# to print remaining arguments in order of decreasing length
+#
+# This function runs at one tenth the speed of the sort program
+# but we use the function because we don't want to rely on any
+# programs in /usr/.
+#
+# N.B.: Arguments must not be null and must not contain whitespace
+#
+pioodl() {
+    [ "$1" ] || return 0
+    ARGNUM=1
+    ARGNUM_LONGEST=0
+    ARGLENGTH_LONGEST=0
+    for ARG in "$@"
+    do
+        ARGLENGTH="${#ARG}"
+        if [ "$ARGLENGTH" -gt "$ARGLENGTH_LONGEST" ]
+        then
+            ARGLENGTH_LONGEST="$ARGLENGTH"
+            ARGNUM_LONGEST="$ARGNUM"
+        fi
+        ARGNUM=$(($ARGNUM + 1))
+    done
+    # The method of passing prevargs assumes that args can be
+    # delimited with spaces
+    ARGNUM=1
+    PREVARGS=""
+    while [ "$ARGNUM" -lt "$ARGNUM_LONGEST" ]
+    do
+        PREVARGS="$PREVARGS $1"
+        shift
+        ARGNUM=$(($ARGNUM + 1))
+    done
+    echo "$1"
+    shift
+    pioodl $PREVARGS "$@"
+}
+
+
 eval $(/usr/local/bin/readhash /var/ipcop/main/settings)
 
 echo "Stopping the RED interface..."
@@ -36,10 +82,56 @@
     fi
 fi
 
+# Get all mounts
+exec 9<&0 </proc/mounts
+
+REG_MOUNTPTS=""
+TMPFS_MOUNTPTS=""
+
+# Filter out dev, proc, sys etc.
+while read DEV MOUNTPT FSTYPE REST
+do
+    case "$MOUNTPT" in
+          /)
+            continue
+            ;;
+          /proc|/proc/*|/sys)
+            continue
+            ;;
+          /dev|/.dev|/dev/pts|/dev/shm|/dev/.static/dev)
+            continue
+            ;;
+    esac
+    case "$FSTYPE" in 
+      proc|procfs|linprocfs|devfs|sysfs|usbfs|usbdevfs|devpts)
+        continue
+        ;;
+      tmpfs)
+        TMPFS_MOUNTPTS="$TMPFS_MOUNTPTS $MOUNTPT"
+        ;;
+      *)
+        REG_MOUNTPTS="$REG_MOUNTPTS $MOUNTPT"
+        ;;
+    esac
+done
+
+# From Debian S40umountfs, 
+#   first umount tmpfs file systems after that turn off swap to avoid runnung out of \
memory. +echo "Unmounting tmpfs file systems"
+if [ "$TMPFS_MOUNTPTS" ]; then
+    TMPFS_MOUNTPTS="$(pioodl $TMPFS_MOUNTPTS)"
+    umount -f -r -d $TMPFS_MOUNTPTS
+fi
+
 echo "Turning off swap"
 /sbin/swapoff -a
-echo "Unmounting others"
-/bin/umount -n -a
+
+echo "Unmounting file systems"
+if [ "$REG_MOUNTPTS" ]; then
+    REG_MOUNTPTS="$(pioodl $REG_MOUNTPTS)"
+    umount -f -r -d $REG_MOUNTPTS
+fi
+
 echo "Unmounting root"
 /bin/mount -n -o remount,ro /
 


This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.

------------------------------------------------------------------------------
_______________________________________________
Ipcop-svn mailing list
Ipcop-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipcop-svn


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic