SVN: geninitrd/trunk/geninitrd

glen glen at pld-linux.org
Wed Oct 24 20:20:06 CEST 2007


Author: glen
Date: Wed Oct 24 20:20:06 2007
New Revision: 8857

Modified:
   geninitrd/trunk/geninitrd
Log:
- moved dm-multipath handling to function

Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd	(original)
+++ geninitrd/trunk/geninitrd	Wed Oct 24 20:20:06 2007
@@ -517,6 +517,42 @@
 	return $rc
 }
 
+# find dm-multipath modules for $devpath
+# returns false if $devpath is not dm-multipath
+find_modules_multipath() {
+	local devpath="$1"
+
+	# remove partition, if any
+	local disk=${devpath%p[0-9]*}
+	# need only dm name
+	local id=${disk#/dev/mapper/}
+
+	local info=$(multipath -l $id)
+	if [ -z "$info" ]; then
+		return 1
+	fi
+
+	debug "have multipath"
+	have_multipath=yes
+	local dev phydevs=$(echo "$info" | awk '$2 ~ /^[0-9]+:[0-9]+:[0-9]+:[0-9]+$/{printf("/dev/%s\n", $3)}')
+	for dev in $phydevs; do
+		find_modules_for_device $dev
+	done
+
+	local hw hwhandlers=$(echo "$info" | awk '/hwhandler=1/{sub(/.*hwhandler=1 /, ""); sub(/\]$/, ""); print}')
+	for hw in $hwhandlers; do
+		findmodule "dm-$hw"
+	done
+
+	local target targets=$(echo "$info" | awk '/prio=/{print $2}' | sort -u)
+	for target in $targets; do
+		findmodule "dm-$target"
+	done
+
+	findmodule "dm-mod"
+	return 0
+}
+
 # find modules for $devpath
 find_modules_for_device() {
 	local devpath="$1"
@@ -536,6 +572,7 @@
 		if [ ! -x /usr/bin/pcidev -a -z "$NFS_ETH_MODULES" ] ; then
 			die "root on NFS but /usr/bin/pcidev not found. Please install correct pci-database package and rerun $PROGRAM."
 		fi
+		local m
 		[ -z "$NFS_ETH_MODULES" ] && NFS_ETH_MODULES=$(/usr/bin/pcidev /m net | xargs)
 		for m in $NFS_ETH_MODULES; do
 			findmodule "$m"
@@ -554,33 +591,9 @@
 	fi
 
 	if [[ "$devpath" == /dev/mapper/* ]] && is_yes "$USE_MULTIPATH"; then
-		# remove partition
-		local disk=${devpath%p[0-9]*}
-		local id=${disk#/dev/mapper/}
-
-		local info=$(multipath -l $id)
-		if [ "$info" ]; then
-			debug "have multipath"
-			have_multipath=yes
-			local dev phydevs=$(echo "$info" | awk '$2 ~ /^[0-9]+:[0-9]+:[0-9]+:[0-9]+$/{printf("/dev/%s\n", $3)}')
-			for dev in $phydevs; do
-				find_modules_for_device $dev
-			done
-
-			local hw hwhandlers=$(echo "$info" | awk '/hwhandler=1/{sub(/.*hwhandler=1 /, ""); sub(/\]$/, ""); print}')
-			for hw in $hwhandlers; do
-				findmodule "dm-$hw"
-			done
-
-			local target targets=$(echo "$info" | awk '/prio=/{print $2}' | sort -u)
-			for target in $targets; do
-				findmodule "dm-$target"
-			done
-
-			findmodule "dm-mod"
+		if find_modules_multipath "$devpath"; then
 			return
 		fi
-
 		# fallback
 	fi
 


More information about the pld-cvs-commit mailing list