From: Kairui Song Date: Mon, 12 Oct 2020 07:18:45 +0000 (+0800) Subject: dracut-init.sh: Add a helper for detect device kernel modules X-Git-Tag: 051~37 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cbafcd0fc739f92a6a6a4777a102dae7c96a6c86;p=thirdparty%2Fdracut.git 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 --- diff --git a/dracut-functions.sh b/dracut-functions.sh index a8887dcc6..e5e6884b0 100755 --- a/dracut-functions.sh +++ b/dracut-functions.sh @@ -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' +}