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