#!/bin/ksh -p
#*******************************************************************************
#
# NAME:         symconf
# SUMMARY:      %description%
# COMPONENT:    solsysd
# VERSION:      31
# UPDATE DATE:  %date_modified: Fri May 25 11:47:08 2001 %
# PROGRAMMER:   %created_by:    awilner %
#
#               Copyright 2001 by Symbios Logic Inc.
#
# DESCRIPTION:
# symconf is a shell script whose function is to generate the
# rdriver.conf file used by the RDAC driver.  
#
# NOTES:
# (to maintenance programmers:)  the "<pipeline> | while read VAR do ... done
# consstruct is used heavily in this script.  After spending a great deal of
# time trying to figure out why variables were losing their values, it was
# discovered that the aforementioned construct invokes a sub-shell for the
# while loop, meaning that variables used within the loop are distinct from
# those outside the loop having the same name, and are furthermore, not
# preserved.  This is why files are used where it is necessary to pass a
# value from within the loop to the containing part of the script.
#
# REFERENCE:
#
# CODING STANDARD WAIVERS:
#
#*******************************************************************************

#*******************************************************************************
# PROCEDURE:	MutexAcquire
# SUMMARY:	get exclusive ownership of mutex file
#
# DESCRIPTION:
# MutexAcquire will try repeatedly to acquire a "mutex file" - success means
# the thread has been admitted to a "critical region"
#
# SYNTAX:
# MutexAcquire <mutex file>
# <mutex file> - name of the mutex guarding the critical region
#
# NOTES:
# MutexAcquire and the program it calls, rm_mutex_acquire, rely on O_CREAT
# semantics
#
# RETURNS:
# Nothing

MutexAcquire()
{
	while true
	do
		$RM_BOOT_HOME/rm_mutex_acquire $1
		if [ $? = 0 ]
		then
			break;
		fi
		sleep 1
	done;
}

#*******************************************************************************
# PROCEDURE:	MutexRelease
# SUMMARY:	relenquish mutex file ownership
#
# DESCRIPTION:
# MutexRelease releases mutex file ownership, so another thread can enter the
# critical region
#
# SYNTAX:
# MutexRelease <mutex file>
# <mutex file> - name of the mutex guarding the critical region
#
# NOTES:
#
# RETURNS:
# Nothing

MutexRelease()
{
	/bin/rm $1;
}
#*******************************************************************************
# PROCEDURE:	AddRdacAdrsFile
# SUMMARY:	Add to the /etc/raid/rdac_address file
#
# RETURNS:
# Nothing

