fs-root revision a192e900f6d2b0e1a822e3252c0dfd795ed49d76
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk#!/sbin/sh
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk#
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk# CDDL HEADER START
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk#
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk# The contents of this file are subject to the terms of the
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk# Common Development and Distribution License (the "License").
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk# You may not use this file except in compliance with the License.
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk#
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk# or http://www.opensolaris.org/os/licensing.
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk# See the License for the specific language governing permissions
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk# and limitations under the License.
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk#
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk# When distributing Covered Code, include this CDDL HEADER in each
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk# If applicable, add the following below this CDDL HEADER, with the
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk# fields enclosed by brackets "[]" replaced with your own identifying
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk# information: Portions Copyright [yyyy] [name of copyright owner]
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk#
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk# CDDL HEADER END
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk#
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk#
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk# Use is subject to license terms.
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk#
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk# ident "%Z%%M% %I% %E% SMI"
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster#
4c0f084e476c05989eb702c500a763ef09ba044ejeff.schenk# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster# All rights reserved.
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster#
6e153e9671eb382c49354ab856404a71477cce58jeff.schenk
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster# Make sure that the libraries essential to this stage of booting can be found.
fb98811412f1a61efdc30b38091bf4708148a806Allan FosterLD_LIBRARY_PATH=/lib; export LD_LIBRARY_PATH
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Fosterlibc_mount() {
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster #
6e153e9671eb382c49354ab856404a71477cce58jeff.schenk # If there is an optimized libc available in /usr that fits this
6e153e9671eb382c49354ab856404a71477cce58jeff.schenk # processor, mount it on top of the base libc.
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster #
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster MOE=`/usr/bin/moe -32 '/usr/lib/libc/$HWCAP'`
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster if [ -n "$MOE" ]; then
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /usr/sbin/mount | egrep -s "^/lib/libc.so.1 on "
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster if [ $? -ne 0 ]; then
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /usr/sbin/mount -O -F lofs $MOE /lib/libc.so.1
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster fi
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster fi
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster}
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster# This mount function is sun4v only. It may be melded with the sun4u-us3
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster# version later.
fb98811412f1a61efdc30b38091bf4708148a806Allan Fostersun4v_libc_psr_mount() {
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster LIBC_MOE_32=`/usr/bin/moe -32 /platform/$PLAT/lib/libc_psr/'$HWCAP'`
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster if [ -n "$LIBC_MOE_32" ]; then
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /usr/sbin/mount |
4c0f084e476c05989eb702c500a763ef09ba044ejeff.schenk egrep -s "^/platform/[^/]*/lib/libc_psr.so.1 on "
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster if [ $? -ne 0 ]; then
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /usr/sbin/mount -O -F lofs $LIBC_MOE_32 \
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /platform/$PLAT/lib/libc_psr.so.1
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster fi
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster fi
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster LIBC_MOE_64=`/usr/bin/moe -64 \
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /platform/$PLAT/lib/sparcv9/libc_psr/'$HWCAP'`
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster if [ -n "$LIBC_MOE_64" ]; then
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /usr/sbin/mount |
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster egrep -s "^/platform/[^/]*/lib/sparcv9/libc_psr.so.1 on "
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster if [ $? -ne 0 ]; then
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk /usr/sbin/mount -O -F lofs $LIBC_MOE_64 \
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /platform/$PLAT/lib/sparcv9/libc_psr.so.1
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster fi
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster fi
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster}
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster# This is specific to sun4u[-us3].
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster# try to intelligently handle the various ways that a hwcap library can
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster# be present for libc_psr for sun4u.
fb98811412f1a61efdc30b38091bf4708148a806Allan Fostersun4u_libc_psr_mount() {
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster # first look for $PLAT specific
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster # the string $HWCAP is not an env var but part of the argument to moe
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster LIBC_MOE_32=`/usr/bin/moe -32 /platform/$PLAT/lib/libc_psr/'$HWCAP'`
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster if [ -n "$LIBC_MOE_32" ]; then
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /usr/sbin/mount |
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster egrep -s "^/platform/$PLAT/lib/libc_psr.so.1 on "
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster if [ $? -ne 0 ]; then
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /usr/sbin/mount -O -F lofs $LIBC_MOE_32 \
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /platform/$PLAT/lib/libc_psr.so.1
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster fi
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster else
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster # try the 'generic' one under $ARCH
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster LIBC_MOE_32=`/usr/bin/moe -32 \
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /platform/$ARCH/lib/libc_psr/'$HWCAP'`
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster if [ -n "$LIBC_MOE_32" ]; then
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /usr/sbin/mount |
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster egrep -s "^/platform/$ARCH/lib/libc_psr.so.1 on "
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster if [ $? -ne 0 ]; then
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /usr/sbin/mount -O -F lofs $LIBC_MOE_32 \
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster /platform/$ARCH/lib/libc_psr.so.1
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster fi
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster fi
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster fi
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk # now repeat for 64 bit.
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk LIBC_MOE_64=`/usr/bin/moe -64 \
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk /platform/$PLAT/lib/sparcv9/libc_psr/'$HWCAP'`
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk if [ -n "$LIBC_MOE_64" ]; then
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk /usr/sbin/mount |
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk egrep -s "^/platform/$PLAT/lib/sparcv9/libc_psr.so.1 on "
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk if [ $? -ne 0 ]; then
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk /usr/sbin/mount -O -F lofs $LIBC_MOE_64 \
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk /platform/$PLAT/lib/sparcv9/libc_psr.so.1
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk fi
73308f54e60e4cdb893e8b02955497e8f45b5893jeff.schenk else
fb98811412f1a61efdc30b38091bf4708148a806Allan Foster # now try $ARCH version
LIBC_MOE_64=`/usr/bin/moe -64 \
/platform/$ARCH/lib/sparcv9/libc_psr/'$HWCAP'`
if [ -n "$LIBC_MOE_64" ]; then
/usr/sbin/mount |
egrep -s \
"^/platform/$ARCH/lib/sparcv9/libc_psr.so.1 on "
if [ $? -ne 0 ]; then
/usr/sbin/mount -O -F lofs $LIBC_MOE_64 \
/platform/$ARCH/lib/sparcv9/libc_psr.so.1
fi
fi
fi
}
#
# Discover architecture and find and mount optimal libc_psr
#
libc_psr_mount() {
PLAT=`/usr/bin/uname -i`
ARCH=`/usr/bin/uname -m`
if [ "$ARCH" = "sun4v" ]; then
sun4v_libc_psr_mount
elif [ "$ARCH" = "sun4u" ]; then
if [ -h /platform/$PLAT/lib/libc_psr.so.1 ]; then
LINKSTO=`/usr/bin/ls -l \
/platform/$PLAT/lib/libc_psr.so.1 |
/usr/bin/awk '{print $NF}'`
if [ "$LINKSTO" = \
"../../sun4u-us3/lib/libc_psr.so.1" ]; then
ARCH=sun4u-us3
fi
fi
sun4u_libc_psr_mount
fi
}
. /lib/svc/share/smf_include.sh
. /lib/svc/share/fs_include.sh
#
# Most of the operations in this script are only necessary in the global
# zone but due to the way initialization scripts like this are packaged,
# it needs to currently exist for all zones.
#
if smf_is_nonglobalzone; then
libc_mount
libc_psr_mount
exit $SMF_EXIT_OK
fi
#
# Root is already mounted (by the kernel), but still needs to be
# checked, possibly remounted and entered into mnttab. First
# mount /usr read only if it is a separate file system. This must
# be done first to allow utilities such as fsck and setmnt to
# reside on /usr minimizing the space required by the root file
# system.
#
readvfstab "/usr" < $vfstab
if [ -n "$mountp" ]; then
if [ "$fstype" = cachefs ]; then
#
# Mount without the cache initially. We'll enable it
# later at remount time. This lets us avoid
# teaching the statically linked mount program about
# cachefs. Here we determine the backfstype.
# This is not pretty, but we have no tools for parsing
# the option string until we get /usr mounted...
#
case "$mntopts" in
*backfstype=nfs*)
cfsbacktype=nfs
;;
*backfstype=hsfs*)
cfsbacktype=hsfs
;;
*)
msg='invalid vfstab entry for /usr'
echo $msg
echo "$SMF_FMRI:" $msg >/dev/msglog
cfsbacktype=nfs
;;
esac
mountfs - /usr $cfsbacktype ro $special ||
exit $SMF_EXIT_ERR_FATAL
else
#
# Must use -o largefiles here to ensure the
# read-only mount does not fail as a result of
# having a large file present on /usr. This gives
# fsck a chance to fix up the largefiles flag
# before we remount /usr read-write.
#
if [ "x$mntopts" = x- ]; then
mntopts='ro,largefiles'
else
checkopt largefiles $mntopts
if [ "x$option" != xlargefiles ]; then
mntopts="largefiles,$mntopts"
fi
checkopt ro $mntopts
if [ "x$option" != xro ]; then
mntopts="ro,$mntopts"
fi
#
# Requesting logging on a read-only mount
# causes errors to be displayed, so remove
# "logging" from the list of options for now.
# The read-write mount performed later will
# specify the logging option if appropriate.
#
checkopt logging $mntopts
if [ "x$option" = xlogging ]; then
mntopts="$otherops"
fi
fi
mountfs -O /usr $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL
fi
fi
#
# Also mount /boot now so that things like keymap.sh can access
# boot properties through eeprom. Readonly isn't required because
# /boot (and other pcfs filesystems) aren't fsck'ed at boot yet.
# Also, we don't account for caching /boot as it must be on a local
# disk. So what's in vfstab is fine as it stands; just look to see
# if it's there and avoid the mount if not.
#
readvfstab "/boot" < $vfstab
if [ -n "$mountp" ]; then
mountfs - /boot $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL
fi
#
# Update kernel driver.conf cache with any additional driver.conf
# files found on /usr, and device permissions from /etc/minor_perm.
#
/usr/sbin/devfsadm -I -P
libc_mount
libc_psr_mount
exit $SMF_EXIT_OK