]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dracut-functions: fixed instmods() return value
authorHarald Hoyer <harald@redhat.com>
Mon, 7 Mar 2011 12:09:25 +0000 (13:09 +0100)
committerHarald Hoyer <harald@redhat.com>
Mon, 7 Mar 2011 12:37:18 +0000 (13:37 +0100)
The FIPS installkernel() relies on the instmods() return value. So only
return 0, if the module and its dependencies were actually installed
correctly.

dracut-functions

index d8827fcc2e2ad84d4f1748e9c76f0659f39ec3b5..594cc0e281fd397f353e473a10192f515da6ae7e 100755 (executable)
@@ -667,8 +667,10 @@ check_module_dir() {
 install_kmod_with_fw() {
     local modname=${1##*/} fwdir found
     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/}" || \
-        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
         found=''
         for fwdir in $fw_dir; do
@@ -681,6 +683,7 @@ install_kmod_with_fw() {
             dinfo "Possible missing firmware \"${fw}\" for kernel module \"${mod}.ko\""
         fi
     done
+    return 0
 }
 
 # Do something with all the dependencies of a kernel module.
@@ -690,13 +693,16 @@ install_kmod_with_fw() {
 # $2 = module to get dependencies for
 # rest of args = arguments to modprobe
 for_each_kmod_dep() {
-    local func=$1 kmod=$2 cmd modpapth options
+    local func=$1 kmod=$2 cmd modpapth options 
     shift 2
-    modprobe "$@" --ignore-install --quiet --show-depends $kmod | \
-        while read cmd modpath options; do
-        [[ $cmd = insmod ]] || continue
-        $func $modpath
-    done
+    modprobe "$@" --ignore-install --show-depends $kmod 2>/dev/null | ( \
+        local found=0;
+       while read cmd modpath options; do
+           [[ $cmd = insmod ]] || continue
+           $func ${modpath} || exit $?
+            found=1
+        done; [[ $found -eq 0 ]] && exit 1; exit 0;)
+    return $?
 }
 
 # filter kernel modules to install certain modules that meet specific
@@ -727,6 +733,7 @@ filter_kernel_modules () (
 instmods() {
     [[ $no_kernel = yes ]] && return
     local mod mpargs modpath modname cmd moddirname
+    local ret=0
     while (($# > 0)); do
         mod=${1%.ko*}
         case $mod in
@@ -761,13 +768,15 @@ instmods() {
                 # old version of modprobe which doesn't have '-d' option.
                 moddirname=${srcmods%%/lib/modules/*}
                 [[ -n ${moddirname} ]] && moddirname="-d ${moddirname}/"
-
+                
                 # ok, load the module, all its dependencies, and any firmware
                 # it may require
                 for_each_kmod_dep install_kmod_with_fw $mod \
                     --set-version $kernel ${moddirname}
+                ret=$((ret+$?))
                 ;;
-    esac      
-    shift
+        esac      
+        shift
     done
+    return $ret
 }