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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
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 * SV type functions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* next one had better be ours */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* primary vol may be used more than once */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volcount = (volcount_t *)nsc_lookup(volhash, vol);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volcount = (volcount_t *)malloc(sizeof (volcount_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* bitmap ought to be only used once */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volcount = (volcount_t *)nsc_lookup(volhash, bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte volcount = (volcount_t *)malloc(sizeof (volcount_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_OS, 0, "unable to stat %s", vol);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL, "%s is not"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(svc.svc_path, vol, sizeof (svc.svc_path));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sv", NULL, gettext("enabled %s"), svc.svc_path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((stat(vol, &stbv) != 0) || (stat(bmp, &stbb) != 0))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((!S_ISCHR(stbv.st_mode)) || (!S_ISCHR(stbb.st_mode)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(svcv.svc_path, vol, sizeof (svcv.svc_path));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(svcb.svc_path, bmp, sizeof (svcb.svc_path));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* SV enable the volume */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* SV enable the bitmap disable the vol on error */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
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 if (cfg_vol_enable(cfg, vol, rdc->ctag, "sndr") < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_vol_enable(cfg, bmp, rdc->ctag, "sndr") < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_vol_disable(cfg, vol, rdc->ctag, "sndr") < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (!vc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_vol_disable(cfg, bmp, rdc->ctag, "sndr") < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (!vc) {
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 return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * disable the appropriate bitmap in rdc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and replace it with bitmap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_reconfig(CFGFILE *cfg, rdcconfig_t *rdc, char *oldbmp, char *newbmp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!rdcp->persist) { /* just enable, don't disable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (rdcp->persist) { /* do sv disable and enable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_vol_disable(cfg, oldbmp, rdc->ctag, "sndr") < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * SNDR functions
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 return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cfg_put_cstring(cfg, "sndr", buf, CFG_MAX_BUF) < 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecfg_lookup(CFGFILE *cfg, char *shost, char *sfile)
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 return (-1);
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 return (-1);
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 Fortereplace_cfgfield(rdcconfig_t *rdc, char *field, char *entry)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((setnum = cfg_lookup(cfg, rdcp->shost, rdcp->sfile)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte snprintf(key, CFG_MAX_KEY, "sndr.set%d.%s", setnum, field);
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 (sv_reconfig(cfg, rdcp, oldbmp, newentry) < 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "unable to sv reconfig %s to %s", oldbmp, newentry);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg_put_cstring(cfg, key, newentry, CFG_MAX_BUF)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reverse_in_cfg
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * used by RDC_OPT_REVERSE_ROLE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * swaps primary info and secondary info
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((setnum = cfg_lookup(cfg, rdcp->shost, rdcp->sfile)) < 0) {
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 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 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 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 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 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 return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);