4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
44 (void) fprintf(stderr
, gettext("\
45 usage: %s [-s setname] [-f] mirror submirror\n"),
51 * Metaoffline: to offline a metadevice
60 mdsetname_t
*sp
= NULL
;
61 mdcmdopts_t options
= (MDCMD_PRINT
);
65 md_error_t status
= mdnullerror
;
66 md_error_t
*ep
= &status
;
68 bool_t called_thru_rpc
= FALSE
;
71 char **origargv
= argv
;
74 * Get the locale set up before calling any other routines
75 * with messages to ouput. Just in case we're not in a build
76 * environment, make sure that TEXT_DOMAIN gets set to
79 #if !defined(TEXT_DOMAIN)
80 #define TEXT_DOMAIN "SYS_TEST"
82 (void) setlocale(LC_ALL
, "");
83 (void) textdomain(TEXT_DOMAIN
);
85 if ((cp
= strstr(argv
[0], ".rpc_call")) == NULL
) {
86 if (sdssc_bind_library() == SDSSC_OKAY
)
87 if (sdssc_cmd_proxy(argc
, argv
, SDSSC_PROXY_PRIMARY
,
88 &error
) == SDSSC_PROXY_DONE
)
91 *cp
= '\0'; /* cut off ".rpc_call" */
92 called_thru_rpc
= TRUE
;
96 if (md_init(argc
, argv
, 0, 1, ep
) != 0 ||
97 meta_check_root(ep
) != 0) {
105 while ((c
= getopt(argc
, argv
, "hs:f?")) != -1) {
116 options
|= MDCMD_FORCE
;
134 if ((sp
= metasetname(sname
, ep
)) == NULL
) {
141 if (((mirnp
= metaname(&sp
, argv
[0], META_DEVICE
, ep
)) == NULL
) ||
142 ((submirnp
= metaname(&sp
, argv
[1], META_DEVICE
, ep
)) == NULL
)) {
149 if ((called_thru_rpc
== FALSE
) &&
150 meta_is_mn_name(&sp
, argv
[0], ep
)) {
152 * If we are dealing with a MN set and we were not
153 * called thru an rpc call, we are just to send this
154 * command string to the master of the set and let it
156 * Note that if sp is NULL, meta_is_mn_name() derives sp
157 * from argv[0] which is the metadevice arg
158 * If this fails, the master must panic as the mddb may be
162 result
= meta_mn_send_command(sp
, origargc
, origargv
,
163 MD_DISP_STDERR
| MD_PANIC_WHEN_INCONSISTENT
,
164 NO_CONTEXT_STRING
, ep
);
169 if (meta_lock(sp
, TRUE
, ep
)) {
174 /* check for ownership */
175 if (meta_check_ownership(sp
, ep
) != 0) {
180 /* offline submirror */
181 if (meta_mirror_offline(sp
, mirnp
, submirnp
, options
, ep
) != 0) {