From cbafcd0fc739f92a6a6a4777a102dae7c96a6c86 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 12 Oct 2020 15:18:45 +0800 Subject: [PATCH] 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 --- dracut-functions.sh | 5 +++++ 1 file changed, 5 insertions(+) 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' +} -- 2.47.3