From 7997d8764313d5dc10689e3b6bbdde3dcc373498 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Fri, 22 Jun 2012 15:33:15 +0200
Subject: [PATCH] multipath/module-setup.sh:installkernel() fix return code
---
modules.d/90multipath/module-setup.sh | 43 ++++++++++++++++++++++++---------
1 file changed, 31 insertions(+), 12 deletions(-)
diff --git a/modules.d/90multipath/module-setup.sh b/modules.d/90multipath/module-setup.sh
index 0e8857c..8791560 100755
--- a/modules.d/90multipath/module-setup.sh
+++ b/modules.d/90multipath/module-setup.sh
@@ -32,23 +32,42 @@ depends() {
installkernel() {
local _ret
- set +x
+ local _arch=$(uname -m)
mp_mod_filter() {
- local _mpfuncs='scsi_register_device_handler|dm_dirty_log_type_register|dm_register_path_selector|dm_register_target'
- local _f
- while read _f; do case "$_f" in
- *.ko) [[ $(< $_f) =~ $_mpfuncs ]] && echo "$_f" ;;
- *.ko.gz) [[ $(gzip -dc <$_f) =~ $_mpfuncs ]] && echo "$_f" ;;
- *.ko.xz) [[ $(xz -dc <$_f) =~ $_mpfuncs ]] && echo "$_f" ;;
- esac
- done
+ local _funcs='scsi_register_device_handler|dm_dirty_log_type_register|dm_register_path_selector|dm_register_target'
+ # subfunctions inherit following FDs
+ local _merge=8 _side2=9
+ function bmf1() {
+ local _f
+ while read _f; do
+ case "$_f" in
+ *.ko) [[ $(< $_f) =~ $_funcs ]] && echo "$_f" ;;
+ *.ko.gz) [[ $(gzip -dc <$_f) =~ $_funcs ]] && echo "$_f" ;;
+ *.ko.xz) [[ $(xz -dc <$_f) =~ $_funcs ]] && echo "$_f" ;;
+ esac
+ done
+ return 0
+ }
+
+ function rotor() {
+ local _f1 _f2
+ while read _f1; do
+ echo "$_f1"
+ if read _f2; then
+ echo "$_f2" 1>&${_side2}
+ fi
+ done | bmf1 1>&${_merge}
+ return 0
+ }
+ # Use two parallel streams to filter alternating modules.
+ set +x
+ eval "( ( rotor ) ${_side2}>&1 | bmf1 ) ${_merge}>&1"
+ [[ $debug ]] && set -x
+ return 0
}
( find_kernel_modules_by_path drivers/scsi; if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then find_kernel_modules_by_path drivers/s390/scsi; fi;
find_kernel_modules_by_path drivers/md ) | mp_mod_filter | instmods
- _ret=$?
- [[ $debug ]] && set -x
- return $_ret
}
install() {