postinstall revision 4496171313bed39e96f21bc2f9faf2868e267ae3
a7c412f37cc73d0332887a746e81220cbf09dd00Mark Andrews# CDDL HEADER START
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# The contents of this file are subject to the terms of the
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# Common Development and Distribution License (the "License").
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# You may not use this file except in compliance with the License.
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# See the License for the specific language governing permissions
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# and limitations under the License.
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# When distributing Covered Code, include this CDDL HEADER in each
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# If applicable, add the following below this CDDL HEADER, with the
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# fields enclosed by brackets "[]" replaced with your own identifying
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# information: Portions Copyright [yyyy] [name of copyright owner]
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# CDDL HEADER END
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# Use is subject to license terms.
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# ident "%Z%%M% %I% %E% SMI"
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# Function: check_add_drv()
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# This function will check if the module has an entry in etc/name_to_major
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# If not simply calls add_drv with the arguments given. If there is
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# such an entry in name_to_major file, it adds entries in driver_aliases
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# driver_classes and minor_perm if necessary.
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews# The syntax of this function is the same as add_drv.
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews while getopts i:b:m:c:N opt
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews \?) echo "check_add_drv can not handle this option"
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews drvname=`echo $drvname | /usr/bin/sed 's;.*/;;g'`
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews /usr/bin/grep "^$drvname[ ]" $BASEDIR/etc/name_to_major > /dev/null 2>&1
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews # entry already in name_to_major, add alias, class, minorperm
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews /usr/bin/egrep "^$drvname[ ]+$i" $BASEDIR/etc/driver_aliases>/dev/null 2>&1
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews if [ $? -ne 0 ]
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews echo "$drvname $i" >> $BASEDIR/etc/driver_aliases
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews /usr/bin/egrep "^$drvname[ ]+$class( | |$)" $BASEDIR/etc/driver_classes > /dev/null 2>&1
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews if [ $? -ne 0 ]
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews echo "$drvname\t$class" >> $BASEDIR/etc/driver_classes
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews /usr/bin/grep "^$drvname:" $BASEDIR/etc/minor_perm > /dev/null 2>&1
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews if [ $? -ne 0 ]
c3c8823fed039b3a2b8e5ca8bc2f3301d1dd840eMark Andrews'"SUNW,niumx"