AddRdacAdrsFile()
{
ADRS_MODULE_NAME=$1
ADRS_FIRST_NEXUS_PATH=$2
ADRS_SECOND_NEXUS_PATH=$3
RM_BOOT_HOME=`grep -v "^#" $RMPARAMS_FILE | grep System_RmBootHomeDirectory | cut -d= -f2`
STORUTIL=$RM_BOOT_HOME/storutil
RDACUTIL=$RM_BOOT_HOME/rdacutil

if [ "${ADRS_FIRST_NEXUS_PATH}" = "VOID" ]  
then
	ADRS_FIRST_NEXUS_PATH=""
fi

if [ -z "${ADRS_FIRST_NEXUS_PATH}" ]  &&  [ -z "${ADRS_SECOND_NEXUS_PATH}" ]
then
	return 0
fi

if [ -z "${ADRS_FIRST_NEXUS_PATH}" ]  
then
	echo "$ADRS_MODULE_NAME:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:" >>$RDAC_ADRS_FILE
	if [ $? -ne 0 ]
	then
		echo "Error adding Array Module $ADRS_MODULE_NAME to the RDAC address file" >>/tmp/symconf_err.$$
		return 2
	fi
	return 0
fi

if [ -z "${ADRS_SECOND_NEXUS_PATH}" ]  
then
	echo "$ADRS_MODULE_NAME:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:" >>$RDAC_ADRS_FILE
	if [ $? -ne 0 ]
	then
		echo "Error adding Array Module $ADRS_MODULE_NAME to the RDAC address file"  >>/tmp/symconf_err.$$
		return 3
	fi
	return 0
fi

	
PATH_A_LUNS=`$STORUTIL -Z -y -c $ADRS_FIRST_NEXUS_PATH 2>/dev/null | grep ContALunMask | cut -d: -f2`
if [ $? -eq 0 ]
then
	PATH_B_LUNS=`$STORUTIL -Z -y -c $ADRS_FIRST_NEXUS_PATH 2>/dev/null | grep ContBLunMask | cut -d: -f2`
fi

if [ -z "${PATH_A_LUNS}" ] && [ -z "${PATH_B_LUNS}" ]
then
	PATH_A_LUNS=`$STORUTIL -Z -y -c $ADRS_SECOND_NEXUS_PATH 2>/dev/null | grep ContALunMask | cut -d: -f2`
	if [ $? -eq 0 ]
	then
		PATH_B_LUNS=`$STORUTIL -Z -y -c $ADRS_SECOND_NEXUS_PATH 2>/dev/null | grep ContBLunMask | cut -d: -f2`
	fi
fi

if [ -z "${PATH_A_LUNS}" ] && [ -z "${PATH_B_LUNS}" ]
then
	ACTIVE_PATH=`$RDACUTIL -y -i -c $ADRS_FIRST_NEXUS_PATH 2>/dev/null`

	if [ -z "${ACTIVE_PATH}" ]
	then
		ACTIVE_PATH=`$RDACUTIL -y -i -c $ADRS_SECOND_NEXUS_PATH 2>/dev/null`
	fi

	if [ -z "${ACTIVE_PATH}" ]
	then
		return 0
	fi

	ACTIVE_CONTROLLER=`echo "$ACTIVE_PATH" | grep "controller a"`

	if [ -z "${ACTIVE_PATH}" ]
	then
		echo "$ADRS_MODULE_NAME:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:B:" >>$RDAC_ADRS_FILE
		if [ $? -ne 0 ]
		then
			echo "Error adding Array Module $ADRS_MODULE_NAME to the RDAC address file"  >>/tmp/symconf_err.$$
			return 4
		fi
	else
		echo "$ADRS_MODULE_NAME:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:A:" >>$RDAC_ADRS_FILE
		if [ $? -ne 0 ]
		then
			echo "Error adding Array Module $ADRS_MODULE_NAME to the RDAC address file"  >>/tmp/symconf_err.$$
			return 5
			fi
 		fi
	return 0
fi

MODULE_ADRS=$ADRS_MODULE_NAME:

for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
do
	A_CNTRL=`echo $ADRS_FIRST_NEXUS_PATH | cut -dd -f1`
	B_CNTRL=`echo $ADRS_SECOND_NEXUS_PATH | cut -dd -f1`
	A_PATH_EXISTS=`ls -l /dev/rdsk/$A_CNTRL"d$i""s0" 2>/dev/null | grep rdnexus`
	B_PATH_EXISTS=`ls -l /dev/rdsk/$B_CNTRL"d$i""s0" 2>/dev/null | grep rdnexus`

	if [ -n "${B_PATH_EXISTS}" ] && [ -z "${A_PATH_EXISTS}" ]
	then
		MODULE_ADRS="${MODULE_ADRS}"B:
		continue
	fi

	if [ -n "${A_PATH_EXISTS}" ] && [ -z "${B_PATH_EXISTS}" ]
	then
		MODULE_ADRS="${MODULE_ADRS}"A:
		continue
	fi

	B_CREATE=""

	for BLUN in $PATH_B_LUNS
	do
		
		if [ "${BLUN}" = "${i}" ] 
		then
			MODULE_ADRS="${MODULE_ADRS}"B:
			B_CREATE="YES"
			break
		fi
	done

	if [ -z "${B_CREATE}" ]
	then
		MODULE_ADRS="${MODULE_ADRS}"A:
	fi
done

echo $MODULE_ADRS  >>$RDAC_ADRS_FILE
if [ $? -ne 0 ]
then
	echo "Error adding Array Module $ADRS_MODULE_NAME to the RDAC address file" >>/tmp/symconf_err.$$
	return 6
fi

return 0

}

#*******************************************************************************
# PROCEDURE:	CreateRdacAdrsFile
# SUMMARY:	Create the /etc/raid/rdac_address file
#
# RETURNS:
# Nothing

