1#!/sbin/sh 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22# 23# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24# Use is subject to license terms. 25# 26# ident "%Z%%M% %I% %E% SMI" 27# 28# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T. 29# All rights reserved. 30# 31 32# Make sure that the libraries essential to this stage of booting can be found. 33LD_LIBRARY_PATH=/lib; export LD_LIBRARY_PATH 34 35libc_mount() { 36 # 37 # If there is an optimized libc available in /usr that fits this 38 # processor, mount it on top of the base libc. 39 # 40 MOE=`/usr/bin/moe -32 '/usr/lib/libc/$HWCAP'` 41 if [ -n "$MOE" ]; then 42 /usr/sbin/mount | egrep -s "^/lib/libc.so.1 on " 43 if [ $? -ne 0 ]; then 44 /usr/sbin/mount -O -F lofs $MOE /lib/libc.so.1 45 fi 46 fi 47} 48 49# This mount function is sun4v only. It may be melded with the sun4u-us3 50# version later. 51sun4v_libc_psr_mount() { 52 LIBC_MOE_32=`/usr/bin/moe -32 /platform/$PLAT/lib/libc_psr/'$HWCAP'` 53 if [ -n "$LIBC_MOE_32" ]; then 54 /usr/sbin/mount | 55 egrep -s "^/platform/[^/]*/lib/libc_psr.so.1 on " 56 if [ $? -ne 0 ]; then 57 /usr/sbin/mount -O -F lofs $LIBC_MOE_32 \ 58 /platform/$PLAT/lib/libc_psr.so.1 59 fi 60 fi 61 62 LIBC_MOE_64=`/usr/bin/moe -64 \ 63 /platform/$PLAT/lib/sparcv9/libc_psr/'$HWCAP'` 64 if [ -n "$LIBC_MOE_64" ]; then 65 /usr/sbin/mount | 66 egrep -s "^/platform/[^/]*/lib/sparcv9/libc_psr.so.1 on " 67 if [ $? -ne 0 ]; then 68 /usr/sbin/mount -O -F lofs $LIBC_MOE_64 \ 69 /platform/$PLAT/lib/sparcv9/libc_psr.so.1 70 fi 71 fi 72} 73 74# This is specific to sun4u[-us3]. 75# try to intelligently handle the various ways that a hwcap library can 76# be present for libc_psr for sun4u. 77sun4u_libc_psr_mount() { 78 # first look for $PLAT specific 79 # the string $HWCAP is not an env var but part of the argument to moe 80 LIBC_MOE_32=`/usr/bin/moe -32 /platform/$PLAT/lib/libc_psr/'$HWCAP'` 81 if [ -n "$LIBC_MOE_32" ]; then 82 /usr/sbin/mount | 83 egrep -s "^/platform/$PLAT/lib/libc_psr.so.1 on " 84 if [ $? -ne 0 ]; then 85 /usr/sbin/mount -O -F lofs $LIBC_MOE_32 \ 86 /platform/$PLAT/lib/libc_psr.so.1 87 fi 88 else 89 # try the 'generic' one under $ARCH 90 LIBC_MOE_32=`/usr/bin/moe -32 \ 91 /platform/$ARCH/lib/libc_psr/'$HWCAP'` 92 if [ -n "$LIBC_MOE_32" ]; then 93 /usr/sbin/mount | 94 egrep -s "^/platform/$ARCH/lib/libc_psr.so.1 on " 95 if [ $? -ne 0 ]; then 96 /usr/sbin/mount -O -F lofs $LIBC_MOE_32 \ 97 /platform/$ARCH/lib/libc_psr.so.1 98 fi 99 fi 100 101 fi 102 103 # now repeat for 64 bit. 104 105 LIBC_MOE_64=`/usr/bin/moe -64 \ 106 /platform/$PLAT/lib/sparcv9/libc_psr/'$HWCAP'` 107 if [ -n "$LIBC_MOE_64" ]; then 108 /usr/sbin/mount | 109 egrep -s "^/platform/$PLAT/lib/sparcv9/libc_psr.so.1 on " 110 if [ $? -ne 0 ]; then 111 /usr/sbin/mount -O -F lofs $LIBC_MOE_64 \ 112 /platform/$PLAT/lib/sparcv9/libc_psr.so.1 113 fi 114 else 115 # now try $ARCH version 116 LIBC_MOE_64=`/usr/bin/moe -64 \ 117 /platform/$ARCH/lib/sparcv9/libc_psr/'$HWCAP'` 118 if [ -n "$LIBC_MOE_64" ]; then 119 /usr/sbin/mount | 120 egrep -s \ 121 "^/platform/$ARCH/lib/sparcv9/libc_psr.so.1 on " 122 if [ $? -ne 0 ]; then 123 /usr/sbin/mount -O -F lofs $LIBC_MOE_64 \ 124 /platform/$ARCH/lib/sparcv9/libc_psr.so.1 125 fi 126 fi 127 fi 128} 129 130. /lib/svc/share/smf_include.sh 131. /lib/svc/share/fs_include.sh 132 133# 134# Most of the operations in this script are only necessary in the global 135# zone but due to the way initialization scripts like this are packaged, 136# it needs to currently exist for all zones. 137# 138if smf_is_nonglobalzone; then 139 libc_mount 140 exit $SMF_EXIT_OK 141fi 142 143# 144# Root is already mounted (by the kernel), but still needs to be 145# checked, possibly remounted and entered into mnttab. First 146# mount /usr read only if it is a separate file system. This must 147# be done first to allow utilities such as fsck and setmnt to 148# reside on /usr minimizing the space required by the root file 149# system. 150# 151readvfstab "/usr" < $vfstab 152if [ -n "$mountp" ]; then 153 if [ "$fstype" = cachefs ]; then 154 # 155 # Mount without the cache initially. We'll enable it 156 # later at remount time. This lets us avoid 157 # teaching the statically linked mount program about 158 # cachefs. Here we determine the backfstype. 159 # This is not pretty, but we have no tools for parsing 160 # the option string until we get /usr mounted... 161 # 162 case "$mntopts" in 163 *backfstype=nfs*) 164 cfsbacktype=nfs 165 ;; 166 *backfstype=hsfs*) 167 cfsbacktype=hsfs 168 ;; 169 *) 170 msg='invalid vfstab entry for /usr' 171 echo $msg 172 echo "$SMF_FMRI:" $msg >/dev/msglog 173 cfsbacktype=nfs 174 ;; 175 esac 176 mountfs - /usr $cfsbacktype ro $special || 177 exit $SMF_EXIT_ERR_FATAL 178 else 179 # 180 # Must use -o largefiles here to ensure the 181 # read-only mount does not fail as a result of 182 # having a large file present on /usr. This gives 183 # fsck a chance to fix up the largefiles flag 184 # before we remount /usr read-write. 185 # 186 if [ "x$mntopts" = x- ]; then 187 mntopts='ro,largefiles' 188 else 189 checkopt largefiles $mntopts 190 if [ "x$option" != xlargefiles ]; then 191 mntopts="largefiles,$mntopts" 192 fi 193 194 checkopt ro $mntopts 195 if [ "x$option" != xro ]; then 196 mntopts="ro,$mntopts" 197 fi 198 199 # 200 # Requesting logging on a read-only mount 201 # causes errors to be displayed, so remove 202 # "logging" from the list of options for now. 203 # The read-write mount performed later will 204 # specify the logging option if appropriate. 205 # 206 207 checkopt logging $mntopts 208 if [ "x$option" = xlogging ]; then 209 mntopts="$otherops" 210 fi 211 fi 212 213 mountfs -O /usr $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL 214 fi 215fi 216 217# 218# Also mount /boot now so that things like keymap.sh can access 219# boot properties through eeprom. Readonly isn't required because 220# /boot (and other pcfs filesystems) aren't fsck'ed at boot yet. 221# Also, we don't account for caching /boot as it must be on a local 222# disk. So what's in vfstab is fine as it stands; just look to see 223# if it's there and avoid the mount if not. 224# 225readvfstab "/boot" < $vfstab 226 227if [ -n "$mountp" ]; then 228 mountfs - /boot $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL 229fi 230 231# 232# Update kernel driver.conf cache with any additional driver.conf 233# files found on /usr, and device permissions from /etc/minor_perm. 234# 235/usr/sbin/devfsadm -I -P 236 237[ -f /etc/.dynamic_routing ] && /usr/bin/rm -f /etc/.dynamic_routing 238 239libc_mount 240 241# 242# Discover architecture and find and mount optimal libc_psr 243# 244PLAT=`/usr/bin/uname -i` 245ARCH=`/usr/bin/uname -m` 246if [ "$ARCH" = "sun4v" ]; then 247 sun4v_libc_psr_mount 248elif [ "$ARCH" = "sun4u" ]; then 249 if [ -h /platform/$PLAT/lib/libc_psr.so.1 ]; then 250 LINKSTO=`/usr/bin/ls -l /platform/$PLAT/lib/libc_psr.so.1 | 251 /usr/bin/awk '{print $NF}'` 252 if [ "$LINKSTO" = "../../sun4u-us3/lib/libc_psr.so.1" ]; then 253 ARCH=sun4u-us3 254 fi 255 fi 256 sun4u_libc_psr_mount 257fi 258 259exit $SMF_EXIT_OK 260