]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dracut-functions: add a helper to check if kernel module is available
authorKairui Song <kasong@redhat.com>
Tue, 20 Oct 2020 08:58:01 +0000 (16:58 +0800)
committerDaniel Molkentin <daniel@molkentin.de>
Wed, 21 Oct 2020 15:04:00 +0000 (17:04 +0200)
It's like check_kernel_config, help to check if a kernel module is
enabled (cover built-in or compiled module case).

Signed-off-by: Kairui Song <kasong@redhat.com>
dracut-functions.sh

index e0ca75742ea2b33720a0843af69445e23eb1d1b0..5304520688792991c56704c84984d70c8a0c7154 100755 (executable)
@@ -674,6 +674,11 @@ check_kernel_config()
     return 1
 }
 
+# 0 if the kernel module is either built-in or available
+# 1 if the kernel module is not enabled
+check_kernel_module() {
+    modprobe -S $kernel --dry-run $1 &>/dev/null || return 1
+}
 
 # get_cpu_vendor
 # Only two values are returned: AMD or Intel