metahs.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* hotspare maintenance
*/
#include <meta.h>
#include <sdssc.h>
/*
* possible actions
*/
enum metahs_op {
NONE,
};
/*
* report status of a hotspare pool
*/
static int
)
{
/* must have set */
/* print status */
return (-1);
/* return success */
return (0);
}
/*
* print usage message
*/
static void
int eval
)
{
usage: %s [-s setname] -a hot_spare_pool [component...]\n\
%s [-s setname] -a \"all\" component...\n\
%s [-s setname] -d hot_spare_pool [component...]\n\
%s [-s setname] -d \"all\" component...\n\
%s [-s setname] -e component...\n\
%s [-s setname] -r hot_spare_pool component_old component_new\n\
%s [-s setname] -r \"all\" component_old component_new\n\
%s [-s setname] -i [hot_spare_pool...]\n"),
}
/*
* check for "all"
*/
static int
is_all(char *s)
{
return (1);
return (0);
}
/*
* parse args and add hotspares
*/
static int
mdsetname_t **spp,
int argc,
char *argv[],
)
{
int cnt;
mdhspnamelist_t *p;
int rval = -1;
/* get hotspare pool name(s) */
if (argc < 1)
return (-1);
}
/* check for ownership */
return (-1);
return (-1);
} else if (cnt == 0) {
}
ep)) < 0) {
return (-1);
}
/* grab set lock */
return (-1);
/* check for ownership */
return (-1);
/* get hotspares */
goto out;
}
/* add hotspares */
goto out;
}
rval = 0;
/* cleanup, return success */
out:
return (rval);
}
/*
* parse args and delete hotspares
*/
static int
mdsetname_t **spp,
int argc,
char *argv[],
)
{
int cnt;
mdhspnamelist_t *p;
int rval = -1;
/* get hotspare pool name(s) */
if (argc < 1)
return (-1);
}
/* check for ownership */
return (-1);
return (-1);
} else if (cnt == 0) {
}
ep)) < 0) {
return (-1);
}
/* grab set lock */
return (-1);
/* check for ownership */
return (-1);
/* get hotspares */
goto out;
}
/* delete hotspares */
cnt = 0;
mdclrerror(ep);
else
goto out;
} else {
++cnt;
}
}
/* make sure we got some */
goto out;
}
/* success */
rval = 0;
/* cleanup, return success */
out:
return (rval);
}
/*
* parse args and enable hotspares
*/
static int
mdsetname_t **spp,
int argc,
char *argv[],
)
{
int rval = -1;
/* enable hotspares */
if (argc < 1)
/* get list of hotspares */
goto out;
/* grab set lock */
return (-1);
/* check for ownership */
return (-1);
/* enable hotspares */
/* cleanup, return success */
out:
return (rval);
}
/*
* parse args and replace hotspares
*/
static int
mdsetname_t **spp,
int argc,
char *argv[],
)
{
int cnt;
mdhspnamelist_t *p;
int rval = -1;
/* get hotspare pool name(s) */
if (argc != 3)
return (-1);
}
/* check for ownership */
return (-1);
return (-1);
} else if (cnt == 0) {
}
ep)) < 0) {
return (-1);
}
/* grab set lock */
return (-1);
/* check for ownership */
return (-1);
/* get old component */
goto out;
/* get new component */
goto out;
/* replace hotspares */
cnt = 0;
!= 0) {
mdclrerror(ep);
else
goto out;
} else {
++cnt;
}
}
/* make sure we got some */
if (cnt == 0) {
goto out;
}
/* success */
rval = 0;
/* cleanup, return success */
out:
return (rval);
}
/*
* print_hsp_devid will collect the information for each underlying
* physical device for all the hotspare pools and print out the
* device relocation information
* INPUT:
* mdsetname_t *sp set the hsp is in
* mdhspnamelist_t *hspnlp list of hsp
* FILE *fp where to print to
* md_error_t *ep errors
* RETURN:
* 0 SUCCESS
* -1 ERROR
*/
static int
)
{
int retval = 0;
mdhspnamelist_t *p;
/* for all hotspare pools */
/* for all hotspares within a pool */
for (hsi = 0;
hsname =
}
}
/* cleanup */
}
return (retval);
}
/*
* parse args and status hotspares
*/
static int
mdsetname_t **spp,
int argc,
char *argv[],
)
{
int cnt;
mdhspnamelist_t *p;
int rval = -1;
/* get hotspare pool name(s) */
if (argc == 0) {
return (-1);
}
/* check for ownership */
return (-1);
return (-1);
} else if (cnt == 0) {
}
return (-1);
}
/* check for ownership */
return (-1);
/* status hotspare pools */
goto out;
}
rval = 0;
}
/* cleanup, return success */
out:
return (rval);
}
/*
* parse args and doit
*/
int
main(
int argc,
char **argv
)
{
char *sname = MD_LOCAL_NAME;
int c;
int error;
char *cp;
/*
* 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)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
if (sdssc_bind_library() == SDSSC_OKAY)
&error) == SDSSC_PROXY_DONE)
} else {
}
/* initialize */
}
/* parse args */
optind = 1;
opterr = 1;
switch (c) {
case 'h':
break;
case 's':
break;
case 'a':
break;
case 'd':
break;
case 'e':
break;
case 'r':
break;
case 'i':
break;
case 'n':
if (called_thru_rpc == TRUE) {
options &= ~MDCMD_DOIT;
} else {
}
break;
case '?':
if (optopt == '?')
/*FALLTHROUGH*/
default:
break;
}
}
/* get set context */
}
/*
* Send the command to all nodes if the -s argument refers to a MN
* set or the next argument refers to MN set hotspare name ( argc
* greater than optind if there is a next argument)
*/
if ((called_thru_rpc == FALSE) &&
int i;
int newargc;
int result;
char **newargv;
/*
* If we are dealing with a MN set and we were not
* called thru an rpc call, we are just to send this
* command string to the master of the set and let it
* deal with it.
* First we send out a dryrun version of this command.
* If that returns success, we know it succeeded on all
* nodes and it is safe to do the real command now.
*/
newargv[0] = "metahs";
newargc = 2;
/* If we found a problem don't do it for real */
if (result != 0) {
}
/*
* Do it for real now. Remove "-n" from the arguments and
* MD_DRYRUN from the flags. If this fails the master must panic
* as the mddbs may be inconsistent.
*/
/* No further action required */
}
if (which_op == STATUS_A_HSP) {
}
}
if (meta_check_root(ep) != 0) {
}
/* dispatch */
switch (which_op) {
case ADD_A_HS:
}
break;
case DELETE_A_HS:
}
break;
case ENABLE_A_HS:
}
break;
case REPLACE_A_HS:
}
break;
default:
assert(0);
break;
}
/* update md.cf */
out:
}
/*NOTREACHED*/
return (0);
}