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 2009 Sun Microsystems, Inc. All rights reserved. 24 # Use is subject to license terms. 25 # 26 # ident "%Z%%M% %I% %E% SMI" 27 28 # Function: check_add_drv() 29 # 30 # This function will check if the module has an entry in etc/name_to_major 31 # If not simply calls add_drv with the arguments given. If there is 32 # such an entry in name_to_major file, it adds entries in driver_aliases 33 # driver_classes and minor_perm if necessary. 34 # The syntax of this function is the same as add_drv. 35 36 check_add_drv() 37 { 38 if [ "$BASEDIR" = "" ] 39 then 40 BASEDIR=/ 41 fi 42 alias="" 43 class="" 44 ADD_ALIAS=0 45 ADD_CLASS=0 46 ADD_MINOR=0 47 OPTIND=1 48 IS_NET_DRIVER=0 49 50 cmd="add_drv" 51 52 NO_CMD= 53 while getopts i:b:m:c:N opt 54 do 55 case $opt in 56 N ) NO_CMD=1;; 57 i ) ADD_ALIAS=1 58 alias=$OPTARG 59 cmd=$cmd" -i '$alias'" 60 ;; 61 m ) ADD_MINOR=1 62 minor=$OPTARG 63 cmd=$cmd" -m '$minor'" 64 ;; 65 c) ADD_CLASS=1 66 class=$OPTARG 67 cmd=$cmd" -c $class" 68 ;; 69 b) BASEDIR=$OPTARG 70 cmd=$cmd" -b $BASEDIR" 71 ;; 72 \?) echo "check_add_drv can not handle this option" 73 return 74 ;; 75 esac 76 done 77 shift `/usr/bin/expr $OPTIND - 1` 78 79 drvname=$1 80 81 cmd=$cmd" "$drvname 82 83 drvname=`echo $drvname | /usr/bin/sed 's;.*/;;g'` 84 85 /usr/bin/grep "^$drvname[ ]" $BASEDIR/etc/name_to_major > /dev/null 2>&1 86 87 # 88 # NB: We really would have liked to use update_drv here, but 89 # since we can't do that (see CR 6281386), we have this code. 90 # Note that if we've never added this driver before, the add_drv 91 # below takes care of worrying about conflicting entries in 92 # /etc/driver_aliases. (It will fail if there is a conflicting 93 # driver squatting on the alias.) 94 # 95 if [ "$NO_CMD" = "" -a $? -ne 0 ] 96 then 97 eval $cmd 98 else 99 # entry already in name_to_major, add alias, class, minorperm 100 # if necessary 101 if [ $ADD_ALIAS = 1 ] 102 then 103 for i in $alias 104 do 105 /usr/bin/egrep "^$drvname[ ]+$i" $BASEDIR/etc/driver_aliases>/dev/null 2>&1 106 if [ $? -ne 0 ] 107 then 108 echo "$drvname $i" >> $BASEDIR/etc/driver_aliases 109 fi 110 done 111 fi 112 113 if [ $ADD_CLASS = 1 ] 114 then 115 /usr/bin/egrep "^$drvname[ ]+$class( | |$)" $BASEDIR/etc/driver_classes > /dev/null 2>&1 116 if [ $? -ne 0 ] 117 then 118 echo "$drvname\t$class" >> $BASEDIR/etc/driver_classes 119 fi 120 fi 121 122 if [ $ADD_MINOR = 1 ] 123 then 124 /usr/bin/grep "^$drvname:" $BASEDIR/etc/minor_perm > /dev/null 2>&1 125 if [ $? -ne 0 ] 126 then 127 minorentry="$drvname:$minor" 128 echo $minorentry >> $BASEDIR/etc/minor_perm 129 fi 130 fi 131 132 fi 133 134 135 } 136 137 check_add_drv -b "${BASEDIR}" -i \ 138 '"pci10b7,9300" 139 "pci1113,1216" 140 "pci1317,981" 141 "pci1317,985" 142 "pci1317,1985" 143 "pci1317,9511" 144 "pci1317,9513" 145 "pci13d1,ab02" 146 "pci13d1,ab03" 147 "pci13d1,ab08" 148 "pci1737,ab08"' \ 149 -m '* 0666 root sys' afe 150