dracut-functions: fixed instmods() return value

The FIPS installkernel() relies on the instmods() return value. So only
return 0, if the module and its dependencies were actually installed
correctly.
master
Harald Hoyer 2011-03-07 13:09:25 +01:00
parent 724b87a6f8
commit 0b440844bd
1 changed files with 19 additions and 10 deletions

View File

@ -667,8 +667,10 @@ check_module_dir() {
install_kmod_with_fw() { install_kmod_with_fw() {
local modname=${1##*/} fwdir found local modname=${1##*/} fwdir found
modname=${modname%.ko*} modname=${modname%.ko*}
# no need to go further if the module is already installed
[[ -e "${initdir}/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" ]] && return 0
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 return $?
for fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do for fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do
found='' found=''
for fwdir in $fw_dir; do for fwdir in $fw_dir; do
@ -681,6 +683,7 @@ install_kmod_with_fw() {
dinfo "Possible missing firmware \"${fw}\" for kernel module \"${mod}.ko\"" dinfo "Possible missing firmware \"${fw}\" for kernel module \"${mod}.ko\""
fi fi
done done
return 0
} }


# Do something with all the dependencies of a kernel module. # Do something with all the dependencies of a kernel module.
@ -692,11 +695,14 @@ install_kmod_with_fw() {
for_each_kmod_dep() { for_each_kmod_dep() {
local func=$1 kmod=$2 cmd modpapth options local func=$1 kmod=$2 cmd modpapth options
shift 2 shift 2
modprobe "$@" --ignore-install --quiet --show-depends $kmod | \ modprobe "$@" --ignore-install --show-depends $kmod 2>/dev/null | ( \
while read cmd modpath options; do local found=0;
[[ $cmd = insmod ]] || continue while read cmd modpath options; do
$func $modpath [[ $cmd = insmod ]] || continue
done $func ${modpath} || exit $?
found=1
done; [[ $found -eq 0 ]] && exit 1; exit 0;)
return $?
} }


# filter kernel modules to install certain modules that meet specific # filter kernel modules to install certain modules that meet specific
@ -727,6 +733,7 @@ filter_kernel_modules () (
instmods() { instmods() {
[[ $no_kernel = yes ]] && return [[ $no_kernel = yes ]] && return
local mod mpargs modpath modname cmd moddirname local mod mpargs modpath modname cmd moddirname
local ret=0
while (($# > 0)); do while (($# > 0)); do
mod=${1%.ko*} mod=${1%.ko*}
case $mod in case $mod in
@ -766,8 +773,10 @@ instmods() {
# it may require # it may require
for_each_kmod_dep install_kmod_with_fw $mod \ for_each_kmod_dep install_kmod_with_fw $mod \
--set-version $kernel ${moddirname} --set-version $kernel ${moddirname}
ret=$((ret+$?))
;; ;;
esac esac
shift shift
done done
return $ret
} }