From 73189f9515cc40015381a24731205c493107f04f Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 26 Jun 2016 12:28:39 -0400 Subject: handle the case of modinfo returning multiple modules This is true of more and more modules with the advent of aliases, e.g. $ modinfo -F filename crc32c /lib/modules/4.6.2-rampage/kernel/arch/x86/crypto/crc32c-intel.ko.gz /lib/modules/4.6.2-rampage/kernel/crypto/crc32c_generic.ko.gz --- functions | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/functions b/functions index 0d998a3..0252ab5 100644 --- a/functions +++ b/functions @@ -348,8 +348,8 @@ add_module() { # discovered and added. # $1: module name - local module= path= softdeps= deps= field= value= firmware=() - local ign_errors=0 + local target= module= softdeps= deps= field= value= firmware=() + local ign_errors=0 found=0 [[ $KERNELVERSION == none ]] && return 0 @@ -358,15 +358,19 @@ add_module() { set -- "${1%?}" fi - module=${1%.ko*} + target=${1%.ko*} target=${target//-/_} # skip expensive stuff if this module has already been added - (( _addedmodules["${module//-/_}"] )) && return + (( _addedmodules["$target"] )) && return while IFS=':= ' read -r -d '' field value; do case "$field" in filename) - path=$value + found=1 + module=${value##*/} module=${module%.ko*} + quiet "adding module: %s" "$module" + _modpaths["$value"]=1 + _addedmodules["${module//-/_}"]=1 ;; depends) IFS=',' read -r -a deps <<< "$value" @@ -383,26 +387,21 @@ add_module() { done ;; esac - done < <(modinfo -b "$_optmoduleroot" -k "$KERNELVERSION" -0 "$module" 2>/dev/null) + done < <(modinfo -b "$_optmoduleroot" -k "$KERNELVERSION" -0 "$target" 2>/dev/null) - if [[ -z $path ]]; then + if (( !found )); then (( ign_errors )) && return 0 - error "module not found: \`%s'" "$module" + error "module not found: \`%s'" "$target" return 1 fi if (( ${#firmware[*]} )); then add_firmware "${firmware[@]}" || - warning 'Possibly missing firmware for module: %s' "$module" + warning 'Possibly missing firmware for module: %s' "$target" fi - # aggregate modules and add them all at once to save some forks - quiet "adding module: %s" "$1" - _modpaths["$path"]=1 - _addedmodules["${module//-/_}"]=1 - # handle module quirks - case $module in + case $target in fat) add_module "nls_cp437?" add_module "nls_iso8859-1?" -- cgit v1.2.3-24-g4f1b