File s390-tools-sles11sp2-ziomon-parsing.patch of Package s390-tools
Description: ziomon: Fix handling of multiple multipath devices
Symptom: Specifying more than one multipath devices produces a 'device
does not seem to exist' error. E.g.
ziomon -i 10 -d 1 -o test /dev/mapper/mpatha /dev/mapper/mpathb
Check devices...
ziomon: The following devices do not seem to exist:
/dev/mapper/mpatha
Problem: The internal parsing logic that identifies the devices which
belong to multipath devices does not work in later versions of
the bash shell.
Solution: Switch the internal parsing logic to use a bash-independent
construct.
Problem-ID: 81158
---
ziomon/ziomon | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
--- a/ziomon/ziomon
+++ b/ziomon/ziomon
@@ -122,12 +122,16 @@ function parse_params() {
local tmp;
local i;
local error=0;
+ local args;
if [ $# -eq 0 ]; then
print_usage;
exit 1;
fi
+ args=`getopt -u -o hVd:fi:o:l:v -l help,verbose,duration:,force,interval-length:,outfile:,size-limit:,version -- $@`;
+ set -- $args;
+
let i=0;
while [ $# -gt 0 ]; do
case $1 in
@@ -154,13 +158,19 @@ function parse_params() {
--version|-v)
print_version;
exit 0;;
+ --) ;;
-*)
echo "$WRP_TOOLNAME: Invalid option -- $1";
echo "Try '$WRP_TOOLNAME --help' for more information.";
exit 1;;
*)
- WRP_DEVICES[$i]=$1;
- (( i++ ));;
+ echo ${WRP_DEVICES[@]} | grep -w $1 >/dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ WRP_DEVICES[$i]=$1;
+ (( i++ ));
+ else
+ debug "Skipping duplicate: $1";
+ fi
esac
shift;
done
@@ -501,15 +511,16 @@ function check_for_multipath_devices() {
tmp=`echo ${mp_arr[$i]} | awk '{print $1}'`;
for (( j=0; j<${#WRP_DEVICES[@]}; ++j )); do
if [ "$tmp" == "`basename ${WRP_DEVICES[$j]}`" ]; then
+ ddebug " multipath device found: $tmp";
WRP_DEVICES[$j]="";
devices_basenames[$j]="";
clean_devices;
(( i+=2 ));
- while [[ ! "${mp_arr[$i]:0:1}" =~ "[0-9a-zA-Z]" ]] && [ $i -lt ${#mp_arr[@]} ]; do
+ while [[ `echo "${mp_arr[$i]:0:1}" | grep -ve "[0-9a-zA-Z]"` ]] && [ $i -lt ${#mp_arr[@]} ]; do
if [ `echo ${mp_arr[$i]} | grep -e "[0-9]\{1,\}:[0-9]\{1,\}:[0-9]\{1,\}:[0-9]\{1,\}" | wc -l` -ne 0 ]; then
line="`echo ${mp_arr[$i]} | sed 's/.*\([0-9]\{1,\}:[0-9]\{1,\}:[0-9]\{1,\}:[0-9]\{1,\}\)/\1/'`";
checked_devs[${#checked_devs[@]}]=`echo $line | awk '{print "/dev/"$2}'`;
- ddebug " add ${checked_devs[${#checked_devs[@]}-1]}";
+ ddebug " adding ${checked_devs[${#checked_devs[@]}-1]}";
WRP_HOST_ADAPTERS[${#WRP_HOST_ADAPTERS[@]}]="host${line%%:*}";
WRP_LUNS[${#WRP_LUNS[@]}]=`echo $line | awk '{print $1}'`;
fi