xref: /titanic_44/usr/src/cmd/svc/milestone/fs-local (revision 0bb073995ac5a95bd35f2dd790df1ea3d8c2d507)
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 2007 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26#ident	"%Z%%M%	%I%	%E% SMI"
27
28. /lib/svc/share/smf_include.sh
29
30result=$SMF_EXIT_OK
31
32# Mount all local filesystems.
33
34cd /; /sbin/mountall -l >/dev/msglog
35rc=$?
36if [ $rc -ne 0 ]; then
37	msg="WARNING: /sbin/mountall -l failed: exit status $rc"
38	echo $msg
39	echo "$SMF_FMRI:" $msg >/dev/msglog
40	result=$SMF_EXIT_ERR_FATAL
41fi
42
43#
44# If there are non-global UFS filesystems with quotas, check and enable them.
45#
46
47# vlist is the non-global filesystems in vfstab requesting quotas
48vlist=`/usr/bin/nawk '$1 !~ /^(#|-)/ && $4 == "ufs" {
49	if (match($7, "(^|,)(quota|rq)(,|$)") != 0 &&
50	    match($7, "(^|,)global(,|$)") == 0) print $1; }' /etc/vfstab`
51
52if [ -n "$vlist" ]; then
53	# mlist is the filesystems in mnttab that are ufs, mounted rw,
54	# and without quotas turned on
55	mlist=`/usr/sbin/mount -p | /usr/bin/nawk '$4 == "ufs" {
56		if (match($7, "(^|,)ro(,|$)") == 0) print $1; }'`
57
58	# qlist is the intersection of vlist and mlist
59	qlist=`echo "$vlist\n-\n$mlist" | \
60		/usr/bin/nawk '{if ($1 == "-") { mlist = 1; }
61			else if (mlist == 0) { vlist[$1] = 1; }
62			else if (vlist[$1]) { print $1; } }'`
63
64	#
65	# Just check and enable the non-global UFS file systems with quotas
66	# enabled. Note that "quotacheck -a" and "quotaon -a" will try
67	# to process all UFS entries with quotas rather than excluding
68	# the entries with the global option (the global entries are handled
69	# later in another script if the cluster package is installed).
70	#
71	if [ -n "$qlist" ]; then
72		echo 'Checking UFS quotas: \c'
73		/usr/sbin/quotacheck -p $qlist
74		echo 'done.'
75		/usr/sbin/quotaon $qlist
76	fi
77fi
78
79# Mount all ZFS filesystems.
80
81if [ -x /usr/sbin/zfs ]; then
82	/usr/sbin/zfs mount -va >/dev/msglog 2>&1
83	rc=$?
84	if [ $rc -ne 0 ]; then
85		msg="WARNING: /usr/sbin/zfs mount -a failed: exit status $rc"
86		echo $msg
87		echo "$SMF_FMRI:" $msg >/dev/msglog
88		result=$SMF_EXIT_ERR_FATAL
89	fi
90fi
91
92exit $result
93