|
|
9f65cc |
From bc6b4ffd4e7babd34e207c2aa8bed7f0fd8bafcf Mon Sep 17 00:00:00 2001
|
|
|
9f65cc |
From: Lukas Nykryn <lnykryn@redhat.com>
|
|
|
9f65cc |
Date: Mon, 2 Aug 2021 12:42:09 +0200
|
|
|
9f65cc |
Subject: [PATCH] dracut-functions: backport block_is_* functions
|
|
|
9f65cc |
|
|
|
9f65cc |
Based on 480aa9695f8c2e2b30c8f41ae8483140020d23db
|
|
|
9f65cc |
RHEL-only
|
|
|
9f65cc |
|
|
|
9f65cc |
Related: #1959336
|
|
|
9f65cc |
---
|
|
|
9f65cc |
dracut-functions.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++
|
|
|
9f65cc |
1 file changed, 44 insertions(+)
|
|
|
9f65cc |
|
|
|
9f65cc |
diff --git a/dracut-functions.sh b/dracut-functions.sh
|
|
|
9f65cc |
index d75696fd..14e60a9c 100755
|
|
|
9f65cc |
--- a/dracut-functions.sh
|
|
|
9f65cc |
+++ b/dracut-functions.sh
|
|
|
9f65cc |
@@ -718,3 +718,47 @@ btrfs_devs() {
|
|
|
9f65cc |
printf -- "%s\n" "$_dev"
|
|
|
9f65cc |
done
|
|
|
9f65cc |
}
|
|
|
9f65cc |
+
|
|
|
9f65cc |
+# block_is_nbd <maj:min>
|
|
|
9f65cc |
+# Check whether $1 is an nbd device
|
|
|
9f65cc |
+block_is_nbd() {
|
|
|
9f65cc |
+ [[ -b /dev/block/$1 && $1 == 43:* ]]
|
|
|
9f65cc |
+}
|
|
|
9f65cc |
+
|
|
|
9f65cc |
+# block_is_iscsi <maj:min>
|
|
|
9f65cc |
+# Check whether $1 is an nbd device
|
|
|
9f65cc |
+block_is_iscsi() {
|
|
|
9f65cc |
+ local _dir
|
|
|
9f65cc |
+ local _dev=$1
|
|
|
9f65cc |
+ [[ -L "/sys/dev/block/$_dev" ]] || return
|
|
|
9f65cc |
+ _dir="$(readlink -f "/sys/dev/block/$_dev")" || return
|
|
|
9f65cc |
+ until [[ -d "$_dir/sys" || -d "$_dir/iscsi_session" ]]; do
|
|
|
9f65cc |
+ _dir="$_dir/.."
|
|
|
9f65cc |
+ done
|
|
|
9f65cc |
+ [[ -d "$_dir/iscsi_session" ]]
|
|
|
9f65cc |
+}
|
|
|
9f65cc |
+
|
|
|
9f65cc |
+# block_is_fcoe <maj:min>
|
|
|
9f65cc |
+# Check whether $1 is an FCoE device
|
|
|
9f65cc |
+# Will not work for HBAs that hide the ethernet aspect
|
|
|
9f65cc |
+# completely and present a pure FC device
|
|
|
9f65cc |
+block_is_fcoe() {
|
|
|
9f65cc |
+ local _dir
|
|
|
9f65cc |
+ local _dev=$1
|
|
|
9f65cc |
+ [[ -L "/sys/dev/block/$_dev" ]] || return
|
|
|
9f65cc |
+ _dir="$(readlink -f "/sys/dev/block/$_dev")"
|
|
|
9f65cc |
+ until [[ -d "$_dir/sys" ]]; do
|
|
|
9f65cc |
+ _dir="$_dir/.."
|
|
|
9f65cc |
+ if [[ -d "$_dir/subsystem" ]]; then
|
|
|
9f65cc |
+ subsystem=$(basename $(readlink $_dir/subsystem))
|
|
|
9f65cc |
+ [[ $subsystem == "fcoe" ]] && return 0
|
|
|
9f65cc |
+ fi
|
|
|
9f65cc |
+ done
|
|
|
9f65cc |
+ return 1
|
|
|
9f65cc |
+}
|
|
|
9f65cc |
+
|
|
|
9f65cc |
+# block_is_netdevice <maj:min>
|
|
|
9f65cc |
+# Check whether $1 is a net device
|
|
|
9f65cc |
+block_is_netdevice() {
|
|
|
9f65cc |
+ block_is_nbd "$1" || block_is_iscsi "$1" || block_is_fcoe "$1"
|
|
|
9f65cc |
+}
|
|
|
9f65cc |
\ No newline at end of file
|
|
|
9f65cc |
|