From 794c8eb0482c5b2a4f5054f9d926e2f66286a14d Mon Sep 17 00:00:00 2001 From: Oron Peled Date: Mon, 31 Mar 2014 13:35:34 +0300 Subject: [PATCH] xpp: waitfor_xpds: handle missing serial numbers Fixes a regression since 949ea4ca9f9c9050811af9e80d44530beb10fd8f (2.7.0) - allows using an Astribank with no serial. * Some of the olderst Astribanks don't have a serial number burned in them. Thus there is no serial attribute for the sysfs USB device node. * waitfor_xpds identifies the Astribanks by their serial numbers. * An lone Astribank without serial number would thus block waitfor_xpds (until timeout). * Now we warn about them. * We also try to handle it gracefully. As long as there's only one of thease, it would be counted as "NO-SERIAL". Signed-off-by: Tzafrir Cohen --- xpp/waitfor_xpds | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/xpp/waitfor_xpds b/xpp/waitfor_xpds index bffa8c2..79e2806 100755 --- a/xpp/waitfor_xpds +++ b/xpp/waitfor_xpds @@ -41,18 +41,25 @@ ab_list() { } ab_serial_nums() { - ab_list | \ - sed 's,$,/serial,' | \ - xargs grep -H '' 2>/dev/null | \ - sed 's,.*/serial:,,' | \ - sed 's/^$/NO-SERIAL/' | \ - sort -u + for i in `ab_list`; do + s=`cat "$i/serial" 2>/dev/null` || : + if [ "$s" = '' ]; then + echo "NO-SERIAL" + else + echo "$s" + fi + done | sort -u || : } detected_serial_nums() { - cat /sys/bus/astribanks/devices/*/transport/serial 2> /dev/null | \ - sed 's/^$/NO-SERIAL/' | \ - sort -u || : + for i in /sys/bus/astribanks/devices/*/transport; do + s=`cat "$i/serial" 2>/dev/null` || : + if [ "$s" = '' ]; then + echo "NO-SERIAL" + else + echo "$s" + fi + done | sort -u || : } calc_union() { @@ -98,6 +105,14 @@ if ! astribank_is_starting; then exit 0 fi +# Sanity check +for i in `ab_list`; do + s=`cat "$i/serial" 2>/dev/null` || : + if [ "$s" = '' ]; then + echo >&2 "WARNING! Astribank without serial number: $i" + fi +done + serial_nums=`ab_serial_nums` # Loop until detected (hopefully) all astribanks and they are initialized