Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(RHEL-55708) rhel 9 fix 55708 #99

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion dracut-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -967,12 +967,41 @@ 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() {
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')
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
Expand All @@ -989,6 +1018,7 @@ get_dev_module() {
[[ -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
Expand Down
Loading