fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
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 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
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 * CDDL HEADER END
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Special re-use of sndrboot to fix SNDR set IDs during post-patch processing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * config file user level Dual copy pair structure
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 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 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 lhost[MAX_RDC_HOST_SIZE]; /* Logical hostname for cluster */
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 Forteextern char *basename(char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("incorrect Solaris release (requires %s)\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s unable to get maxsets value from kernel"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to get maxsets value from kernel"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pair_list = calloc(rdc_maxsets, sizeof (*pair_list));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "unable to allocate pair_list"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " array for %d sets"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sndr", NULL, gettext("Fixed %d Remote Mirror"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("Fixed %d Remote Mirror set "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * At this point, this is the child process. Do the operation
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rdc_operation(fromhost, fromfile, frombitmap,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tohost, tofile, tobitmap, flag, directfile, group,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((wait((int *)0) > 0))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_operation(fromhost, fromfile, frombitmap, tohost, tofile,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tobitmap, flag, directfile, group, diskqueue, doasync,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fromname[MAXHOSTNAMELEN], toname[MAXHOSTNAMELEN];
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(fromname, hp->h_name, MAXHOSTNAMELEN);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(toname, hp->h_name, MAXHOSTNAMELEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (self_check(fromname) && self_check(toname)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("Both %s and %s are local"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now build up the address for each host including port and transport
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp = get_addr(toname, RDC_PROGRAM, RDC_VERS_MIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &conf, proto_test?NC_UDP: NULL, "rdc", &tinfo, rpcbind);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("get_addr failed for Ver 4 %s\n", toname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->secondary.addr.maxlen = svaddr.maxlen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->secondary.addr.buf = (void *)svaddr.buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "secondary buf %x len %d\n", svaddr.buf, svaddr.len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp = get_addr(fromname, RDC_PROGRAM, RDC_VERS_MIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &conf, proto_test?NC_UDP: NULL, "rdc", &tinfo, rpcbind);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->primary.addr.maxlen = svaddr.maxlen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "primary buf %x len %d\n",
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 if (!clustered && !self_check(fromname) && !self_check(toname)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("Neither %s nor %s is local"),
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(parms.rdc_set->primary.intf, fromhost,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(parms.rdc_set->primary.file, fromfile, NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(parms.rdc_set->primary.bitmap, frombitmap, NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(parms.rdc_set->secondary.intf, tohost,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(parms.rdc_set->secondary.file, tofile, NSC_MAXPATH);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(parms.rdc_set->secondary.bitmap, tobitmap, NSC_MAXPATH);
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 /* gethostid(3c) is defined to return a 32bit value */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "logical hostname: %s\n", lhost);
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(parms.rdc_set->direct_file, directfile,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->direct_file[0] = 0; /* no fcal direct */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If not clustered, don't resume sndr sets with lhost
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((flag == RDC_CMD_RESUME) && lhost && strlen(lhost))
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(parms.rdc_set->direct_file, directfile,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte parms.rdc_set->direct_file[0] = 0; /* no fcal direct */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = RDC_IOCTL(RDC_CONFIG, &parms, NULL, 0, 0, 0, ustatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Surpress error messages for suspend on cluster elements */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((flag == RDC_CMD_SUSPEND) && (errno == RDC_EALREADY) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fromhost, fromfile, frombitmap, tohost, tofile, tobitmap);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * assign setid's to any existing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sets without setids, making sure of course NOT to re-use a setid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteupdate_setids(CFGFILE *cfg, int *no_id, int highest)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If in a Sun Cluster, SetIDs need to have a ctag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Paranoia. IF there are any sets with setids, we don't
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * want to re-use their number.
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 (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 /* Restore old ctag if in a Sun Cluster */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("sndrboot: Failed to commit setids"));
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 Forteget_lghn(CFGFILE *cfg, char *ctag, int setnum, int flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* BEGIN CSTYLED */
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 rdc_err(NULL, gettext("Error getting scrgadm output"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_err(NULL, gettext("Unable to get logical host"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* not really failing, but suspend does not have the config lock */
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 gettext("sndrboot: Failed to commit logical host name"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * read_libcfg()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * DESCRIPTION: Read the relevant config info via libcfg
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * int i Number of pairs of devices
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Side Effects: The 0 to i-1 entries in the pair_list are filled.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j = 0;
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 rdc_err(NULL, gettext("Error write locking config"));
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 no_id = (int *)calloc(numsets + 1, sizeof (int));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < rdc_maxsets; i++) {
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 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 rdc_err(NULL, gettext("cfg input error (%d)"), rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_single_option(cfg, CFG_SEC_CONF, key,
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 (void) strncpy(pair_list[i].diskqueue, diskqueue,
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 if (cfg_get_single_option(cfg, CFG_SEC_CONF, key, "setid",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "addresses for hosts %s, %s"), fromhost, tohost);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fix any lost set ids if possible, also deal with upgrade
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i = j; /* Set number of fixups */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((c = getopt(argc, argv, "C:Urs")) != -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (c) {
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 * /use/sbin/sndrboot -C post-patch-setids -r -s
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Command will be called in post-install of the patch containing fix
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (clustered && (strcmp(ctag, "post-patch-setids") == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_warn(NULL, gettext("Invalid argument combination"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);