From: Kairui Song Date: Tue, 20 Oct 2020 08:58:01 +0000 (+0800) Subject: dracut-functions: add a helper to check if kernel module is available X-Git-Tag: 051~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c050190f86c8e6e66087b7bd076f9ed117756d65;p=thirdparty%2Fdracut.git 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 --- 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