CreateRdacAdrsFile()
{
cat /tmp/ctrls.$$ |
while read CTRL_INFO
do
	if [ $? -ne 0 ]
	then
		echo "Error while creating RDAC Address File: Unable to read /tmp/disksmnf.$$" >>/tmp/symconf_err.$$
		return 1
	fi

	ADRS_MODULE_NAME=`echo $CTRL_INFO | cut -d~ -f1`

	ADRS_FIRST_NEXUS_PATH=`echo $CTRL_INFO | cut -d~ -f9`

	SLICE0="s0"
	PATH_SLICE=`echo $ADRS_FIRST_NEXUS_PATH | grep s`
	if [ -n "${ADRS_FIRST_NEXUS_PATH}" ] &&  [ -z "${PATH_SLICE}" ]
	then
		ADRS_FIRST_NEXUS_PATH="$ADRS_FIRST_NEXUS_PATH""$SLICE0"
	fi

	ADRS_SECOND_NEXUS_PATH=`echo $CTRL_INFO | cut -d~ -f10`

	PATH_SLICE=`echo $ADRS_SECOND_NEXUS_PATH | grep s`
	if [ -n "${ADRS_SECOND_NEXUS_PATH}" ] &&  [ -z "${PATH_SLICE}" ]
	then
		ADRS_SECOND_NEXUS_PATH="$ADRS_SECOND_NEXUS_PATH""$SLICE0"
	fi

	if [ -z "${ADRS_FIRST_NEXUS_PATH}" ]
	then
		AddRdacAdrsFile "$ADRS_MODULE_NAME"  "VOID"  $ADRS_SECOND_NEXUS_PATH
	else
		AddRdacAdrsFile "$ADRS_MODULE_NAME"  $ADRS_FIRST_NEXUS_PATH  $ADRS_SECOND_NEXUS_PATH
	fi

	if [ $? -ne 0 ]
	then
		return 2
	fi
done
return 0
}

#*******************************************************************************
# PROCEDURE:	symconf (main)
# SUMMARY:	Generate rdriver.conf file
#
# DESCRIPTION:
# Below is the main procedure for symconf which, as described above, generates
# the rdriver.conf.  The output of symconf is written to stdout.
#
# SYNTAX:
# symconf [ -v ]
# 
# -v - turn on shell trace (-x)
#
# NOTES:
#
# RETURNS: (exit statuses)
# 0 - successful termination
# 1 - command line syntax error
# 6 - errors during parsing. output is not a valid rdriver.conf file, and RDAC will
#     not work if the system is rebooted.
# 10 -  Too many "rdnexus pseudo-busses" were referenced; /kernel/drv/rdnexus.conf
#       needs to be updated.


# S Y M C O N F   M A I N   P R O C E D U R E

CONF_FILE=/kernel/drv/rdriver.conf
RMPARAMS_FILE=/etc/raid/rmparams

MAXLUNS=`grep -v "^#" $RMPARAMS_FILE | grep System_MaxLunsPerController | cut -d= -f2`
MAXIDS=`grep -v "^#" $RMPARAMS_FILE | grep System_MaxSCSIid | cut -d= -f2`
Q_TIMEOUT=`grep -v "^#" $RMPARAMS_FILE | grep Rdac_Quiescence_Timeout | cut -d= -f2`
if [ -z $"{Q_TIMEOUT}" ]
then
	Q_TIMEOUT=5
fi

RM_BOOT_HOME=`grep -v "^#" $RMPARAMS_FILE | grep System_RmBootHomeDirectory | cut -d= -f2`
RM_NAME_FILE=`grep -v "^#" $RMPARAMS_FILE | grep System_NamefileDirPath | cut -d= -f2`


LAD=$RM_BOOT_HOME/lad
STORUTIL=$RM_BOOT_HOME/storutil
RDACUTIL=$RM_BOOT_HOME/rdacutil
RDAC_ADRS_FILE=/etc/raid/rdac_address 


USAGE="Usage:  $0 [ -v ]"
VERBOSE=FALSE

TooManyBusses=0

set -- `getopt v $* 2>/dev/null`
if [ $? != 0 ]
then
	echo $USAGE
	exit 1
fi
for i in $*
do
	case $i in
	-v) VERBOSE=TRUE; shift;;
	--) shift; break;;
        esac
done

if [ $VERBOSE = TRUE ]
then
	set -x
fi

