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