#+
# ============================================================================
# = exer_read - Randomly read blocks of data from a device.                  =
# ============================================================================
#
# OVERVIEW:
#
#	Seek to a random block number on the device then read a packet of
# 	2048 bytes.  Repeat this until one of the following conditions occur:
###	
#	1 All blocks on the device(s) have been read for passcount of d_passes.
#	2 The exer process has been killed via ^C or by the kill command.
##	
#
#	Nothing is displayed unless an error occurs.
#
#   COMMAND FORM:
#
#       exer_read ( [<device>...] )
#
#   COMMAND ARGUMENT(S):
#
#       <device> - Specifies the device name(s) to be exercised. 
#		   Defaults to du*.* dk*.* dr*.*,
#		   all online DSSI, SCSI, and RAID disks.
#
#   COMMAND OPTION(S):
#
#	None
#
#   COMMAND EXAMPLE(S):
#~
#       >>>exer_read	# Run on all, if any, disks that are online.
#~
#   COMMAND REFERENCES:
#
#	exer_write
#
#-
#set device list not present flag
set aa_dvx_spec$$ 1 2>nl
set a_err$$ 1 2>nl
# screen out some of the invalid syntax cases
for i in $* ; do
	case $i in
		   "-sec") ;;
		 "[0-9]*") ;;
			*) if (ls $i >nl) then
#dvx list present
				set aa_dvx_spec$$ 0
			   else
				echo device not found
				set a_err$$ 0
			   fi ;;
	esac
done

if (eval a_err$$ >nl) then
	clear aa_dvx_spec$$ a_err$$
	exit 1
fi

# setup arg_list with command line device list or default device list
echo $* >arg_list$$ -n
if (eval aa_dvx_spec$$ >nl) then
#use command line device list
else
#use device list default
	if (ls du*.* >nl) then
		echo -n " du*.*" >> arg_list$$
	fi
	if (ls dk*.* >nl) then
		echo -n " dk*.*" >> arg_list$$
	fi
	if (ls dr*.* >nl) then
		echo -n " dr*.*" >> arg_list$$
	fi
fi
clear aa_dvx_spec$$ a_err$$

if (exer -bc 4 `cat arg_list${p}`) then
#success
	exit `echo 0;rm arg_list${p}`
else
	exit `echo 1;rm arg_list${p}`
fi
