zconf/lsdasd: add Copy Pair output option

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 <sth@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Stefan Haberland
2022-10-12 15:55:43 +02:00
committed by Jan Höppner
parent 5107a7be16
commit 803b87e324

View File

@@ -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