i.nametomajor revision 7c478bd95313f5f23a4c958a745db2134aa03244
0N/A# The contents of this file are subject to the terms of the 0N/A# Common Development and Distribution License, Version 1.0 only 0N/A# (the "License"). You may not use this file except in compliance 0N/A# See the License for the specific language governing permissions 0N/A# and limitations under the License. 0N/A# When distributing Covered Code, include this CDDL HEADER in each 0N/A# If applicable, add the following below this CDDL HEADER, with the 0N/A# fields enclosed by brackets "[]" replaced with your own identifying 0N/A# information: Portions Copyright [yyyy] [name of copyright owner] 0N/A# Copyright 2005 Sun Microsystems, Inc. All rights reserved. 0N/A# Use is subject to license terms. 0N/A#ident "%Z%%M% %I% %E% SMI" 0N/A# add_major - adds new major numbers to system for device drivers on older 0N/A# Solaris systems where add_drv -b was not available or had bugs. This 0N/A# code will be removed when doing a server_upgrade on systems with missing 0N/A# or broken add_drv is eventually EOL'd. DO NOT COPY THIS CODE TO OTHER 0N/ABEGIN {oldmajor = -1} 0N/ANR == 1 {n=split(namelist,x) 0N/A for (i=1; i<=n; i++) 0N/A {for (name in chklist) 0N/A delete chklist[name] 0N/A if (($2 - oldmajor) > 1) 0N/A gaplist[gap] = oldmajor " " $2; 0N/A for (name in chklist) 0N/A addlist[addsize++] = name 0N/A for (i=1; i<=gap && addidx < addsize; i++) for (begmajor++;begmajor < endmajor && addidx < addsize;) printf "%s %d\n",addlist[addidx],begmajor for (; addidx < addsize; addidx++) printf "%s %d\n",addlist[addidx],oldmajor echo "Adding the following devices to $dest :" # obsolete_sparc - Filter function to remove obsolete SPARC driver entries. # We define an associative array of bad driver names, and then nawk out # lines where the first token is defined in our array. } !($1 in obs) { print $1, $2 }' # obsolete_i386 - Filter function to remove obsolete i386 driver entries. # We define an associative array of bad driver names, and then nawk out # lines where the first token is defined in our array. } !($1 in obs) { print $1, $2 }' # Useful debugging which is reasonable to include in a production system: # we copy the salient driver files to the package undo directory before # doing any work. This will help diagnose add_drv errors before the system # becomes an unbootable smoldering ruin. # some reason it has been removed, create an empty one at this time. # Recall that in SUNWcsr's pkginfo.tmpl, the driver_aliases class-action # script is invoked *after* this class-action script. This is critical # because if we are going to add_drv a new driver 'foo', and 'foo' has # an alias 'bar', the add_drv of 'foo' will fail if the alias is already # present. Thus new aliases must be added *after* new driver major entries. # The driver_aliases class-action script will add the complete set of aliases # if we create an empty file here, so this code allows us to continue and # get a correct upgrade in the face of a missing driver_aliases file. # Strip obsolete entries from the existing name_to_major # PKG_CLIENT_VERSION is provided by PSARC 2001/472 for allowing # package developers to inspect a client's OS VERSION from # within a package procedure script. It returns following # possible OS VERSION #'s(up to S10): 2.3, 2.4, 2.5, 2.5.1, 2.6 # remove the leading "2.", if any # fall back to use "uname" and remove the leading "5." # If the driver is already present in name_to_major, # leave the existing number and continue # Otherwise add the driver to name_to_major using # add_drv produces spurious output even on # success, so save its output in a temporary # file in case an error occurs. # If no name_to_major is present on the target system, # just copy over the one from the package.