#!/bin/ksh
#
# Copyright (c) 2001 by Sun Microsystems, Inc.
# All rights reserved.
#
#ident	"@(#)ctd2did	1.2	01/02/05 SMI"
#
# Given a CTD number, the DID number is returned, e.g. c3t1d0 -> 4

ctd=$1
bin_dir=/usr/cluster/bin

# The CTD might have a slice partition attached/
# e.g. ctd=c1t1d1s2
# if so, then get rid of the s2 part.
ctd=$(echo $ctd | awk -F's' '{print$1}')

did=$($bin_dir/scdidadm -l -o path -o name | grep "$ctd" | awk '{print $2}')

if [[ -z $did ]]
then
	echo "Error in converting the CTD name to the DID format."
	return 1
else
	echo $did
	return 0
fi


