From c050190f86c8e6e66087b7bd076f9ed117756d65 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 20 Oct 2020 16:58:01 +0800 Subject: [PATCH] dracut-functions: add a helper to check if kernel module is available 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 --- dracut-functions.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dracut-functions.sh b/dracut-functions.sh index e0ca75742..530452068 100755 --- a/dracut-functions.sh +++ b/dracut-functions.sh @@ -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 -- 2.47.3