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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/stat.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/mkdev.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <fcntl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stropts.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <libintl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <locale.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/rdcerr.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/rdc_ioctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/librdc.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/cfg.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/nsc_hash.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/sv.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_dtrinkets.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_etrinkets.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_s.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_s_u.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_s_impl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_errors.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct volcount_s {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} volcount_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortehash_node_t **volhash = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconfig2buf(char *buf, rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(buf, CFG_MAX_BUF, "%s %s %s %s %s %s %s %s %s %s %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc->phost, rdc->pfile, rdc->pbmp, rdc->shost, rdc->sfile,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc->sbmp, rdc->direct, rdc->mode, rdc->group ? rdc->group : "",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc->ctag ? rdc->ctag : "", rdc->options ? rdc->options : "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * SV type functions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteload_rdc_vols(CFGFILE *cfg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int set;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[ CFG_MAX_KEY ];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buf[ CFG_MAX_BUF ];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *vol, *bmp, *host1, *host2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volcount_t *volcount;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (volhash) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_rewind(cfg, CFG_SEC_CONF);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volhash = nsc_create_hash();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (set = 1; /*CSTYLED*/; set++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(key, CFG_MAX_KEY, "sndr.set%d", set);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte host1 = strtok(buf, " ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vol = strtok(NULL, " ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp = strtok(NULL, " ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!self_check(host1)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* next one had better be ours */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte host2 = strtok(NULL, " ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vol = strtok(NULL, " ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bmp = strtok(NULL, " ");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!self_check(host2)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* primary vol may be used more than once */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volcount = (volcount_t *)nsc_lookup(volhash, vol);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (volcount) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volcount->count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volcount = (volcount_t *)malloc(sizeof (volcount_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volcount->count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_insert_node(volhash, volcount, vol);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* bitmap ought to be only used once */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volcount = (volcount_t *)nsc_lookup(volhash, bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (volcount) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* argh */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volcount->count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volcount = (volcount_t *)malloc(sizeof (volcount_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volcount->count = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_insert_node(volhash, volcount, bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_enable_one_nocfg(char *vol)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stat sb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_conf_t svc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int fd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&svc, sizeof (svc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stat(vol, &sb) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_OS, 0, "unable to stat %s", vol);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!S_ISCHR(sb.st_mode)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL, "%s is not"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " a character device", vol);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svc.svc_major = major(sb.st_rdev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svc.svc_minor = minor(sb.st_rdev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(svc.svc_path, vol, sizeof (svc.svc_path));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fd = open(SV_DEVICE, O_RDONLY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fd < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_OS, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svc.svc_flag = (NSC_DEVICE | NSC_CACHE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svc.svc_error = spcs_s_ucreate();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ioctl(fd, SVIOC_ENABLE, &svc) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno != SV_EENABLED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(&svc.svc_error, RDC_INTERNAL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte RDC_NONFATAL, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sv", NULL, gettext("enabled %s"), svc.svc_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_enable_nocfg(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stat stbv;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct stat stbb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_conf_t svcv;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_conf_t svcb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char vol[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char bmp[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int fd = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (self_check(rdc->phost)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(vol, rdc->pfile, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(bmp, rdc->pbmp, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(vol, rdc->sfile, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(bmp, rdc->sbmp, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&svcv, sizeof (svcv));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(&svcb, sizeof (svcb));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((stat(vol, &stbv) != 0) || (stat(bmp, &stbb) != 0))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((!S_ISCHR(stbv.st_mode)) || (!S_ISCHR(stbb.st_mode)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svcv.svc_major = major(stbv.st_rdev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svcb.svc_minor = minor(stbb.st_rdev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(svcv.svc_path, vol, sizeof (svcv.svc_path));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(svcb.svc_path, bmp, sizeof (svcb.svc_path));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fd = open(SV_DEVICE, O_RDONLY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fd < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* SV enable the volume */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svcv.svc_flag = (NSC_DEVICE | NSC_CACHE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svcv.svc_error = spcs_s_ucreate();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ioctl(fd, SVIOC_ENABLE, &svcv) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno != SV_EENABLED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sv", &svcv.svc_error,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to enable %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svcv.svc_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_ufree(&svcv.svc_error);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* SV enable the bitmap disable the vol on error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svcb.svc_flag = (NSC_DEVICE | NSC_CACHE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svcb.svc_error = spcs_s_ucreate();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ioctl(fd, SVIOC_ENABLE, &svcb) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno != SV_EENABLED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sv", &svcb.svc_error,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to enable %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svcb.svc_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ioctl(fd, SVIOC_DISABLE, &svcv) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sv", &svcv.svc_error,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to disable %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svcv.svc_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_ufree(&svcv.svc_error);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_ufree(&svcb.svc_error);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sv", NULL, gettext("enabled %s"), svcv.svc_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sv", NULL, gettext("enabled %s"), svcb.svc_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_ufree(&svcv.svc_error);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_ufree(&svcb.svc_error);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fd >= 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedo_autosv_enable(CFGFILE *cfg, rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char vol[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char bmp[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_load_svols(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_load_dsvols(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_load_shadows(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte load_rdc_vols(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (self_check(rdc->phost)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(vol, rdc->pfile, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(bmp, rdc->pbmp, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(vol, rdc->sfile, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(bmp, rdc->sbmp, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nsc_lookup(volhash, vol) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_vol_enable(cfg, vol, rdc->ctag, "sndr") < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "auto sv enable failed for %s", vol);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nsc_lookup(volhash, bmp) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_vol_enable(cfg, bmp, rdc->ctag, "sndr") < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "auto sv enable failed for %s", vol);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_remove_all(volhash, free);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volhash = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_unload_shadows();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_unload_dsvols();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_unload_svols();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedo_autosv_disable(CFGFILE *cfg, rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char vol[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char bmp[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volcount_t *vc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_load_svols(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_load_dsvols(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_load_shadows(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte load_rdc_vols(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (self_check(rdc->phost)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(vol, rdc->pfile, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(bmp, rdc->pbmp, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(vol, rdc->sfile, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(bmp, rdc->sbmp, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vc = nsc_lookup(volhash, vol);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vc && (vc->count == 1)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_vol_disable(cfg, vol, rdc->ctag, "sndr") < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "auto sv disable failed for %s", vol);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (!vc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unable to find %s in config", vol);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vc = nsc_lookup(volhash, bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vc && (vc->count == 1)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_vol_disable(cfg, bmp, rdc->ctag, "sndr") < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "auto sv disable failed for %s", bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (!vc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unable to find %s in config", bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * do sv enables for the appropriate vol
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and bitmap. If called without persistance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * it will follow a chain and sv enable all
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * otherwise, it will enable only the one
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_enable(CFGFILE *cfg, rdcconfig_t *rdcs)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp->persist) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (sv_enable_nocfg(rdcp));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (cfg == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do_autosv_enable(cfg, rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_disable(CFGFILE *cfg, rdcconfig_t *rdcs)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp->persist) { /* don't disable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (cfg == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte do_autosv_disable(cfg, rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * disable the appropriate bitmap in rdc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and replace it with bitmap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_reconfig(CFGFILE *cfg, rdcconfig_t *rdc, char *oldbmp, char *newbmp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int fail = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp->persist) { /* just enable, don't disable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_enable_one_nocfg(newbmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (rdcp->persist) { /* do sv disable and enable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volcount_t *vc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_load_svols(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_load_dsvols(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_load_shadows(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte load_rdc_vols(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vc = (volcount_t *)nsc_lookup(volhash, oldbmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vc && (vc->count == 1)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_vol_disable(cfg, oldbmp, rdc->ctag, "sndr") < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "auto sv disable failed for %s", oldbmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nsc_lookup(volhash, newbmp) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_vol_enable(cfg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte newbmp, rdc->ctag, "sndr") < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "auto sv enable failed for %s", newbmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fail++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_remove_all(volhash, free);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volhash = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_unload_shadows();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_unload_dsvols();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_unload_svols();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fail)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * SNDR functions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add_to_rdc_cfg
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this adds the successfully created rdc sets to libdscfg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * also, as auto_sv stuff is part of libdscfg, it does the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * auto_sv stuff and enables the correct volumes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteadd_to_rdc_cfg(rdcconfig_t *rdcs)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFGFILE *cfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buf = calloc(CFG_MAX_BUF, sizeof (char));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!buf) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_OS, RDC_FATAL, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg = cfg_open(NULL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg_lock(cfg, CFG_WRLOCK)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buf = config2buf(buf, rdcp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((sv_enable(cfg, rdcp) < 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cfg_put_cstring(cfg, "sndr", buf, CFG_MAX_BUF) < 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_commit(cfg)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecfg_lookup(CFGFILE *cfg, char *shost, char *sfile)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buf[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int setnum;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int numsets = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte numsets = cfg_get_num_entries(cfg, "sndr");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (setnum = 1; setnum <= numsets; setnum++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(key, CFG_MAX_KEY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(key, CFG_MAX_KEY, "sndr.set%d.shost", setnum);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(buf, shost, strlen(shost)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(key, CFG_MAX_KEY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(key, CFG_MAX_KEY, "sndr.set%d.secondary", setnum);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(buf, sfile, strlen(sfile)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (setnum);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteremove_from_rdc_cfg(rdcconfig_t *rdcs)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFGFILE *cfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg = cfg_open(NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_lock(cfg, CFG_WRLOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(key, CFG_MAX_KEY, "sndr.set%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_lookup(cfg, rdcp->shost, rdcp->sfile));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((sv_disable(cfg, rdcp) < 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cfg_put_cstring(cfg, key, NULL, 0)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_commit(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortereplace_entry(int offset, char *entry)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this will set the value at "field" in dscfg to the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * value contained in entry.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for things like bitmap reconfigs, only pass one rdc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * not a chain
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortereplace_cfgfield(rdcconfig_t *rdc, char *field, char *entry)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFGFILE *cfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char newentry[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char oldbmp[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int setnum;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ispbmp = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int issbmp = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(field, "pbitmap", NSC_MAXPATH) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ispbmp++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(field, "sbitmap", NSC_MAXPATH) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte issbmp++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(newentry, sizeof (newentry));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!entry || strlen(entry) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *newentry = '-';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(newentry, entry, CFG_MAX_BUF);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg = cfg_open(NULL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg_lock(cfg, CFG_WRLOCK)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((setnum = cfg_lookup(cfg, rdcp->shost, rdcp->sfile)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(key, CFG_MAX_KEY, "sndr.set%d.%s", setnum, field);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!((ispbmp || issbmp) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cfg_get_cstring(cfg, key, oldbmp, CFG_MAX_BUF)) == 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, "unable to get %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte key);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((ispbmp && self_check(rdcp->phost)) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (issbmp && self_check(rdcp->shost))) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sv_reconfig(cfg, rdcp, oldbmp, newentry) < 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "unable to sv reconfig %s to %s", oldbmp, newentry);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg_put_cstring(cfg, key, newentry, CFG_MAX_BUF)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_commit(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reverse_in_cfg
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * used by RDC_OPT_REVERSE_ROLE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * swaps primary info and secondary info
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortereverse_in_cfg(rdcconfig_t *rdc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFGFILE *cfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcconfig_t *rdcp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int setnum;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg = cfg_open(NULL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg_lock(cfg, CFG_WRLOCK)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((setnum = cfg_lookup(cfg, rdcp->shost, rdcp->sfile)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto badconfig;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(key, CFG_MAX_KEY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(key, CFG_MAX_KEY, "sndr.set%d.phost", setnum);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg_put_cstring(cfg, key, rdcp->shost, CFG_MAX_BUF)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto badconfig;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(key, CFG_MAX_KEY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(key, CFG_MAX_KEY, "sndr.set%d.primary", setnum);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg_put_cstring(cfg, key, rdcp->sfile, CFG_MAX_BUF)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto badconfig;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(key, CFG_MAX_KEY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(key, CFG_MAX_KEY, "sndr.set%d.pbitmap", setnum);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg_put_cstring(cfg, key, rdcp->sbmp, CFG_MAX_BUF)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto badconfig;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(key, CFG_MAX_KEY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(key, CFG_MAX_KEY, "sndr.set%d.shost", setnum);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg_put_cstring(cfg, key, rdcp->phost, CFG_MAX_BUF)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto badconfig;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(key, CFG_MAX_KEY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(key, CFG_MAX_KEY, "sndr.set%d.secondary", setnum);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg_put_cstring(cfg, key, rdcp->pfile, CFG_MAX_BUF)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto badconfig;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(key, CFG_MAX_KEY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(key, CFG_MAX_KEY, "sndr.set%d.sbitmap", setnum);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg_put_cstring(cfg, key, rdcp->pbmp, CFG_MAX_BUF)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_DSCFG, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto badconfig;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdcp = rdcp->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_commit(cfg)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortebadconfig:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}