summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpyther@pyther.net <pyther@pyther.net>2011-01-23 18:06:21 -0500
committerDieter Plaetinck <dieter@plaetinck.be>2011-01-29 16:58:36 +0100
commit4a11b07deedbebdeb576889272a1e0ebbebb1ad3 (patch)
treee25b784a055eacbc7b0fe499dd8b240041a1bf71
parent1c1c2bf461a9887e0dbe487472c161e17fa659f6 (diff)
Improve logic which checks whether blockdevice is a raid device
device_is_raid now uses dev major number to determine if a device is a raid device. A major ID of 8 is a /dev/sd? device whereas a major ID of 9 is a 'metadata' (raid) device. Signed-off-by: Dieter Plaetinck <dieter@plaetinck.be>
-rw-r--r--src/core/libs/lib-blockdevices-filesystems.sh19
-rw-r--r--src/core/libs/lib-ui-interactive.sh2
2 files changed, 7 insertions, 14 deletions
diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh
index 8573b19..d00ef81 100644
--- a/src/core/libs/lib-blockdevices-filesystems.sh
+++ b/src/core/libs/lib-blockdevices-filesystems.sh
@@ -919,19 +919,12 @@ get_blockdevice_size ()
# $1 blockdevice (ex: /dev/md0 or /dev/sda1)
-# return true when blockdevice is an md raid, otherwise return a unset value
-mdraid_is_raid()
-{
- local israid
- if [ -z $1 ]; then
- # Don't call mdadm on empty blockdevice parameter!
- israid=""
- elif [ "$(mdadm --query $1 | cut -d':' -f2)" == " is not an md array" ]; then
- israid=""
- else
- israid=true
- fi
- echo $israid
+# All MD RAID block devices have a major id of 9
+device_is_raid() {
+ [[ -b "$1" ]] || die_error "device_is_raid needs a blockdevice as \$1 ($1 given)"
+ [[ -f /proc/mdstast ]] || return 1
+ local devmajor=$(stat -c %t "$1")
+ (( devmajor == 9 ))
}
# $1 md raid blockdevice (ex: /dev/md0)
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh
index 881af90..829556a 100644
--- a/src/core/libs/lib-ui-interactive.sh
+++ b/src/core/libs/lib-ui-interactive.sh
@@ -878,7 +878,7 @@ interactive_grub() {
bootdev=$(mount | grep $var_TARGET_DIR/boot | cut -d' ' -f 1)
# check if bootdev or PART_ROOT is on a md raid array
# This dialog is only shown when we detect / or /boot on a raid device.
- if [ -n "$(mdraid_is_raid $bootdev)" -o -n "$(mdraid_is_raid $PART_ROOT)" ]; then
+ if device_is_raid $bootdev || device_is_raid $PART_ROOT; then
ask_yesno "Do you have your system installed on software raid?\nAnswer 'YES' to install grub to another hard disk." no
if [ $? -eq 0 ]; then
onraid=true