if grep -v "^#" $RMPARAMS_FILE | grep "Rdac_SupportDisabled.*=.*TRUE" >/dev/null 2>&1
then
	echo name=\"rdriver\" parent=\"pseudo\" instance=0\; 
	exit 0
fi

if grep -v "^#" $RMPARAMS_FILE | grep "Rdac_SinglePathSupportDisabled.*=.*TRUE" >/dev/null 2>&1
then
	RDAC_NO_SINGLE="TRUE"
fi

if grep -v "^#" $RMPARAMS_FILE | grep "Rdac_HotAddDisabled.*=.*TRUE" >/dev/null 2>&1
then
	RDAC_NO_HOTADD="TRUE"
fi

if grep -v "^#" $RMPARAMS_FILE | grep "Rdac_HotAddDisabled.*=.*PARTIAL" >/dev/null 2>&1
then
	RDAC_HOTADD_IDS=`grep -v "^#" $RMPARAMS_FILE | grep Rdac_HotAddIDs`
fi

if grep -v "^#" $RMPARAMS_FILE | grep "Rdac_ExposeDualPath.*=.*TRUE" >/dev/null 2>&1
then
	RDAC_DUAL_PATH="TRUE"
fi

if grep -v "^#" $RMPARAMS_FILE | grep "Rdac_Fail_Flag.*=.*FALSE" >/dev/null 2>&1
then
	RDAC_NO_FAIL_FLAG="TRUE"
fi

$LAD -y >/dev/null

if [ -z "${RDAC_NO_FAIL_FLAG}" ]
then
	echo name=\"rdriver\" target=1 parent=\"/pseudo/rdnexus@0\" probe=1 qtime=$Q_TIMEOUT\; >/tmp/symconf_out.$$
else
	echo name=\"rdriver\" target=1 parent=\"/pseudo/rdnexus@0\" probe=1 qtime=$Q_TIMEOUT nofail=1\; >/tmp/symconf_out.$$
fi

>/tmp/ctrls.$$

if [ -f $RM_NAME_FILE ]
then
	cat $RM_NAME_FILE >/tmp/ctrls.$$ 2>/dev/null
	if [ $? -ne 0 ]
	then
		echo name=\"rdriver\" parent=\"pseudo\" instance=0\; 
		echo "Error while creating rdriver.conf: Unable to read $RM_NAME_FILE or create /tmp/ctrls.$$" >>/tmp/symconf_err.$$
		cp /tmp/symconf_err.$$ /tmp/symconf.err
		exit 6
	fi
fi

if [ -s /etc/raid/rdac_address ]
then
 	continue
else
	CreateRdacAdrsFile
fi

