OpenSolaris_b135/pkgdefs/SUNWmegasas/postinstall

#!/sbin/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
#
# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

# Function: check_add_drv()
#
# This function will check if the module has an entry in etc/name_to_major
# If not simply calls add_drv with the arguments given. If there is
# such an entry in name_to_major file, it adds entries in driver_aliases
# driver_classes and minor_perm if necessary.
# The syntax of this function is the same as add_drv. 

check_add_drv()
{
	if [ "$BASEDIR" = "" ]
	then
		BASEDIR=/  
	fi
	alias=""
	class=""
	ADD_ALIAS=0
	ADD_CLASS=0
	ADD_MINOR=0
	OPTIND=1
	IS_NET_DRIVER=0

	cmd="add_drv"

	NO_CMD=

	while getopts i:b:m:c:N  opt
	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

	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


}

# We should all use main PCI ID entries. The 4-tuple entries are used to patch 
# specific cards, or they will be wrongly matched by other drivers.

check_add_drv -b "${BASEDIR}" -i \
	'"pci1000,57.8086.3002"
	"pci1000,60.1000.1006"
	"pci1000,60.1000.100a"
	"pci1000,60.1000.100e"
	"pci1000,60.1000.100f"
	"pci1000,60.1000.1010"
	"pci1000,60.1000.1011"
	"pci1000,60.1000.1012"
	"pci1000,60.1000.1013"
	"pci1000,60.1000.1014"
	"pci1000,60.1000.1015"
	"pci1000,60.1000.1016"
	"pci1000,60.1000.1017"
	"pci1000,60.1000.1018"
	"pci1000,60.1000.1019"
	"pci1000,60.1000.101a"
	"pci1000,60.1000.101b"
	"pci1000,60.1000.1021"
	"pci1000,60.1000.1022"
	"pci1000,60.1014.363"
	"pci1000,60.1014.364"
	"pci1000,60.1014.365"
	"pci1000,60.1014.379"
	"pci1000,60.1014.3a2"
	"pci1000,60.1014.3ac"
	"pci1000,60.1028.1f0a"
	"pci1000,60.1028.1f0b"
	"pci1000,60.1028.1f0c"
	"pci1000,60.1028.1f0d"
	"pci1000,60.1028.1f11"
	"pci1000,60.1033.835a"
	"pci1000,60.1033.836e"
	"pci1000,60.1043.824d"
	"pci1000,60.1054.3019"
	"pci1000,60.1170.2f"
	"pci1000,60.1170.34"
	"pci1000,60.1170.36"
	"pci1000,60.1458.1000"
	"pci1000,60.1734.10f9"
	"pci1000,60.1734.1102"
	"pci1000,60.1734.114b"
	"pci1000,60.17aa.6b7c"
	"pci1000,60.15d9.c080"
	"pci1000,60.18a1.3"
	"pci1000,60.19e5.2001"
	"pci1000,60.19e5.2002"
	"pci1000,60.19e5.2003"
	"pci1000,60.19e5.2004"
	"pci1000,60.19e5.2005"
	"pci1000,60.19e5.2006"
	"pci1000,60.19e5.2010"
	"pci1000,60.19e5.2011"
	"pci1000,60.19e5.2012"
	"pci1000,60.19e5.2013"
	"pci1000,60.19e5.2014"
	"pci1000,60.19e5.2015"
	"pci1000,60.19e5.2016"
	"pci1000,60.19e5.2017"
	"pci1000,60.19e5.2018"
	"pci1000,60.19e5.2019"
	"pci1000,60.19e5.201a"
	"pci1000,60.19e5.d203"
	"pci1000,60.1b0a.14"
	"pci1000,60.1fca.2163"
	"pci1000,60.1fca.2164"
	"pci1000,60.8086.1006"
	"pci1000,60.8086.100a"
	"pci1000,60.8086.1010"
	"pci1000,60.8086.1013"
	"pci1000,60.8086.1021"
	"pci1000,60.8086.34cc"
	"pci1000,60.8086.34cd"
	"pci1000,60.8086.34e4"
	"pci1000,60.8086.3505"
	"pci1000,60.8086.3508"
	"pci1000,7c.1000.101c"
	"pci1000,7c.1000.101d"
	"pci1000,7c.1014.395"
	"pci1000,411.1000.1001"
	"pci1000,411.1000.1002"
	"pci1000,411.1000.1003"
	"pci1000,411.1000.1004"
	"pci1000,411.1000.1008"
	"pci1000,411.1000.100c"
	"pci1000,411.1000.100d"
	"pci1000,411.1000.2004"
	"pci1000,411.1000.2005"
	"pci1000,411.1033.8287"
	"pci1000,411.1054.3016"
	"pci1000,411.1734.1081"
	"pci1000,411.1734.10a3"
	"pci1000,411.8086.1001"
	"pci1000,411.8086.1003"
	"pci1000,411.8086.1008"
	"pci1000,411.8086.3490"
	"pci1000,411.8086.3500"
	"pci1000,411.8086.3501"
	"pci1000,411.8086.3504"
	"pci1000,411.8086.3507"
	"pci1000,413.1000.1005"
	"pci1028,15.1028.1f01"
	"pci1028,15.1028.1f02"
	"pci1028,15.1028.1f03"' \
	-c scsi mega_sas