File hcnmgr-Avoid-hexdum-squeezing-consecutive-identical-.patch of Package powerpc-utils.22902
From 4d56ac27688743ff707966255cfe958f19eb5b6d Mon Sep 17 00:00:00 2001
From: Michal Suchanek <msuchanek@suse.de>
Date: Thu, 28 Oct 2021 11:11:27 +0200
Subject: [PATCH] hcnmgr: Avoid hexdump squeezing consecutive identical bytes.
References: bsc#1192095 ltc#194963 https://github.com/ibm-power-utilities/powerpc-utils/pull/72
Upstream: merged, expected 1.3.10
Git-commit: 4d56ac27688743ff707966255cfe958f19eb5b6d
When the file contains multiple consecutive bytes of the same value
hexdump squeezes them replacing all but first with *
Use the -v argument to avoid this problem.
Also put the hexdump invocation into a function.
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com>
---
scripts/hcnmgr | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/scripts/hcnmgr b/scripts/hcnmgr
index 6c3c6ab25ed1..4386084e6566 100644
--- a/scripts/hcnmgr
+++ b/scripts/hcnmgr
@@ -155,6 +155,12 @@ hcnlog() {
}
+# function xdump4:
+# Print first 4 bytes of specified file in hexadecimal
+xdump4() {
+ hexdump -n 4 -ve '/1 "%02x"' "$1"
+}
+
# function search_dev:
# Given DRX_INDEX, Search for device-tree, looking for migratable SR_IOV
# backend vnic or ibmveth device to configure hybrid network
@@ -168,7 +174,7 @@ search_dev() {
# Look at pci ethernet devices
for pci_dev in "$DT_PATH"/pci*; do
[ -d "$pci_dev" ] || continue
- index=$(hexdump -n 4 -e '/1 "%02x"' "$pci_dev"/ibm,my-drc-index)
+ index=$(xdump4 "$pci_dev"/ibm,my-drc-index)
if [[ $index != "$1" ]]; then
continue
fi
@@ -189,7 +195,7 @@ search_dev() {
hcnlog DEBUG "search vnic device with drc_index $1"
for dev in "$DT_PATH"/vdevice/vnic*; do
[ -d "$dev" ] || continue
- index=$(hexdump -n 4 -e '/1 "%02x"' "$dev"/ibm,my-drc-index)
+ index=$(xdump4 "$dev"/ibm,my-drc-index)
if [[ $index == "$1" ]]; then
hcnlog DEBUG "found matching drc_index $index in $dev"
if [ -e "$dev"/ibm,hcn-id ] && get_dev_hcn "$dev"; then
@@ -205,7 +211,7 @@ search_dev() {
hcnlog DEBUG "search ibmveth device with drc_index $1"
for dev in "$DT_PATH"/vdevice/l-lan*; do
[ -d "$dev" ] || continue
- index=$(hexdump -n 4 -e '/1 "%02x"' "$dev"/ibm,my-drc-index)
+ index=$(xdump4 "$dev"/ibm,my-drc-index)
if [[ $index == "$1" ]]; then
hcnlog DEBUG "found matching drc_index $index in $dev"
if [ -e "$dev"/ibm,hcn-id ] && get_dev_hcn "$dev"; then
@@ -233,7 +239,7 @@ get_dev_hcn() {
local dev=$1
hcnlog DEBUG "get_dev_hcn: enter $1"
- HCNID=$(hexdump -n 4 -e '/1 "%02x"' "$dev"/ibm,hcn-id)
+ HCNID=$(xdump4 "$dev"/ibm,hcn-id)
MODE=$(tr -d '\0' <"$dev"/ibm,hcn-mode)
PHYSLOC=$(tr -d '\0' <"$dev"/ibm,loc-code)
DEVPATH=$1
--
2.31.1