#!/bin/ksh #******************************************************************************* # # NAME: add_rdac # SUMMARY: %description% # COMPONENT: solsysd # VERSION: rm6_6 # UPDATE DATE: %date_modified: Tue Sep 16 15:44:32 1997 % # PROGRAMMER: %created_by: mgallagh % # # Copyright 1997 by Symbios Logic Inc. # # DESCRIPTION: # add_rdac carries out the necessary steps to register newly-created LUNs with # the RDAC driver, and to make names for the new LUN appear under /dev. # # NOTES: # # 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 # - 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_HOME/bin/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 # - name of the mutex guarding the critical region # # NOTES: # # RETURNS: # Nothing MutexRelease() { /bin/rm $1; } #******************************************************************************* # PROCEDURE: add_rdac (main) # SUMMARY: Register a new LUN with the RDAC driver # # DESCRIPTION: # add_rdac peforms the following steps: (1) modify rdriver.conf to reflect # the new LUN configuration, (2) inform the RDAC driver of the new LUN # existence (via the "bind_rd" program), (3) register the new LUN with the OS # (via the "drvconfig" program), and (4) create device names for the new LUNs # (via the "symdisks" program). # # SYNTAX: # add_rdac # # NOTES: # # RETURNS: # 0 - success # 1 - failure # A D D _ R D A C M A I N P R O C E D U R E PARMS=/etc/raid/rmparams DEV_KEY=System_AltDevDirRoot HOME_DIR_KEY=System_RmHomeDirectory BOOT_HOME_KEY=System_RmBootHomeDirectory RD_SUPPORT_KEY=Rdac_SupportDisabled.*=.*TRUE RMDEVROOT=`grep -v "^#" $PARMS | grep $DEV_KEY | cut -d= -f2 | awk -F/ '{ ORS = "/"; for (i = NF; i > 1; --i) print $i; ORS = "\n"; print $1 }' | cut -d"/" -f3-32 | awk -F/ '{ ORS = "/"; for (i = NF; i > 1; --i) print $i; ORS = "\n"; print $1 }'` RM_HOME=`grep -v "^#" $PARMS | grep $HOME_DIR_KEY | cut -d= -f2` RM_BOOT_HOME=`grep -v "^#" $PARMS | grep $BOOT_HOME_KEY | cut -d= -f2` SYMCONF=$RM_BOOT_HOME/symconf SYMDISKS=$RM_BOOT_HOME/symdisks if grep -v "^#" $PARMS | grep "$RD_SUPPORT_KEY" >/dev/null 2>&1 then RDAC_DISABLED=TRUE fi if [ -x "/usr/ucb/logger" ] then LOGGER=/usr/ucb/logger elif [ -x "/usr/bin/logger" ] then LOGGER=/usr/bin/logger else LOGGER=/bin/echo fi if [ -z "$RDAC_DISABLED" ] # (RDAC is enabled) then # # modify rdriver.conf # MutexAcquire /tmp/mutex.add_rdac cp /kernel/drv/rdriver.conf /tmp/rdriver.conf.orig.$$ $SYMCONF -i >/tmp/rdriver.conf.$$ 2>/dev/null SYMCONF_STAT=$? if [ \( $SYMCONF_STAT -eq 0 \) -a \( -s /tmp/rdriver.conf.$$ \) ] then cp /tmp/rdriver.conf.$$ /kernel/drv/rdriver.conf else cp /tmp/rdriver.conf.orig.$$ /kernel/drv/rdriver.conf $LOGGER -p user.err "$SYMCONF called by $0 failed" MutexRelease /tmp/mutex.add_rdac exit 1 fi # make sure we don't foul up permissions on rdriver.conf chmod 644 /kernel/drv/rdriver.conf chown root /kernel/drv/rdriver.conf chgrp sys /kernel/drv/rdriver.conf rm /tmp/rdriver.conf.$$ /tmp/rdriver.conf.orig.$$ 2>/dev/null MutexRelease /tmp/mutex.add_rdac fi $SYMDISKS -r / -d rdriver >/dev/null 2>&1 exit 0