[readonly/geninitrd: 462/1068] - optimize little dmraid part

draenog draenog at pld-linux.org
Sat Nov 2 19:51:13 CET 2013


commit 1a63b128c1d34f38a054463e23d9be924c7fe8b7
Author: Elan Ruusamäe <glen at pld-linux.org>
Date:   Wed Oct 24 18:31:22 2007 +0000

    - optimize little dmraid part
    
    svn-id: @8858

 geninitrd | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index 390e1f2..38578f1 100755
--- a/geninitrd
+++ b/geninitrd
@@ -590,7 +590,7 @@ find_modules_for_device() {
 		return
 	fi
 
-	if [[ "$devpath" == /dev/mapper/* ]] && is_yes "$USE_MULTIPATH"; then
+	if is_yes "$USE_MULTIPATH" && [[ "$devpath" == /dev/mapper/* ]]; then
 		if find_modules_multipath "$devpath"; then
 			return
 		fi
@@ -607,21 +607,19 @@ find_modules_for_device() {
 		return
 	fi
 
-	if is_yes "$(echo "$devpath" | awk '/^\/dev\/mapper\/(sil|hpt37x|hpt45x|isw|lsi|nvidia|pdc|sil|via|dos)_/ { print "yes"; }')"; then
+	if is_yes "$USE_DMRAID" && is_yes "$(echo "$devpath" | awk '/^\/dev\/mapper\/(sil|hpt37x|hpt45x|isw|lsi|nvidia|pdc|sil|via|dos)_/ { print "yes"; }')"; then
 		# dmraid nodes taken from: `dmraid -l` output
-		if [ ! -x /usr/sbin/dmraid ]; then
-			die "root on dmraid but /usr/sbin/dmraid not found."
-		fi
-
 		# XXX dmraid could say to us that /dev/dm-3 consists from /dev/sda, /dev/sdb
 
+		local node
 		# get blockdev itself (without partition)
-		local node blockdev
-		blockdev=${devpath%%[0-9]*}
-		blockdev=${blockdev#/dev/mapper/}
-		for node in $(dmraid -r -cdevpath,raidname |awk -F, -vv="$blockdev" '{if ($2 == v) print $1}'); do
-			find_modules_for_device $node
-			dmraid_devices="$dmraid_devices $node"
+		# /dev/mapper/sil_ahbgadcbchfc3 -> /dev/mapper/sil_ahbgadcbchfc
+		local blockdev=${devpath%%[0-9]*}
+		local raidname=${blockdev#/dev/mapper/}
+		local dev phydevs=$(dmraid -r -cdevpath,raidname | awk -F, -vv="$raidname" '{if ($2 == v) print $1}'); do
+		for dev in $phydevs; do
+			find_modules_for_device $dev
+			dmraid_devices="$dmraid_devices $dev"
 		done
 
 		# XXX probably should detect
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/readonly/geninitrd.git/commitdiff/147754ca159d40ca5eb541074dc043d8cbd92090



More information about the pld-cvs-commit mailing list