@@ -28,6 +28,22 @@ _have_root() {
return 0
}
+_module_file_exists()
+{
+ local ko_underscore=${1//-/_}.ko
+ local ko_hyphen=${1//_/-}.ko
+ local libpath
+ local -i count
+
+ libpath="/lib/modules/$(uname -r)/kernel"
+ count=$(find "$libpath" -name "$ko_underscore" -o \
+ -name "$ko_hyphen" | wc -l)
+ ((count)) && return 0
+ return 1
+}
+
+# Check that the specified module or driver is available, regardless of whether
+# it is built-in or built separately as a module.
_have_driver()
{
local modname="${1//-/_}"
@@ -41,12 +57,14 @@ _have_driver()
return 0
}
+# Check that the specified modules are available as loadable modules and not
+# built-in the kernel.
_have_modules() {
local missing=()
local module
for module in "$@"; do
- if ! modprobe -n -q "$module"; then
+ if ! _module_file_exists "${module}"; then
missing+=("$module")
fi
done