Blame SOURCES/0537-dracut-function.sh-check_block_and_slaves-check-for-.patch

2d7ffa
From dd235965dd7b5de9dd87e5e5a4244005c5fb21e2 Mon Sep 17 00:00:00 2001
2d7ffa
From: Harald Hoyer <harald@redhat.com>
2d7ffa
Date: Mon, 19 Feb 2018 09:03:02 +0100
2d7ffa
Subject: [PATCH] dracut-function.sh:check_block_and_slaves() check for block
2d7ffa
 devices
2d7ffa
2d7ffa
Some nvme have char parents, so check if the "slave" is a block dev.
2d7ffa
2d7ffa
Fixes https://github.com/dracutdevs/dracut/issues/373
2d7ffa
2d7ffa
Cherry-picked from: e64dafd1f2489f1d926cce3e3bfd33f62b29b192
2d7ffa
Resolves: #1549498
2d7ffa
---
2d7ffa
 dracut-functions.sh | 18 ++++++++++--------
2d7ffa
 1 file changed, 10 insertions(+), 8 deletions(-)
2d7ffa
2d7ffa
diff --git a/dracut-functions.sh b/dracut-functions.sh
2d7ffa
index 98a4b88b..ca54bd7f 100755
2d7ffa
--- a/dracut-functions.sh
2d7ffa
+++ b/dracut-functions.sh
2d7ffa
@@ -616,13 +616,14 @@ check_block_and_slaves() {
2d7ffa
     [[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry.
2d7ffa
     if ! lvm_internal_dev $2; then "$1" $2 && return; fi
2d7ffa
     check_vol_slaves "$@" && return 0
2d7ffa
-    if [[ -f /sys/dev/block/$2/../dev ]]; then
2d7ffa
+    if [[ -f /sys/dev/block/$2/../dev ]] && [[ /sys/dev/block/$2/../subsystem -ef /sys/class/block ]]; then
2d7ffa
         check_block_and_slaves $1 $(<"/sys/dev/block/$2/../dev") && return 0
2d7ffa
     fi
2d7ffa
     [[ -d /sys/dev/block/$2/slaves ]] || return 1
2d7ffa
-    for _x in /sys/dev/block/$2/slaves/*/dev; do
2d7ffa
-        [[ -f $_x ]] || continue
2d7ffa
-        check_block_and_slaves $1 $(<"$_x") && return 0
2d7ffa
+    for _x in /sys/dev/block/$2/slaves/*; do
2d7ffa
+        [[ -f $_x/dev ]] || continue
2d7ffa
+        [[ $_x/subsystem -ef /sys/class/block ]] || continue
2d7ffa
+        check_block_and_slaves $1 $(<"$_x/dev") && return 0
2d7ffa
     done
2d7ffa
     return 1
2d7ffa
 }
2d7ffa
@@ -634,13 +635,14 @@ check_block_and_slaves_all() {
2d7ffa
         _ret=0
2d7ffa
     fi
2d7ffa
     check_vol_slaves_all "$@" && return 0
2d7ffa
-    if [[ -f /sys/dev/block/$2/../dev ]]; then
2d7ffa
+    if [[ -f /sys/dev/block/$2/../dev ]] && [[ /sys/dev/block/$2/../subsystem -ef /sys/class/block ]]; then
2d7ffa
         check_block_and_slaves_all $1 $(<"/sys/dev/block/$2/../dev") && _ret=0
2d7ffa
     fi
2d7ffa
     [[ -d /sys/dev/block/$2/slaves ]] || return 1
2d7ffa
-    for _x in /sys/dev/block/$2/slaves/*/dev; do
2d7ffa
-        [[ -f $_x ]] || continue
2d7ffa
-        check_block_and_slaves_all $1 $(<"$_x") && _ret=0
2d7ffa
+    for _x in /sys/dev/block/$2/slaves/*; do
2d7ffa
+        [[ -f $_x/dev ]] || continue
2d7ffa
+        [[ $_x/subsystem -ef /sys/class/block ]] || continue
2d7ffa
+        check_block_and_slaves_all $1 $(<"$_x/dev") && _ret=0
2d7ffa
     done
2d7ffa
     return $_ret
2d7ffa
 }