summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-02-11 19:53:49 +0100
committerDave Reisner <dreisner@archlinux.org>2012-02-11 20:51:16 +0100
commitd11ba0046d74b61f14c79c0793e53a99e51395cb (patch)
tree33ea3d3ac9d9062fb42448c3bc3b1a379c88e43d /install
parent9a2d5f4450d71803aa5013f8f1cdb5d962fb2617 (diff)
downloadmkinitcpio-d11ba0046d74b61f14c79c0793e53a99e51395cb.tar.gz
mkinitcpio-d11ba0046d74b61f14c79c0793e53a99e51395cb.tar.xz
autodetect: refactor raid device detection
FS#10061 still isn't dead, its just resting: https://bbs.archlinux.org/viewtopic.php?pid=1056003 An strace from a helpful user shows that our mdadm call is trying to open a block device and the call never returns: open("/dev/sdb", O_RDONLY|O_DIRECT|O_LARGEFILE Fix this by only scanning explicitly the block devices we're interested in, found via sysfs. This is an all around win for everyone, especially users who have mdadm installed without any need for it. This changes some of our assumptions about the environment: - the mdadm binary exists when we find md devices in /sys - the user running mkinitcpio isn't any specific UID or part of any particular group, but merely has read access to the block devices we're about to scan. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'install')
-rw-r--r--install/autodetect28
1 files changed, 22 insertions, 6 deletions
diff --git a/install/autodetect b/install/autodetect
index 3fb87ce..5cc908c 100644
--- a/install/autodetect
+++ b/install/autodetect
@@ -1,6 +1,9 @@
#!/bin/bash
build() {
+ local -a md_devs
+ local dev insufficient_perms
+
MODULE_FILE=$workdir/autodetect_modules
add_if_avail() {
@@ -29,15 +32,28 @@ build() {
add_if_avail "$usrfstype"
fi
- if (( UID == 0 )) || in_array 'disk' $(groups); then
- if [[ -x $(type -P mdadm) ]]; then
- mdadm -Esv /dev/[hrsv]d* /dev/{ida,cciss,ataraid,mapper}/* |
+ # look for raid devices
+ shopt -s nullglob
+ for dev in /sys/class/block/*/md/dev-*; do
+ dev=/dev/${dev#*/dev-}
+
+ [[ -r $dev ]] || insufficient_perms=1
+
+ md_devs+=("$dev")
+ done
+ shopt -u nullglob
+
+ # scan members of raid devices if found
+ if (( ${#md_devs[*]} )); then
+ (( !QUIET )) && plain "found %d raid members to scan" "${#md_devs[*]}"
+ if (( ! insufficient_perms )); then
+ mdadm -Esv "${md_devs[@]}" |
sed -n 's/.*level=\([^ ]\+\) .*/\1/p' |
sed 's/\<raid[456]\>/raid456/g' | sort -u >>"$MODULE_FILE"
+ else
+ warning "Insufficient permission to perform autodetection for mdadm devices"
+ raid_autodetect_failed=1
fi
- else
- error "Insufficient permission to perform autodetection for mdadm devices"
- raid_autodetect_failed=1
fi
if (( !QUIET )) && [[ -s $MODULE_FILE ]]; then