xref: /titanic_51/usr/src/cmd/svc/milestone/fs-usr (revision bdfc6d18da790deeec2e0eb09c625902defe2498)
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, Version 1.0 only
7# (the "License").  You may not use this file except in compliance
8# with the License.
9#
10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11# or http://www.opensolaris.org/os/licensing.
12# See the License for the specific language governing permissions
13# and limitations under the License.
14#
15# When distributing Covered Code, include this CDDL HEADER in each
16# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17# If applicable, add the following below this CDDL HEADER, with the
18# fields enclosed by brackets "[]" replaced with your own identifying
19# information: Portions Copyright [yyyy] [name of copyright owner]
20#
21# CDDL HEADER END
22#
23#
24# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
28# All rights reserved.
29#
30#
31# ident	"%Z%%M%	%I%	%E% SMI"
32
33. /lib/svc/share/smf_include.sh
34. /lib/svc/share/fs_include.sh
35
36#
37# Add physical swap.
38#
39/sbin/swapadd -1
40
41#
42# Check and remount the / (root) file system.
43# For NFS mounts, force the llock option on.
44#
45if [ "${_INIT_ZONENAME:=`/sbin/zonename`}" = "global" ]; then
46	readvfstab / < $vfstab
47	checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL
48	checkopt "llock" $mntopts
49	mntopts='remount'
50
51	[ -n "$otherops" ] && mntopts="${mntopts},${otherops}"
52	[ "$fstype" = nfs ] && mntopts="${mntopts},llock"
53
54	# if root dev is a read-only metadevice then fail
55	case $special in
56	/dev/md/dsk/*)
57		dd if=/dev/null of=$special count=0 >/dev/null 2>&1 ||
58		    exit $SMF_EXIT_ERR_FATAL
59		;;
60	esac
61
62	mountfs -m $mountp $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL
63fi
64
65#
66# Check and remount the /usr file system (formerly mounted read-only).
67#
68readvfstab /usr < $vfstab
69if [ "$mountp" ]; then
70	if [ "$fstype" = cachefs ]; then
71		mountfs -O $mountp cachefs $mntopts $special ||
72		    exit $SMF_EXIT_ERR_FATAL
73	else
74		checkopt ro $mntopts
75		if [ "x$option" != xro ]; then
76			checkfs $fsckdev $fstype $mountp ||
77			    exit $SMF_EXIT_ERR_FATAL
78			if [ "x$mntopts" != x- ]; then
79				mntopts="remount,$mntopts"
80			else
81				mntopts="remount"
82			fi
83
84			# if usr dev is a read-only metadevice then fail
85			case $special in
86			/dev/md/dsk/*)
87				dd if=/dev/null of=$special count=0 \
88				    >/dev/null 2>&1 || exit $SMF_EXIT_ERR_FATAL
89				;;
90			esac
91
92			mountfs - /usr $fstype $mntopts - ||
93			    exit $SMF_EXIT_ERR_FATAL
94		fi
95	fi
96fi
97
98#
99# Check and mount the /usr/platform file system.  This should only be
100# present when a SunOS 5.5 (Solaris 2.5) or greater client is being
101# administered by a SunOS 5.4 or less host.
102#
103readvfstab /usr/platform < $vfstab
104if [ "$mountp" ]; then
105	checkfs $fsckdev $fstype $mountp || exit $SMF_EXIT_ERR_FATAL
106	mountfs - $mountp $fstype $mntopts - || exit $SMF_EXIT_ERR_FATAL
107fi
108
109#
110# Mount the fd file systems if mount point exists.
111#
112readvfstab /dev/fd < $vfstab
113if [ "$mountp" -a -d /dev/fd ]; then
114	mountfs - /dev/fd - - - || exit $SMF_EXIT_ERR_FATAL
115fi
116
117# Clean up existing /etc/dfs/sharetab as there are no shared file systems
118# at this point. This also takes care of a corrupt sharetab.
119
120if [ -f /etc/dfs/sharetab ]; then
121	> /etc/dfs/sharetab
122fi
123
124exit $SMF_EXIT_OK
125