summaryrefslogtreecommitdiff
path: root/usr/src/cmd/svc/milestone/fs-root
blob: f9de44c831685e35499f082ad1b6ff92ba0ad108 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/sbin/sh
#
# 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
# or http://www.opensolaris.org/os/licensing.
# 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 (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
# Copyright 2016 Joyent, Inc.
#

# Make sure that the libraries essential to this stage of booting can be found.
LD_LIBRARY_PATH=/lib; export LD_LIBRARY_PATH

libc_mount() {
	#
	# If there is an optimized libc available in /usr that fits this
	# processor, mount it on top of the base libc.
	#
	LIBC_MOE_32=`/usr/bin/moe -32 '/usr/lib/libc/$HWCAP'`
	if [ -n "$LIBC_MOE_32" ]; then
		/usr/sbin/mount | egrep -s "^/lib/libc.so.1 on "
		if [ $? -ne 0 ]; then
			/usr/sbin/mount -O -F lofs $LIBC_MOE_32 /lib/libc.so.1
		fi
	fi

	ARCH64=`isainfo | awk '{print $1}'`
	LIBC_MOE_64=`/usr/bin/moe -64 /usr/lib/$ARCH64/libc/'$HWCAP'`
	if [ -n "$LIBC_MOE_64" ]; then
		/usr/sbin/mount | egrep -s "^/lib/$ARCH64/libc.so.1 on "
		if [ $? -ne 0 ]; then
			/usr/sbin/mount -O -F lofs $LIBC_MOE_64 \
				/lib/$ARCH64/libc.so.1
		fi
	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
	exit $SMF_EXIT_OK
fi

/sbin/mount -F ufs -o remount,rw,nologging /devices/ramdisk:a /
/usr/sbin/lofiadm -X -a /usr.lgz

#
# Prior to mounting /usr, devfsadm is not yet available.  As such, we must
# locate the lofi block device node in /devices rather than in /dev.  This
# path has changed over time so we try both the old (pre-partition support)
# and new paths.
#
lofi_devices_path='/devices/pseudo/lofi@1:disk'
if [ ! -b "$lofi_devices_path" ]; then
	lofi_devices_path='/devices/pseudo/lofi@0:1'
	if [ ! -b "$lofi_devices_path" ]; then
		echo 'could not locate lofi block device in /devices' >&2
		exit $SMF_EXIT_ERR_FATAL
	fi
fi

if ! /sbin/mount -F ufs -o ro "$lofi_devices_path" /usr; then
	echo "could not mount /usr from $lofi_devices_path" >&2
	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

exit $SMF_EXIT_OK