postinstall revision 4bb7efa72ed531c10f097919636e67724ec4c25a
c80e152862cc3e3207dc837fde7116bd4c0e4b9dTinderbox User# CDDL HEADER START
8d1b3ceb4d491ce32572f1702f37ed585eede993Evan Hunt# The contents of this file are subject to the terms of the
d77cb075aae5595e460e3299bfc1e8ea5d42b560Evan Hunt# Common Development and Distribution License (the "License").
d77cb075aae5595e460e3299bfc1e8ea5d42b560Evan Hunt# You may not use this file except in compliance with the License.
30ca20f720ad0887772a79e7abb25b4fa0e4b5b0Mark Andrews# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
30ca20f720ad0887772a79e7abb25b4fa0e4b5b0Mark Andrews# See the License for the specific language governing permissions
30ca20f720ad0887772a79e7abb25b4fa0e4b5b0Mark Andrews# and limitations under the License.
7ec97ae74e42ec21b354fd2d1366313b41d947d6Evan Hunt# When distributing Covered Code, include this CDDL HEADER in each
701a93f5a592e4652343e049aa495d409c3ee133Mark Andrews# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
701a93f5a592e4652343e049aa495d409c3ee133Mark Andrews# If applicable, add the following below this CDDL HEADER, with the
002f1373374a0b72fc0329baa682917929bef168Tony Finch# fields enclosed by brackets "[]" replaced with your own identifying
002f1373374a0b72fc0329baa682917929bef168Tony Finch# information: Portions Copyright [yyyy] [name of copyright owner]
8f1ed05dc0aae7ae6c3da6ec6d405df61257a61eMark Andrews# CDDL HEADER END
8f1ed05dc0aae7ae6c3da6ec6d405df61257a61eMark Andrews# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
73cf0ba4e82c6baef638ecc4e31321223f841d28Mark Andrews# Use is subject to license terms.
d8351dfc9b725b0d727be7acab6247d7d501d9a0Mark Andrews# Function: check_add_drv()
d8351dfc9b725b0d727be7acab6247d7d501d9a0Mark Andrews# This function will check if the module has an entry in etc/name_to_major
3a29ce9c08dd31709c73e7187aebda0d360c537bEvan Hunt# If not simply calls add_drv with the arguments given. If there is
3a29ce9c08dd31709c73e7187aebda0d360c537bEvan Hunt# such an entry in name_to_major file, it adds entries in driver_aliases
5c78f1f50e53d8e2ed51a187efc2c9a0f43b4b1bMark Andrews# driver_classes and minor_perm if necessary.
f1740da065d4555039fe8bb53beb4153e3f94de3Mark Andrews# The syntax of this function is the same as add_drv.
1cf118a656f5fd210787908b845362077fc507f8Evan Hunt while getopts i:b:m:c:N opt
2cf0fe3b8092f64f8f68ae3693fe2e73e90ad1a4Mark Andrews \?) echo "check_add_drv can not handle this option"
e526027287b849f0b6ab6e069156697cbafa22c1Michał Kępień drvname=`echo $drvname | /usr/bin/sed 's;.*/;;g'`
e526027287b849f0b6ab6e069156697cbafa22c1Michał Kępień /usr/bin/grep "^$drvname[ ]" $BASEDIR/etc/name_to_major > /dev/null 2>&1
929329d2d66a7e1083c70a9c918381935bf12799Mukund Sivaraman # NB: We really would have liked to use update_drv here, but
7e1a62eea2e4ba9d6c3fc718e679b965fa514f69Mark Andrews # since we can't do that (see CR 6281386), we have this code.
ec29d217ba3a2bf3e617a7b5b6708ae221bee999Mark Andrews # Note that if we've never added this driver before, the add_drv
ec29d217ba3a2bf3e617a7b5b6708ae221bee999Mark Andrews # below takes care of worrying about conflicting entries in
afefd754734f896bf3e0590177fff83e7cdfdf35Mark Andrews # /etc/driver_aliases. (It will fail if there is a conflicting
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt # entry already in name_to_major, add alias, class, minorperm
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt /usr/bin/egrep "^$drvname[ ]+$i" $BASEDIR/etc/driver_aliases>/dev/null 2>&1
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt if [ $? -ne 0 ]
cad79077bd5b2616bc4a7a6b3cbc0953bef8917fMark Andrews echo "$drvname $i" >> $BASEDIR/etc/driver_aliases
c3237dec879f82855403ff7e3ba87b298172efd5Mark Andrews /usr/bin/egrep "^$drvname[ ]+$class( | |$)" $BASEDIR/etc/driver_classes > /dev/null 2>&1
c3237dec879f82855403ff7e3ba87b298172efd5Mark Andrews if [ $? -ne 0 ]
c3237dec879f82855403ff7e3ba87b298172efd5Mark Andrews echo "$drvname\t$class" >> $BASEDIR/etc/driver_classes
c0a2210466dec0cc81ebf2ffbe21693b57b9c29cMark Andrews /usr/bin/grep "^$drvname:" $BASEDIR/etc/minor_perm > /dev/null 2>&1
534057c9f91a3eb6e0541f3526459c716239b337Mark Andrews if [ $? -ne 0 ]
2d82ed9456e72dc4373bea19d63411afe1c48962Mark Andrews -i '"pciclass,080500" "pciclass,080501"' \