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.
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.
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]
25 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
37 static boolean_t fs_temporarily_enabled
= B_FALSE
;
38 char svm_core_svcs
[] = "system/filesystem/local:default";
41 * Name: enable_local_fs
42 * Description: If the SMF service system/filesystem/local:default is not
43 * enabled, then this function enables the service, so that,
44 * all the local filesystems are mounted.
46 * Returns: B_TRUE on success; B_FALSE on error.
53 boolean_t fs_enabled_here
= B_FALSE
;
55 if (fs_temporarily_enabled
) {
59 if ((cur_smf_state
= smf_get_state(svm_core_svcs
)) != NULL
) {
60 if (strcmp(cur_smf_state
, SCF_STATE_STRING_DISABLED
) == 0) {
61 if (smf_enable_instance(svm_core_svcs
, SMF_TEMPORARY
)
67 fs_enabled_here
= B_TRUE
;
69 } else if (strcmp(cur_smf_state
, SCF_STATE_STRING_ONLINE
)
73 } else if (strcmp(cur_smf_state
, SCF_STATE_STRING_OFFLINE
)
85 for (i
= 0; i
< MAX_TRY
; i
++) {
86 if ((cur_smf_state
= smf_get_state(svm_core_svcs
)) != NULL
) {
87 if (strcmp(cur_smf_state
, SCF_STATE_STRING_ONLINE
)
90 if (fs_enabled_here
) {
91 fs_temporarily_enabled
= B_TRUE
;
94 } else if ((strcmp(cur_smf_state
,
95 SCF_STATE_STRING_OFFLINE
) == 0) ||
96 (strcmp(cur_smf_state
, SCF_STATE_STRING_DISABLED
) == 0)) {
112 * Name: restore_local_fs
113 * Description: If the SMF service system/filesystem/local:default was
114 * enabled using enable_local_fs(), then this function disables
117 * Returns: B_TRUE on success; B_FALSE on error.
120 restore_local_fs(void)
125 if (!fs_temporarily_enabled
) {
129 if (smf_disable_instance(svm_core_svcs
, SMF_TEMPORARY
) != 0) {
133 for (i
= 0; i
< MAX_TRY
; i
++) {
134 if ((cur_smf_state
= smf_get_state(svm_core_svcs
)) != NULL
) {
135 if (strcmp(cur_smf_state
, SCF_STATE_STRING_DISABLED
)
137 fs_temporarily_enabled
= B_FALSE
;
149 return (!fs_temporarily_enabled
);