dracut-init.sh: Add a helper for detect device kernel modules

Use udevadm to detect the required kernel modules to load a given
device. udevadm will follow the device chain, help detect all required
parent device drivers as well.

Signed-off-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
Kairui Song 2020-10-12 15:18:45 +08:00 committed by Harald Hoyer
parent ab17cb8515
commit cbafcd0fc7

View File

@ -889,3 +889,8 @@ block_is_fcoe() {
block_is_netdevice() {
block_is_nbd "$1" || block_is_iscsi "$1" || block_is_fcoe "$1"
}
# 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'
}