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
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Utility functions for iiadm and rdcadm/sndradm.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic hash_data_t *make_svol_data(char *, char *, char *, int);
c946faca5d4627284fb79c6b04e652b471034495allanstatic hash_data_t *make_dsvol_data(char *, char *, char *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void delete_svol_data(void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void delete_dsvol_data(void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int sv_action(char *, CFGFILE *, char *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int add_dev_entry(const char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int compare(const void *, const void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *find_devid(const char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cfg_add_user
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Adds the calling tool as a user of the volume.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * char *path: The pathname of the volume to be enabled.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * char *cnode: The device group name, or NULL if -C local or not cluster
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CFGFILE *cfg: A pointer to the current config file, or NULL if this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * function is to open/write/commit/close the change itself.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return values:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CFG_USER_FIRST: Indicates that this is the first user of this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * particular volume.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CFG_USER_OK: Indicates that the volume has already been entered into
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the config file.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CFG_USER_ERR: Indicates that some failure has occurred and no changes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the config file have been made.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CFG_USER_REPEAT: Indicates that this user has already registered for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the volume.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecfg_add_user(CFGFILE* cfg, char *path, char *cnode, char *user)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *ctag, search_key[ CFG_MAX_KEY ], buf[ CFG_MAX_BUF ];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check cnode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* find the volume */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(search_key, CFG_MAX_KEY, "%s:%s", path, cnode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* whoops, not found. Add as new user */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(buf, CFG_MAX_BUF, "%s %s %s", path, cnode,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = cfg_put_cstring(cfg, "dsvol", buf, strlen(buf));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reload hash, if we need to */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check to ensure we're not already listed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte free(p); /* not using data; only testing 'q' ptr */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* not listed as a user */
d8c54e3d070f57cc1b4d6c8262f0868219c8ce7cSam Cramer (void) snprintf(search_key, CFG_MAX_KEY, "dsvol.set%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Since we deleted an entry from the config
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file, we don't know what all the new
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set numbers are. We need to reload
if (!self_loaded) {
if (self_open) {
return (CFG_USER_ERR);
if (self_loaded) {
if (self_open) {
if (change_made)
return (retval);
self_loaded = 0;
change_made = 0;
++user;
if (cnode) {
if (ctag) {
return (CFG_USER_ERR);
if (self_open) {
return (CFG_USER_ERR);
return (CFG_USER_ERR);
change_made = 0;
if (!dsvol_loaded) {
if (self_open) {
return (CFG_USER_ERR);
if (!data) {
} else if (force_remove) {
if (self_loaded) {
if (self_open) {
return (CFG_USER_ERR);
if (!self_loaded) {
if (self_open) {
return (CFG_USER_ERR);
if (appended) {
if (appended) {
if (appended) {
if (self_loaded) {
if (self_open) {
return (CFG_USER_ERR);
if (!self_loaded) {
if (self_open) {
return (CFG_USER_ERR);
if (self_loaded) {
if (self_open) {
return (CFG_USER_ERR);
if (!self_loaded) {
if (self_open) {
return (CFG_USER_ERR);
if (self_loaded) {
if (self_open) {
if (change_made)
return (retval);
switch (rc) {
case CFG_USER_ERR:
path);
case CFG_USER_OK:
retval = 0;
case CFG_USER_FIRST:
if (retval < 0) {
return (retval);
switch (rc) {
case CFG_USER_ERR:
path);
case CFG_USER_OK:
retval = 0;
case CFG_USER_GONE:
case CFG_USER_LAST:
return (retval);
if (!dsvol) {
rc = 0;
++offset;
if (!data) {
if (rc < 0) {
if (rc < 0) {
} else if (rc)
++devs_added;
rc = 0;
if (entries)
if (devs_added) {
if (dsvol) {
dsvol = 0;
dsvol_loaded = 0;
if (!svol) {
++offset;
if (!data) {
if (entries)
if (svol) {
svol = 0;
svol_loaded = 0;
if (devlist) {
self_loaded = 0;
retval = 0;
if (self_loaded) {
return (retval);
if (dsvol_loaded) {
self_loaded = 0;
if (!shadowvol) {
rc = 0;
if (rc < 0) {
} else if (rc)
++devs_added;
if (rc < 0) {
} else if (rc)
++devs_added;
rc = 0;
if (entries)
if (self_loaded) {
if (devs_added) {
return (rc);
static hash_data_t *
if (!data) {
return (data);
free(p);
static hash_data_t *
if (!data) {
return (data);
free(p);
if (ctag)
self_loaded = 0;
if (devhash)
if (statinfo) {
goto error;
goto error;
goto error;
if (fd < 0)
goto error;
if (rc < 0) {
if (enable)
goto error;
goto error;
if (enable) {
print_log++;
if (!svol_loaded) {
if (node) {
if (!self_loaded) {
if (self_loaded) {
self_loaded = 0;
#ifdef lint
if (fd >= 0)
if (cfg_changed)
if (print_log)
if (!devhash) {
if (!devhash) {
if (data) {
sizeof (device_t));
if (!newmem) {
++devcount;
if (!devhash)
if (!devhash)
for (i = 0; i < devcount; i++) {
return (NULL);
if (result) {
return (NULL);
return (NULL);
if (result) {
return (NULL);
device_t *p;
if (!devlist) {
devcount = 0;
devalloc = 0;
if (devhash) {