From 0355cd14d3e5edc0776a81e3b97ff8d7b156affc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Hor=C3=A1k?= Date: Fri, 25 May 2012 09:04:27 +0200 Subject: [PATCH] improve DASD parameters handling in normalize_dasd_arg (#824807) --- normalize_dasd_arg | 146 ++++++++++++++++++++++++--------------------- s390utils.spec | 5 +- 2 files changed, 81 insertions(+), 70 deletions(-) diff --git a/normalize_dasd_arg b/normalize_dasd_arg index 2f622e3..3e7afa6 100644 --- a/normalize_dasd_arg +++ b/normalize_dasd_arg @@ -39,74 +39,82 @@ function canonicalize_devno() } read DASD -for dasditem in $(echo $DASD |sed 's/,/ /g') - do - unset range features lo hi attrs devno lodevno hidevno devbusid sys - case $dasditem in - autodetect|probeonly|nopav|nofcx|"") continue ;; # these don't gen a config - *) - IFS='(' - read range features <<< "$dasditem" - unset IFS - lo=${range%%-*} - [[ "$lo" =~ (^[[:xdigit:]]+\.[0-3]\.[[:xdigit:]]{4}$)|(^[[:xdigit:]]{3,4}$) ]] - case $? in - 0) # string matched the pattern - lo=$(canonicalize_devno $lo) ;; - 1) # string did not match the pattern - echo $"Incorrect format for lower bound of DASD range $range: $lo" - exit 1 - ;; - 2) echo "l.$LINENO: syntax error in regex of match operator =~, code needs to be fixed" 1>&2 ;; - *) echo "l.$LINENO: unexpected return code of regex match operator =~, code needs to be fixed" 1>&2 ;; - esac - if [ "${range//*-*/}" = "" ]; then - hi=${range##*-} - [[ "$hi" =~ (^[[:xdigit:]]+\.[0-3]\.[[:xdigit:]]{4}$)|(^[[:xdigit:]]{3,4}$) ]] - case $? in - 0) # string matched the pattern - hi=$(canonicalize_devno $hi) - if [ "${lo%.*}" != "${hi%.*}" ]; then - echo $"Prefixes of DASD range $range do not match: ${lo%.*} != ${hi%.*}" +# See if we've gotten a format like ,feature or ,, +[[ "$DASD" =~ (\,*=[[:digit:]]) ]] +case $? in + # case of 0 is features, just turn the comma into a space + 0) echo $DASD |sed 's/,/ /g';; + *) # We've got no features, do things normally + for dasditem in $(echo $DASD |sed 's/,/ /g') + do + unset range features lo hi attrs devno lodevno hidevno devbusid sys + case $dasditem in + autodetect|probeonly|nopav|nofcx|"") continue ;; # these don't gen a config + *) + IFS='(' + read range features <<< "$dasditem" + unset IFS + lo=${range%%-*} + [[ "$lo" =~ (^[[:xdigit:]]+\.[0-3]\.[[:xdigit:]]{4}$)|(^[[:xdigit:]]{3,4}$) ]] + case $? in + 0) # string matched the pattern + lo=$(canonicalize_devno $lo) ;; + 1) # string did not match the pattern + echo $"Incorrect format for lower bound of DASD range $range: $lo" 1>&2 exit 1 - fi - ;; - 1) # string did not match the pattern - echo $"Incorrect format for upper bound of DASD range $range: $hi" - exit 1 - ;; - 2) echo "l.$LINENO: syntax error in regex of match operator =~, code needs to be fixed" 1>&2 ;; - *) echo "l.$LINENO: unexpected return code of regex match operator =~, code needs to be fixed" 1>&2 ;; - esac - fi - if [ "${features//*)/}" != "" ]; then - echo $"Missing closing parenthesis at features of DASD range $range: ($features" - exit 1 - fi - if [ -n "$features" ]; then - attrs="" - features="${features%)}" - for feature in $(echo $features |sed 's/:/\n/g'); do - case $feature in - ro) attrs=$attrs" readonly" ;; - diag) attrs=$attrs" use_diag" ;; - erplog|failfast) attrs=$attrs" "$feature ;; - *) echo $"Unknown DASD feature for device range $range: $feature" - exit 1 - ;; + ;; + 2) echo "l.$LINENO: syntax error in regex of match operator =~, code needs to be fixed" 1>&2 ;; + *) echo "l.$LINENO: unexpected return code of regex match operator =~, code needs to be fixed" 1>&2 ;; esac - done - fi - [ -z "$hi" ] && hi=$lo - lodevno=$((0x${lo##*.})) - hidevno=$((0x${hi##*.})) - for ((devno=$lodevno; $devno <= $hidevno; ++devno)); do - devbusid=$(printf "%s.%04x" ${lo%.*} $devno) - echo -n "$devbusid" - for attr in $attrs; do - echo -n " $attr=1" - done - echo - done - esac -done + if [ "${range//*-*/}" = "" ]; then + hi=${range##*-} + [[ "$hi" =~ (^[[:xdigit:]]+\.[0-3]\.[[:xdigit:]]{4}$)|(^[[:xdigit:]]{3,4}$) ]] + case $? in + 0) # string matched the pattern + hi=$(canonicalize_devno $hi) + if [ "${lo%.*}" != "${hi%.*}" ]; then + echo $"Prefixes of DASD range $range do not match: ${lo%.*} != ${hi%.*}" 1>&2 + exit 1 + fi + ;; + 1) # string did not match the pattern + echo $"Incorrect format for upper bound of DASD range $range: $hi" 1>&2 + exit 1 + ;; + 2) echo "l.$LINENO: syntax error in regex of match operator =~, code needs to be fixed" 1>&2 ;; + *) echo "l.$LINENO: unexpected return code of regex match operator =~, code needs to be fixed" 1>&2 ;; + esac + fi + if [ "${features//*)/}" != "" ]; then + echo $"Missing closing parenthesis at features of DASD range $range: ($features" 1>&2 + exit 1 + fi + if [ -n "$features" ]; then + attrs="" + features="${features%)}" + for feature in $(echo $features |sed 's/:/\n/g'); do + case $feature in + ro) attrs=$attrs" readonly" ;; + diag) attrs=$attrs" use_diag" ;; + erplog|failfast) attrs=$attrs" "$feature ;; + *) echo $"Unknown DASD feature for device range $range: $feature" 1>&2 + exit 1 + ;; + esac + done + fi + [ -z "$hi" ] && hi=$lo + lodevno=$((0x${lo##*.})) + hidevno=$((0x${hi##*.})) + for ((devno=$lodevno; $devno <= $hidevno; ++devno)); do + devbusid=$(printf "%s.%04x" ${lo%.*} $devno) + echo -n "$devbusid" + for attr in $attrs; do + echo -n " $attr=1" + done + echo + done + esac + done + ;; +esac diff --git a/s390utils.spec b/s390utils.spec index 463d374..285993b 100644 --- a/s390utils.spec +++ b/s390utils.spec @@ -8,7 +8,7 @@ Name: s390utils Summary: Utilities and daemons for IBM System/z Group: System Environment/Base Version: 1.16.0 -Release: 8%{?dist} +Release: 9%{?dist} Epoch: 2 License: GPLv2 and GPLv2+ and CPL Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -867,6 +867,9 @@ User-space development files for the s390/s390x architecture. %changelog +* Fri May 25 2012 Dan Horák 2:1.16.0-9 +- improve DASD parameters handling in normalize_dasd_arg (#824807) + * Wed May 23 2012 Dan Horák 2:1.16.0-8 - add normalize_dasd_arg script (#823078)