]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Minor fixups to kernel module loading
authorVictor Lowther <victor.lowther@gmail.com>
Fri, 21 Aug 2009 03:21:33 +0000 (22:21 -0500)
committerVictor Lowther <victor.lowther@gmail.com>
Fri, 21 Aug 2009 03:21:33 +0000 (22:21 -0500)
Also rewrite filter_kernel_modules to make it a little easier to read.

dracut-functions

index f40d96b83e509d8fb4e8adbdffc87cc0fc71d7b3..b74be435d5f4cd69f06bb870b9823072bd62fb39 100755 (executable)
@@ -327,7 +327,8 @@ check_modules() {
 install_kmod_with_fw() {
     local modname=${1##*/} fwdir found
     modname=${modname%.ko}
-    inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}"
+    inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" || \
+       return 0 # no need to go further if the module is already installed
     for fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do
        found=''
        for fwdir in $fw_dir; do
@@ -365,18 +366,16 @@ for_each_kmod_dep() {
 # The behaviour of this function can vary depending on whether $hostonly is set.
 # If it is, we will only look at modules that are already in memory.
 # If it is not, we will look at all kernel modules
-# This function returns the full filenames of modules that match
+# This function returns the full filenames of modules that match $1
 filter_kernel_modules () (
     if [[ $hostonly = '' ]]; then
-       for modname in $(find "$srcmods/kernel/drivers" -name '*.ko'); do
-           "$1" "$modname" && echo "$modname"
-       done
+       filtercmd='find "$srcmods/kernel/drivers" -name "*.ko"'
     else
-       while read modname rest; do
-           modname=$(modinfo -F filename -k $kernel $modname)
-           "$1" "$modname" && echo "$modname"
-       done </proc/modules
+       filtercmd='cut -d " " -f 1 </proc/modules|xargs modinfo -F filename -k $kernel'
     fi
+    for modname in $(eval $filtercmd); do
+       "$1" "$modname" && echo "$modname"
+    done
 )
 
 # install kernel modules along with all their dependencies.
@@ -384,7 +383,8 @@ instmods() {
     [[ $no_kernel = yes ]] && return
     local mod mpargs modpath modname cmd
     while (($# > 0)); do
-       mod=${1%.ko}
+       mod=${1##*/}
+       mod=${mod%.ko}
        case $mod in
            =*) # This introduces 2 incompatible meanings for =* arguments
                 # to instmods.  We need to decide which one to keep.
@@ -401,8 +401,7 @@ instmods() {
                     # Must never run this diagnostic-only module
                     shift; continue;
                 ;;
-           *)  mod=${mod##*/}
-               # if we are already installed, skip this module and go on
+           *)  # if we are already installed, skip this module and go on
                # to the next one.
                [[ -f $initdir/$1 ]] && { shift; continue; }
                # If we are building a host-specific initramfs and this