Home | History | Annotate | Download | only in SUNWpsdir
      1 #
      2 # CDDL HEADER START
      3 #
      4 # The contents of this file are subject to the terms of the
      5 # Common Development and Distribution License (the "License").
      6 # You may not use this file except in compliance with the License.
      7 #
      8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9 # or http://www.opensolaris.org/os/licensing.
     10 # See the License for the specific language governing permissions
     11 # and limitations under the License.
     12 #
     13 # When distributing Covered Code, include this CDDL HEADER in each
     14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15 # If applicable, add the following below this CDDL HEADER, with the
     16 # fields enclosed by brackets "[]" replaced with your own identifying
     17 # information: Portions Copyright [yyyy] [name of copyright owner]
     18 #
     19 # CDDL HEADER END
     20 #
     21 #
     22 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     23 # Use is subject to license terms.
     24 #
     25 
     26 #
     27 # postinstall script for SUNWpsdir package.
     28 #
     29 #ident	"%Z%%M%	%I%	%E% SMI"
     30 #
     31 #
     32 	
     33 # This function will check if the module has an entry in etc/name_to_major
     34 # If not simply calls add_drv with the arguments given. If there is
     35 # such an entry in name_to_major file, it adds entries in driver_aliases
     36 # driver_classes and minor_perm if necessary.
     37 # The syntax of this function is the same as add_drv. 
     38 
     39 
     40 check_add_drv()
     41 {
     42 	basedir=/  
     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 	while getopts i:b:m:c:n  opt
     54 	do
     55 		case $opt in
     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 			n)	IS_NET_DRIVER=1
     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 [ $? -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 	# The following clone device/dev is needed for Custom Jumpstart
    128 
    129 	if [ $IS_NET_DRIVER -eq 1 ]
    130 	then
    131 		CLONE_DEVICE=devices/pseudo/clone@0:$drvname
    132 		set `/usr/bin/grep "^clone[ 	]" $basedir/etc/name_to_major`
    133 		CLONE_MAJ=$2
    134 		set `/usr/bin/grep "^$drvname[ 	]" $basedir/etc/name_to_major`
    135 		DRIVER_MAJ=$2
    136 		mknod $basedir/$CLONE_DEVICE c $CLONE_MAJ $DRIVER_MAJ
    137 		chmod 600 $basedir/$CLONE_DEVICE
    138 		chgrp sys $basedir/$CLONE_DEVICE
    139 		chown root $basedir/$CLONE_DEVICE
    140 		ln -s ../$CLONE_DEVICE $basedir/dev/$drvname
    141 	fi
    142 	
    143 }
    144 
    145 #
    146 # Update /etc/driver_classes for drivers which change from class
    147 # "scsi" to class "dada".
    148 #
    149 
    150 drvclasses_updates()
    151 {
    152 	nawk '
    153 	BEGIN {
    154 	  seen_ata = 0
    155 	  }
    156 	/^#/ || /^$/ {
    157 	  print
    158 	  next
    159 	  }
    160 
    161 	# ATA controller driver now is a dual mode driver
    162 	# which supports both scsi and dada classes.
    163 	# Add an entry to advertise it as such in the
    164 	# /etc/driver_classes
    165 
    166 	$1 == "ata" {
    167 	  if (seen_ata == 0) {
    168 	    print "ata\tdada"
    169 	    print "ata\tscsi"
    170 	    seen_ata = 1
    171 	    }
    172 	  next
    173 	  }
    174 	{ printf "%s\t%s\n", $1, $2 }' ${BASEDIR}/etc/driver_classes > /tmp/d.$$
    175 
    176 	cp /tmp/d.$$ ${BASEDIR}/etc/driver_classes
    177 	rm /tmp/d.$$
    178 }
    179 
    180 #
    181 # Add new device drivers to system 
    182 #
    183 
    184 # Platform-specific drivers
    185 case "${ARCH}" in
    186 i386)
    187 	drvclasses_updates
    188 	check_add_drv -b "${BASEDIR}" pci-ide
    189 	check_add_drv -b "${BASEDIR}" -i '"ide"' ata
    190 	;;
    191 ppc)
    192 	;;
    193 esac
    194