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
6a227b7f4Shs# Common Development and Distribution License (the "License").
7a227b7f4Shs# 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#
23*d1419d5aSNobutomo Nakano# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate# Use is subject to license terms.
257c478bd9Sstevel@tonic-gate#
267c478bd9Sstevel@tonic-gate# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
277c478bd9Sstevel@tonic-gate# All rights reserved.
287c478bd9Sstevel@tonic-gate#
297c478bd9Sstevel@tonic-gate#
307c478bd9Sstevel@tonic-gate
317c478bd9Sstevel@tonic-gate. /lib/svc/share/smf_include.sh
327c478bd9Sstevel@tonic-gate. /lib/svc/share/fs_include.sh
337c478bd9Sstevel@tonic-gate
347c478bd9Sstevel@tonic-gate# Mount other file systems to be available in single user mode.
357c478bd9Sstevel@tonic-gate# Currently, these are /var, /var/adm, /var/run and /tmp.  A change
367c478bd9Sstevel@tonic-gate# here will require a modification to the following programs (and
377c478bd9Sstevel@tonic-gate# documentation): /sbin/mountall, /sbin/umountall, and
387c478bd9Sstevel@tonic-gate# /lib/svc/bin/svc.startd.
397c478bd9Sstevel@tonic-gate
40a227b7f4Shsrootiszfs=0
41a227b7f4Shsreadmnttab / < /etc/mnttab
42a227b7f4Shsif [ "$fstype" = zfs ] ; then
43a227b7f4Shs	rootiszfs=1
44a227b7f4Shs	be=$special
45a227b7f4Shsfi
46a227b7f4Shs
477c478bd9Sstevel@tonic-gatefor fs in /var /var/adm /tmp; do
487c478bd9Sstevel@tonic-gate	readvfstab $fs < $vfstab
497c478bd9Sstevel@tonic-gate	if [ -n "$mountp" ]; then
507c478bd9Sstevel@tonic-gate		mounted $mountp $mntopts $fstype < /etc/mnttab && continue
517c478bd9Sstevel@tonic-gate		checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL
527c478bd9Sstevel@tonic-gate		mountfs -O $mountp $fstype $mntopts - ||
537c478bd9Sstevel@tonic-gate		    exit $SMF_EXIT_ERR_FATAL
54a227b7f4Shs		continue
55a227b7f4Shs	fi
56a227b7f4Shs	if [ "$rootiszfs" = 1 ]; then
57a227b7f4Shs		mountpt=`zfs get -H -o value mountpoint $be$fs 2>/dev/null`
58a227b7f4Shs		if [ $? = 0 ] ; then
59a227b7f4Shs			if [ "x$mountpt" = "x$fs" ] ; then
60e7cbe64fSgw				/sbin/zfs mount -O $be$fs
61a227b7f4Shs			fi
62a227b7f4Shs		fi
637c478bd9Sstevel@tonic-gate	fi
647c478bd9Sstevel@tonic-gatedone
657c478bd9Sstevel@tonic-gate
66a227b7f4Shsmounted /var/run - tmpfs < /etc/mnttab
67a227b7f4Shsif [ $? != 0 ] ; then
68a227b7f4Shs	mountfs -O /var/run tmpfs - swap || exit $SMF_EXIT_ERR_FATAL
69a227b7f4Shsfi
70a227b7f4Shs
71*d1419d5aSNobutomo Nakanoif [ ! -f /var/run/tzsync ] ; then
72*d1419d5aSNobutomo Nakano	/sbin/tzreload -I
73*d1419d5aSNobutomo Nakanofi
74*d1419d5aSNobutomo Nakano
75a227b7f4Shsif [ "$rootiszfs" = 1 ] ; then
76b21718f0Sgw	/sbin/zfs list -rH -o mountpoint -s mountpoint -t filesystem $be | \
77a227b7f4Shs	    while read mountp ; do
78a227b7f4Shs		if [ "x$mountp" != "x" -a "$mountp" != "legacy" ] ; then
79a227b7f4Shs			mounted $mountp - zfs < /etc/mnttab  && continue
80a227b7f4Shs			/sbin/zfs mount $be$mountp
81a227b7f4Shs		fi
82a227b7f4Shs	done
83a227b7f4Shsfi
847c478bd9Sstevel@tonic-gate
857c478bd9Sstevel@tonic-gateexit $SMF_EXIT_OK
86