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 * libdscfg type stuff here
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int sv_enable(CFGFILE *cfg, rdcconfig_t *rdc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int remove_from_rdc_cfg(rdcconfig_t *rdcs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int replace_cfgfield(rdcconfig_t *rdcs, char *field, char *value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc->next = NULL; /* don't want to hook into wrong chaing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * takes in a chain of rdcconfig_t's and a chain
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of rdc_rc_t's, checks for success in the rdc_rc_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * then adds the corresponding rdcconfig_t to the return
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechain_successful(rdcconfig_t *rdcs, rdc_rc_t *rcs)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(urdc.primary.intf, rdc->phost, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(urdc.primary.file, rdc->pfile, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(urdc.primary.bitmap, rdc->pbmp, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(urdc.secondary.intf, rdc->shost, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(urdc.secondary.file, rdc->sfile, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(urdc.secondary.bitmap, rdc->sbmp, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(urdc.group_name, rdc->group, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* this needs changin if we do campus */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set up return stuff.. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc.set.phost, set->primary.intf, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc.set.pfile, set->primary.file, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc.set.shost, set->secondary.intf, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc.set.sfile, set->secondary.file, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc.rc = RDC_IOCTL(RDC_CONFIG, rdccfg, NULL, 0, 0, 0, ustatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* this needs changin if we do campus */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc[0]->set.phost, set->primary.intf, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc[0]->set.pfile, set->primary.file, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc[0]->set.pbmp, set->primary.bitmap, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc[0]->set.shost, set->secondary.intf, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc[0]->set.sfile, set->secondary.file, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc[0]->set.sbmp, set->secondary.bitmap, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc[0]->rc = RDC_IOCTL(RDC_CONFIG, rdccfg, NULL, 0, 0, 0, ustatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rc[0]->msg, rdc_error(NULL), RDC_ERR_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sleep(1); /* give thr_join a chance to be called */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(fromname, urdc->primary.intf, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(toname, urdc->secondary.intf, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fromname[0] == '\0') || (fromname[0] == '\0')) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "NULL hostname recieved");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(fromname, hp->h_name, MAX_RDC_HOST_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (self_check(fromname) && self_check(toname)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdc_set_error(NULL, RDC_INTERNAL, RDC_FATAL, "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp = get_addr(toname, RDC_PROGRAM, RDC_VERS_MIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp = get_addr(fromname, RDC_PROGRAM, RDC_VERS_MIN,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else while (rdcp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_alloc_config(const char *phost, const char *pfile,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *pbmp, const char *shost, const char *sfile, const char *sbmp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *mode, const char *group, const char *ctag, const char *options,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rcp->msg, rdc_error(NULL), RDC_ERR_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rcp->set.phost, rdcp->phost, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rcp->set.pfile, rdcp->pfile, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rcp->set.shost, rdcp->shost, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rcp->set.sfile, rdcp->sfile, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * rdc_enable
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * return values
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NULL on error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pointer to rdc_rc_t list of return values
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(rdcp->mode, "sync", NSC_MAXPATH) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(rdc->mode, "async", NSC_MAXPATH) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* do the operation */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* set up what rdc_config would've set up */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if we are not persisting, do this now,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * otherwise we will do it when
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we have a lock on the cfg in add_to_rdc_cfg
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* dont free here, return what you have */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * travel the rc chain and rdc chain checking results,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * building a new chain, and updating dscfg
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* XXX should disable or something here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(rdcp->mode, "sync", NSC_MAXPATH) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (strncmp(rdc->mode, "async", NSC_MAXPATH) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* do the operation */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* set up what rdc_config would've set up */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rcp->next = (rdc_rc_t *)calloc(1, sizeof (rdc_rc_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * travel the rc chain and rdc chain checking results,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * building a new chain, and updating dscfg
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* XXX should disable or something here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* freed in rdc_mtconfig */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg = (rdc_config_t *)calloc(1, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->options = RDC_OPT_UPDATE|RDC_OPT_FORWARD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * collect status here from thr_join-status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and add to rdc_rc_t chain ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this will block, but caller could always thread too
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (thr_join(NULL, NULL, (void**) &tmprc) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* freed in rdc_mtconfig */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg = (rdc_config_t *)calloc(1, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * collect status here from thr_join-status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and add to rdc_rc_t chain ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this will block, but caller could always thread too
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (thr_join(NULL, NULL, (void**) &tmprc) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* freed in rdc_mtconfig */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg = (rdc_config_t *)calloc(1, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * collect status here from thr_join-status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and add to rdc_rc_t chain ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this will block, but caller could always thread too
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (thr_join(NULL, NULL, (void**) &tmprc) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* freed in rdc_mtconfig */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg = (rdc_config_t *)calloc(1, sizeof (rdc_config_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rdccfg->options = RDC_OPT_REVERSE | RDC_OPT_UPDATE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * collect status here from thr_join-status,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and add to rdc_rc_t chain ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * this will block, but caller could always thread too
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (thr_join(NULL, NULL, (void**) &tmprc) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterdc_set_maxqitems(rdcconfig_t *rdc, int maxqitems)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * reconfig bitmaps are single set only ops
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for obvious reasons
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rdccfg.rdc_set[0].primary.bitmap, pbmp, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (replace_cfgfield(rdc, "pbitmap", pbmp) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strncpy(rdccfg.rdc_set[0].secondary.bitmap, sbmp, NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* just in case */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reconfig group rules enforced in kernel */