summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2011-07-01 01:06:13 +0200
committerDave Reisner <dreisner@archlinux.org>2011-07-01 05:05:36 +0200
commit549af8c1b9a72cacf8cda41f8dd4b76983930945 (patch)
treeab8b08c58bbb22d38c3433e609ade6d14d9eb274
parent726ff1f9466847cbe27e807cf79560070651781c (diff)
downloadmkinitcpio-549af8c1b9a72cacf8cda41f8dd4b76983930945.tar.gz
mkinitcpio-549af8c1b9a72cacf8cda41f8dd4b76983930945.tar.xz
functions: reduce calls to modinfo
Cut back to a single call to modinfo, instead of 3, which yields roughly a 30% decrease in execution time for a single run of add_module. This of course varies by module but it's an overall win. Suggested-by: Dan McGee <dan@archlinux.org> Signed-off-by: Dave Reisner <dreisner@archlinux.org>
-rw-r--r--functions51
1 files changed, 24 insertions, 27 deletions
diff --git a/functions b/functions
index 3e3fee9..1aea1a7 100644
--- a/functions
+++ b/functions
@@ -56,14 +56,6 @@ in_array() {
return 1 # Not Found
}
-kmodinfo() {
- # A wrapper around modinfo, which is aware of our $BASEDIR and
- # $KERNELVERSION
- # $@: args to modinfo
-
- modinfo -b "$BASEDIR" -k "$KERNELVERSION" "$@" 2>/dev/null
-}
-
auto_modules() {
# Perform auto detection of modules via sysfs.
@@ -171,34 +163,39 @@ add_module() {
# discovered and added.
# $1: module name
- local module path fw dep deps
+ local module path dep deps field value
module=${1%.ko*}
# skip expensive stuff if this module has already been added
in_array "${module//-/_}" "${ADDED_MODULES[@]}" && return
- path=$(kmodinfo -0F filename "$module")
- if [[ $path ]]; then
- # get module firmware
- while read -r -d '' fw; do
- if [[ -e "$BASEDIR/lib/firmware/$fw" ]]; then
- add_file "/lib/firmware/$fw"
- fi
- done < <(kmodinfo -0F firmware "$module")
-
- # get module depends
- IFS=',' read -r -d '' -a deps < <(kmodinfo -0F depends "$module")
- for dep in "${deps[@]}"; do
- add_module "$dep"
- done
-
- ADDED_MODULES+=("${module//-/_}")
- add_file "${path#$BASEDIR}" || return
- else
+ while IFS=':= ' read -r -d '' field value; do
+ case "$field" in
+ filename)
+ path=$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" 644
+ fi
+ ;;
+ esac
+ done < <(modinfo -b "$BASEDIR" -k "$KERNELVERSION" -0 "$module" 2>/dev/null)
+
+ if [[ -z $path ]]; then
error "module '$module' not found"
return 1
fi
+ add_file "${path#$BASEDIR}"
+ ADDED_MODULES+=("${module//-/_}")
+
# explicit module depends
case "$module" in
fat) add_module "nls_cp437" ;;