#!/bin/ksh -p
# $Id: //depot/stable/explorer/tools/ssa#2 $
#
# Explorer Version:
EXP_VERSION=4.0
#

# Source tools functions
. ${EXP_LIB}/exp_tools

# Run if specified to do so
script=${0##*/}
which_gate_exit storage $script default all

# Get luxadm or ssaadm command PATH
if [ -x /usr/sbin/luxadm ]
then
    SSAADM=/usr/sbin/luxadm
else
    # Find ssaadm if available (check in C locale)
    LC_SAVE=${LC_ALL}
    export LC_ALL=C
    SSAADM=`type ssaadm 2>&1 | sed 's/.*is //'`
    export LC_ALL=${LC_SAVE}
fi

export SSAADM

# check for the existence of ssa devices in /dev/rdsk, and pull the
# cNtNdN numbers
# NOTE: that this doesn't mean that an SSA is currently installed on
#       that device. To be sure, I can pull this info from format, but
#	I am concerned that if format gets stuck for some reasone, then
#	the whole script will get stck too. This can be fixed when I
#	process the data. At that point I will match the info from
#	format agianst the disks in here.
LIST=`ls -l /dev/rdsk/ | egrep -e "/SUNW,pln" | egrep -e "s0" | nawk '{ print $9 }' | sed s/t.\*// | sort -u`
TEXT=`gettext "No SSAs installed"`
require "test -n \"${LIST}\"" "${TEXT}"

for SSA in ${LIST}
do
    get_cmd "$SSAADM -v display ${SSA}" disks/ssa/ssaadm."${SSA}"

    for diskpath in `ls /dev/rdsk/"${SSA}"t*s0`
    do
        diskname=`echo $diskpath | sed s/.dev.rdsk.//`
	get_cmd "$SSAADM display $diskpath" disks/ssa/${SSA}.disk_list/$diskname
    done
done
