/*
* 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 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <errno.h>
#include <limits.h>
#include <fcntl.h>
#include <strings.h>
#include <stdlib.h>
#include <unistd.h>
#include <locale.h>
#include <langinfo.h>
#include <libintl.h>
#include <stdarg.h>
#include <netdb.h>
#include <ctype.h>
#include "rdcadm.h"
/*
* Special re-use of sndrboot to fix SNDR set IDs during post-patch processing
*/
/*
* config file user level Dual copy pair structure
*/
typedef struct _sd_dual_pair {
int parseopts(int, char **, int *);
static int rdc_operation(char *, char *, char *, char *, char *, char *, int,
char *, char *, char *, int, char *, int setid);
static int read_libcfg(int);
static void usage(void);
extern char *basename(char *);
int rdc_maxsets;
char *program;
static int clustered = 0;
static int proto_test = 0;
#ifdef lint
int
#else
int
#endif
{
int pairs;
int pid;
int flag = 0;
int doasync;
int rc;
char *required;
int setid;
(void) textdomain("rdc");
if (rc < 0) {
gettext("unable to determine the current "
gettext("incorrect Solaris release (requires %s)\n"),
required);
}
if (rdc_maxsets == -1) {
gettext("%s unable to get maxsets value from kernel"),
program);
gettext("unable to get maxsets value from kernel"));
}
"unable to allocate pair_list"
" array for %d sets"),
}
return (1);
if (flag == RDC_CMD_FIXSETIDS) {
if (pairs) {
" set IDs"), pairs);
#ifdef DEBUG
"IDs"), pairs);
#endif
}
return (0);
}
if (pairs == 0) {
#ifdef DEBUG
gettext("Config contains no dual copy sets"));
#else
return (0);
#endif
}
while (pairs--) {
perror("fork");
continue;
}
if (pid > 0) /* this is parent process */
continue;
/*
* At this point, this is the child process. Do the operation
*/
(void) strncpy(frombitmap,
(void) strncpy(directfile,
< 0) {
exit(255);
}
exit(0);
}
while ((wait((int *)0) > 0))
;
return (0);
}
static int
char *directfile;
int setid;
char *lhost;
{
int ret;
int i;
gettext("%s gethost_byname failed for %s"),
}
else {
}
}
if (fromname[0] == '\0') {
gettext("%s host %s is not local"),
fromhost);
}
gettext("%s gethost_byname failed for %s"),
}
else {
}
}
if (toname[0] == '\0') {
gettext("%s host %s is not local"),
tohost);
}
gettext("%s Both %s and %s are local"),
}
/*
* Now build up the address for each host including port and transport
*/
if (getaddr) {
#ifdef DEBUG
#endif
gettext("%s get_addr failed for Ver 4"),
program);
return (-1);
}
} else {
}
#ifdef DEBUG_ADDR
(void) printf("\n");
#endif
if (getaddr) {
#ifdef DEBUG
(void) printf("get_addr failed for Ver 4 %s\n",
fromname);
#endif
return (-1);
}
} else {
;
/*EMPTY*/
}
#ifdef DEBUG_ADDR
(void) printf("\n");
#endif
if (getaddr) {
#ifdef DEBUG_ADDR
#endif
} else {
}
gettext("%s Neither %s nor %s is local"),
}
/* gethostid(3c) is defined to return a 32bit value */
if (flag == RDC_CMD_RESUME) {
if (doasync)
else
}
if (clustered) {
if (!ctag)
goto noconfig;
goto noconfig;
#ifdef DEBUG
#endif
} else {
}
} else {
/*
* If not clustered, don't resume sndr sets with lhost
*/
return (0);
if (self_check(fromname)) {
} else {
}
}
ustatus = spcs_s_ucreate();
errno = 0;
/* Surpress error messages for suspend on cluster elements */
return (0);
}
gettext("Remote Mirror: %s %s %s %s %s %s\n"),
if (errno == RDC_EEINVAL) {
gettext("%s %s %s %s %s %s %s %s\n%s"),
gettext("invalid command option"));
gettext("Remote Mirror: invalid command option "
} else {
gettext("%s %s %s %s %s %s %s %s"),
}
}
gettext("%s %s %s %s %s %s %s %s\nSuccessful"),
return (0);
}
/*
* assign setid's to any existing
* sets without setids, making sure of course NOT to re-use a setid
*/
int
{
int setid;
char *ctag;
/* If in a Sun Cluster, SetIDs need to have a ctag */
}
/*
* Paranoia. IF there are any sets with setids, we don't
* want to re-use their number.
*/
sizeof (buf)) < 0)
"new setid"));
}
"unique setid"));
}
/* Restore old ctag if in a Sun Cluster */
if (ctag) {
}
if (cfg_commit(cfg) < 0)
return (setid);
}
/*
* this is called when the option lghn is no available in libdscfg
* that should only happen on an upgrade.
* cfg write lock must be held across this function
*/
char *
{
int rc;
goto fail;
/* BEGIN CSTYLED */
| fgrep %s | fgrep value | awk -F: '{ print $4 }'", rsgrp);
/* END CSTYLED */
if (rc < 0) {
}
}
if (rc != 1) {
}
/* not really failing, but suspend does not have the config lock */
if (flag == RDC_CMD_SUSPEND)
goto fail;
"host name in configuration database"));
if (cfg_commit(cfg) < 0)
gettext("sndrboot: Failed to commit logical host name"));
fail:
return (lhostname);
}
/*
* read_libcfg()
*
* DESCRIPTION: Read the relevant config info via libcfg
*
* Outputs:
* int i Number of pairs of devices
*
* Side Effects: The 0 to i-1 entries in the pair_list are filled.
*
*/
static int
{
int doasync;
int i, j = 0;
int rc;
int setnumber;
int numsets;
int highest = 0;
int *no_id;
/*
* If RDC_CMD_FIXSETIDS, we were called during post-patch install
* Acquire a write-lock on the cfg_lock(), so the code can attempt
* to fix setIDs
*/
if (flag == RDC_CMD_FIXSETIDS) {
} else {
}
if (!no_id)
for (i = 0; i < rdc_maxsets; i++) {
setnumber = i + 1;
break;
if (rc != 12)
doasync = 0;
doasync = 1;
else {
gettext("Set %s:%s neither sync nor async"),
}
}
gettext("%s unable to determine IP addresses "
}
}
/*
* fix any lost set ids if possible, also deal with upgrade
*/
if (j > 0 && flag == RDC_CMD_FIXSETIDS) {
i = j; /* Set number of fixups */
}
return (i);
}
int
int argc;
char **argv;
int *flag;
{
int errflag = 0;
char c;
char inval = 0;
#ifdef DEBUG
#else
#endif
switch (c) {
case 'C':
break;
#ifdef DEBUG
case 'U':
proto_test = 1;
break;
#endif
case 'r':
if (*flag)
inval = 1;
*flag = RDC_CMD_RESUME;
break;
case 's':
if (*flag)
inval = 1;
*flag = RDC_CMD_SUSPEND;
break;
case '?':
errflag++;
}
}
/*
* Special fix to address no SetIds in AVS 3.1 to 3.2 install + patch
* Adjust set IDs, if someone invokes the following invalid command
*
*
* Command will be called in post-install of the patch containing fix
*
*/
return (0);
}
if (inval) {
errflag = 1;
}
usage();
return (-1);
}
return (0);
}
static void
usage()
{
gettext("\t%s -r [-C tag]\t\t"
"resume\n"), program);
gettext("\t%s -s [-C tag]\t\t"
"suspend\n"), program);
}