cat /tmp/ctrls.$$ |
while read CTRL_INFO
do
	if [ $? -ne 0 ]
	then
		echo name=\"rdriver\" parent=\"pseudo\" instance=0\; 
		echo "Error while creating rdriver.conf: Unable to read /tmp/ctrls.$$" >>/tmp/symconf_err.$$
		cp /tmp/symconf_err.$$ /tmp/symconf.err
		exit 6
	fi

	MODULE_NAME=`echo $CTRL_INFO | cut -d~ -f1`

	MODULE_NO=`echo $CTRL_INFO | cut -d~ -f6`
	MODULE_NO=`expr $MODULE_NO / 64`
        MODULE_NO=`expr $MODULE_NO + 1`

	A_NEXUS_PATH=`echo $CTRL_INFO | cut -d~ -f9`
	B_NEXUS_PATH=`echo $CTRL_INFO | cut -d~ -f10`

	if [ -n "${RDAC_NO_SINGLE}" ]
	then
		if [ -z "${A_NEXUS_PATH}" ] -o [ -z "${B_NEXUS_PATH}" ]
		then
			continue
		fi
	fi

	if [ -z "${A_NEXUS_PATH}" ] && [ -z "${B_NEXUS_PATH}" ]
	then
		continue
	fi

	if [ -n "${A_NEXUS_PATH}" ]
	then
		A_NEXUS_BUS=`echo $A_NEXUS_PATH | cut -dc -f2 | cut -dt -f1`
		A_NEXUS_TARGET=`echo $A_NEXUS_PATH | cut -dt -f2 | cut -dd -f1`
		A_PARENT=/pseudo/rdnexus@$A_NEXUS_BUS
	fi

	if [ -n "${B_NEXUS_PATH}" ]
	then
		B_NEXUS_BUS=`echo $B_NEXUS_PATH | cut -dc -f2 | cut -dt -f1`
		B_NEXUS_TARGET=`echo $B_NEXUS_PATH | cut -dt -f2 | cut -dd -f1`
		B_PARENT=/pseudo/rdnexus@$B_NEXUS_BUS
	fi

	MODULE_ADRS_ENTRY=`cat $RDAC_ADRS_FILE 2>/dev/null | grep "^${MODULE_NAME}:" `

	if [ -z "${MODULE_ADRS_ENTRY}" ]
	then
		SLICE0="s0"
		PATH_SLICE=`echo $A_NEXUS_PATH | grep s`
		if [ -z "${PATH_SLICE}" ] && [ -n "${A_NEXUS_PATH}" ]
		then
			A_NEXUS_PATH="$A_NEXUS_PATH""$SLICE0"
		fi

		PATH_SLICE=`echo $B_NEXUS_PATH | grep s`
		if [ -z "${PATH_SLICE}" ] && [ -n "${B_NEXUS_PATH}" ]
		then
			B_NEXUS_PATH="$B_NEXUS_PATH""$SLICE0"
		fi

		if [ -n "${A_NEXUS_PATH}" ] && [ -n "${B_NEXUS_PATH}" ]
		then
			AddRdacAdrsFile "$MODULE_NAME"  $A_NEXUS_PATH  $B_NEXUS_PATH
		fi

		if [ -z "${A_NEXUS_PATH}" ]
		then
			AddRdacAdrsFile "$MODULE_NAME"  "VOID"  $B_NEXUS_PATH
		fi

		if [ -z "${B_NEXUS_PATH}" ]
		then
			AddRdacAdrsFile "$MODULE_NAME"  $A_NEXUS_PATH
		fi
	fi

	MODULE_ADRS_ENTRY=`cat $RDAC_ADRS_FILE | grep "^${MODULE_NAME}:"`
	if [ -z "${MODULE_ADRS_ENTRY}" ]
	then
		echo name=\"rdriver\" parent=\"pseudo\" instance=0\; 
		echo "Error unable to add $MODULE_NAME to RDAC Address file" >>/tmp/symconf_err.$$
		cp /tmp/symconf_err.$$ /tmp/symconf.err
		exit 6
	fi

	# Make sure the rdnexus busses exist.
	if [ -n "${A_NEXUS_BUS}" ]
	then
		Exists=`grep -c "instance=${A_NEXUS_BUS};" /kernel/drv/rdnexus.conf`
		if [ $Exists -eq 0 ]
		then
			TooManyBusses=1
			A_CTL=`echo ${A_NEXUS_PATH} | cut -dd -f1`
			echo "Warning: pseudo bus ${A_NEXUS_BUS} is not defined in rdnexus.conf. Volumes on controller ${A_CTL} may be inaccessible." >>/tmp/symconf_err.$$
		fi
	fi
	if [ -n "${B_NEXUS_BUS}" ]
	then
		Exists=`grep -c "instance=${B_NEXUS_BUS};" /kernel/drv/rdnexus.conf`
		if [ $Exists -eq 0 ]
		then
			TooManyBusses=1
			B_CTL=`echo ${B_NEXUS_PATH} | cut -dd -f1`
			echo "Warning: pseudo bus ${B_NEXUS_BUS} is not defined in rdnexus.conf. Volumes on controller ${B_CTL} may be inaccessible." >>/tmp/symconf_err.$$
		fi
	fi

	# Now print the entries for this subsystem
	LUN=0
	while [ $LUN -lt $MAXLUNS ]
	do
		
		LUN_FIELD=`expr $LUN + 2`
		LUN_OWNER=`echo $MODULE_ADRS_ENTRY | cut -d: -f$LUN_FIELD`
		if [ "${LUN_OWNER}" = "A" ] || [ -n "${RDAC_DUAL_PATH}"  ]
		then
			CF_LINE=`printf 'name="rdriver" module=%s lun=%s target=%s parent="%s" mname="%s" nexusbus=%s path="A";\n' "$MODULE_NO" "$LUN" "$A_NEXUS_TARGET" "$A_PARENT" "$MODULE_NAME" "$A_NEXUS_BUS"`
				
			echo ${CF_LINE} >>/tmp/symconf_out.$$
			if [ $? -ne 0 ]
			then
				echo name=\"rdriver\" parent=\"pseudo\" instance=0\; 
				echo "Error while creating rdriver.conf: Unable to write /tmp/symconf_out.$$"  >>/tmp/symconf_err.$$
				cp /tmp/symconf_err.$$ /tmp/symconf.err
				exit 6
			fi
		fi

		if [ "${LUN_OWNER}" = "B" ] || [ -n "${RDAC_DUAL_PATH}"  ]
		then
			CF_LINE=`printf 'name="rdriver" module=%s lun=%s target=%s parent="%s" mname="%s" nexusbus=%s path="B";\n' "$MODULE_NO" "$LUN" "$B_NEXUS_TARGET" "$B_PARENT" "$MODULE_NAME" "$B_NEXUS_BUS"`
			echo ${CF_LINE} >>/tmp/symconf_out.$$
			if [ $? -ne 0 ]
			then
				echo name=\"rdriver\" parent=\"pseudo\" instance=0\; 
				echo "Error while creating rdriver.conf: Unable to write /tmp/symconf_out.$$"  >>/tmp/symconf_err.$$
				cp /tmp/symconf_err.$$ /tmp/symconf.err
				exit 6
			fi
		fi

		LUN=`expr $LUN + 1`
	done
