fi
}
+
+# block_is_nbd <maj:min>
+# Check whether $1 is an nbd device
+block_is_nbd() {
+ [[ -b /dev/block/$1 && $1 == 43:* ]]
+}
+
+# block_is_iscsi <maj:min>
+# Check whether $1 is an nbd device
+block_is_iscsi() {
+ local _dir
+ local _dev=$1
+ [[ -L "/sys/dev/block/$_dev" ]] || return
+ _dir="$(readlink -f "/sys/dev/block/$_dev")" || return
+ until [[ -d "$_dir/sys" || -d "$_dir/iscsi_session" ]]; do
+ _dir="$_dir/.."
+ done
+ [[ -d "$_dir/iscsi_session" ]]
+}
+
+# block_is_fcoe <maj:min>
+# Check whether $1 is an FCoE device
+# Will not work for HBAs that hide the ethernet aspect
+# completely and present a pure FC device
+block_is_fcoe() {
+ local _dir
+ local _dev=$1
+ [[ -L "/sys/dev/block/$_dev" ]] || return
+ _dir="$(readlink -f "/sys/dev/block/$_dev")"
+ until [[ -d "$_dir/sys" ]]; do
+ _dir="$_dir/.."
+ if [[ -d "$_dir/subsystem" ]]; then
+ subsystem=$(basename $(readlink $_dir/subsystem))
+ [[ $subsystem == "fcoe" ]] && return 0
+ fi
+ done
+ return 1
+}
+
+# block_is_netdevice <maj:min>
+# Check whether $1 is a net device
+block_is_netdevice() {
+ block_is_nbd "$1" || block_is_iscsi "$1" || block_is_fcoe "$1"
+}
# If hostonly was requested, fail the check if we are not actually
# booting from root.
- is_iscsi() {
- local _dev=$1
-
- [[ -L "/sys/dev/block/$_dev" ]] || return
- cd "$(readlink -f "/sys/dev/block/$_dev")"
- until [[ -d sys || -d iscsi_session ]]; do
- cd ..
- done
- [[ -d iscsi_session ]]
- }
-
[[ $hostonly ]] || [[ $mount_needs ]] && {
pushd . >/dev/null
- for_each_host_dev_and_slaves is_iscsi
+ for_each_host_dev_and_slaves block_is_iscsi
local _is_iscsi=$?
popd >/dev/null
[[ $_is_iscsi == 0 ]] || return 255
inst_hook cmdline 90 "$moddir/parse-iscsiroot.sh"
inst_hook cleanup 90 "$moddir/cleanup-iscsi.sh"
inst "$moddir/iscsiroot.sh" "/sbin/iscsiroot"
+
if ! dracut_module_included "systemd"; then
inst "$moddir/mount-lun.sh" "/bin/mount-lun.sh"
else
# if an nbd device is not somewhere in the chain of devices root is
# mounted on, fail the hostonly check.
[[ $hostonly ]] || [[ $mount_needs ]] && {
- is_nbd() { [[ -b /dev/block/$1 && $1 == 43:* ]] ;}
-
_rootdev=$(find_root_block_device)
[[ -b /dev/block/$_rootdev ]] || return 1
- check_block_and_slaves is_nbd "$_rootdev" || return 255
+ check_block_and_slaves block_is_nbd "$_rootdev" || return 255
}
require_binaries nbd-client || return 1
# called by dracut
check() {
+ swap_on_netdevice() {
+ local _dev
+ for _dev in "${swap_devs[@]}"; do
+ block_is_netdevice $_dev && return 0
+ done
+ return 1
+ }
+
# Only support resume if hibernation is currently on
+ # and no swap is mounted on a net device
[[ $hostonly ]] || [[ $mount_needs ]] && {
- [[ "$(cat /sys/power/resume)" == "0:0" ]] && return 255
+ swap_on_netdevice || [[ "$(cat /sys/power/resume)" == "0:0" ]] && return 255
}
return 0