Author: glen
Date: Wed Oct 24 20:45:34 2007
New Revision: 8859

Modified:
   geninitrd/trunk/geninitrd
Log:
- typo (multipath part was always generated)
- find_modules_dmraid() moved to function
- $have_dmraid variable to denote dmraid status

Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd   (original)
+++ geninitrd/trunk/geninitrd   Wed Oct 24 20:45:34 2007
@@ -59,12 +59,15 @@
 proc_partitions=no
 # dmraid component devices of rootfs is on dmraid
 dmraid_devices=''
+
 # if we should init NFS at boot
 have_nfs=no
 # if we should init LVM at boot
 have_lvm=no
 # if we should init md (softraid) at boot
 have_md=no
+# if we should init dmraid at boot
+have_dmraid=no
 # if we should init dm-multipath at boot
 have_multipath=no
 
@@ -553,6 +556,34 @@
        return 0
 }
 
+# find dmraid modules for $devpath
+# returns false if $devpath is not on dmraid
+find_modules_dmraid() {
+       local devpath="$1"
+
+       # get blockdev itself (without partition)
+       # /dev/mapper/sil_ahbgadcbchfc3 -> /dev/mapper/sil_ahbgadcbchfc
+       local blockdev=${devpath%%[0-9]*}
+       local raidname=${blockdev#/dev/mapper/}
+       local found=0
+
+       local dev phydevs=$(dmraid -r -cdevpath,raidname | awk -F, 
-vv="$raidname" '{if ($2 == v) print $1}')
+       for dev in $phydevs; do
+               find_modules_for_device $dev
+               dmraid_devices="$dmraid_devices $dev"
+               found=1
+       done
+
+       if [ $found = 0 ]; then
+               return 1
+       fi
+
+       # XXX probably should detect
+       findmodule "dm-mirror"
+       have_dmraid=yes
+       return 0
+}
+
 # find modules for $devpath
 find_modules_for_device() {
        local devpath="$1"
@@ -597,6 +628,13 @@
                # fallback
        fi
 
+       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
+               if find_modules_dmraid "$devpath"; then
+                       return
+               fi
+               # fallback
+       fi
+
        if is_yes "$(echo "$devpath" | awk '/^\/dev\/(sd|scsi)/ { print "yes"; 
}')" ; then
                find_modules_scsi
                return
@@ -607,26 +645,6 @@
                return
        fi
 
-       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
-               # XXX dmraid could say to us that /dev/dm-3 consists from 
/dev/sda, /dev/sdb
-
-               local node
-               # get blockdev itself (without partition)
-               # /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
-               findmodule "dm-mirror"
-               return
-       fi
-
        if is_yes "`echo "$devpath" | awk '/\/dev\/rd\// { print "yes"; }'`" ; 
then
                findmodule "DAC960"
                return
@@ -1506,7 +1524,7 @@
                if is_yes "$have_md"; then
                        echo "  md_component_detection = 1" >> 
"$MNTIMAGE/etc/lvm.conf"
                fi
-               if [ "$dmraid_devices" ] || is_yes "$have_multipath"; then
+               if is_yes "$have_dmraid" || is_yes "$have_multipath"; then
                        echo '  types = [ "device-mapper", 254 ]' >> 
"$MNTIMAGE/etc/lvm.conf"
                fi
                if [ "$dmraid_devices" ]; then
@@ -1583,11 +1601,11 @@
        initrd_gen_tuxonice
 fi
 
-if [ "$dmraid_devices" ]; then
+if is_yes "$have_dmraid" ]; then
        initrd_gen_dmraid
 fi
 
-if [ "$have_multipath" ]; then
+if is_yes "$have_multipath"; then
        initrd_gen_multipath
 fi
 
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to