rdcpersist.c revision 2
6a55cc6751be1162fa737fa656ffae0729c2e2a0Krzysztof Kosiński * CDDL HEADER START
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog * The contents of this file are subject to the terms of the
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog * Common Development and Distribution License (the "License").
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog * You may not use this file except in compliance with the License.
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog * See the License for the specific language governing permissions
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog * and limitations under the License.
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog * When distributing Covered Code, include this CDDL HEADER in each
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog * If applicable, add the following below this CDDL HEADER, with the
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog * fields enclosed by brackets "[]" replaced with your own identifying
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog * information: Portions Copyright [yyyy] [name of copyright owner]
1df6105803c4c56c020a56301c7c9c4890fd4158mathog * CDDL HEADER END
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
1df6105803c4c56c020a56301c7c9c4890fd4158mathog * Use is subject to license terms.
1df6105803c4c56c020a56301c7c9c4890fd4158mathogtypedef struct volcount_s {
1df6105803c4c56c020a56301c7c9c4890fd4158mathog snprintf(buf, CFG_MAX_BUF, "%s %s %s %s %s %s %s %s %s %s %s",
1df6105803c4c56c020a56301c7c9c4890fd4158mathog rdc->phost, rdc->pfile, rdc->pbmp, rdc->shost, rdc->sfile,
1df6105803c4c56c020a56301c7c9c4890fd4158mathog rdc->sbmp, rdc->direct, rdc->mode, rdc->group ? rdc->group : "",
1df6105803c4c56c020a56301c7c9c4890fd4158mathog rdc->ctag ? rdc->ctag : "", rdc->options ? rdc->options : "");
1df6105803c4c56c020a56301c7c9c4890fd4158mathog * SV type functions.
1df6105803c4c56c020a56301c7c9c4890fd4158mathog /* next one had better be ours */
1df6105803c4c56c020a56301c7c9c4890fd4158mathog /* primary vol may be used more than once */
1df6105803c4c56c020a56301c7c9c4890fd4158mathog volcount = (volcount_t *)malloc(sizeof (volcount_t));
1df6105803c4c56c020a56301c7c9c4890fd4158mathog /* bitmap ought to be only used once */
1df6105803c4c56c020a56301c7c9c4890fd4158mathog volcount = (volcount_t *)malloc(sizeof (volcount_t));
1df6105803c4c56c020a56301c7c9c4890fd4158mathog rdc_set_error(NULL, RDC_OS, 0, "unable to stat %s", vol);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL, "%s is not"
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog if (fd < 0) {
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog spcs_log("sv", NULL, gettext("enabled %s"), svc.svc_path);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog if ((stat(vol, &stbv) != 0) || (stat(bmp, &stbb) != 0))
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog if ((!S_ISCHR(stbv.st_mode)) || (!S_ISCHR(stbb.st_mode)))
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog /* SV enable the volume */
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog /* SV enable the bitmap disable the vol on error */
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog spcs_log("sv", NULL, gettext("enabled %s"), svcv.svc_path);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog spcs_log("sv", NULL, gettext("enabled %s"), svcb.svc_path);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog if (cfg_vol_enable(cfg, vol, rdc->ctag, "sndr") < 0) {
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog if (cfg_vol_enable(cfg, bmp, rdc->ctag, "sndr") < 0) {
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog if (cfg_vol_disable(cfg, vol, rdc->ctag, "sndr") < 0)
1df6105803c4c56c020a56301c7c9c4890fd4158mathog } else if (!vc) {
1df6105803c4c56c020a56301c7c9c4890fd4158mathog if (cfg_vol_disable(cfg, bmp, rdc->ctag, "sndr") < 0)
1df6105803c4c56c020a56301c7c9c4890fd4158mathog } else if (!vc) {
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog * do sv enables for the appropriate vol
1df6105803c4c56c020a56301c7c9c4890fd4158mathog * and bitmap. If called without persistance
1df6105803c4c56c020a56301c7c9c4890fd4158mathog * it will follow a chain and sv enable all
1df6105803c4c56c020a56301c7c9c4890fd4158mathog * otherwise, it will enable only the one
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (1);
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog return (1);
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog return (-1);
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog return (1);
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog * disable the appropriate bitmap in rdc
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog * and replace it with bitmap
06517eb74772b7c18a8ab8d703405646d9ec05d3mathogsv_reconfig(CFGFILE *cfg, rdcconfig_t *rdc, char *oldbmp, char *newbmp)
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog if (!rdcp->persist) { /* just enable, don't disable */
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog } else if (rdcp->persist) { /* do sv disable and enable */
06517eb74772b7c18a8ab8d703405646d9ec05d3mathog if (cfg_vol_disable(cfg, oldbmp, rdc->ctag, "sndr") < 0)
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog * SNDR functions
1df6105803c4c56c020a56301c7c9c4890fd4158mathog * add_to_rdc_cfg
1df6105803c4c56c020a56301c7c9c4890fd4158mathog * this adds the successfully created rdc sets to libdscfg,
1df6105803c4c56c020a56301c7c9c4890fd4158mathog * also, as auto_sv stuff is part of libdscfg, it does the
1df6105803c4c56c020a56301c7c9c4890fd4158mathog * auto_sv stuff and enables the correct volumes
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog (cfg_put_cstring(cfg, "sndr", buf, CFG_MAX_BUF) < 0)) {
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (0);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog snprintf(key, CFG_MAX_KEY, "sndr.set%d.shost", setnum);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0) {
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog snprintf(key, CFG_MAX_KEY, "sndr.set%d.secondary", setnum);
1df6105803c4c56c020a56301c7c9c4890fd4158mathog if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0) {
1df6105803c4c56c020a56301c7c9c4890fd4158mathog return (-1);
int setnum;
int ispbmp = 0;
int issbmp = 0;
ispbmp++;
issbmp++;
while (rdcp) {
key);
int setnum;
while (rdcp) {
goto badconfig;
goto badconfig;
goto badconfig;
goto badconfig;
goto badconfig;
goto badconfig;
goto badconfig;