]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dracut-init.sh: Add a helper for detect device kernel modules
authorKairui Song <kasong@redhat.com>
Mon, 12 Oct 2020 07:18:45 +0000 (15:18 +0800)
committerHarald Hoyer <harald@hoyer.xyz>
Fri, 30 Oct 2020 09:13:37 +0000 (10:13 +0100)
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>
dracut-functions.sh

index a8887dcc66e9c66582f664cec49c432aa3aa7032..e5e6884b0924dc80a4a77e38227b16844f33a94a 100755 (executable)
@@ -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'
+}