done



EXISTING_IDS=""

cat /tmp/ctrls.$$ |
while read CTRL_INFO
do
	A_ID=`echo $CTRL_INFO | cut -d~ -f9 | cut -dt -f2 | cut -dd -f1`
	if [ -n "${A_ID}" ]
	then
		EXISTING_IDS="$EXISTING_IDS"":$A_ID:"
	fi
	B_ID=`echo $CTRL_INFO | cut -d~ -f10 | cut -dt -f2 | cut -dd -f1`
	if [ -n "${B_ID}" ]
	then
		EXISTING_IDS="$EXISTING_IDS"":$B_ID:"
	fi
	echo $EXISTING_IDS >/tmp/symconf.ids.$$

done

EXISTING_IDS=`cat /tmp/symconf.ids.$$ 2>/dev/null`

rm /tmp/symconf.ids.$$  2>/dev/null

rm  /tmp/ctrls.$$  2>/dev/null

ID=0

while [ $ID -le $MAXIDS ]
do
	if [ -n "${RDAC_NO_HOTADD}" ]
	then
		DOID=`echo $EXISTING_IDS | grep ":$ID:"`
		if [ -z "${DOID}" ]
		then
			ID=`expr $ID + 1`
			continue
		fi
	fi
	if [ -n "${RDAC_HOTADD_IDS}" ]
	then
		DOID=`echo $RDAC_HOTADD_IDS | grep ":$ID:"`
		EXISTING_DOID=`echo $EXISTING_IDS | grep ":$ID:"`
		if [ -z "${DOID}" ] && [ -z "${EXISTING_DOID}" ]
		then
			ID=`expr $ID + 1`
			continue
		fi
	fi
	LUN=0
	while [ $LUN -lt $MAXLUNS ]
	do
		CF_LINE=`printf 'name="rdriver" parent="rdnexus" target=%s lun=%s;\n' "$ID" "$LUN"`
		echo ${CF_LINE} >>/tmp/symconf_out.$$
		if [ $? -ne 0 ]
		then
			echo name=\"rdriver\" parent=\"pseudo\" instance=0\; 
			echo "Error while creating rdriver.conf: Unable to write /tmp/symconf_out.$$" >>/tmp/symconf_err.$$
			cp /tmp/symconf_err.$$ /tmp/symconf.err
			exit 6
		fi
		LUN=`expr $LUN + 1`
	done
	ID=`expr $ID + 1`
done


cat /tmp/symconf_out.$$
if [ $? -ne 0 ]
then
	echo name=\"rdriver\" parent=\"pseudo\" instance=0\; 
	echo "Error while creating rdriver.conf: Unable to read /tmp/symconf_out.$$" >>/tmp/symconf_err.$$
	cp /tmp/symconf_err.$$ /tmp/symconf.err
	exit 6
fi
rm /tmp/symconf_out.$$  2>/dev/null

if [ $TooManyBusses -ne 0 ]
then
	cp /tmp/symconf_err.$$ /tmp/symconf.err
	exit 10
fi

exit 0
