add filter_kernel_modules_by_path() to speed up module search
authorHarald Hoyer <harald@redhat.com>
Fri, 12 Aug 2011 08:29:00 +0000 (10:29 +0200)
committerHarald Hoyer <harald@redhat.com>
Fri, 12 Aug 2011 08:29:00 +0000 (10:29 +0200)
dracut-functions
modules.d/40network/module-setup.sh
modules.d/90multipath/module-setup.sh
modules.d/95iscsi/module-setup.sh

index 991e0ebc9964841ff14e8584a6fc9bb017c69cab..d44695937473ebac871aab4232b22f3e53645a8c 100755 (executable)
@@ -810,6 +810,36 @@ for_each_kmod_dep() {
     return $?
 }
 
+# filter kernel modules to install certain modules that meet specific
+# requirements.
+# $1 = search only in subdirectory of /kernel/$1
+# $2 = function to call with module name to filter.
+#      This function will be passed the full path to the module to test.
+# 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 $1
+filter_kernel_modules_by_path () (
+    local _modname _filtercmd
+    if ! [[ $hostonly ]]; then
+        _filtercmd='find "$srcmods/kernel/$1" "$srcmods/extra"'
+        _filtercmd+=' "$srcmods/weak-updates" -name "*.ko" -o -name "*.ko.gz"'
+        _filtercmd+=' 2>/dev/null'
+    else
+        _filtercmd='cut -d " " -f 1 </proc/modules|xargs modinfo -F filename '
+        _filtercmd+='-k $kernel 2>/dev/null'
+    fi
+    for _modname in $(eval $_filtercmd); do
+        case $_modname in
+            *.ko) "$2" "$_modname" && echo "$_modname";;
+            *.ko.gz) gzip -dc "$_modname" > $initdir/$$.ko
+                $2 $initdir/$$.ko && echo "$_modname"
+                rm -f $initdir/$$.ko
+                ;;
+        esac
+    done
+)
+
 # filter kernel modules to install certain modules that meet specific
 # requirements.
 # $1 = function to call with module name to filter.
index 331354040ccb52f14a7905e38314d61ee828898d..1cb7ebcf4b5b0c9d4edc465f9a121342d5d35796 100755 (executable)
@@ -32,7 +32,7 @@ installkernel() {
             [[ ! $1 =~ $_unwanted_drivers ]]
     }
 
-    instmods $(filter_kernel_modules net_module_test)
+    instmods $(filter_kernel_modules_by_path drivers/net net_module_test)
 
     instmods ecb arc4
     # bridge modules
index 285218b3a121126bc980aafb2b7271ce7451cfae..e9a47fc823140e07a3e7d9e0826e82d74f5eb019 100755 (executable)
@@ -38,7 +38,8 @@ installkernel() {
         egrep -q "$mpfuncs" "$1"
     }
 
-    instmods $(filter_kernel_modules mp_mod_test)
+    instmods $(filter_kernel_modules_by_path drivers/scsi mp_mod_test)
+    instmods $(filter_kernel_modules_by_path drivers/md mp_mod_test)
 }
 
 install() {
index b25d422c4d31a21189c3120c29e30941ef4ae8ae..3db40eafcc315d84c76badaa0deab6dfb33d4e7d 100755 (executable)
@@ -46,7 +46,7 @@ installkernel() {
         local _iscsifuncs='iscsi_register_transport'
         fgrep -q "$_iscsifuncs" "$1"
     }
-    instmods $(filter_kernel_modules iscsi_module_test)
+    instmods $(filter_kernel_modules_by_path drivers/scsi iscsi_module_test)
 }
 
 install() {