From 803b87e324d704036c5bef1d1daba6cf5b69b668 Mon Sep 17 00:00:00 2001 From: Stefan Haberland Date: Wed, 12 Oct 2022 15:55:43 +0200 Subject: [PATCH] zconf/lsdasd: add Copy Pair output option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add an option -P|--copy-pairs to show all DASD devices with copy relations set up in the system and their roles. The output looks like: # ./s390-tools/zconf/lsdasd -h [...] -P|--copy-pairs Print information about copy pairs. # ./s390-tools/zconf/lsdasd -P Bus-ID Role Name Paired devices ================================================================================ 0.0.9700 primary dasdd 0.0.9740,0.0.9743,0.0.9744,0.0.9745 0.0.9740 secondary 0.0.9700 0.0.9701 primary dasdf 0.0.9741 0.0.9741 secondary 0.0.9701 0.0.9702 primary dasdh 0.0.9742 0.0.9742 secondary 0.0.9702 Signed-off-by: Stefan Haberland Reviewed-by: Jan Hoeppner Signed-off-by: Jan Höppner --- zconf/lsdasd | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/zconf/lsdasd b/zconf/lsdasd index 8b2cc0ff..59720b63 100755 --- a/zconf/lsdasd +++ b/zconf/lsdasd @@ -35,6 +35,8 @@ function PrintUsage() { Print extended information about DASDs. -H|--host-access-list Print information about hosts accessing DASDs. + -P|--copy-pairs + Print information about copy pairs. -v|--verbose For compatibility/future use. Currently ignored. --version @@ -292,6 +294,8 @@ function gatherDeviceData() { uid elif [[ "$OUTPUT" == "host" ]]; then host + elif [[ "$OUTPUT" == "copy" ]]; then + copy else newoutput fi @@ -769,6 +773,41 @@ printf "\n"; rm -f $temp } +# pad sortkey with given number zeroes +function padSortKey() +{ + local LEN=$1 + for (( i=0; i<$LEN; i++ )) + do + printf -v SORTKEY "%s0" $SORTKEY + done +} + +function copy() +{ + if [[ "$COPYROLE" == "none" ]]; then + return + fi + + SORTKEYLEN=$((${#PRIMARY_UID}+${#DEV_UID})) + if [[ "$COPYROLE" == "secondary" ]]; then + SORTKEY=$PRIMARY_UID$DEV_UID + PAIREDDEVICES=$PRIMARY_UID + BLOCKNAME="" + else + SORTKEY=$PRIMARY_UID + padSortKey ${#DEV_UID} + PAIREDDEVICES=$SECONDARY_LIST + fi + + printf "%s:%s:%-8s %-10s %-8s %-8s %s \n" \ + "$SORTKEYLEN" "$SORTKEY" \ + "$BUSID" \ + "$COPYROLE" \ + "$BLOCKNAME" \ + "$PAIREDDEVICES"; +} + function uid() { #-------------------------------------------# @@ -835,6 +874,9 @@ while [ $# -gt 0 ]; do --host-access-list|-H) OUTPUT="host" ;; + --copy-pairs|-P) + OUTPUT="copy" + ;; --version) PrintVersion exit 0 @@ -889,6 +931,9 @@ if [[ "$PRINTUID" == "true" ]] && [[ "$OUTPUT" != "old" ]]; then elif [[ "$OUTPUT" == "new" ]]; then printf "Bus-ID Status Name Device Type BlkSz Size Blocks\n" printf "================================================================================\n" +elif [[ "$OUTPUT" == "copy" ]]; then + printf "Bus-ID Role Name Paired devices\n"; + printf "================================================================================\n"; elif [[ "$OUTPUT" == "extended" ]]; then PROCESSING=" $PROCESSING | sed 's/#/\n/g' " fi