Home | History | Annotate | Download | only in SUNWamd8111s
      1 #!/sbin/sh
      2 #
      3 # CDDL HEADER START
      4 #
      5 # The contents of this file are subject to the terms of the
      6 # Common Development and Distribution License (the "License").
      7 # You may not use this file except in compliance with the License.
      8 #
      9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10 # or http://www.opensolaris.org/os/licensing.
     11 # See the License for the specific language governing permissions
     12 # and limitations under the License.
     13 #
     14 # When distributing Covered Code, include this CDDL HEADER in each
     15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16 # If applicable, add the following below this CDDL HEADER, with the
     17 # fields enclosed by brackets "[]" replaced with your own identifying
     18 # information: Portions Copyright [yyyy] [name of copyright owner]
     19 #
     20 # CDDL HEADER END
     21 #
     22 #
     23 # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
     24 # Use is subject to license terms.
     25 #
     26 # ident	"%Z%%M%	%I%	%E% SMI"
     27 #
     28 
     29 # Function: check_add_drv()
     30 #
     31 # This function will check if the module has an entry in etc/name_to_major
     32 # If not simply calls add_drv with the arguments given. If there is
     33 # such an entry in name_to_major file, it adds entries in driver_aliases
     34 # driver_classes and minor_perm if necessary.
     35 # The syntax of this function is the same as add_drv. 
     36 
     37 check_add_drv()
     38 {
     39 	if [ "$BASEDIR" = "" ]
     40 	then
     41 		BASEDIR=/  
     42 	fi
     43 	alias=""
     44 	class=""
     45 	ADD_ALIAS=0
     46 	ADD_CLASS=0
     47 	ADD_MINOR=0
     48 	OPTIND=1
     49 	IS_NET_DRIVER=0
     50 
     51 	cmd="add_drv"
     52 
     53 	NO_CMD=
     54 	while getopts i:b:m:c:N  opt
     55 	do
     56 		case $opt in
     57 			N )	NO_CMD=1;;
     58 			i )	ADD_ALIAS=1	
     59 				alias=$OPTARG
     60 				cmd=$cmd" -i '$alias'"
     61 				;;
     62 			m )	ADD_MINOR=1
     63 				minor=$OPTARG
     64 				cmd=$cmd" -m '$minor'"
     65 				;;
     66 			c)	ADD_CLASS=1
     67 				class=$OPTARG
     68 				cmd=$cmd" -c $class"
     69 				;;
     70 			b)	BASEDIR=$OPTARG
     71 				cmd=$cmd" -b $BASEDIR"
     72 				;;
     73 			\?) 	echo "check_add_drv can not handle this option"
     74 				return
     75 				;;
     76 			esac
     77 	done 
     78 	shift `/usr/bin/expr $OPTIND - 1`
     79 	
     80 	drvname=$1
     81 
     82 	cmd=$cmd" "$drvname
     83 
     84 	drvname=`echo $drvname | /usr/bin/sed 's;.*/;;g'`
     85 
     86 	/usr/bin/grep "^$drvname[ 	]" $BASEDIR/etc/name_to_major >  /dev/null 2>&1
     87 
     88 	if [ "$NO_CMD" = "" -a $? -ne 0 ] 
     89 	then
     90 		eval $cmd
     91 	else	
     92 		# entry already in name_to_major, add alias, class, minorperm
     93 		# if necessary
     94 		if [ $ADD_ALIAS = 1 ]	
     95 		then
     96 			for i in $alias
     97 			do
     98 				/usr/bin/egrep "^$drvname[ 	]+$i" $BASEDIR/etc/driver_aliases>/dev/null 2>&1
     99 				if [ $? -ne 0 ]
    100 				then
    101 					echo "$drvname $i" >> $BASEDIR/etc/driver_aliases	
    102 				fi
    103 			done
    104 		fi
    105 
    106 		if [ $ADD_CLASS = 1 ]
    107 		then
    108 			/usr/bin/egrep "^$drvname[ 	]+$class( |	|$)" $BASEDIR/etc/driver_classes > /dev/null 2>&1
    109 			if [ $? -ne 0 ]
    110 			then 
    111 				echo "$drvname\t$class" >> $BASEDIR/etc/driver_classes
    112 			fi
    113 		fi
    114 
    115 		if [ $ADD_MINOR = 1 ]
    116 		then
    117 			/usr/bin/grep "^$drvname:" $BASEDIR/etc/minor_perm > /dev/null 2>&1
    118 			if [ $? -ne 0 ]
    119 			then 
    120 				minorentry="$drvname:$minor"
    121 				echo $minorentry >> $BASEDIR/etc/minor_perm
    122 			fi
    123 		fi
    124 
    125 	fi
    126 
    127 
    128 }
    129 
    130 ARCH=`uname -p`
    131 if [ ${ARCH} = "i386" ]
    132 then
    133 	check_add_drv -i \
    134 	'"pci1022,7462"' \
    135 	-b "$BASEDIR" amd8111s
    136 fi
    137