Skip to content

Commit

Permalink
make fewer calls to modinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
falconindy committed Jul 1, 2011
1 parent 21346da commit e800382
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
4 changes: 0 additions & 4 deletions geninit
Expand Up @@ -405,10 +405,6 @@ __build_preset() { # {{{
done
} # }}}

__kmodinfo() { # {{{
modinfo -b "$basedir" -0k $kernver "$@"
} # }}}

__ldd() { # {{{
LD_TRACE_LOADED_OBJECTS=1 "$ld_so" "$@"
} # }}}
Expand Down
40 changes: 22 additions & 18 deletions geninit.api
Expand Up @@ -74,34 +74,38 @@ add_module() { # {{{

(( $# )) || return 1

local -a firmware moddeps
local modpath= module= mod= dep=
local -a deps
local modpath= module= mod= dep= field= value=

module=${1%%.*}

read -rd '' modpath < <(__kmodinfo -n "$module" 2>/dev/null)
if [[ -z "$modpath" ]]; then
while IFS=':= ' read -r -d '' field value; do
case "$field" in
filename)
modpath=$value
;;
depends)
IFS=',' read -r -a deps <<< "$value"
for dep in "${deps[@]}"; do
add_module "$dep"
done
;;
firmware)
if [[ -e "$basedir/lib/firmware/$value" ]]; then
__add_file "/lib/firmware/$value" "$basedir/lib/firmware/$value"
fi
;;
esac
done < <(modinfo "$module" -b "$basedir" -0k $kernver 2>/dev/null)

if [[ -z $modpath ]]; then
error "Module not found: $module"
return 1
fi

__add_file "${modpath#$basedir}" "$modpath" 644
[[ $? = @(0|$EEXIST) ]] || return 1

# grab firmware
IFS=',' read -rd '' -a firmware < <(__kmodinfo -F firmware "$modpath")
for fw in "${firmware[@]}"; do
if [[ -e $basedir/lib/firmware/$fw ]]; then
__add_file "/lib/firmware/$fw" "$basedir/lib/firmware/$fw" 644
fi
done

# resolve deps
IFS=',' read -rd '' -a moddeps < <(__kmodinfo -F depends "$modpath")
for dep in "${moddeps[@]}"; do
add_module "$dep"
done

# add in any quirks
for mod in ${modquirks[$module]}; do
add_module "$mod"
Expand Down

0 comments on commit e800382

Please sign in to comment.