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 27 # Function: check_add_drv() 28 # 29 # This function will check if the module has an entry in etc/name_to_major 30 # If not simply calls add_drv with the arguments given. If there is 31 # such an entry in name_to_major file, it adds entries in driver_aliases 32 # driver_classes and minor_perm if necessary. 33 # The syntax of this function is the same as add_drv. 34 35 check_add_drv() 36 { 37 if [ "$BASEDIR" = "" ] 38 then 39 BASEDIR=/ 40 fi 41 alias="" 42 class="" 43 ADD_ALIAS=0 44 ADD_CLASS=0 45 ADD_MINOR=0 46 OPTIND=1 47 IS_NET_DRIVER=0 48 49 cmd="add_drv" 50 51 NO_CMD= 52 while getopts i:b:m:c:N opt 53 do 54 case $opt in 55 N ) NO_CMD=1;; 56 i ) ADD_ALIAS=1 57 alias=$OPTARG 58 cmd=$cmd" -i '$alias'" 59 ;; 60 m ) ADD_MINOR=1 61 minor=$OPTARG 62 cmd=$cmd" -m '$minor'" 63 ;; 64 c) ADD_CLASS=1 65 class=$OPTARG 66 cmd=$cmd" -c $class" 67 ;; 68 b) BASEDIR=$OPTARG 69 cmd=$cmd" -b $BASEDIR" 70 ;; 71 \?) echo "check_add_drv can not handle this option" 72 return 73 ;; 74 esac 75 done 76 shift `/usr/bin/expr $OPTIND - 1` 77 78 drvname=$1 79 80 cmd=$cmd" "$drvname 81 82 drvname=`echo $drvname | /usr/bin/sed 's;.*/;;g'` 83 84 /usr/bin/grep "^$drvname[ ]" $BASEDIR/etc/name_to_major > /dev/null 2>&1 85 86 if [ "$NO_CMD" = "" -a $? -ne 0 ] 87 then 88 eval $cmd 89 else 90 # entry already in name_to_major, add alias, class, minorperm 91 # if necessary 92 if [ $ADD_ALIAS = 1 ] 93 then 94 for i in $alias 95 do 96 /usr/bin/egrep "^$drvname[ ]+$i" $BASEDIR/etc/driver_aliases>/dev/null 2>&1 97 if [ $? -ne 0 ] 98 then 99 echo "$drvname $i" >> $BASEDIR/etc/driver_aliases 100 fi 101 done 102 fi 103 104 if [ $ADD_CLASS = 1 ] 105 then 106 /usr/bin/egrep "^$drvname[ ]+$class( | |$)" $BASEDIR/etc/driver_classes > /dev/null 2>&1 107 if [ $? -ne 0 ] 108 then 109 echo "$drvname\t$class" >> $BASEDIR/etc/driver_classes 110 fi 111 fi 112 113 if [ $ADD_MINOR = 1 ] 114 then 115 /usr/bin/grep "^$drvname:" $BASEDIR/etc/minor_perm > /dev/null 2>&1 116 if [ $? -ne 0 ] 117 then 118 minorentry="$drvname:$minor" 119 echo $minorentry >> $BASEDIR/etc/minor_perm 120 fi 121 fi 122 123 fi 124 125 exit 0 126 127 128 } 129 130 check_add_drv -b "${BASEDIR}" -i \ 131 '"pci10de,56" "pci10de,57" "pci10de,269" "pci10de,268" "pci10de,373" "pci10de,372" 132 "pci10de,37" "pci10de,38" "pci10de,3ee" "pci10de,3ef" "pci10de,760" "pci10de,ab0" "pci10de,e6" "pci10de,df"' nge 133