Description: lsdasd,lscss: suppress error messages when working on unsettled
             sysfs tree.
Symptom:     lsdasd and lscss sometimes show error messages when working on
             unsettled sysfs tree.
Problem:     Devices may disappear while these tools try to access device
             attributes.
Solution:    Suppress the related error messages.
             Note: also fix the return code for lscss -h
Problem-ID:  75158
---
 zconf/lscss  |   21 +++++++++++----------
 zconf/lsdasd |   23 ++++++++++++-----------
 2 files changed, 23 insertions(+), 21 deletions(-)

--- a/zconf/lscss
+++ b/zconf/lscss
@@ -1,6 +1,6 @@
 #!/bin/bash
 #==============================================================================
-# Copyright IBM Corp. 2003,2009
+# Copyright IBM Corp. 2003,2011
 #
 # lscss
 #
@@ -70,7 +70,7 @@ function print_usage() {
 function print_version()
 {
     VERSION="%S390_TOOLS_VERSION%"
-    echo -ne "$CMD: version $VERSION\nCopyright IBM Corp. 2003, 2009\n"
+    echo -ne "$CMD: version $VERSION\nCopyright IBM Corp. 2003, 2011\n"
 }
 
 
@@ -156,7 +156,7 @@ while [ $# -gt 0 ]; do
     case $1 in
 	-h|--help)
 	    print_usage
-	    exit 1
+	    exit 0
 	    ;;
 	-s|--short)
 	    SHORTID=true
@@ -246,7 +246,8 @@ function print_schid_within()
 
 function list_sch_of_type()
 {
-    find /sys/bus/css/devices/ -type l -name "$IDFORMAT" | sort -t/ -k6 |
+    find /sys/bus/css/devices/ -type l -name "$IDFORMAT" 2> /dev/null |
+    sort -t/ -k6 |
     while read SCH ;do
 	if [ -f $SCH/type ] ;then
 	    read TYPE < $SCH/type
@@ -270,9 +271,9 @@ function print_io()
     while read DEV ;do
 	SCH=${DEV%/*}
 	if [ -d $DEV ] ;then
-	    read CUTYPE < $DEV/cutype
-	    read ONLINE < $DEV/online
-	    read DEVTYPE < $DEV/devtype
+	    read CUTYPE 2> /dev/null < $DEV/cutype || continue
+	    read ONLINE 2> /dev/null < $DEV/online || continue
+	    read DEVTYPE 2> /dev/null < $DEV/devtype || continue
 	    if [[ $DEVTYPE == "n/a" ]] ;then DEVTYPE="0000/00" ;fi
 	    if [ $DEVTYPES ] ;then
 		__MATCHED=false
@@ -288,7 +289,7 @@ function print_io()
 	    fi
 	    if [ $ONLINE = 1 ] ;then ONLINE="yes" ;else ONLINE="" ;fi
 	    if [ $SHOW_AVAIL ] ;then
-		read AVAIL < $DEV/availability
+		read AVAIL 2> /dev/null < $DEV/availability || continue
 	    fi
 	    DEV=${DEV##*/}
 	else
@@ -308,8 +309,8 @@ function print_io()
 		continue
 	    fi
 	else
-	    read PIM PAM POM < $SCH/pimpampom
-	    read -a C < $SCH/chpids
+	    read PIM PAM POM 2> /dev/null < $SCH/pimpampom || continue
+	    read -a C 2> /dev/null < $SCH/chpids || continue
 	    SCH=${SCH##*/}
 	    if [ "$SHORTID" -a ${SCH:0:4} != "0.0." ] ; then
 		continue
--- a/zconf/lsdasd
+++ b/zconf/lsdasd
@@ -112,7 +112,8 @@ function CheckDeviceString() {
 # Generate list of DASDs
 #------------------------------------------------------------------------------
 function listDASDDeviceDirectories() {
-    find "$SYSFSDIR/devices" -type l -name "driver" -lname "*/dasd*" -printf "%h\n"
+    find "$SYSFSDIR/devices" -type l -name "driver" -lname "*/dasd*" \
+	-printf "%h\n" 2> /dev/null
     return 0
 }
 
@@ -125,15 +126,15 @@ function gatherDeviceData() {
 		#-------------------------------------------#
 		# gather information from device attributes #
 		#-------------------------------------------#
-		read  ONLINE < $DEVPATH/online
+		read ONLINE 2> /dev/null < $DEVPATH/online || continue
 		if [[ "$ONLINE" == 0 ]] &&
 			[[ "$PRINTOFFLINE" == "false" ]]; then
 			continue
 		fi
-		read  ALIAS < $DEVPATH/alias
-		read  DEV_UID < $DEVPATH/uid
-		read  READONLY < $DEVPATH/readonly
-		read  DISCIPLINE < $DEVPATH/discipline
+		read ALIAS 2> /dev/null < $DEVPATH/alias || continue
+		read DEV_UID 2> /dev/null < $DEVPATH/uid || continue
+		read READONLY 2> /dev/null < $DEVPATH/readonly || continue
+		read DISCIPLINE 2> /dev/null < $DEVPATH/discipline || continue
 
 		# Block device specific information is only available for
 		# devices that are online and not a PAV alias
@@ -148,10 +149,10 @@ function gatherDeviceData() {
 				cd -P "$1"
 				BLOCKPATH=$PWD
 				BLOCKNAME=${BLOCKPATH##*/}
-				read MAJMIN < $BLOCKPATH/dev
+				read MAJMIN 2> /dev/null < $BLOCKPATH/dev || continue
 				MAJOR=${MAJMIN%%:*}
 				MINOR=${MAJMIN##*:}
-				read SIZE < $BLOCKPATH/size
+				read SIZE 2> /dev/null < $BLOCKPATH/size || continue
 			else
 				BLOCKNAME="???"
 				MAJMIN=
@@ -338,9 +339,9 @@ function oldoutput()
 function extended()
 {
 	# additional information
-	read  DIAG < $DEVPATH/use_diag
-	read  EER < $DEVPATH/eer_enabled
-	read  ERP < $DEVPATH/erplog
+	read DIAG 2> /dev/null < $DEVPATH/use_diag || continue
+	read EER 2> /dev/null < $DEVPATH/eer_enabled || continue
+	read ERP 2> /dev/null < $DEVPATH/erplog || continue
 
        	#-------------------------------------------#
        	# format data for output                    #
