[Pkg-sysvinit-commits] r768 - in sysvinit/trunk/debian: . initscripts/etc/init.d

Thomas Hood jdthood-guest at costa.debian.org
Thu Mar 16 18:46:25 UTC 2006


Author: jdthood-guest
Date: 2006-03-16 18:46:24 +0000 (Thu, 16 Mar 2006)
New Revision: 768

Modified:
   sysvinit/trunk/debian/changelog
   sysvinit/trunk/debian/initscripts/etc/init.d/umountfs
Log:
Fix #356226 properly

Modified: sysvinit/trunk/debian/changelog
===================================================================
--- sysvinit/trunk/debian/changelog	2006-03-16 01:32:09 UTC (rev 767)
+++ sysvinit/trunk/debian/changelog	2006-03-16 18:46:24 UTC (rev 768)
@@ -1,13 +1,15 @@
 sysvinit (2.86.ds1-14~1) unstable; urgency=low
 
-  * 
+  [ Jiri Polach, Thomas Hood ]
+  * umountfs: Unmount in order of decreasing mount point length
+    without making use of the sort program  (Closes: #356226)
 
- -- Henrique de Moraes Holschuh <hmh at debian.org>  Wed, 15 Mar 2006 21:47:47 -0300
+ -- Thomas Hood <jdthood at yahoo.co.uk>  Thu, 16 Mar 2006 19:45:04 +0100
 
 sysvinit (2.86.ds1-13) unstable; urgency=low
 
   [ Thomas Hood ]
-  * umountfs: Unmount even if sort not available  (Closes: #356226)
+  * umountfs: Unmount even if sort not available (Addresses #356226)
   * last:  Fix strncmp bug  (Closes: #353585)
   * umountroot: Tweak handling of error messages from mount
     (Closes: #352398)

Modified: sysvinit/trunk/debian/initscripts/etc/init.d/umountfs
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/init.d/umountfs	2006-03-16 01:32:09 UTC (rev 767)
+++ sysvinit/trunk/debian/initscripts/etc/init.d/umountfs	2006-03-16 18:46:24 UTC (rev 768)
@@ -16,22 +16,43 @@
 
 umask 022
 
-# List all mounts, sorting to ensure that deeper mount points
-# are unmounted before shallower ones
-list_mounts() {
-	if which sort >/dev/null 2>&1
-	then
-		LC_ALL=C sort -r -k 2 /proc/mounts
-	else
-		# On systems with /usr on NFS, sort may not be around any more
-		# so just use cat
-		cat /proc/mounts
-	fi
+# Print in order of decreasing length
+#
+# Algorithm: Find and print longest argument, then call self
+# to print remaining arguments in order of decreasing length
+#
+# N.B.: Arguments must not contain spaces
+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
+	ARGNUM=1
+	PREVARGS=""
+	while [ "$ARGNUM" -lt "$ARGNUM_LONGEST" ]
+	do
+		PREVARGS="$PREVARGS $1"
+		shift
+		ARGNUM=$(($ARGNUM + 1))
+	done
+	echo $1
+	shift
+	pioodl $PREVARGS $@
 }
 
 
 do_stop () {
-	list_mounts | 
+	cat /proc/mounts | 
 	(
 		REG_MTPTS=""
 		TMPFS_MTPTS=""
@@ -105,6 +126,7 @@
 		#
 		if [ "$REG_MTPTS" ]
 		then
+			REG_MTPTS="$(pioodl $REG_MTPTS)"
 			if [ "$VERBOSE" = no ]
 			then
 				log_action_begin_msg "Unmounting local filesystems"




More information about the Pkg-sysvinit-commits mailing list