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 2008 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# 131# Discover architecture and find and mount optimal libc_psr 132# 133libc_psr_mount() { 134 PLAT=`/usr/bin/uname -i` 135 ARCH=`/usr/bin/uname -m` 136 if [ "$ARCH" = "sun4v" ]; then 137 sun4v_libc_psr_mount 138 elif [ "$ARCH" = "sun4u" ]; then 139 if [ -h /platform/$PLAT/lib/libc_psr.so.1 ]; then 140 LINKSTO=`/usr/bin/ls -l \ 141 /platform/$PLAT/lib/libc_psr.so.1 | 142 /usr/bin/awk '{print $NF}'` 143 if [ "$LINKSTO" = \ 144 "../../sun4u-us3/lib/libc_psr.so.1" ]; then 145 ARCH=sun4u-us3 146 fi 147 fi 148 sun4u_libc_psr_mount 149 fi 150} 151 152. /lib/svc/share/smf_include.sh 153. /lib/svc/share/fs_include.sh 154 155# 156# Most of the operations in this script are only necessary in the global 157# zone but due to the way initialization scripts like this are packaged, 158# it needs to currently exist for all zones. 159# 160if smf_is_nonglobalzone; then 161 libc_mount 162 libc_psr_mount 163 exit $SMF_EXIT_OK 164fi 165 166# 167# Root is already mounted (by the kernel), but still needs to be 168# checked, possibly remounted and entered into mnttab. First 169# mount /usr if it is a separate file system. If the file system 170# type is something other than zfs, mount it read-only. This must 171# be done first to allow utilities such as fsck and setmnt to 172# reside on /usr minimizing the space required by the root file 173# system. 174# 175readvfstab "/usr" < $vfstab 176if [ -n "$mountp" ]; then 177 if [ "$fstype" = cachefs ]; then 178 # 179 # Mount without the cache initially. We'll enable it 180 # later at remount time. This lets us avoid 181 # teaching the statically linked mount program about 182 # cachefs. Here we determine the backfstype. 183 # This is not pretty, but we have no tools for parsing 184 # the option string until we get /usr mounted... 185 # 186 case "$mntopts" in 187 *backfstype=nfs*) 188 cfsbacktype=nfs 189 ;; 190 *backfstype=hsfs*) 191 cfsbacktype=hsfs 192 ;; 193 *) 194 msg='invalid vfstab entry for /usr' 195 echo $msg 196 echo "$SMF_FMRI:" $msg >/dev/msglog 197 cfsbacktype=nfs 198 ;; 199 esac 200 mountfs - /usr $cfsbacktype ro $special || 201 exit $SMF_EXIT_ERR_FATAL 202 elif [ "$fstype" = zfs ]; then 203 mountfs - /usr $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL 204 else 205 # 206 # Must use -o largefiles here to ensure the 207 # read-only mount does not fail as a result of 208 # having a large file present on /usr. This gives 209 # fsck a chance to fix up the largefiles flag 210 # before we remount /usr read-write. 211 # 212 if [ "x$mntopts" = x- ]; then 213 mntopts='ro,largefiles' 214 else 215 checkopt largefiles $mntopts 216 if [ "x$option" != xlargefiles ]; then 217 mntopts="largefiles,$mntopts" 218 fi 219 220 checkopt ro $mntopts 221 if [ "x$option" != xro ]; then 222 mntopts="ro,$mntopts" 223 fi 224 225 # 226 # Requesting logging on a read-only mount 227 # causes errors to be displayed, so remove 228 # "logging" from the list of options for now. 229 # The read-write mount performed later will 230 # specify the logging option if appropriate. 231 # 232 233 checkopt logging $mntopts 234 if [ "x$option" = xlogging ]; then 235 mntopts="$otherops" 236 fi 237 fi 238 239 mountfs -O /usr $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL 240 fi 241fi 242 243# 244# if we are booted from zfs, the /usr mount probably won't be a 245# legacy mount. Use the standard zfs mount command instead. 246 247readmnttab "/" < /etc/mnttab 248if [ "$fstype" = zfs ]; then 249 mountp=`/sbin/zfs get -H -o value mountpoint $special/usr 2>/dev/null` 250 # 251 # if mountp = /usr, there is a non-legacy mount of /usr 252 # in the boot environment being booted. 253 # 254 if [ "x$mountp" = "x/usr" ] ; then 255 /sbin/zfs mount $special/usr 256 if [ $? != 0 ] ; then 257 msg='zfs-mount failed' 258 echo $msg 259 echo "$SMF_FMRI:" $msg >/dev/msglog 260 exit $SMF_EXIT_ERR_FATAL 261 fi 262 fi 263fi 264 265# 266# Also mount /boot now so that things like keymap.sh can access 267# boot properties through eeprom. Readonly isn't required because 268# /boot (and other pcfs filesystems) aren't fsck'ed at boot yet. 269# Also, we don't account for caching /boot as it must be on a local 270# disk. So what's in vfstab is fine as it stands; just look to see 271# if it's there and avoid the mount if not. 272# 273readvfstab "/boot" < $vfstab 274 275if [ -n "$mountp" ]; then 276 mountfs - /boot $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL 277fi 278 279# 280# Update kernel driver.conf cache with any additional driver.conf 281# files found on /usr, and device permissions from /etc/minor_perm. 282# 283/usr/sbin/devfsadm -I -P 284 285libc_mount 286libc_psr_mount 287 288exit $SMF_EXIT_OK 289