diff --git a/dracut.spec b/dracut.spec index 6cf4784cc3bf4eadf06128076346428f37a3620c..74c21094ccadea58eed0776cbef5cfe923d04d2e 100644 --- a/dracut.spec +++ b/dracut.spec @@ -40,6 +40,7 @@ Patch13: backport-feat-lvm-only-run-lvchange-for-LV-that-is-seen-on-de.patch Patch14: backport-fix-lvm-restore-setting-LVM_MD_PV_ACTIVATED.patch Patch15: backport-Bring-back-51-dracut-rescue-postinst.sh.patch Patch16: backport-fix-dracut-shutdown-add-cleanup-handler-on-failure.patch +Patch17: fix-virture.patch Patch9000: remove-iscsi-related-code-since-it-is-no-longer-main.patch @@ -516,6 +517,9 @@ install -m 0755 51-dracut-rescue-postinst.sh $RPM_BUILD_ROOT%{_sysconfdir}/kerne %endif %changelog +* Wed Nov 1 2023 kangyihang - 055-8 +- fix(dracut-functions.sh): get block device driver if in a virtual subsystem + * Wed Mar 22 2023 wangyuhang - 055-7 - fix(dracut-shutdown): add cleanup handler on failure diff --git a/fix-virture.patch b/fix-virture.patch new file mode 100644 index 0000000000000000000000000000000000000000..a37e4e2944c6e6942365e3e5dd5c3d9ddf73d651 --- /dev/null +++ b/fix-virture.patch @@ -0,0 +1,83 @@ +From 326e29ffd44eef2f0dc67f16b4075cc8efe23f70 Mon Sep 17 00:00:00 2001 +From: "Kang.Yihang" +Date: Thu, 2 Nov 2023 14:45:35 +0800 +Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98=E5=88=B0=E6=9C=AC=E5=9C=B0?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + dracut-functions.sh | 57 ++++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 56 insertions(+), 1 deletion(-) + +diff --git a/dracut-functions.sh b/dracut-functions.sh +index 5206bd2..1efad3b 100644 +--- a/dracut-functions.sh ++++ b/dracut-functions.sh +@@ -922,7 +922,62 @@ block_is_netdevice() { + block_is_nbd "$1" || block_is_iscsi "$1" || block_is_fcoe "$1" + } + ++# convert the driver name given by udevadm to the corresponding kernel module name ++get_module_name() { ++ local dev_driver ++ while read -r dev_driver; do ++ case "$dev_driver" in ++ mmcblk) ++ echo "mmc_block" ++ ;; ++ *) ++ echo "$dev_driver" ++ ;; ++ esac ++ done ++} ++ + # get the corresponding kernel modules of a /sys/class/*/* or/dev/* device + get_dev_module() { +- udevadm info -a "$1" | sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p' ++ #udevadm info -a "$1" | sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p' ++ local dev_attr_walk ++ local dev_drivers ++ local dev_paths ++ dev_attr_walk=$(udevadm info -a "$1") ++ dev_drivers=$(echo "$dev_attr_walk" \ ++ | sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p' \ ++ | get_module_name) ++ ++ # also return modalias info from sysfs paths parsed by udevadm ++ dev_paths=$(echo "$dev_attr_walk" | sed -n 's/.*\(\/devices\/.*\)'\'':/\1/p') ++ local dev_path ++ for dev_path in $dev_paths; do ++ local modalias_file="/sys$dev_path/modalias" ++ if [ -e "$modalias_file" ]; then ++ dev_drivers="$(printf "%s\n%s" "$dev_drivers" "$(cat "$modalias_file")")" ++ fi ++ done ++ ++ # if no kernel modules found and device is in a virtual subsystem, follow symlinks ++ if [[ -z $dev_drivers && $(udevadm info -q path "$1") == "/devices/virtual"* ]]; then ++ local dev_vkernel ++ local dev_vsubsystem ++ local dev_vpath ++ dev_vkernel=$(echo "$dev_attr_walk" | sed -n 's/\s*KERNELS=="\(\S\+\)"/\1/p' | tail -1) ++ dev_vsubsystem=$(echo "$dev_attr_walk" | sed -n 's/\s*SUBSYSTEMS=="\(\S\+\)"/\1/p' | tail -1) ++ dev_vpath="/sys/devices/virtual/$dev_vsubsystem/$dev_vkernel" ++ if [[ -n $dev_vkernel && -n $dev_vsubsystem && -d $dev_vpath ]]; then ++ local dev_links ++ local dev_link ++ dev_links=$(find "$dev_vpath" -maxdepth 1 -type l ! -name "subsystem" -exec readlink {} \;) ++ for dev_link in $dev_links; do ++ [[ -n $dev_drivers && ${dev_drivers: -1} != $'\n' ]] && dev_drivers+=$'\n' ++ dev_drivers+=$(udevadm info -a "$dev_vpath/$dev_link" \ ++ | sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p' \ ++ | get_module_name \ ++ | grep -v -e pcieport) ++ done ++ fi ++ fi ++ echo "$dev_drivers" + } +-- +2.36.1 +