109 lines
3.5 KiB
Diff
109 lines
3.5 KiB
Diff
|
From 281327f72cfc4c9ef6308039c7e1da82f79b139f Mon Sep 17 00:00:00 2001
|
||
|
From: Harald Hoyer <harald@redhat.com>
|
||
|
Date: Mon, 26 Aug 2013 14:04:56 +0200
|
||
|
Subject: [PATCH] dmraid/mdraid: improve hostonly recognition
|
||
|
|
||
|
Factor out get_devpath_block(), which also fixes a dmraid hostonly bug.
|
||
|
|
||
|
Also only include dmraid and mdraid, if they are actually in use.
|
||
|
---
|
||
|
dracut-functions.sh | 17 +++++++++++++++++
|
||
|
modules.d/90dmraid/module-setup.sh | 24 ++++++++++++------------
|
||
|
modules.d/90mdraid/module-setup.sh | 13 +++++++++++--
|
||
|
3 files changed, 40 insertions(+), 14 deletions(-)
|
||
|
|
||
|
diff --git a/dracut-functions.sh b/dracut-functions.sh
|
||
|
index c89d816..9b24419 100755
|
||
|
--- a/dracut-functions.sh
|
||
|
+++ b/dracut-functions.sh
|
||
|
@@ -296,6 +296,23 @@ get_maj_min() {
|
||
|
printf "%s" "$((0x${_majmin%:*})):$((0x${_majmin#*:}))"
|
||
|
}
|
||
|
|
||
|
+
|
||
|
+# get_devpath_block <device>
|
||
|
+# get the DEVPATH in /sys of a block device
|
||
|
+get_devpath_block() {
|
||
|
+ local majmin i
|
||
|
+ _majmin=$(get_maj_min "$1")
|
||
|
+
|
||
|
+ for _i in /sys/block/*/dev /sys/block/*/*/dev; do
|
||
|
+ [[ -e "$_i" ]] || continue
|
||
|
+ if [[ "$_majmin" == "$(<"$_i")" ]]; then
|
||
|
+ printf "%s" "${_i%/dev}"
|
||
|
+ return 0
|
||
|
+ fi
|
||
|
+ done
|
||
|
+ return 1
|
||
|
+}
|
||
|
+
|
||
|
# get a persistent path from a device
|
||
|
get_persistent_dev() {
|
||
|
local i _tmp _dev
|
||
|
diff --git a/modules.d/90dmraid/module-setup.sh b/modules.d/90dmraid/module-setup.sh
|
||
|
index 2d73963..11181cf 100755
|
||
|
--- a/modules.d/90dmraid/module-setup.sh
|
||
|
+++ b/modules.d/90dmraid/module-setup.sh
|
||
|
@@ -9,8 +9,17 @@ check() {
|
||
|
type -P dmraid >/dev/null || return 1
|
||
|
|
||
|
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||
|
- for fs in "${host_fs_types[@]}"; do
|
||
|
- [[ $fs = *_raid_member ]] && return 0
|
||
|
+ for dev in "${!host_fs_types[@]}"; do
|
||
|
+ [[ "${host_fs_types[$dev]}" != *_raid_member ]] && continue
|
||
|
+
|
||
|
+ DEVPATH=$(get_devpath_block "$dev")
|
||
|
+
|
||
|
+ for holder in "$DEVPATH"/holders/*; do
|
||
|
+ [[ -e "$holder" ]] || continue
|
||
|
+ [[ -e "$holder/dm" ]] && return 0
|
||
|
+ break
|
||
|
+ done
|
||
|
+
|
||
|
done
|
||
|
return 255
|
||
|
}
|
||
|
@@ -31,16 +40,7 @@ cmdline() {
|
||
|
local holder DEVPATH DM_NAME majmin
|
||
|
[[ "${host_fs_types[$dev]}" != *_raid_member ]] && continue
|
||
|
|
||
|
- majmin=$(get_maj_min $dev)
|
||
|
- DEVPATH=$(
|
||
|
- for i in /sys/block/*; do
|
||
|
- [[ -e "$i/dev" ]] || continue
|
||
|
- if [[ $a == $(<"$i/dev") ]]; then
|
||
|
- printf "%s" "$i"
|
||
|
- break
|
||
|
- fi
|
||
|
- done
|
||
|
- )
|
||
|
+ DEVPATH=$(get_devpath_block "$dev")
|
||
|
|
||
|
for holder in "$DEVPATH"/holders/*; do
|
||
|
[[ -e "$holder" ]] || continue
|
||
|
diff --git a/modules.d/90mdraid/module-setup.sh b/modules.d/90mdraid/module-setup.sh
|
||
|
index 2bedbfd..5df2274 100755
|
||
|
--- a/modules.d/90mdraid/module-setup.sh
|
||
|
+++ b/modules.d/90mdraid/module-setup.sh
|
||
|
@@ -8,8 +8,17 @@ check() {
|
||
|
type -P mdadm >/dev/null || return 1
|
||
|
|
||
|
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||
|
- for fs in "${host_fs_types[@]}"; do
|
||
|
- [[ "$fs" == *_raid_member ]] && return 0
|
||
|
+ for dev in "${!host_fs_types[@]}"; do
|
||
|
+ [[ "${host_fs_types[$dev]}" != *_raid_member ]] && continue
|
||
|
+
|
||
|
+ DEVPATH=$(get_devpath_block "$dev")
|
||
|
+
|
||
|
+ for holder in "$DEVPATH"/holders/*; do
|
||
|
+ [[ -e "$holder" ]] || continue
|
||
|
+ [[ -e "$holder/md" ]] && return 0
|
||
|
+ break
|
||
|
+ done
|
||
|
+
|
||
|
done
|
||
|
return 255
|
||
|
}
|