From 4fe0e76e1d02787b4cf60eafd2fb3667897becf4 Mon Sep 17 00:00:00 2001 From: Michael Bringmann Date: Tue, 23 Jul 2019 15:58:21 -0500 Subject: [PATCH 1/1] powerpc-utils: Suppress errors reading kernel files A problem was observed with the evaluation of the '${devspec}' by the script 'ofpathname'. This patch provided improved handling of errors within that script, and by some of the follow-on uses of the tool by the 'bootlist' script. * Deal with error messages returned sometimes by evaluation of ${devspec} in 'ofpathname'. * Strip embedded nulls from values provided by kernel files, especially, /proc/device-tree${devspec}/namespace/name, in 'ofpathname'. * Redirect more error messages to /dev/null Signed-off-by: Michael Bringmann --- scripts/bootlist | 8 ++++---- scripts/ofpathname | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/bootlist b/scripts/bootlist index 65926d7..5ce20cf 100755 --- a/scripts/bootlist +++ b/scripts/bootlist @@ -169,7 +169,7 @@ get_logical_device_name() local devname=$1 local logical_name - logical_name=`$OFPATHNAME -l $devname 2>/dev/null` + logical_name=`$OFPATHNAME -l $devname 2>/dev/null | tr -d '\000'` if [[ $? -ne 0 ]]; then echo "" else @@ -207,11 +207,11 @@ show_bootlist() local devlist=$1 local i - for i in `$NVRAM --print-config=${devlist} | sed 's/ /\n/g'`; do + for i in `$NVRAM --print-config=${devlist} 2> /dev/null | sed 's/ /\n/g'`; do if [[ $TRANSLATE_NAMES = "yes" ]]; then name=`get_logical_device_name $i` if [[ -z $name ]]; then - echo "Could not translate $i to logical device name" + echo "Could not translate $i to logical device name" 2>&1 else case $name in eth*) parse_eth_info $name $i ;; @@ -230,7 +230,7 @@ show_bootlist() . $PSERIES_PLATFORM if [[ $platform != $PLATFORM_PSERIES_LPAR ]]; then - echo "bootlist: is not supported on the $platform_name platform" + echo "bootlist: is not supported on the $platform_name platform" 2>&1 exit 1 fi diff --git a/scripts/ofpathname b/scripts/ofpathname index c37c6bd..09c0209 100755 --- a/scripts/ofpathname +++ b/scripts/ofpathname @@ -656,7 +656,7 @@ l2of_nvme() goto_dir $PWD "device/devspec" - devspec=`$CAT $PWD/device/devspec` + devspec=`$CAT $PWD/device/devspec | tr -d '\000'` if [[ -n $devspec ]]; then found=1 break @@ -681,7 +681,7 @@ l2of_nvme() # Device type is usually 'namespace'. # Get it from device-tree just in case. - devtype=`$CAT /proc/device-tree${devspec}/namespace/name` + devtype=`$CAT /proc/device-tree${devspec}/namespace/name | tr -d '\000'` 2> /dev/null if [[ -z $devtype ]]; then err $ERR_NO_OFPATH fi -- 1.8.3.1