postinstall revision 5c1d0199d69216ebefa9ed86940778f6d215a97f
696N/A#!/sbin/sh
696N/A#
696N/A# CDDL HEADER START
696N/A#
696N/A# The contents of this file are subject to the terms of the
696N/A# Common Development and Distribution License (the "License").
696N/A# You may not use this file except in compliance with the License.
696N/A#
696N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
696N/A# or http://www.opensolaris.org/os/licensing.
696N/A# See the License for the specific language governing permissions
696N/A# and limitations under the License.
696N/A#
696N/A# When distributing Covered Code, include this CDDL HEADER in each
696N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
696N/A# If applicable, add the following below this CDDL HEADER, with the
696N/A# fields enclosed by brackets "[]" replaced with your own identifying
696N/A# information: Portions Copyright [yyyy] [name of copyright owner]
696N/A#
696N/A# CDDL HEADER END
696N/A#
696N/A#
696N/A# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
696N/A# Use is subject to license terms.
696N/A#
696N/A# ident "%Z%%M% %I% %E% SMI"
696N/A#
696N/A
696N/A# Function: check_add_drv()
696N/A#
844N/A# This function will check if the module has an entry in etc/name_to_major
844N/A# If not simply calls add_drv with the arguments given. If there is
696N/A# such an entry in name_to_major file, it adds entries in driver_aliases
696N/A# driver_classes and minor_perm if necessary.
696N/A# The syntax of this function is the same as add_drv.
696N/A
696N/Acheck_add_drv()
696N/A{
696N/A if [ "$BASEDIR" = "" ]
696N/A then
696N/A BASEDIR=/
696N/A fi
696N/A alias=""
696N/A class=""
696N/A ADD_ALIAS=0
696N/A ADD_CLASS=0
696N/A ADD_MINOR=0
696N/A OPTIND=1
696N/A IS_NET_DRIVER=0
696N/A
696N/A cmd="add_drv"
696N/A
696N/A NO_CMD=
696N/A while getopts i:b:m:c:N opt
696N/A do
case $opt in
N ) NO_CMD=1;;
i ) ADD_ALIAS=1
alias=$OPTARG
cmd=$cmd" -i '$alias'"
;;
m ) ADD_MINOR=1
minor=$OPTARG
cmd=$cmd" -m '$minor'"
;;
c) ADD_CLASS=1
class=$OPTARG
cmd=$cmd" -c $class"
;;
b) BASEDIR=$OPTARG
cmd=$cmd" -b $BASEDIR"
;;
\?) echo "check_add_drv can not handle this option"
return
;;
esac
done
shift `/usr/bin/expr $OPTIND - 1`
drvname=$1
cmd=$cmd" "$drvname
drvname=`echo $drvname | /usr/bin/sed 's;.*/;;g'`
/usr/bin/grep "^$drvname[ ]" $BASEDIR/etc/name_to_major > /dev/null 2>&1
#
# NB: We really would have liked to use update_drv here, but
# since we can't do that (see CR 6281386), we have this code.
# Note that if we've never added this driver before, the add_drv
# below takes care of worrying about conflicting entries in
# /etc/driver_aliases. (It will fail if there is a conflicting
# driver squatting on the alias.)
#
if [ "$NO_CMD" = "" -a $? -ne 0 ]
then
eval $cmd
else
# entry already in name_to_major, add alias, class, minorperm
# if necessary
if [ $ADD_ALIAS = 1 ]
then
for i in $alias
do
/usr/bin/egrep "^$drvname[ ]+$i" $BASEDIR/etc/driver_aliases>/dev/null 2>&1
if [ $? -ne 0 ]
then
echo "$drvname $i" >> $BASEDIR/etc/driver_aliases
fi
done
fi
if [ $ADD_CLASS = 1 ]
then
/usr/bin/egrep "^$drvname[ ]+$class( | |$)" $BASEDIR/etc/driver_classes > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo "$drvname\t$class" >> $BASEDIR/etc/driver_classes
fi
fi
if [ $ADD_MINOR = 1 ]
then
/usr/bin/grep "^$drvname:" $BASEDIR/etc/minor_perm > /dev/null 2>&1
if [ $? -ne 0 ]
then
minorentry="$drvname:$minor"
echo $minorentry >> $BASEDIR/etc/minor_perm
fi
fi
fi
}
#
# Okay, so 128h is not a legal PCI vendor id. But apparently some SPARC
# firmware creates the node with this id. Not sure why, possibly it is
# a firmware bug, possibly it was intended to prevent the driver from
# being used with 3rd party NICs. Whatever the reason, it isn't relevant
# anymore, but we still have to support the old node.
#
check_add_drv \
-b "$BASEDIR" \
-i '"pci128h,9102" "pci108e,9102" "pci1282,9102"' \
dmfe