From: Victor Lowther Date: Sun, 16 Aug 2009 15:35:15 +0000 (-0500) Subject: Make mdraid checking use common functionality in dracut-functions X-Git-Tag: 001~39 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7e2b4f8367df360d326fe1497d1a3c009c2acc5c;p=thirdparty%2Fdracut.git Make mdraid checking use common functionality in dracut-functions --- diff --git a/modules.d/90mdraid/check b/modules.d/90mdraid/check index a13d6711d..d002bdc33 100755 --- a/modules.d/90mdraid/check +++ b/modules.d/90mdraid/check @@ -3,38 +3,20 @@ # No mdadm? No mdraid support. which mdadm >/dev/null 2>&1 || exit 1 -is_mdraid() { /lib/udev/vol_id /dev/block/$1 |egrep -q '(linux|isw)_raid'; } +. $dracutfunctions -check_block_and_slaves() ( - # $1 = block device in major:minor format - local x - cd /sys/dev/block/$1 - [[ -b /dev/block/$1 ]] || return 1 # Not a block device? So sorry. - is_mdraid $1 && return - [[ -d slaves ]] || return 1 # there are no underlying devices, done. - # we want to search the tree breadthwise, so... - for x in slaves/*/dev; do - is_mdraid $(cat "$x") && return 0 - done - for x in slaves/*/dev; do - check_block_and_slaves $(cat "$x") && return 0 - done - return 1 -) +is_mdraid() { /lib/udev/vol_id /dev/block/$1 |egrep -q '(linux|isw)_raid'; } -if [[ $1 = '-h' ]] ; then - rootdev='' - while read blkdev fs type opts misc; do - [[ $blkdev = rootfs ]] && continue # skip rootfs entry - [[ $fs = / ]] && { rootdev=$blkdev; break; } - done < /proc/mounts - [[ -b $rootdev ]] || exit 1 # Not on a block device? Definitly not mdraid. - # get major/minor for the device - majmin=$(ls -nLl "$rootdev" | \ - (read x x x x maj min x; maj=${maj//,/}; echo $maj:$min)) - # now, walk backwards though our master/slave relationships looking - # for a mdraid device - check_block_and_slaves $majmin || exit 1 -fi +[[ $1 = '-h' ]] && { + rootdev=$(find_root_block_device) + if [[ $rootdev ]]; then + # root lives on a block device, so we can be more precise about + # hostonly checking + check_block_and_slaves is_mdraid "$rootdev" || exit 1 + else + # root is not on a block device, use the shotgun approach + blkid | grep -q linux_raid || exit 1 + fi +} exit 0