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#include "../sv/svadm.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * support for the special cluster tag "local" to be used with -C in a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cluster for local volumes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * libcfg access.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int cfg_changed; /* set to 1 if we need to commit changes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *cfg_cluster_tag; /* local cluster tag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *implicit_tag; /* implicit cluster tag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print width for print_sv() output.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Pathnames.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Functions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int read_config_file(const caddr_t, sv_name_t []);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void remove_from_cfgfile(char *path, int setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error(NULL, gettext("unable to access the configuration"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* NOTREACHED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error(NULL, gettext("unable to lock the configuration"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* NOTREACHED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\t%s [-C tag] display status\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\t%s [-C tag] -i display "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\t%s [-C tag] -v display "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\t%s [-C tag] -e { -f file | volume } enable\n"), program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\t%s [-C tag] -d { -f file | volume } disable\n"), program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\t%s [-C tag] -r { -f file | volume } reconfigure\n"), program);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemessage(caddr_t prefix, spcs_s_info_t *status, caddr_t string, va_list ap)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s: ", program, prefix);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error(&svl.svl_error, gettext("unable to get max devs"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error(NULL, "unable to allocate %ld bytes of memory",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * check where this disk service is mastered
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "disk service, %s: %s"), dgname, strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "active on node \"%s\"\nPlease re-issue "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Carry out cluster based checks for a specified volume, or just
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * global options.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static int sv_iscluster = -1; /* set to 1 if running in a cluster */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Find out if we are running in a cluster
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error(NULL, gettext("unable to ascertain environment"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error(NULL, gettext("-C is not valid when not in a cluster"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!sv_iscluster || sv_islocal || path == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Cluster-only checks on pathname
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_dgname(path, dgname, sizeof (dgname)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Do dgislocal check now in case path did not contain
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * E.g. adding a /dev/did/ device to a disk service.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return; /* NULL dgname is valid */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Implicitly set the cluster tag to dgname
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "for cluster tag"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check dgname and cluster tag from -C are the same.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sv_check_dgislocal(cfg_cluster_tag) was called above.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* NOTREACHED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("Storage Volume version %d.%d.%d.%d\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("Storage Volume version %d.%d.%d\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svv.svv_major_rev, svv.svv_minor_rev, svv.svv_micro_rev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("Storage Volume version %d.%d\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte extern char *optarg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((opt = getopt(argc, argv, "C:def:hirv")) != EOF) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* NOTREACHED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Compare running system with sv.cf */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* NOTREACHED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Usage checks
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte warn(NULL, gettext("-d, -e and -r are mutually exclusive"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte warn(NULL, gettext("-f is only valid with -d, -e or -r"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check for no more args */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* check for inline args */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for the special cluster tag and convert into the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * internal representation.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Process commands
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* deal with inline volume argument */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else /* if (compare) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else /* if (version) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* LINT - not static as fwcadm uses it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for more data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This was set when reading sv.conf. After the last
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * line svn_path was set to \0, so we are finished.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We shouldn't get here, but put this in just in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* LINT - not static as fwcadm uses it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(svn.svn_path, path, sizeof (svn.svn_path));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* force NULL termination */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte warn(NULL, gettext("%s is not a character device - ignored"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy(svc.svc_path, svn->svn_path, sizeof (svc.svc_path));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* first, check for duplicates */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = cfg_get_canonical_name(cfg, svn->svn_path, &altname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sv", NULL, gettext("Unable to parse config file"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte warn(NULL, gettext("Unable to parse config file"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error(NULL, gettext("'%s' has already been configured as "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "'%s'. Re-enter command with the latter name."),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* secondly, try to insert it into the dsvol config */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (cfg_cluster_tag && *cfg_cluster_tag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = cfg_add_user(cfg, svn->svn_path, lcltag, "sv");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte warn(NULL, gettext("unable to put %s into dsvol cfg"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* success */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((CFG_USER_REPEAT == rc) && (SV_EENABLED == errno)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* it's ok -- we were just double-checking */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte warn(&svc.svc_error, gettext("unable to enable %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove it from dsvol, if we're the ones who put it in */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cfg_rem_user(cfg, svn->svn_path, lcltag, "sv");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("enable_dev: -C %s AND implicit_tag %s!"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_put_cstring(cfg, "sv", buf, sizeof (buf)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to add %s to configuration storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This routine parses the config file passed in via conf_file and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stores the data in the svn array. The return value is the number
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of entries read from conf_file. If an error occurs the error()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * routine is called (which exits the program).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteread_config_file(const caddr_t conf_file, sv_name_t svn[])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int index = 0; /* Current location in svn array */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error(NULL, gettext("cannot read config file %s"), conf_file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error(NULL, gettext("unable to open config file %s: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "line %d: line too long -- should be less than %d characters"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * check for comment line.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur_svn = &svn[index]; /* For easier reading below */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strlen(rdev) >= sizeof (cur_svn->svn_path)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "line %d: raw device name (%s) longer than %d characters"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set the last path to NULL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Disable the device from the kernel configuration.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero on failure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Failures are reported to the user.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue the ioctl to attempt to disable this device. Note that all
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the libdscfg details are handled elsewhere.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sv", NULL, gettext("%s: disabled %s"), program, path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sv.set%d.cnode", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) cfg_get_cstring(cfg, key, buf, sizeof (buf));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" [%s]", gettext("local to node"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" [%s: %s]", gettext("cluster"), buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* LINT - not static as fwcadm uses it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_name_t *svn, *svn_system; /* Devices in system */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Grab the system list from the driver */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error(&svl_system.svl_error, gettext("unable to get list"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We build a hashmap out of the entries from the config file to make
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * searching faster. We end up taking a performance hit when the # of
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * volumes is small, but for larger configurations it's a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * HUGE improvement.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* build the hashtable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * For each volume found from the kernel, print out
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * info about it from the kernel.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get sv entry from the hashtable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((setnumber = find_in_hash(svn->svn_path)) != -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We didn't find the entry in the hashtable. Let
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the user know that the persistent storage is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * inconsistent with the kernel configuration.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s is configured, but not in the "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* free up the hashtable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* LINT - not static as fwcadm uses it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_name_t *svn, *svn_system; /* Devices in system */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Grab the system list from the driver */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svl_system.svl_count = read_config_file(conf_file, svn_system);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((setnumber = find_in_hash(svn->svn_path)) != -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* warn the user that we didn't find it in cfg file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s was not found in the config storage"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* try to disable anyway */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* LINT - not static as fwcadm uses it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove from kernel */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove the cfgline */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* warn the user that we didn't find it in cfg file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s was not found in the config storage"), path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* still attempt to remove */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buf[CFG_MAX_BUF], vol[CFG_MAX_BUF], cnode[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_cluster_tag != NULL && implicit_tag != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error(NULL, gettext("compare_tag: -C %s AND implicit_tag %s!"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < sv_max_devices; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sv.set%d", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, sizeof (buf)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte warn(NULL, gettext("unable to find %s in the configuration"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* have name match, compare cnode to new tag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cluster tags match */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* need to change the cluster tag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sv.set%d.cnode", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_put_cstring(cfg, key, tag, strlen(tag)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("unable to change cluster tag for %s"), path);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* change "-" tags to "" for display purposes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: changed cluster tag for %s from \"%s\" to \"%s\"\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: changed cluster tag for %s from \"%s\" to \"%s\""),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* LINT - not static as fwcadm uses it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_name_t *svn_config; /* Devices in config file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_name_t *enable; /* Devices that need enabled */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Read the configuration file
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The return value is the number of entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte config_cnt = read_config_file(conf_file, svn_config);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Grab the system list from the driver */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error(&svl_system.svl_error, gettext("unable to get list"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Count the number of devices in the system.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The last entry in the array has '\0' for a path name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0; j < sv_max_devices; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare the configuration array with the system array.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Mark any differences and disable conflicting devices.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < config_cnt; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0; j < sys_cnt; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check to see if path matches */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Found a match */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Minor number not in system = > enable device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Disable any devices that weren't in the config file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0; j < sys_cnt; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the volume was found in cfg store */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Config file doesn't match system => enable the devices
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in enable[]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: enabling new sv: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Search for entries where the cluster tag has changed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < sv_max_devices; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We assume that the volume is already enabled and we can only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be changing the cluster tag. Anything else is an error.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* LINT - not static as fwcadm uses it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Read all sets from the libdscfg configuration file, and store everything in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the hashfile.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We assume that the config file has been opened & rewound for us. We store
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the volume name as the key, and the setnumber where we found it as the data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The caller can pass in a pointer to the maximum number of volumes, or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * a pointer to NULL, specifying we want 'all' the volumes. The table is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * searched using find_in_hash.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error(NULL, gettext("unable to create hash table"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (setnumber = 1; /* CSTYLED */; setnumber++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sv.set%d", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, sizeof (buf)) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Function to search the hash for a specific volume. If it is found,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we return the set number. If it isn't found, we return -1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((found_entry = hsearch(item, FIND)) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Just a wrapper to destory the hashtable. At some point in the future we
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * might want to do something more.... For instance, verify that the cfg
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * database and the kernel configuration match (?) Just an idea.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This function will remove a particular set from the config file.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We make a whole host of assumptions:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * o the hashfile is up to date;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * o The config file has been opened with a WRLOCK for us.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* attempt to remove the volume from config storage */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "sv.set%d", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (cfg_cluster_tag && *cfg_cluster_tag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_rem_user(cfg, path, lcltag, "sv") != CFG_USER_LAST) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte warn(NULL, gettext("unable to remove %s from dsvol"),