#! /bin/sh # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # ident "%Z%%M% %I% %E% SMI" # # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # SUNWpd postremove script killproc() { # kill the named process(es) pid=`/usr/bin/ps -e | /usr/bin/grep $1 | /usr/bin/sed -e 's/^ *//' -e 's/ .*//'` [ "$pid" != "" ] && kill $pid } PATH="/usr/bin:/usr/sbin:${PATH}" export PATH status=0 ISA_TYPE_I386="i386" ISA_TYPE_SPARC="sparc" ISA_TYPE="$ARCH" NAMEMAJOR="${BASEDIR}/etc/name_to_major" MINORPERM="${BASEDIR}/etc/minor_perm" DEVLINKTB="$BASEDIR/etc/devlink.tab" DRIVERALS="$BASEDIR/etc/driver_aliases" # # Driver info # DRV=glm DRVPERM='* 0600 root sys' DRVALIAS="\"pci1000,b\"" PATH_TO_INST="$BASEDIR/etc/path_to_inst" rm -f /dev/pmc if test ! -f ${NAMEMAJOR} -o ! -w ${NAMEMAJOR} then echo "rem_major: data file \'${NAMEMAJOR}\' is missing/inaccessible." >&2 exit 1 fi if test ! -f ${MINORPERM} -o ! -w ${MINORPERM} then echo "rem_minor: data file \'${MINORPERM}\' is missing/inaccessible." >&2 exit 1 fi if test ! -f ${DEVLINKTB} -o ! -w ${DEVLINKTB}; then echo "rem_devlink: data file ${DEVLINKTB} is missing/inaccessible." >&2 exit 1 fi if test ! -f ${DRIVERALS} -o ! -w ${DRIVERALS}; then echo "rem_drv_alias: data file ${DRIVERALS} is missing/inaccessible." >&2 exit 1 fi trap "rm -f /tmp/$$.*;exit 1" 1 2 3 13 15 TMP=/tmp/$$ # removes major numbers from system for device drivers # Usage: # rem_major name1 name2 name3 name4 .... rem_major() { sort +1 -2n ${NAMEMAJOR} | nawk '# NR == 1 {n=split(namelist,x) if (n < 1) exit(1) for (i=1; i<=n; i++) chklist[x[i]]++ } {if ($1 in chklist) print } ' namelist="$*" - > $TMP.del if [ -s $TMP.del ] then fgrep -v -x -f $TMP.del ${NAMEMAJOR} | sort +1 -2n -o ${NAMEMAJOR} fi } # removes minor permissions from system for device drivers # Usage: # rem_minor name1 name2 name3 name4 .... # i.e. # rem_minor 'sd:*' 'sd:a' rem_minor() { for p in "$@" do echo "$p" done | nawk '# FILENAME != "-" {permtab[$1] = $0;next} FILENAME == "-" { if ($1 !~ /:/) { printf("Bad name:minor pair: %s, skipping.\n", $1) next } if ($1 in permtab) print permtab[$1] >> permdel next } ' permdel=$TMP.perm ${MINORPERM} - >&2 if [ -s $TMP.perm ] then fgrep -v -x -f $TMP.perm ${MINORPERM} | sort +0 -1 -o ${MINORPERM} fi } # removes entries from devlink.tab file # Usage: # rem_devlink spec1 spec2 spec3 spec4 ... # # where each <spec> is: # <devfs-spec> <dev-name> <dev-link> # # rem_devlink() { while test $# -ge 2 do echo "$1 $2" shift 2 done | nawk '-F ' '# FILENAME != "-" {devlinktab[$1] = $0;next} FILENAME == "-" {if ($1 in devlinktab) print devlinktab[$1] >> devlinktmp } ' devlinktmp=$TMP.devlink ${DEVLINKTB} - >&2 if [ -s $TMP.devlink ] then fgrep -v -x -f $TMP.devlink ${DEVLINKTB} > $TMP.devlinknew && \ cp $TMP.devlinknew ${DEVLINKTB} fi } # removes entries to driver_aliases file # Usage: # rem_drv_alias spec1 spec2 spec3 # # where spec is: # <driver> <alias> # rem_drv_alias() { while test $# -ge 2 do echo "$1 $2" shift 2 done | nawk '# FILENAME != "-" {drvalias[$1] = $0;next} FILENAME == "-" {if ($1 in drvalias) print drvalias[$1] >> drvaliastmp } ' drvaliastmp=$TMP.drvalias ${DRIVERALS} - >&2 if [ -s $TMP.drvalias ] then # echo Removing # cat $TMP.drvalias fgrep -v -x -f $TMP.drvalias ${DRIVERALS} > $TMP.drvaliasnew && \ cp $TMP.drvaliasnew ${DRIVERALS} fi } # Remove drivers if installed # SUNWpd contains ecpp on SPARC only - run on SPARC only if [ "${ISA_TYPE}" = "${ISA_TYPE_SPARC}" ]; then modnum=`grep -c ecpp ${NAMEMAJOR}` if [ "$modnum" = "1" ]; then /usr/sbin/rem_drv -b ${BASEDIR} ecpp || status=1 fi fi rm -f /tmp/$$.* # Do not update on sparc machine if [ "${ISA_TYPE}" = "${ISA_TYPE_I386}" ]; then # # Select the correct rem_drv options to execute. # Only attempt to unload the driver on a running system. # if [ "${BASEDIR}" = "/" ]; then REM_DRV="rem_drv" else REM_DRV="rem_drv -b ${BASEDIR}" fi # # before attempting to remove the driver. # grep -w "${DRV}" ${BASEDIR}/etc/name_to_major > /dev/null 2>&1 if [ $? -eq 0 ]; then ${REM_DRV} ${DRV} if [ $? -ne 0 ]; then echo "\nFailed rem_drv!\n" >&2 exit 1 fi fi # # rem_drv doesn't remove the entry in /dev therefore this script # will have to finish off that clean up. # rm -f ${BASEDIR}/dev/${DRV} # # restore symhisl entries # # Select the correct add_drv options to execute for symhisl # if [ "${BASEDIR}" = "/" ]; then # # Irrespective of whether hardware exists # or not don't attempt to attach driver # to the hardware. This is to avoid problems # with installing a 32 bit driver on a 64 bit # running system. # ADD_DRV="add_drv -n" else # # On a client, # modify the system files and touch/reconfigure # for reconfigure reboot # ADD_DRV="add_drv -b ${BASEDIR}" fi echo "symhisl ${DRVALIAS}" >> ${BASEDIR}/etc/driver_aliases # Remove references to glm if any in /etc/path_to_inst to # avoid confusion. grep -v "pci1000,b@" $PATH_TO_INST >> $PATH_TO_INST.new mv $PATH_TO_INST.new $PATH_TO_INST fi exit $status