]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Abstract out hostonly vs. generic module installation differences.
authorVictor Lowther <victor.lowther@gmail.com>
Thu, 20 Aug 2009 20:52:45 +0000 (15:52 -0500)
committerVictor Lowther <victor.lowther@gmail.com>
Thu, 20 Aug 2009 20:52:45 +0000 (15:52 -0500)
This introduces filter_kernel_modules, which should be used to install
all kernel modules that match whatever criteria you want.

If running in --hostonly, filter_kernel_modules will only consider
modules that are loaded in the kernel, otherwise it will consider
all the modules installed on the system for the appropriate kernel.

This drastically reduces initramfs generation time when using --hostonly
by eliminating lots of unneeded filesystem activity.

dracut-functions
modules.d/40network/installkernel
modules.d/90kernel-modules/installkernel

index 0b5f1f86913ad6c1e82060e2909e457f3ef811a9..f40d96b83e509d8fb4e8adbdffc87cc0fc71d7b3 100755 (executable)
@@ -358,6 +358,27 @@ for_each_kmod_dep() {
     done
 }
 
+# filter kernel modules to install certian modules that meet specific
+# requirements.
+# $1 = 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
+filter_kernel_modules () (
+    if [[ $hostonly = '' ]]; then
+       for modname in $(find "$srcmods/kernel/drivers" -name '*.ko'); do
+           "$1" "$modname" && echo "$modname"
+       done
+    else
+       while read modname rest; do
+           modname=$(modinfo -F filename -k $kernel $modname)
+           "$1" "$modname" && echo "$modname"
+       done </proc/modules
+    fi
+)
+
 # install kernel modules along with all their dependencies.
 instmods() {
     [[ $no_kernel = yes ]] && return
index 5235714ef6fb4fc3601474e3d91f322a8ef1db8d..fe878370394143d7eec05630cec94e548f364e47 100755 (executable)
@@ -1,15 +1,16 @@
 #!/bin/bash
 # Include wired net drivers, excluding wireless
-for modname in $(find "$srcmods/kernel/drivers" -name '*.ko'); do
-  if nm -uPA $modname | egrep -q 'eth_type_trans|register_virtio_device' \
-       && ! nm -uPA $modname | egrep -q 'iw_handler_get_spy'; then
-    if echo "$modname" | egrep -q '/wireless/|/isdn/|/uwb/'; then
-      continue
-    else
-      instmods $modname 
-    fi
-  fi
-done
+
+net_module_test() {
+    local net_drivers='eth_type_transfer|register_virtio_device'
+    local unwanted_drivers='/(wireless|isdn|uwb)/'
+    nm -uPA "$1" | egrep -q $net_drivers && \
+       nm -uPA "$1" | egrep -qv 'iw_handler_get_spy' && \
+       [[ ! $1 =~ $unwanted_drivers ]]
+}
+
+instmods $(filter_kernel_modules net_module_test)
+    
 instmods ecb arc4
 # bridge modules
 instmods bridge stp llc
index 253cdc06ea2599ab453e265c6860834ed60312ae..08c0c740c1c41a16bc3cdb3d748185c9825e13fe 100755 (executable)
@@ -1,27 +1,19 @@
 #!/bin/bash
 if [[ -z $drivers ]]; then
-  drivers="sd_mod"
-  # Include block controller drivers
-  blockfuncs='ata_scsi_ioctl|scsi_add_host|blk_init_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device'
-  if [[ $hostonly = "" ]]; then
-      for modname in $(find "$srcmods/kernel/drivers" -name '*.ko'); do
-         if nm -uPA $modname | egrep -q "$blockfuncs"; then
-             drivers="${drivers} $modname"
-         fi
-      done
-      drivers="${drivers} =fs"
-  else
-      while read modname rest; do
-         modname=$(modinfo -F filename -k $kernel $modname)
-         if nm -uPA $modname |egrep -q "$blockfuncs"; then
-             drivers="${drivers} $modname"
-         fi
-      done </proc/modules
-      instmods $(get_fs_type "/dev/block/$(find_root_block_device)")
-  fi
-  instmods $drivers
-  # hardcoded list of exceptions
-  rm -fr ${initdir}/lib/modules/*/kernel/fs/ocfs2
+    block_module_test() {
+       local blockfuncs='ata_scsi_ioctl|scsi_add_host|blk_init_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device'
+
+        nm -uPA "$1" | egrep -q "$blockfuncs"
+    }
+    instmods sd_mod $(filter_kernel_modules block_module_test)
+    # if not on hostonly mode, install all known filesystems.
+    if [[ $hostonly = '' ]]; then
+       instmods '=fs'
+    else
+       instmods $(get_fs_type "/dev/block/$(find_root_block_device)")
+    fi
+    # hardcoded list of exceptions
+    rm -fr ${initdir}/lib/modules/*/kernel/fs/ocfs2
 else
   instmods $drivers
 fi