Browse Source

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.
master
Harald Hoyer 12 years ago
parent
commit
281327f72c
  1. 17
      dracut-functions.sh
  2. 24
      modules.d/90dmraid/module-setup.sh
  3. 13
      modules.d/90mdraid/module-setup.sh

17
dracut-functions.sh

@ -296,6 +296,23 @@ get_maj_min() {
printf "%s" "$((0x${_majmin%:*})):$((0x${_majmin#*:}))" 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 a persistent path from a device
get_persistent_dev() { get_persistent_dev() {
local i _tmp _dev local i _tmp _dev

24
modules.d/90dmraid/module-setup.sh

@ -9,8 +9,17 @@ check() {
type -P dmraid >/dev/null || return 1 type -P dmraid >/dev/null || return 1


[[ $hostonly ]] || [[ $mount_needs ]] && { [[ $hostonly ]] || [[ $mount_needs ]] && {
for fs in "${host_fs_types[@]}"; do for dev in "${!host_fs_types[@]}"; do
[[ $fs = *_raid_member ]] && return 0 [[ "${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 done
return 255 return 255
} }
@ -31,16 +40,7 @@ cmdline() {
local holder DEVPATH DM_NAME majmin local holder DEVPATH DM_NAME majmin
[[ "${host_fs_types[$dev]}" != *_raid_member ]] && continue [[ "${host_fs_types[$dev]}" != *_raid_member ]] && continue


majmin=$(get_maj_min $dev) DEVPATH=$(get_devpath_block "$dev")
DEVPATH=$(
for i in /sys/block/*; do
[[ -e "$i/dev" ]] || continue
if [[ $a == $(<"$i/dev") ]]; then
printf "%s" "$i"
break
fi
done
)


for holder in "$DEVPATH"/holders/*; do for holder in "$DEVPATH"/holders/*; do
[[ -e "$holder" ]] || continue [[ -e "$holder" ]] || continue

13
modules.d/90mdraid/module-setup.sh

@ -8,8 +8,17 @@ check() {
type -P mdadm >/dev/null || return 1 type -P mdadm >/dev/null || return 1


[[ $hostonly ]] || [[ $mount_needs ]] && { [[ $hostonly ]] || [[ $mount_needs ]] && {
for fs in "${host_fs_types[@]}"; do for dev in "${!host_fs_types[@]}"; do
[[ "$fs" == *_raid_member ]] && return 0 [[ "${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 done
return 255 return 255
} }

Loading…
Cancel
Save