/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* sync metadevices
*/
#include <meta.h>
#include <ctype.h>
#include <sdssc.h>
/*
* print usage message
*/
static void
int eval
)
{
usage: %s [-s setname] -r [buffer_size]\n\
%s [-s setname] [buffer_size] metadevices...\n\
%s [-s setname] -c metadevices...\n"),
}
/*
* crack command line arguments.
*/
int
main(
int argc,
char *argv[]
)
{
int rflag = 0;
int pflag = 0;
int c;
int rval = 0;
int error;
char *cp;
int cflag = 0;
/*
* Get the locale set up before calling any other routines
* with messages to ouput. Just in case we're not in a build
* environment, make sure that TEXT_DOMAIN gets set to
* something.
*/
#if !defined(TEXT_DOMAIN)
#endif
(void) textdomain(TEXT_DOMAIN);
if (sdssc_bind_library() == SDSSC_OKAY)
&error) == SDSSC_PROXY_DONE)
} else {
}
/* initialize */
meta_check_root(ep) != 0) {
}
/* parse args */
optind = 1;
opterr = 1;
switch (c) {
case 'h':
break;
case 's':
break;
case 'r':
++rflag;
break;
case 'p':
++pflag;
break;
case 'c':
++cflag;
break;
case '?':
if (optopt == '?')
/*FALLTHROUGH*/
default:
break;
}
}
}
}
}
/*
* look for buffer size. If one is not specified we pass '0' to
* the meta_resync_all() call. This uses whatever size has been
* configured via md_mirror:md_resync_bufsz
* MD_DEF_RESYNC_BUF_SIZE
*/
"illegal buffer size %s\n"),
argv[0]);
}
--argc;
++argv;
}
/* sync all devices in set */
if (rflag) {
/* get set */
if (argc != 0)
}
/*
* For a MN set "metasync -r" can only be called by the
* initiator. We must not take the set lock for a MN set as
* it will only generate individual metasync commands which
* will individually take the lock when executing the
* individual metasync commands.
* Therefore only take the set lock for non MN sets.
*/
/* grab set lock */
}
/* check for ownership */
}
}
/* resync all metadevices in set */
}
}
/* sync specified metadevices */
if (argc <= 0)
/*
* Note that if sp is NULL, meta_is_mn_name() derives sp
* from argv[0] which is the metadevice arg
*/
int result;
/* get device */
rval = -1;
continue;
}
/*
* If we are not called through an rpc call and the
* set associated with the command is an MN set, send
* a setsync message to the master of the set and let it
* deal with it.
*/
if (!called_thru_rpc && mn_set) {
ep)) != 0) {
}
continue;
}
/* grab set lock */
}
/* check for ownership */
}
/* resync or regen (raid only) metadevice */
if (pflag) {
/* regen */
rval = -1;
continue;
}
} else {
!= 0) {
rval = -1;
continue;
}
}
}
/* return success */
/*NOTREACHED*/
return (rval);
}