summaryrefslogtreecommitdiff
path: root/dracut-functions
diff options
context:
space:
mode:
authorVictor Lowther <victor.lowther@gmail.com>2009-08-15 14:17:19 -0500
committerVictor Lowther <victor.lowther@gmail.com>2009-08-16 15:28:45 -0500
commitddfd1d10a08329d94f320aa0a22d8fec2c047dad (patch)
tree65afd09f48a70f82dad2b814b4a5902e0b58feca /dracut-functions
parent0c1a8ebc37f1bdb19cbd65b98266e554e8f2e92b (diff)
Split kernel module loading into smaller chunks.
This prepares to more tightly integrate dracut-gencmdline with the rest of the dracut scripts
Diffstat (limited to 'dracut-functions')
-rwxr-xr-xdracut-functions67
1 files changed, 40 insertions, 27 deletions
diff --git a/dracut-functions b/dracut-functions
index 79982ce..c57174c 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -31,7 +31,7 @@ if ! [[ $dracutlogfile ]]; then
dracutlogfile=/tmp/dracut.log
[[ -w $dracutlogfile ]] || dracutlogfile=/tmp/dracut.log
>"$dracutlogfile"
-fi
+ fi
dwarning() {
echo "W: $@" >&2
@@ -275,7 +275,43 @@ check_modules() {
done
}
-# install kernel modules, and handle installing all their dependencies as well.
+# Install a single kernel module along with any firmware it may require.
+# $1 = full path to kernel module to install
+install_kmod_with_fw() {
+ local modname=${1##*/} fwdir found
+ modname=${modname%.ko}
+ inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}"
+ for fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do
+ found=''
+ for fwdir in $fw_dir; do
+ if [[ -d $fwdir && -f $fwdir/$fw ]]; then
+ inst_simple "$fwdir/$fw" "/lib/firmware/$fw"
+ found=yes
+ fi
+ done
+ if [[ $found != yes ]]; then
+ dwarning "Possible missing firmware ${fw} for module ${mod}.ko"
+ fi
+ done
+}
+
+# Do something with all the dependencies of a kernel module.
+# Note that kernel modules depend on themselves using the technique we use
+# $1 = function to call for each dependency we find
+# It will be passed the full path to the found kernel module
+# $2 = module to get dependencies for
+# rest of args = arguments to modprobe
+for_each_kmod_dep() {
+ local func=$1 kmod=$2 cmd modpapth options
+ shift 2
+ modprobe "$@" --ignore-install --show-depends $kmod 2>/dev/null | \
+ while read cmd modpath options; do
+ [[ $cmd = insmod ]] || continue
+ $func $modpath
+ done
+}
+
+# install kernel modules along with all their dependencies.
instmods() {
[[ $no_kernel = yes ]] && return
local mod mpargs modpath modname cmd
@@ -308,31 +344,8 @@ instmods() {
}
# ok, load the module, all its dependencies, and any firmware
# it may require
- modprobe $mpargs --ignore-install --set-version $kernel -d ${srcmods%%/lib/modules/*}/ \
- --show-depends $mod 2>/dev/null | \
- while read cmd modpath options; do
- [[ $cmd = insmod ]] || continue
- modname=${modpath##*/}
- modname=${modname%.ko}
- if [[ ${mod/-/_} != ${modname/-/_} ]]; then
- dinfo "Installing dependencies for $mod ($modpath)"
- instmods $mpargs $modname
- fi
- inst_simple "$modpath" "/lib/modules/$kernel/${modpath##*/lib/modules/$kernel/}"
- for fw in $(modinfo -k $kernel -F firmware $modpath 2>/dev/null); do
- unset found
- IFS=:
- for fwdir in $fw_dir; do
- if [ -d "$fwdir" -a -f $fwdir/$fw ]; then
- inst_simple "$fwdir/$fw" "/lib/firmware/$fw"
- found=yes
- fi
- done
- if [[ $found != yes ]]; then
- dwarning "Possible missing firmware ${fw} for module ${mod}.ko"
- fi
- done
- done
+ for_each_kmod_dep install_kmod_with_fw $mod \
+ --set-version $kernel -d ${srcmods%%/lib/modules/*}/
;;
esac
shift