postinstall revision 8d483882aa3390058094b043f3d62187b5d1de03
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
# ident "%Z%%M% %I% %E% SMI"
ROOT=${PKG_INSTALL_ROOT:-/}
DRIVER_ALIASES='"pci10de,37f" "pci10de,55" "pci10de,54"'
#
# get_devinfo_prop(file, prop)
#
# <prtconf.out> file that has output from 'prtconf -vp' command
# <prop> name of the property OR "ALL" for all properties
#
# parse the output of prtconf command and print the value of
# of the specified property or all if <prop> is "ALL" in
# the format "<name>=<value>".
#
{
BEGIN {
if (match(prop,"ALL"))
check_all=1;
else
check_all=0;
}
{
if (!match($1, "name="))
next;
if (!check_all) {
pname = sprintf("name=\047%s\047", prop);
if (!match($1, pname))
next;
}
gsub("\047", "", $1);
name = substr($1, index($1,"=")+1);
if (match($2, "type=boolean")) {
value=1;
} else if (match($2, "type=int") || match($2, "type=byte")) {
getline;
value = ""
cnt = split(substr($0,index($0, "=")+1), words, ".");
for (i = 1; i <= cnt; i++) {
w = "0x" skipzeros(words[i]);
if (i > 1)
value = value " ";
value = value w;
}
} else {
getline;
value = substr($0,index($0, "=")+1);
}
if (!check_all) {
print value;
exit (0);
}
print name "=" value;
}
# skp the leading '0' characters in the string
function skipzeros (str, out, n, i)
{
n = length(str);
for (i = 1; i <= n; i++) {
if (!match(substr(str, i, 1), "0")) {
break;
}
}
if (i > n)
out=substr(str,n);
else
out=substr(str,i);
return (out);
}'
}
#
# Function get_properties() gets the following properties for the
# device (i.e /devices path without '/devices' prefix) passed as
# an argument:
#
# vendor-id
# device-id
# subsystem-vendor-id
# subsystem-id
#
# Note: it saves the pathname and the properties in ${DEV_PROPS} file
# to optimize subsequent mapping calls for the same path name.
#
# e.g: get_properties "/pci@0,0/pci-ide@1f,2"
#
{
if [ -f ${DEV_PROPS} ]
then
mapped_path=`${GREP} $1 ${DEV_PROPS}`
if [ $? -eq 0 ]
then
return;
fi
fi
if [ $? -eq 0 ]
then
rm -f ${PRTCONF_OUT}
else
vendor_id=""
device_id=""
subsystem_id=""
fi
}
#
# Function process_bootenvrc_for_install() converts bootpath in ata style
# to nv_sata style in the file /boot/solaris/bootenv.rc for normal upgrade.
#
# Check to see if bootenv.rc file has ata disk entries.
if [ $? -eq 1 ]
then
# There is no ata disk entry. No mapping is needed.
return 0
fi
# Backup the bootenv.rc file.
$CP ${BOOTENVRC} ${BOOTENVRC_BAK}
if [ $? -ne 0 ]
then
# Can't backup bootenv.rc file.
${RM} -rf ${NVSATA_TMP}
exit 1
fi
do
s/\/cmdk@.//
}"`
do
for pair in ${DRIVER_ALIASES}
do
# Check to see if it is a nv_sata device.
then
if [ "X${subsystem_vendor_id}" = "X" ]
then
ids="pci${vendor_id},${device_id}"
else
ids="pci${subsystem_vendor_id},${subsystem_id}"
fi
s/\/cmdk@.//
}"`
if [ ${new_path} = ${mapped_path} ]
then
if [ ! -f ${NVSATA_TMP}/bootenv.rc ]
then
fi
echo "setprop bootpath ${new_path}" \
>> ${NVSATA_TMP}/bootenv.rc
break
fi
fi
done
done
done
# Commit the changes
if [ -f ${NVSATA_TMP}/bootenv.rc ]
then
${CP} ${NVSATA_TMP}/bootenv.rc ${BOOTENVRC}
if [ $? -ne 0 ]
then
# Failed to modify bootenv.rc file.
${RM} -rf ${NVSATA_TMP}
exit 1
fi
fi
}
#
# Function process_bootenvrc_for_lu() converts bootpath in ata style
# to nv_sata style in the file /boot/solaris/bootenv.rc for live upgrade.
#
# Check to see if bootenv.rc has ata disk entries.
if [ $? -eq 1 ]
then
# There is no ata disk. No mapping is needed.
return 0
fi
# Backup the bootenv.rc file.
$CP ${BOOTENVRC} ${BOOTENVRC_BAK}
if [ $? -ne 0 ]
then
# Can't backup bootenv.rc file.
${RM} -rf ${NVSATA_TMP}
exit 1
fi
do
if [ "X${no_nvsata_in_CBE}" != "X0" ]
then
# Check if boot device is a supported nv_sata device.
for pair in ${DRIVER_ALIASES}
do
${dr_device_id} ]
then
if [ "X${subsystem_vendor_id}" = "X" ]
then
ids="pci${vendor_id},${device_id}"
else
ids="pci${subsystem_vendor_id},${subsystem_id}"
fi
if [ ! -f ${NVSATA_TMP}/bootenv.rc ]
then
fi
s/\/cmdk@.//
}"`
echo ${mapped_bootpath_line} >> ${NVSATA_TMP}/bootenv.rc
break
fi
done
else
is_mapped="no"
s/\/cmdk@.//
}"`
do
for pair in ${DRIVER_ALIASES}
do
# Check to see if it is a nv_sata device.
then
if [ "X${subsystem_vendor_id}" = "X" ]
then
ids3="pci${vendor_id},${device_id}"
else
ids3="pci${subsystem_vendor_id},${subsystem_id}"
fi
s/\/cmdk@.//
}"`
mapped_bootpath=`echo ${mapped_bootpath_line} \
if [ $? -eq 0 ]
then
if [ ! -f ${NVSATA_TMP}/bootenv.rc ]
then
fi
echo ${mapped_bootpath_line} >> \
is_mapped="yes"
break
fi
fi
done
if [ "${is_mapped}" = "yes" ]
then
break
fi
done
fi
done
# Commit the changes
if [ -f ${NVSATA_TMP}/bootenv.rc ]
then
${CP} ${NVSATA_TMP}/bootenv.rc ${BOOTENVRC}
if [ $? -ne 0 ]
then
# Failed to modify bootenv.rc file.
${RM} -rf ${NVSATA_TMP}
exit 1
fi
fi
}
#
# old ata fromat to new nv_sata format during live upgrade.
#
# Check to see if system has ata disk as a root device.
if [ $? -eq 1 ]
then
# roodev entry does not exist, or root disk is not ata.
return 0
fi
${CP} ${SYSTEM} ${SYSTEM_BAK}
if [ $? -ne 0 ]
then
# Can't backup system file."
$CP ${BOOTENVRC_BAK} ${BOOTENVRC}
${RM} -rf ${NVSATA_TMP}
exit 1
fi
rootdev=`echo ${rootdev_line} | ${CUT} -d: -f2-`
if [ "X${no_nvsata_in_CBE}" != "X0" ]
then
get_properties ${ar}
# Check if boot device is a supported nv_sata device.
for pair in ${DRIVER_ALIASES}
do
${device_id} = ${dr_device_id} ]
then
if [ "X${subsystem_vendor_id}" = "X" ]
then
ids="pci${vendor_id},${device_id}"
else
ids="pci${subsystem_vendor_id},${subsystem_id}"
fi
$SED "{
s/\/cmdk@.//
break
fi
done
else
s/\/cmdk@.//
}"`
is_mapped="no"
do
get_properties ${ar}
for pair in ${DRIVER_ALIASES}
do
# Check to see if it is a nv_sata device.
then
if [ "X${subsystem_vendor_id}" = "X" ]
then
ids="pci${vendor_id},${device_id}"
else
ids="pci${subsystem_vendor_id},${subsystem_id}"
fi
s/\/cmdk@.//
}"`
if [ $? -eq 0 ]
then
$SED "{
s/\/cmdk@.//
break
fi
fi
done
if [ "${is_mapped}" = "yes" ]
then
break
fi
done
fi
if [ -f ${NVSATA_TMP}/system ]
then
${CP} ${NVSATA_TMP}/system ${SYSTEM}
if [ $? -ne 0 ]
then
# Failed to modify system file.
$CP ${BOOTENVRC_BAK} ${BOOTENVRC}
${RM} -rf ${NVSATA_TMP}
exit 1
fi
fi
}
#
# old ata format to new nv_sata format during the upgrade installation.
#
# Check to see if system has ata disk as a root device.
if [ $? -eq 1 ]
then
# roodev entry does not exist, or root disk is not ata.
return 0
fi
${CP} ${SYSTEM} ${SYSTEM_BAK}
if [ $? -ne 0 ]
then
# Can't backup system file."
$CP ${BOOTENVRC_BAK} ${BOOTENVRC}
${RM} -rf ${NVSATA_TMP}
exit 1
fi
rootdev=`echo ${rootdev_line} | ${CUT} -d: -f2-`
s/\/cmdk@.//
}"`
is_mapped="no"
do
for pair in ${DRIVER_ALIASES}
do
# Check to see if it is a nv_sata device.
then
if [ "X${subsystem_vendor_id}" = "X" ]
then
ids="pci${vendor_id},${device_id}"
else
ids="pci${subsystem_vendor_id},${subsystem_id}"
fi
s/\/cmdk@.//
}"`
if [ $? -eq 0 ]
then
$SED "{
s/\/cmdk@.//
is_mapped="yes"
break
fi
fi
done
if [ "${is_mapped}" = "yes" ]
then
break
fi
done
if [ -f ${NVSATA_TMP}/system ]
then
${CP} ${NVSATA_TMP}/system ${SYSTEM}
if [ $? -ne 0 ]
then
# Failed to modify system file.
$CP ${BOOTENVRC_BAK} ${BOOTENVRC}
${RM} -rf ${NVSATA_TMP}
exit 1
fi
fi
}
#
# Function process_power_conf_for_lu converts ata device path to nv_sata
# device path if any for live upgrade.
#
if [ $? -ne 0 ]
then
# No ata device entry in power.conf. No conversion is needed.
return 0
fi
$CP ${POWER_CONF} ${POWER_CONF_BAK}
if [ $? -ne 0 ]
then
# Failed to back up the power.conf file
$CP ${BOOTENVRC_BAK} ${BOOTENVRC}
$CP ${SYSTEM_BAK} ${SYSTEM}
$RM -rf ${NVSATA_TMP}
exit 1
fi
>> ${NVSATA_TMP}/power.conf
if [ "X${no_nvsata_in_CBE}" != "X0" ]
then
${POWER_CONF} | while read l
do
is_mapped="no"
new_entry=""
for i in $l
do
tp=$i
if [ $? -eq 0 ]
then
for pair in ${DRIVER_ALIASES}
do
${device_id} = ${dr_device_id} ]
then
if [ "X${subsystem_vendor_id}" = "X" ]
then
is="pci${vendor_id},${device_id}"
else
is="pci${subsystem_vendor_id},${subsystem_id}"
fi
s/\/cmdk@.//
}"`
if [ "${is_mapped}" = "no" ]
then
is_mapped="yes"
fi
break
fi
done
fi
done
if [ "${is_mapped}" = "yes" ]
then
echo ${new_entry} >> ${NVSATA_TMP}/mapped_power.conf
else
echo ${new_entry} >> ${NVSATA_TMP}/power.conf
fi
done
else
| while read l
do
is_mapped="no"
new_entry=""
for i in $l
do
tp=$i
if [ $? -eq 0 ]
then
s/\/cmdk@.//
}"`
do
np=""
for pair in ${DRIVER_ALIASES}
do
then
if [ "X${subsystem_vendor_id}" = "X" ]
then
is="pci${vendor_id},${device_id}"
else
is="pci${subsystem_vendor_id},${subsystem_id}"
fi
s/\/cmdk@.//
}"`
if [ ${np} = ${mapped_path} ]
then
tp=${mapped_path}
if [ "${is_mapped}" = "no" ]
then
is_mapped="yes"
fi
break
fi
fi
done
if [ "${is_mapped}" = "yes" ]
then
break
fi
done
fi
done
if [ "${is_mapped}" = "yes" ]
then
echo ${new_entry} >> ${NVSATA_TMP}/mapped_power.conf
else
echo ${new_entry} >> ${NVSATA_TMP}/power.conf
fi
done
fi
if [ -f ${NVSATA_TMP}/mapped_power.conf ]
then
$CAT ${NVSATA_TMP}/mapped_power.conf >> ${NVSATA_TMP}/power.conf
$CP ${NVSATA_TMP}/power.conf ${POWER_CONF}
if [ $? -ne 0 ]
then
$CP ${BOOTENVRC_BAK} ${BOOTENVRC}
$CP ${SYSTEM_BAK} ${SYSTEM}
$RM -rf ${NVSATA_TMP}
exit 1
fi
fi
}
#
# Function process_power_conf_for_install converts ata device path to nv_sata
# device path if any for normal upgrade installation.
#
if [ $? -ne 0 ]
then
# No ata device entry in power.conf. No conversion is needed.
return 0
fi
$CP ${POWER_CONF} ${POWER_CONF_BAK}
if [ $? -ne 0 ]
then
# Failed to back up the power.conf file.
$CP ${BOOTENVRC_BAK} ${BOOTENVRC}
$CP ${SYSTEM_BAK} ${SYSTEM}
$RM -rf ${NVSATA_TMP}
exit 1
fi
>> ${NVSATA_TMP}/power.conf
do
is_mapped="no"
new_entry=""
for i in $l
do
tp=$i
if [ $? -eq 0 ]
then
s/\/cmdk@.//
}"`
do
np=""
for pair in ${DRIVER_ALIASES}
do
then
if [ "X${subsystem_vendor_id}" = "X" ]
then
is="pci${vendor_id},${device_id}"
else
is="pci${subsystem_vendor_id},${subsystem_id}"
fi
s/\/cmdk@.//
}"`
if [ ${np} = ${mapped_path} ]
then
tp=${mapped_path}
if [ "${is_mapped}" = "no" ]
then
is_mapped="yes"
fi
break
fi
fi
done
if [ "${is_mapped}" = "yes" ]
then
break
fi
done
fi
done
if [ "${is_mapped}" = "yes" ]
then
echo ${new_entry} >> ${NVSATA_TMP}/mapped_power.conf
else
echo ${new_entry} >> ${NVSATA_TMP}/power.conf
fi
done
if [ -f ${NVSATA_TMP}/mapped_power.conf ]
then
$CAT ${NVSATA_TMP}/mapped_power.conf >> ${NVSATA_TMP}/power.conf
$CP ${NVSATA_TMP}/power.conf ${POWER_CONF}
if [ $? -ne 0 ]
then
$CP ${BOOTENVRC_BAK} ${BOOTENVRC}
$CP ${SYSTEM_BAK} ${SYSTEM}
$RM -rf ${NVSATA_TMP}
exit 1
fi
fi
}
#
# Function process_devlink_for_lu() links all old ata logical device names
# to new physical device paths on upgraded BE.
#
do
if [ "X${no_nvsata_in_CBE}" != "X0" ]
then
for pair in ${DRIVER_ALIASES}
do
# Check to see if it is a nv_sata device.
then
if [ "X${subsystem_vendor_id}" = "X" ]
then
ids3="pci${vendor_id},${device_id}"
else
ids3="pci${subsystem_vendor_id},${subsystem_id}"
fi
s/\/cmdk@.//
}"`
break
fi
done
else
s/\/cmdk@.//
}"`
is_mapped="no"
do
for pair in ${DRIVER_ALIASES}
do
# Check to see if it is a nv_sata device.
then
if [ "X${subsystem_vendor_id}" = "X" ]
then
ids3="pci${vendor_id},${device_id}"
else
ids3="pci${subsystem_vendor_id},${subsystem_id}"
fi
s/\/cmdk@.//
}"`
if [ ${new_path} = ${mapped_new_path} ]
then
is_mapped="yes"
break
fi
fi
done
if [ "${is_mapped}" = "yes" ]
then
break
fi
done
fi
if [ "X${mapped_new_path}" != "X" ]
then
${MV} ${logical_disk} ${logical_disk}.${BAK}
if [ $? -ne 0 ]
then
# Can't back up old link.
$CP ${BOOTENVRC_BAK} ${BOOTENVRC}
$CP ${SYSTEM_BAK} ${SYSTEM}
$CP ${POWER_CONF_BAK} ${POWER_CONF}
${RM} -rf ${NVSATA_TMP}
exit 1
fi
${LN} -s ${mapped_new_path} ${logical_disk}
if [ $? -ne 0 ]
then
# Can't create symbolic link
${MV} ${logical_disk}.${BAK} ${logical_disk}
$CP ${BOOTENVRC_BAK} ${BOOTENVRC}
$CP ${SYSTEM_BAK} ${SYSTEM}
$CP ${POWER_CONF_BAK} ${POWER_CONF}
${RM} -rf ${NVSATA_TMP}
exit 1
fi
$GREP ${c_number} ${ENUMERATE_RESERVED} >/dev/null
if [ $? -ne 0 ]
then
echo ${c_number} >> ${ENUMERATE_RESERVED}
fi
cd ../rdsk
mapped_new_path="${mapped_new_path},raw"
${MV} ${logical_disk} ${logical_disk}.${BAK}
if [ $? -ne 0 ]
then
# Can't back up old link.
${RM} ../dsk/${logical_disk}
${MV} ../dsk/${logical_disk}.${BAK} \
../dsk/${logical_disk}
$CP ${BOOTENVRC_BAK} ${BOOTENVRC}
$CP ${SYSTEM_BAK} ${SYSTEM}
$CP ${POWER_CONF_BAK} ${POWER_CONF}
${RM} -rf ${NVSATA_TMP}
exit 1
fi
${LN} -s ${mapped_new_path} ${logical_disk}
if [ $? -ne 0 ]
then
# Can't create symbolic link.
${MV} ${logical_disk}.${BAK} ${logical_disk}
${RM} ../dsk/${logical_disk}
${MV} ../dsk/${logical_disk}.${BAK} \
../dsk/${logical_disk}
$CP ${BOOTENVRC_BAK} ${BOOTENVRC}
$CP ${SYSTEM_BAK} ${SYSTEM}
$CP ${POWER_CONF_BAK} ${POWER_CONF}
${RM} -rf ${NVSATA_TMP}
exit 1
fi
fi
done
if [ $? -eq 0 ]
then
$RM ${DEVLINK_DB}
fi
}
#
# Function process_devlink_for_install() links all old ata logical device names
# to new physical device paths for normal upgrade installation.
#
do
s/\/cmdk@.//
}"`
do
for pair in ${DRIVER_ALIASES}
do
# Check to see if it is a nv_sata device.
then
if [ "X${subsystem_vendor_id}" = "X" ]
then
ids3="pci${vendor_id},${device_id}"
else
ids3="pci${subsystem_vendor_id},${subsystem_id}"
fi
s/\/cmdk@.//
}"`
if [ ${new_path} = ${mapped_new_path} ]
then
# Found the match.
${MV} ${logical_disk} ${logical_disk}.${BAK}
if [ $? -ne 0 ]
then
# Can't back up old link.
$CP ${BOOTENVRC_BAK} ${BOOTENVRC}
$CP ${SYSTEM_BAK} ${SYSTEM}
$CP ${POWER_CONF_BAK} ${POWER_CONF}
${RM} -rf ${NVSATA_TMP}
exit 1
fi
${LN} -s ${mapped_new_path} ${logical_disk}
if [ $? -ne 0 ]
then
# Can't create symbolic link
${MV} ${logical_disk}.${BAK} ${logical_disk}
$CP ${BOOTENVRC_BAK} ${BOOTENVRC}
$CP ${SYSTEM_BAK} ${SYSTEM}
$CP ${POWER_CONF_BAK} ${POWER_CONF}
${RM} -rf ${NVSATA_TMP}
exit 1
fi
$GREP ${c_number} ${ENUMERATE_RESERVED} >/dev/null
if [ $? -ne 0 ]
then
echo ${c_number} >> ${ENUMERATE_RESERVED}
fi
cd ../rdsk
mapped_new_path="${mapped_new_path},raw"
${MV} ${logical_disk} ${logical_disk}.${BAK}
if [ $? -ne 0 ]
then
# Can't back up old link.
${RM} ../dsk/${logical_disk}
${MV} ../dsk/${logical_disk}.${BAK} \
../dsk/${logical_disk}
$CP ${BOOTENVRC_BAK} ${BOOTENVRC}
$CP ${SYSTEM_BAK} ${SYSTEM}
$CP ${POWER_CONF_BAK} ${POWER_CONF}
${RM} -rf ${NVSATA_TMP}
exit 1
fi
${LN} -s ${mapped_new_path} ${logical_disk}
if [ $? -ne 0 ]
then
# Can't create symbolic link.
${MV} ${logical_disk}.${BAK} ${logical_disk}
${RM} ../dsk/${logical_disk}
${MV} ../dsk/${logical_disk}.${BAK} \
../dsk/${logical_disk}
$CP ${BOOTENVRC_BAK} ${BOOTENVRC}
$CP ${SYSTEM_BAK} ${SYSTEM}
$CP ${POWER_CONF_BAK} ${POWER_CONF}
${RM} -rf ${NVSATA_TMP}
exit 1
fi
fi
fi
done
done
done
if [ $? -eq 0 ]
then
$RM ${DEVLINK_DB}
fi
}
${RM} -rf ${NVSATA_TMP}
do
${RM} -f ${logical_disk}.${BAK}
cd ../rdsk
${RM} -f ${logical_disk}.${BAK}
done
}
# Function: check_add_drv()
#
# This function will check if the module has an entry in etc/name_to_major
# If not simply calls add_drv with the arguments given. If there is
# such an entry in name_to_major file, it adds entries in driver_aliases
# driver_classes and minor_perm if necessary.
# The syntax of this function is the same as add_drv.
{
then
BASEDIR=/
fi
alias=""
class=""
OPTIND=1
cmd="add_drv"
while getopts i:b:m:c:N opt
do
N ) NO_CMD=1;;
i ) ADD_ALIAS=1
alias=$OPTARG
;;
m ) ADD_MINOR=1
;;
c) ADD_CLASS=1
;;
;;
\?) echo "check_add_drv can not handle this option"
return
;;
esac
done
drvname=$1
then
eval $cmd
else
# entry already in name_to_major, add alias, class, minorperm
# if necessary
if [ $ADD_ALIAS = 1 ]
then
do
if [ $? -ne 0 ]
then
fi
done
fi
if [ $ADD_CLASS = 1 ]
then
if [ $? -ne 0 ]
then
fi
fi
if [ $ADD_MINOR = 1 ]
then
if [ $? -ne 0 ]
then
echo $minorentry >> ${ROOT}/etc/minor_perm
fi
fi
fi
}
#
# Main program starts here.
#
#
# Create temporary directory for node migration
#
if [ ! -d ${NVSATA_TMP} ]
then
${MKDIR} ${NVSATA_TMP}
if [ $? -ne 0 ]
then
# Failed to create ${NVSATA_TMP} directory.
exit 1
fi
fi
#
# If it is an install, do nothing. If it is an upgrade, do the conversion.
#
then
if [ -f ${UPGRADE_LOG} ]
then
# It is an upgrade.
if [ $? -eq 0 ]
then
# The system was running nv_sata before the upgrade.
exit 0
fi
exit 0
fi
exit 0
fi
#
# Liveupgrade.
#
if [ -f ${LIVEUPGRADE_TMP_LOG} ]
then
if [ $? -eq 0 ]
then
# Target BE was running nv_sata driver before the upgrade.
exit 0
fi
exit 0
fi
#
# Pkgadd.
#
exit 0