rdcrules.c revision fcf3ce441efd61da9bb2884968af01cb7c1452cc
/*
* 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.
*/
#include <sys/mdb_modapi.h>
#include <stdio.h>
#include <errno.h>
#include <strings.h>
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
#include <libintl.h>
#include <ctype.h>
#include <thread.h>
#include <pthread.h>
#define RDC_LOCAL_TAG "local"
/*
* bitmap_in_use
* return 1 if in use
* return 0 if not in use
* return -1 on error
*/
int
{
int i, setnumber;
char host[CFG_MAX_BUF];
char shost[CFG_MAX_BUF];
char buf[CFG_MAX_BUF];
char key[CFG_MAX_KEY];
int rc;
int ret = 0;
return (-1);
}
return (-1);
}
/*
* look into II config to see if this is being used elsewhere
*/
/*CSTYLED*/
for (i = 0; ; i++) {
setnumber = i + 1;
break;
if (rc != 5) {
ret = -1;
goto done;
}
/*
* got master shadow bitmap, now compare
*/
"bitmap %s is in use by"
"Point-in-Time Copy", bmp);
ret = 1;
goto done;
}
}
/*
* and last but not least, make sure sndr is not using vol for anything
*/
/*CSTYLED*/
for (i = 0; ; i++) {
setnumber = i + 1;
break;
/*
* I think this is quicker than
* having to double dip into the config
*/
if (cmd == RDC_CMD_ENABLE) {
if (self_check(host)) {
"bitmap %s is in use by %s"),
ret = 1;
goto done;
}
} else {
"bitmap %s is in use by %s"),
ret = 1;
goto done;
}
}
} else if (cmd == RDC_CMD_RECONFIG) {
/*
* read this logic 1000 times and consider
* multi homed, one to many, many to one (marketing)
* etc, etc, before changing
*/
if (self_check(hostp)) {
if (self_check(host)) {
" %s is in use by %s"),
ret = 1;
goto done;
}
} else {
" %s is in use by %s"),
ret = 1;
goto done;
}
}
} else { /* self_check(hostp) failed */
if (self_check(host)) {
" %s is in use by %s"),
ret = 1;
goto done;
}
} else {
" %s is in use by %s"),
ret = 1;
goto done;
}
}
}
}
}
done:
return (ret);
}
int
check_dgislocal(char *dgname)
{
char *othernode;
int rc;
/*
* check where this disk service is mastered
*/
if (rc < 0) {
gettext("unable to find "
return (-1);
}
if (rc == 0) {
gettext("disk service, %s, is "
"active on node \"%s\"\nPlease re-issue "
return (-1);
}
return (DCMD_OK);
}
int
{
char *file_dgname;
char *bmp_dgname;
char *frombitmap, *tobitmap;
char *localfile;
char *ctag;
char file_buf[MAX_RDC_HOST_SIZE];
char bmp_buf[MAX_RDC_HOST_SIZE];
int is_primary;
int islocal = 0;
/*
* Check for the special (local) cluster tag
*/
if (!cfg_iscluster())
return (0);
} else {
}
/*
* If we could get a list of logical hosts on this cluster
* then we could print something intelligent about where
* the volume is mastered. For now, just print some babble
* about the fact that we have no idea.
*/
gettext("either %s:%s or %s:%s is not local"),
return (-1);
}
/*
* If implicit disk group name and no ctag specified by user,
* we set the ctag to it.
* If implicit disk group name, it must match any supplied ctag.
*/
if (is_primary)
else
if (check_dgislocal(file_dgname) < 0) {
/* errors already set */
return (-1);
}
/*
* making an exception here for users giving the "local"tag
* this overrides this error message. (rdc_islocal ! = 1)
*/
strlen(file_dgname) != 0 &&
gettext("ctag \"%s\" does not "
"match disk group name \"%s\" of volume %s"), ctag,
return (-1);
}
(strlen(file_dgname) == 0))) {
/*
* we must have a non-volume managed disk here
* so ask for a tag and get out
*/
gettext("volume \"%s\" is not part"
" of a disk group,\nplease specify resource ctag\n"),
}
/*
* Local bitmap must also have same ctag.
*/
if (is_primary)
else
if (check_dgislocal(bmp_dgname) < 0) {
/* error already set */
return (-1);
}
/* File is in a real disk group */
/* Bitmap is not in a real disk group */
gettext("bitmap %s is not in disk group \"%s\""),
return (-1);
}
}
strlen(bmp_dgname) != 0 &&
gettext("ctag \"%s\" does not "
"match disk group name \"%s\" of bitmap %s"),
return (-1);
}
return (0);
}
int
{
char target[NSC_MAXPATH];
int rdsk;
char *s;
int rc;
int i;
rdsk = i = 0;
rdsk = 1;
else
s++;
}
*s = '\0';
/* Assume the worst, that it is mounted */
return (1);
}
/* found something before EOF */
return (1);
}
return (0);
}
int
{
return (0);
}
if (ctag_check(rdc) < 0) {
/* rdc_error should already be set */
return (0);
}
return (0);
}
return (0);
}
} else { /* on the secondary */
}
dgettext("librdc",
}
}
}
int
{
return (0);
}
int
{
return (0);
}
rdc_rc_t *
{
return (NULL);
return (rc);
}
return (NULL);
}