dracut-function.sh:check_block_and_slaves() check for block devices

Some nvme have char parents, so check if the "slave" is a block dev.

Fixes https://github.com/dracutdevs/dracut/issues/373
master
Harald Hoyer 2018-02-19 09:03:02 +01:00
parent 1779aee72c
commit e64dafd1f2
1 changed files with 10 additions and 8 deletions

View File

@ -497,13 +497,14 @@ check_block_and_slaves() {
[[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry. [[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry.
if ! lvm_internal_dev $2; then "$1" $2 && return; fi if ! lvm_internal_dev $2; then "$1" $2 && return; fi
check_vol_slaves "$@" && return 0 check_vol_slaves "$@" && return 0
if [[ -f /sys/dev/block/$2/../dev ]]; then if [[ -f /sys/dev/block/$2/../dev ]] && [[ /sys/dev/block/$2/../subsystem -ef /sys/class/block ]]; then
check_block_and_slaves $1 $(<"/sys/dev/block/$2/../dev") && return 0 check_block_and_slaves $1 $(<"/sys/dev/block/$2/../dev") && return 0
fi fi
[[ -d /sys/dev/block/$2/slaves ]] || return 1 [[ -d /sys/dev/block/$2/slaves ]] || return 1
for _x in /sys/dev/block/$2/slaves/*/dev; do for _x in /sys/dev/block/$2/slaves/*; do
[[ -f $_x ]] || continue [[ -f $_x/dev ]] || continue
check_block_and_slaves $1 $(<"$_x") && return 0 [[ $_x/subsystem -ef /sys/class/block ]] || continue
check_block_and_slaves $1 $(<"$_x/dev") && return 0
done done
return 1 return 1
} }
@ -515,13 +516,14 @@ check_block_and_slaves_all() {
_ret=0 _ret=0
fi fi
check_vol_slaves_all "$@" && return 0 check_vol_slaves_all "$@" && return 0
if [[ -f /sys/dev/block/$2/../dev ]]; then if [[ -f /sys/dev/block/$2/../dev ]] && [[ /sys/dev/block/$2/../subsystem -ef /sys/class/block ]]; then
check_block_and_slaves_all $1 $(<"/sys/dev/block/$2/../dev") && _ret=0 check_block_and_slaves_all $1 $(<"/sys/dev/block/$2/../dev") && _ret=0
fi fi
[[ -d /sys/dev/block/$2/slaves ]] || return 1 [[ -d /sys/dev/block/$2/slaves ]] || return 1
for _x in /sys/dev/block/$2/slaves/*/dev; do for _x in /sys/dev/block/$2/slaves/*; do
[[ -f $_x ]] || continue [[ -f $_x/dev ]] || continue
check_block_and_slaves_all $1 $(<"$_x") && _ret=0 [[ $_x/subsystem -ef /sys/class/block ]] || continue
check_block_and_slaves_all $1 $(<"$_x/dev") && _ret=0
done done
return $_ret return $_ret
} }