17c478bd9Sstevel@tonic-gate#!/sbin/sh 27c478bd9Sstevel@tonic-gate# 37c478bd9Sstevel@tonic-gate# CDDL HEADER START 47c478bd9Sstevel@tonic-gate# 57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the 66927f468Sdp# Common Development and Distribution License (the "License"). 76927f468Sdp# You may not use this file except in compliance with the License. 87c478bd9Sstevel@tonic-gate# 97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate# and limitations under the License. 137c478bd9Sstevel@tonic-gate# 147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate# 207c478bd9Sstevel@tonic-gate# CDDL HEADER END 217c478bd9Sstevel@tonic-gate# 227c478bd9Sstevel@tonic-gate# 2322defd95Sae112802# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate# Use is subject to license terms. 257c478bd9Sstevel@tonic-gate# 267c478bd9Sstevel@tonic-gate# ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate# 287c478bd9Sstevel@tonic-gate# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T. 297c478bd9Sstevel@tonic-gate# All rights reserved. 307c478bd9Sstevel@tonic-gate# 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate# Make sure that the libraries essential to this stage of booting can be found. 337c478bd9Sstevel@tonic-gateLD_LIBRARY_PATH=/lib; export LD_LIBRARY_PATH 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gatelibc_mount() { 367c478bd9Sstevel@tonic-gate # 377c478bd9Sstevel@tonic-gate # If there is an optimized libc available in /usr that fits this 387c478bd9Sstevel@tonic-gate # processor, mount it on top of the base libc. 397c478bd9Sstevel@tonic-gate # 407c478bd9Sstevel@tonic-gate MOE=`/usr/bin/moe -32 '/usr/lib/libc/$HWCAP'` 417c478bd9Sstevel@tonic-gate if [ -n "$MOE" ]; then 427c478bd9Sstevel@tonic-gate /usr/sbin/mount | egrep -s "^/lib/libc.so.1 on " 437c478bd9Sstevel@tonic-gate if [ $? -ne 0 ]; then 447c478bd9Sstevel@tonic-gate /usr/sbin/mount -O -F lofs $MOE /lib/libc.so.1 457c478bd9Sstevel@tonic-gate fi 467c478bd9Sstevel@tonic-gate fi 477c478bd9Sstevel@tonic-gate} 487c478bd9Sstevel@tonic-gate 491b349f08Sck142721# This mount function is sun4v only. It may be melded with the sun4u-us3 501b349f08Sck142721# version later. 511b349f08Sck142721sun4v_libc_psr_mount() { 5222defd95Sae112802 LIBC_MOE_32=`/usr/bin/moe -32 /platform/$PLAT/lib/libc_psr/'$HWCAP'` 537c478bd9Sstevel@tonic-gate if [ -n "$LIBC_MOE_32" ]; then 541b349f08Sck142721 /usr/sbin/mount | 5522defd95Sae112802 egrep -s "^/platform/[^/]*/lib/libc_psr.so.1 on " 567c478bd9Sstevel@tonic-gate if [ $? -ne 0 ]; then 571b349f08Sck142721 /usr/sbin/mount -O -F lofs $LIBC_MOE_32 \ 5822defd95Sae112802 /platform/$PLAT/lib/libc_psr.so.1 597c478bd9Sstevel@tonic-gate fi 607c478bd9Sstevel@tonic-gate fi 617c478bd9Sstevel@tonic-gate 621b349f08Sck142721 LIBC_MOE_64=`/usr/bin/moe -64 \ 6322defd95Sae112802 /platform/$PLAT/lib/sparcv9/libc_psr/'$HWCAP'` 647c478bd9Sstevel@tonic-gate if [ -n "$LIBC_MOE_64" ]; then 651b349f08Sck142721 /usr/sbin/mount | 6622defd95Sae112802 egrep -s "^/platform/[^/]*/lib/sparcv9/libc_psr.so.1 on " 677c478bd9Sstevel@tonic-gate if [ $? -ne 0 ]; then 681b349f08Sck142721 /usr/sbin/mount -O -F lofs $LIBC_MOE_64 \ 6922defd95Sae112802 /platform/$PLAT/lib/sparcv9/libc_psr.so.1 701b349f08Sck142721 fi 711b349f08Sck142721 fi 721b349f08Sck142721} 731b349f08Sck142721 741b349f08Sck142721# This is specific to sun4u[-us3]. 751b349f08Sck142721# try to intelligently handle the various ways that a hwcap library can 761b349f08Sck142721# be present for libc_psr for sun4u. 771b349f08Sck142721sun4u_libc_psr_mount() { 781b349f08Sck142721 # first look for $PLAT specific 791b349f08Sck142721 # the string $HWCAP is not an env var but part of the argument to moe 801b349f08Sck142721 LIBC_MOE_32=`/usr/bin/moe -32 /platform/$PLAT/lib/libc_psr/'$HWCAP'` 811b349f08Sck142721 if [ -n "$LIBC_MOE_32" ]; then 821b349f08Sck142721 /usr/sbin/mount | 831b349f08Sck142721 egrep -s "^/platform/$PLAT/lib/libc_psr.so.1 on " 841b349f08Sck142721 if [ $? -ne 0 ]; then 851b349f08Sck142721 /usr/sbin/mount -O -F lofs $LIBC_MOE_32 \ 861b349f08Sck142721 /platform/$PLAT/lib/libc_psr.so.1 871b349f08Sck142721 fi 881b349f08Sck142721 else 891b349f08Sck142721 # try the 'generic' one under $ARCH 901b349f08Sck142721 LIBC_MOE_32=`/usr/bin/moe -32 \ 911b349f08Sck142721 /platform/$ARCH/lib/libc_psr/'$HWCAP'` 921b349f08Sck142721 if [ -n "$LIBC_MOE_32" ]; then 931b349f08Sck142721 /usr/sbin/mount | 941b349f08Sck142721 egrep -s "^/platform/$ARCH/lib/libc_psr.so.1 on " 951b349f08Sck142721 if [ $? -ne 0 ]; then 961b349f08Sck142721 /usr/sbin/mount -O -F lofs $LIBC_MOE_32 \ 971b349f08Sck142721 /platform/$ARCH/lib/libc_psr.so.1 981b349f08Sck142721 fi 991b349f08Sck142721 fi 1001b349f08Sck142721 1011b349f08Sck142721 fi 1021b349f08Sck142721 1031b349f08Sck142721 # now repeat for 64 bit. 1041b349f08Sck142721 1051b349f08Sck142721 LIBC_MOE_64=`/usr/bin/moe -64 \ 1061b349f08Sck142721 /platform/$PLAT/lib/sparcv9/libc_psr/'$HWCAP'` 1071b349f08Sck142721 if [ -n "$LIBC_MOE_64" ]; then 1081b349f08Sck142721 /usr/sbin/mount | 1091b349f08Sck142721 egrep -s "^/platform/$PLAT/lib/sparcv9/libc_psr.so.1 on " 1101b349f08Sck142721 if [ $? -ne 0 ]; then 1111b349f08Sck142721 /usr/sbin/mount -O -F lofs $LIBC_MOE_64 \ 1121b349f08Sck142721 /platform/$PLAT/lib/sparcv9/libc_psr.so.1 1131b349f08Sck142721 fi 1141b349f08Sck142721 else 1151b349f08Sck142721 # now try $ARCH version 1161b349f08Sck142721 LIBC_MOE_64=`/usr/bin/moe -64 \ 1171b349f08Sck142721 /platform/$ARCH/lib/sparcv9/libc_psr/'$HWCAP'` 1181b349f08Sck142721 if [ -n "$LIBC_MOE_64" ]; then 1191b349f08Sck142721 /usr/sbin/mount | 1201b349f08Sck142721 egrep -s \ 1211b349f08Sck142721 "^/platform/$ARCH/lib/sparcv9/libc_psr.so.1 on " 1221b349f08Sck142721 if [ $? -ne 0 ]; then 1231b349f08Sck142721 /usr/sbin/mount -O -F lofs $LIBC_MOE_64 \ 1241b349f08Sck142721 /platform/$ARCH/lib/sparcv9/libc_psr.so.1 1251b349f08Sck142721 fi 1267c478bd9Sstevel@tonic-gate fi 1277c478bd9Sstevel@tonic-gate fi 1287c478bd9Sstevel@tonic-gate} 1297c478bd9Sstevel@tonic-gate 130*bc13c17bSae112802# 131*bc13c17bSae112802# Discover architecture and find and mount optimal libc_psr 132*bc13c17bSae112802# 133*bc13c17bSae112802libc_psr_mount() { 134*bc13c17bSae112802 PLAT=`/usr/bin/uname -i` 135*bc13c17bSae112802 ARCH=`/usr/bin/uname -m` 136*bc13c17bSae112802 if [ "$ARCH" = "sun4v" ]; then 137*bc13c17bSae112802 sun4v_libc_psr_mount 138*bc13c17bSae112802 elif [ "$ARCH" = "sun4u" ]; then 139*bc13c17bSae112802 if [ -h /platform/$PLAT/lib/libc_psr.so.1 ]; then 140*bc13c17bSae112802 LINKSTO=`/usr/bin/ls -l \ 141*bc13c17bSae112802 /platform/$PLAT/lib/libc_psr.so.1 | 142*bc13c17bSae112802 /usr/bin/awk '{print $NF}'` 143*bc13c17bSae112802 if [ "$LINKSTO" = \ 144*bc13c17bSae112802 "../../sun4u-us3/lib/libc_psr.so.1" ]; then 145*bc13c17bSae112802 ARCH=sun4u-us3 146*bc13c17bSae112802 fi 147*bc13c17bSae112802 fi 148*bc13c17bSae112802 sun4u_libc_psr_mount 149*bc13c17bSae112802 fi 150*bc13c17bSae112802} 151*bc13c17bSae112802 1526927f468Sdp. /lib/svc/share/smf_include.sh 1536927f468Sdp. /lib/svc/share/fs_include.sh 1546927f468Sdp 1557c478bd9Sstevel@tonic-gate# 1567c478bd9Sstevel@tonic-gate# Most of the operations in this script are only necessary in the global 1577c478bd9Sstevel@tonic-gate# zone but due to the way initialization scripts like this are packaged, 1587c478bd9Sstevel@tonic-gate# it needs to currently exist for all zones. 1597c478bd9Sstevel@tonic-gate# 1606927f468Sdpif smf_is_nonglobalzone; then 1617c478bd9Sstevel@tonic-gate libc_mount 162*bc13c17bSae112802 libc_psr_mount 1636927f468Sdp exit $SMF_EXIT_OK 1647c478bd9Sstevel@tonic-gatefi 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate# 1677c478bd9Sstevel@tonic-gate# Root is already mounted (by the kernel), but still needs to be 1687c478bd9Sstevel@tonic-gate# checked, possibly remounted and entered into mnttab. First 1697c478bd9Sstevel@tonic-gate# mount /usr read only if it is a separate file system. This must 1707c478bd9Sstevel@tonic-gate# be done first to allow utilities such as fsck and setmnt to 1717c478bd9Sstevel@tonic-gate# reside on /usr minimizing the space required by the root file 1727c478bd9Sstevel@tonic-gate# system. 1737c478bd9Sstevel@tonic-gate# 1747c478bd9Sstevel@tonic-gatereadvfstab "/usr" < $vfstab 1757c478bd9Sstevel@tonic-gateif [ -n "$mountp" ]; then 1767c478bd9Sstevel@tonic-gate if [ "$fstype" = cachefs ]; then 1777c478bd9Sstevel@tonic-gate # 1787c478bd9Sstevel@tonic-gate # Mount without the cache initially. We'll enable it 1797c478bd9Sstevel@tonic-gate # later at remount time. This lets us avoid 1807c478bd9Sstevel@tonic-gate # teaching the statically linked mount program about 1817c478bd9Sstevel@tonic-gate # cachefs. Here we determine the backfstype. 1827c478bd9Sstevel@tonic-gate # This is not pretty, but we have no tools for parsing 1837c478bd9Sstevel@tonic-gate # the option string until we get /usr mounted... 1847c478bd9Sstevel@tonic-gate # 1857c478bd9Sstevel@tonic-gate case "$mntopts" in 1867c478bd9Sstevel@tonic-gate *backfstype=nfs*) 1877c478bd9Sstevel@tonic-gate cfsbacktype=nfs 1887c478bd9Sstevel@tonic-gate ;; 1897c478bd9Sstevel@tonic-gate *backfstype=hsfs*) 1907c478bd9Sstevel@tonic-gate cfsbacktype=hsfs 1917c478bd9Sstevel@tonic-gate ;; 1927c478bd9Sstevel@tonic-gate *) 1937c478bd9Sstevel@tonic-gate msg='invalid vfstab entry for /usr' 1947c478bd9Sstevel@tonic-gate echo $msg 1957c478bd9Sstevel@tonic-gate echo "$SMF_FMRI:" $msg >/dev/msglog 1967c478bd9Sstevel@tonic-gate cfsbacktype=nfs 1977c478bd9Sstevel@tonic-gate ;; 1987c478bd9Sstevel@tonic-gate esac 1997c478bd9Sstevel@tonic-gate mountfs - /usr $cfsbacktype ro $special || 2007c478bd9Sstevel@tonic-gate exit $SMF_EXIT_ERR_FATAL 2017c478bd9Sstevel@tonic-gate else 2027c478bd9Sstevel@tonic-gate # 2037c478bd9Sstevel@tonic-gate # Must use -o largefiles here to ensure the 2047c478bd9Sstevel@tonic-gate # read-only mount does not fail as a result of 2057c478bd9Sstevel@tonic-gate # having a large file present on /usr. This gives 2067c478bd9Sstevel@tonic-gate # fsck a chance to fix up the largefiles flag 2077c478bd9Sstevel@tonic-gate # before we remount /usr read-write. 2087c478bd9Sstevel@tonic-gate # 2097c478bd9Sstevel@tonic-gate if [ "x$mntopts" = x- ]; then 2107c478bd9Sstevel@tonic-gate mntopts='ro,largefiles' 2117c478bd9Sstevel@tonic-gate else 2127c478bd9Sstevel@tonic-gate checkopt largefiles $mntopts 2137c478bd9Sstevel@tonic-gate if [ "x$option" != xlargefiles ]; then 2147c478bd9Sstevel@tonic-gate mntopts="largefiles,$mntopts" 2157c478bd9Sstevel@tonic-gate fi 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate checkopt ro $mntopts 2187c478bd9Sstevel@tonic-gate if [ "x$option" != xro ]; then 2197c478bd9Sstevel@tonic-gate mntopts="ro,$mntopts" 2207c478bd9Sstevel@tonic-gate fi 2217c478bd9Sstevel@tonic-gate 2227c478bd9Sstevel@tonic-gate # 2237c478bd9Sstevel@tonic-gate # Requesting logging on a read-only mount 2247c478bd9Sstevel@tonic-gate # causes errors to be displayed, so remove 2257c478bd9Sstevel@tonic-gate # "logging" from the list of options for now. 2267c478bd9Sstevel@tonic-gate # The read-write mount performed later will 2277c478bd9Sstevel@tonic-gate # specify the logging option if appropriate. 2287c478bd9Sstevel@tonic-gate # 2297c478bd9Sstevel@tonic-gate 2307c478bd9Sstevel@tonic-gate checkopt logging $mntopts 2317c478bd9Sstevel@tonic-gate if [ "x$option" = xlogging ]; then 2327c478bd9Sstevel@tonic-gate mntopts="$otherops" 2337c478bd9Sstevel@tonic-gate fi 2347c478bd9Sstevel@tonic-gate fi 2357c478bd9Sstevel@tonic-gate 2367c478bd9Sstevel@tonic-gate mountfs -O /usr $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL 2377c478bd9Sstevel@tonic-gate fi 2387c478bd9Sstevel@tonic-gatefi 2397c478bd9Sstevel@tonic-gate 2407c478bd9Sstevel@tonic-gate# 2417c478bd9Sstevel@tonic-gate# Also mount /boot now so that things like keymap.sh can access 2427c478bd9Sstevel@tonic-gate# boot properties through eeprom. Readonly isn't required because 2437c478bd9Sstevel@tonic-gate# /boot (and other pcfs filesystems) aren't fsck'ed at boot yet. 2447c478bd9Sstevel@tonic-gate# Also, we don't account for caching /boot as it must be on a local 2457c478bd9Sstevel@tonic-gate# disk. So what's in vfstab is fine as it stands; just look to see 2467c478bd9Sstevel@tonic-gate# if it's there and avoid the mount if not. 2477c478bd9Sstevel@tonic-gate# 2487c478bd9Sstevel@tonic-gatereadvfstab "/boot" < $vfstab 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gateif [ -n "$mountp" ]; then 2517c478bd9Sstevel@tonic-gate mountfs - /boot $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL 2527c478bd9Sstevel@tonic-gatefi 2537c478bd9Sstevel@tonic-gate 2547c478bd9Sstevel@tonic-gate# 2557c478bd9Sstevel@tonic-gate# Update kernel driver.conf cache with any additional driver.conf 2567c478bd9Sstevel@tonic-gate# files found on /usr, and device permissions from /etc/minor_perm. 2577c478bd9Sstevel@tonic-gate# 2587c478bd9Sstevel@tonic-gate/usr/sbin/devfsadm -I -P 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate[ -f /etc/.dynamic_routing ] && /usr/bin/rm -f /etc/.dynamic_routing 2617c478bd9Sstevel@tonic-gate 2627c478bd9Sstevel@tonic-gatelibc_mount 263*bc13c17bSae112802libc_psr_mount 2647c478bd9Sstevel@tonic-gate 2656927f468Sdpexit $SMF_EXIT_OK 266