:
# @(#)warn_of_sasbug	1.4 (16 Jun 1994)
#
# Warn the user if the unpatched SAS 1.25 serial driver may be in use.
#
# SAS is by no means required (tslip works with any streams serial driver, 
# including the vendor-supplied asy).  However, many sites use SAS because
# it offers deterministic hardware flow control, supports buffered serial
# ports (NS16550A chips), high speeds (57600 and 115200 baud), and, with 
# a patch, reliable operation.
#
# However, there is a serious bug in sas-1.25 which will panic the kernel
# during sustained high-speed reception.  A patch is included with tslip.
#
# This script warns the user to install the patch if it appears to be needed.


# Look around for the sas source tree
FILE=sas
sasdir=''
set -f
cd ${srcdir:-.}
for pattern in \
	../sas-1.25?* ../sas* \
	./sas-1.25?* ./sas* \
	../../src/sas-1.25?* ../../src/sas* \
	../../../src/sas-1.25?* ../../../src/sas* \
	/usr/local/src/sas-* \
	/*/gnu/src/sas-* \
; do
	set +f	
    	for sasdir in $pattern ; do
	    if test -d "$sasdir" && test -f $sasdir/sas.c && 
				{ case "$sasdir" in *-1.25*) true ;; *) false ;; esac ||
				  egrep -l 'release=1.25' $sasdir/sas.c >/dev/null; } ; then
		break 2
	    fi
        done
done

# Warn the user if the patch doesn't appear to have been applied
test -n "$sasdir" && {
	sasdir=`(cd $sasdir; pwd)`
	if grep '^[ 	]*if[ 	]*(fip->recv_cnt[ 	]*<[ 	]*RECV_BUFF_SIZE' $sasdir/sas.c >/dev/null
	then
		echo "Found SAS source in $sasdir"
		echo "***WARNING***"
		echo "You have the sas-1.25 serial driver source code."
		echo "There is a bug in sas-1.25 which can panic the system during"
		echo "high speed operation.  A patch is available, but the patch does not"
		echo "appear to have been applied.  If you are indeed using sas,"
		echo please apply the patch in *PATCH*SAS* "."
		echo 
	else
		if grep 'if[ 	(]*fip->recv_cnt[ 	<]*fip->alloc_size[ 	]*)' $sasdir/sas.c >/dev/null
		then
		    :
		    # echo "Found SAS source in $sasdir"
		    # echo "    ... and it appears to be okay (did not detect the RECV_BUFF_SIZE bug)."
		else
		    echo "Found SAS source in $sasdir"
		    echo "    ... but could not determine whether it is sas-1.25, which contains a bug."
		    echo "        If this is sas-1.25, please apply the patch in" *PATCH*SAS* "."
		fi
	fi
}
