From: Victor Lowther Date: Thu, 20 Aug 2009 20:52:45 +0000 (-0500) Subject: Abstract out hostonly vs. generic module installation differences. X-Git-Tag: 001~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=240cc7c4806a6f226400ac55fb311deb090bfe82;p=thirdparty%2Fdracut.git Abstract out hostonly vs. generic module installation differences. 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. --- diff --git a/dracut-functions b/dracut-functions index 0b5f1f869..f40d96b83 100755 --- a/dracut-functions +++ b/dracut-functions @@ -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