fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/wait.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/mnttab.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <limits.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <fcntl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <strings.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <locale.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <langinfo.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <libintl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdarg.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <netdb.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ctype.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/utsname.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/rdc_io.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/rdc_ioctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/rdc_prot.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/cfg.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/cfg_cluster.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_s.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_s_u.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_errors.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "rdcadm.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Special re-use of sndrboot to fix SNDR set IDs during post-patch processing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define RDC_CMD_FIXSETIDS 0xFEEDFACE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * config file user level Dual copy pair structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct _sd_dual_pair {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fhost[MAX_RDC_HOST_SIZE]; /* Hostname for primary device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fnetaddr[RDC_MAXADDR]; /* Host netaddr for primary device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char ffile[NSC_MAXPATH]; /* Primary device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fbitmap[NSC_MAXPATH]; /* Primary bitmap device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char thost[MAX_RDC_HOST_SIZE]; /* Hostname for secondary device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char tnetaddr[RDC_MAXADDR]; /* Host netaddr for secondary device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char tfile[NSC_MAXPATH]; /* Secondary device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char tbitmap[NSC_MAXPATH]; /* Secondary bitmap device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char directfile[NSC_MAXPATH]; /* Local FCAL direct IO volume */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char diskqueue[NSC_MAXPATH]; /* Disk Queue volume */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char group[NSC_MAXPATH]; /* Group name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char lhost[MAX_RDC_HOST_SIZE]; /* Logical hostname for cluster */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int doasync; /* Device is in sync/async mode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int setid; /* unique setid of this set */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} _sd_dual_pair_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/socket.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <netinet/in.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <arpa/inet.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <netinet/tcp.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <rpc/rpc_com.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <rpc/rpc.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/librdc.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *ctag = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint parseopts(int, char **, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int rdc_operation(char *, char *, char *, char *, char *, char *, int,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *, char *, char *, int, char *, int setid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int read_libcfg(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void usage(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern char *basename(char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint rdc_maxsets;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic _sd_dual_pair_t *pair_list;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *program;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct netbuf svaddr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct netbuf *svp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct netconfig nconf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct netconfig *conf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct knetconfig knconf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int clustered = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int proto_test = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef lint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesndrboot_lintmain(int argc, char *argv[])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemain(int argc, char *argv[])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fromhost[MAX_RDC_HOST_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char tohost[MAX_RDC_HOST_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fromfile[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char tofile[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char frombitmap[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char tobitmap[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char directfile[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char diskqueue[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char group[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char lhost[MAX_RDC_HOST_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int pairs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int pid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int flag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int doasync;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *required;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int setid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) setlocale(LC_ALL, "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) textdomain("rdc");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program = basename(argv[0]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = rdc_check_release(&required);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to determine the current "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Solaris release: %s\n"), strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (rc == FALSE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("incorrect Solaris release (requires %s)\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte required);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_maxsets = rdc_get_maxsets();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rdc_maxsets == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s unable to get maxsets value from kernel"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to get maxsets value from kernel"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pair_list = calloc(rdc_maxsets, sizeof (*pair_list));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pair_list == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "unable to allocate pair_list"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " array for %d sets"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_maxsets);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (parseopts(argc, argv, &flag))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pairs = read_libcfg(flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag == RDC_CMD_FIXSETIDS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pairs) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL, gettext("Fixed %d Remote Mirror"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " set IDs"), pairs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("Fixed %d Remote Mirror set "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "IDs"), pairs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pairs == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Config contains no dual copy sets"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (pairs--) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pid = fork();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pid == -1) { /* error forking */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte perror("fork");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pid > 0) /* this is parent process */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * At this point, this is the child process. Do the operation
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(fromfile,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki pair_list[pairs].ffile, NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(tofile,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki pair_list[pairs].tfile, NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(frombitmap,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki pair_list[pairs].fbitmap, NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(fromhost,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki pair_list[pairs].fhost, MAX_RDC_HOST_SIZE);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(tohost,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki pair_list[pairs].thost, MAX_RDC_HOST_SIZE);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(tobitmap,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki pair_list[pairs].tbitmap, NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(directfile,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki pair_list[pairs].directfile, NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(diskqueue,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki pair_list[pairs].diskqueue, NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(group,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki pair_list[pairs].group, NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(lhost,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki pair_list[pairs].lhost, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte doasync = pair_list[pairs].doasync;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setid = pair_list[pairs].setid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rdc_operation(fromhost, fromfile, frombitmap,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tohost, tofile, tobitmap, flag, directfile, group,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte diskqueue, doasync, lhost, setid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(255);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((wait((int *)0) > 0))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_operation(fromhost, fromfile, frombitmap, tohost, tofile,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tobitmap, flag, directfile, group, diskqueue, doasync,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lhost, setid)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *fromhost, *fromfile, *frombitmap;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *tohost, *tofile, *tobitmap;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint flag, doasync;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *directfile;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *group, *diskqueue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint setid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *lhost;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const int getaddr = (flag == RDC_CMD_RESUME);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const int rpcbind = !getaddr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_config_t parms;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ret;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct hostent *hp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fromname[MAXHOSTNAMELEN], toname[MAXHOSTNAMELEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct t_info tinfo;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte conf = &nconf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&fromname, MAXHOSTNAMELEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&toname, MAXHOSTNAMELEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hp = gethost_byname(fromhost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s gethost_byname failed for %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, fromhost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(hp->h_name, fromhost) == 0)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(fromname, hp->h_name, MAXHOSTNAMELEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; hp->h_aliases[i] != NULL; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(hp->h_aliases[i], fromhost) == 0)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(fromname, hp->h_aliases[i],
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki MAXHOSTNAMELEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fromname[0] == '\0') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s host %s is not local"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, fromhost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("Host %s is not local"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fromhost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hp = gethost_byname(tohost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s gethost_byname failed for %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, tohost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(hp->h_name, tohost) == 0)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(toname, hp->h_name, MAXHOSTNAMELEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; hp->h_aliases[i] != NULL; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(hp->h_aliases[i], tohost) == 0)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(toname, hp->h_aliases[i],
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki MAXHOSTNAMELEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (toname[0] == '\0') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s host %s is not local"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, tohost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("Host %s is not local"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tohost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (self_check(fromname) && self_check(toname)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s Both %s and %s are local"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, fromhost, tohost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("Both %s and %s are local"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fromhost, tohost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now build up the address for each host including port and transport
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getaddr) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp = get_addr(toname, RDC_PROGRAM, RDC_VERS_MIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &conf, proto_test?NC_UDP: NULL, "rdc", &tinfo, rpcbind);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (svp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("get_addr failed for Ver 4 %s\n", toname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s get_addr failed for Ver 4"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svaddr = *svp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&svaddr, sizeof (svaddr));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->secondary.addr.len = svaddr.len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->secondary.addr.maxlen = svaddr.maxlen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->secondary.addr.buf = (void *)svaddr.buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG_ADDR
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "secondary buf %x len %d\n", svaddr.buf, svaddr.len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < svaddr.len; i++)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("%u ", svaddr.buf[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getaddr) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp = get_addr(fromname, RDC_PROGRAM, RDC_VERS_MIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &conf, proto_test?NC_UDP: NULL, "rdc", &tinfo, rpcbind);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (svp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("get_addr failed for Ver 4 %s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fromname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svaddr = *svp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*EMPTY*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->primary.addr.len = svaddr.len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->primary.addr.maxlen = svaddr.maxlen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->primary.addr.buf =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)svaddr.buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG_ADDR
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "primary buf %x len %d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svaddr.buf, svaddr.len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < svaddr.len; i++)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("%u ", svaddr.buf[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (getaddr) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) convert_nconf_to_knconf(conf, &knconf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG_ADDR
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("knconf %x %s %s %x\n", knconf.knc_semantics,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte knconf.knc_protofmly, knconf.knc_proto, knconf.knc_rdev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->netconfig = &knconf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->netconfig = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!clustered && !self_check(fromname) && !self_check(toname)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s Neither %s nor %s is local"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, fromhost, tohost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("Neither %s nor %s is local"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fromhost, tohost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(parms.rdc_set->primary.intf, fromhost,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki MAX_RDC_HOST_SIZE);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(parms.rdc_set->primary.file, fromfile, NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(parms.rdc_set->primary.bitmap, frombitmap, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(parms.rdc_set->secondary.intf, tohost,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki MAX_RDC_HOST_SIZE);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(parms.rdc_set->secondary.file, tofile, NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(parms.rdc_set->secondary.bitmap, tobitmap, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(parms.rdc_set->group_name, group, NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(parms.rdc_set->disk_queue, diskqueue, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->maxqfbas = maxqfbas;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->maxqitems = maxqitems;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->autosync = autosync;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->asyncthr = asyncthr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->setid = setid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* gethostid(3c) is defined to return a 32bit value */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->syshostid = (int32_t)gethostid();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.command = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.options = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.command = flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag == RDC_CMD_RESUME) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (doasync)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.options |= RDC_OPT_ASYNC;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.options |= RDC_OPT_SYNC;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (clustered) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!ctag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto noconfig;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(ctag, "-") == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto noconfig;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "logical hostname: %s\n", lhost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(lhost, fromname) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.options |= RDC_OPT_PRIMARY;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(parms.rdc_set->direct_file, directfile,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.options |= RDC_OPT_SECONDARY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->direct_file[0] = 0; /* no fcal direct */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortenoconfig:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If not clustered, don't resume sndr sets with lhost
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((flag == RDC_CMD_RESUME) && lhost && strlen(lhost))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (self_check(fromname)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.options |= RDC_OPT_PRIMARY;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(parms.rdc_set->direct_file, directfile,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.options |= RDC_OPT_SECONDARY;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->direct_file[0] = 0; /* no fcal direct */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ustatus = spcs_s_ucreate();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errno = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = RDC_IOCTL(RDC_CONFIG, &parms, NULL, 0, 0, 0, ustatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ret != SPCS_S_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Surpress error messages for suspend on cluster elements */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((flag == RDC_CMD_SUSPEND) && (errno == RDC_EALREADY) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !clustered && lhost && strlen(lhost)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_ufree(&ustatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Remote Mirror: %s %s %s %s %s %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fromhost, fromfile,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte frombitmap, tohost, tofile, tobitmap);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno == RDC_EEINVAL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s %s %s %s %s %s %s %s\n%s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, rdc_decode_flag(flag, parms.options),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fromhost, fromfile, frombitmap,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tohost, tofile, tobitmap,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("invalid command option"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(&ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Remote Mirror: invalid command option "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "'%s'"), rdc_decode_flag(flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.options));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", &ustatus,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s %s %s %s %s %s %s %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, rdc_decode_flag(flag, parms.options),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fromhost, fromfile, frombitmap,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tohost, tofile, tobitmap);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(&ustatus, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s %s %s %s %s %s %s %s\nSuccessful"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte program, rdc_decode_flag(flag, parms.options),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fromhost, fromfile, frombitmap, tohost, tofile, tobitmap);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_ufree(&ustatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * assign setid's to any existing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sets without setids, making sure of course NOT to re-use a setid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteupdate_setids(CFGFILE *cfg, int *no_id, int highest)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int setid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buf[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *ctag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If in a Sun Cluster, SetIDs need to have a ctag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ctag = cfg_get_resource(cfg)) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ctag = strdup(ctag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_resource(cfg, "setid-ctag");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Paranoia. IF there are any sets with setids, we don't
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * want to re-use their number.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (highest > get_new_cfg_setid(cfg)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&buf, sizeof (buf));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(buf, "%d", highest);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_put_cstring(cfg, "setid.set1.value", buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (buf)) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("sndrboot: Unable to store "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "new setid"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (setid = 0; no_id[setid]; setid++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&buf, sizeof (buf));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&key, sizeof (key));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(buf, "%d", get_new_cfg_setid(cfg));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(key, "sndr.set%d.options", no_id[setid]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_put_options(cfg, CFG_SEC_CONF, key, "setid", buf) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("sndrboot: Unable to store "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "unique setid"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pair_list[no_id[setid] - 1].setid = atoi(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Restore old ctag if in a Sun Cluster */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ctag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_resource(cfg, ctag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(ctag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_commit(cfg) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("sndrboot: Failed to commit setids"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (setid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this is called when the option lghn is no available in libdscfg
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that should only happen on an upgrade.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cfg write lock must be held across this function
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_lghn(CFGFILE *cfg, char *ctag, int setnum, int flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FILE *pipe;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char rsgrp[SCCONF_MAXSTRINGLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char cmd[SCCONF_MAXSTRINGLEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static char lhostname[MAX_RDC_HOST_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ctag == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto fail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&lhostname, sizeof (lhostname));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(rsgrp, "%s-stor-rg", ctag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* BEGIN CSTYLED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = snprintf(cmd, SCCONF_MAXSTRINGLEN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "/usr/cluster/bin/scrgadm -pvv | fgrep HostnameList \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte| fgrep %s | fgrep value | awk -F: '{ print $4 }'", rsgrp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* END CSTYLED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("Error getting scrgadm output"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pipe = popen(cmd, "r");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pipe == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("Error opening pipe"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = fscanf(pipe, "%s", lhostname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) pclose(pipe);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc != 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("Unable to get logical host"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* not really failing, but suspend does not have the config lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag == RDC_CMD_SUSPEND)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto fail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&key, sizeof (key));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sndr.set%d.options", setnum);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_put_options(cfg, CFG_SEC_CONF, key, "lghn", lhostname) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("sndrboot: Unable to store logical "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "host name in configuration database"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_commit(cfg) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("sndrboot: Failed to commit logical host name"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortefail:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (lhostname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * read_libcfg()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * DESCRIPTION: Read the relevant config info via libcfg
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Outputs:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * int i Number of pairs of devices
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Side Effects: The 0 to i-1 entries in the pair_list are filled.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteread_libcfg(int flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fromhost[MAX_RDC_HOST_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fromfile[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char frombitmap[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char tohost[MAX_RDC_HOST_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char tofile[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char tobitmap[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char directfile[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char diskqueue[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char group[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char lhost[MAX_RDC_HOST_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char sync[16];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char setid[64];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int doasync;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFGFILE *cfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buf[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char dummy[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int setnumber;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int numsets;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int highest = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char lghn[5];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int *no_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg = cfg_open("")) == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("Error opening config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If RDC_CMD_FIXSETIDS, we were called during post-patch install
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Acquire a write-lock on the cfg_lock(), so the code can attempt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to fix setIDs
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag == RDC_CMD_FIXSETIDS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_WRLOCK))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("Error write locking config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_resource(cfg, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_RDLOCK))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("Error locking config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_resource(cfg, ctag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((numsets = cfg_get_num_entries(cfg, "sndr")) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("Unable to get set info from config"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte no_id = (int *)calloc(numsets + 1, sizeof (int));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!no_id)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("No memory"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(lghn, sizeof (lghn), "lghn");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rdc_maxsets; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber = i + 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(buf, CFG_MAX_BUF);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sndr.set%d", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = sscanf(buf, "%s %s %s %s %s %s %s %s %s %s %s %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fromhost, fromfile, frombitmap, tohost, tofile, tobitmap,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte directfile, sync, group, dummy, dummy, diskqueue);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc != 12)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("cfg input error (%d)"), rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(directfile, "ip") == 0)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(directfile, "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(group, "-") == 0)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(group, "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(diskqueue, "-") == 0)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(diskqueue, "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "sndr.set%d.options", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_single_option(cfg, CFG_SEC_CONF, key,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lghn, lhost, MAX_RDC_HOST_SIZE) < 0)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(lhost,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte get_lghn(cfg, ctag, setnumber, flag));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(sync, "sync") == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte doasync = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (strcmp(sync, "async") == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte doasync = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Set %s:%s neither sync nor async"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tohost, tofile);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(pair_list[i].fhost, fromhost,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki MAX_RDC_HOST_SIZE);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(pair_list[i].ffile, fromfile, NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(pair_list[i].fbitmap, frombitmap, NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(pair_list[i].thost, tohost, MAX_RDC_HOST_SIZE);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(pair_list[i].tfile, tofile, NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(pair_list[i].tbitmap, tobitmap, NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(pair_list[i].directfile, directfile,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(pair_list[i].diskqueue, diskqueue,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(pair_list[i].group, group, NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(pair_list[i].lhost, lhost, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pair_list[i].doasync = doasync;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_single_option(cfg, CFG_SEC_CONF, key, "setid",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setid, sizeof (setid)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte no_id[j++] = setnumber;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pair_list[i].setid = atoi(setid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pair_list[i].setid > highest)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte highest = pair_list[i].setid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (gethost_netaddrs(fromhost, tohost,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)pair_list[i].fnetaddr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (char *)pair_list[i].tnetaddr) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s unable to determine IP addresses "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "for hosts %s %s"), program, fromhost, tohost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("unable to determine IP "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "addresses for hosts %s, %s"), fromhost, tohost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fix any lost set ids if possible, also deal with upgrade
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (j > 0 && flag == RDC_CMD_FIXSETIDS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) update_setids(cfg, no_id, highest);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = j; /* Set number of fixups */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(no_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteparseopts(argc, argv, flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint argc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar **argv;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint *flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int errflag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char inval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((c = getopt(argc, argv, "C:Urs")) != -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((c = getopt(argc, argv, "C:rs")) != -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (c) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'C':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clustered = TRUE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ctag = optarg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'U':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte proto_test = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'r':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inval = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *flag = RDC_CMD_RESUME;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 's':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte inval = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *flag = RDC_CMD_SUSPEND;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case '?':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errflag++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Special fix to address no SetIds in AVS 3.1 to 3.2 install + patch
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Adjust set IDs, if someone invokes the following invalid command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * /use/sbin/sndrboot -C post-patch-setids -r -s
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Command will be called in post-install of the patch containing fix
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (clustered && (strcmp(ctag, "post-patch-setids") == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *flag && inval) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *flag = RDC_CMD_FIXSETIDS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (inval) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("Invalid argument combination"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errflag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!*flag || errflag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte usage();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteusage()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("usage:\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("\t%s -r [-C tag]\t\t"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "resume\n"), program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("\t%s -s [-C tag]\t\t"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "suspend\n"), program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}