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 Fortechar *locname; /* config location from cfg_location */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar output_file[MAX_FILENAME]; /* specified output file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar altroot[MAX_FILENAME]; /* specifed root location */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar config_file[MAX_FILENAME]; /* specified configuration file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar input_file[MAX_FILENAME]; /* specified input file */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar logical_host[MAX_FILENAME]; /* specified cluster node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar device_group[MAX_FILENAME]; /* specified device group name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid cfg_invalidate_hsizes(int, const char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: %s\n", cmdname, errmsg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "local configuration database\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("dscfg -l -s path\t\t"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "List contents of configuration database\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\t\t\t\tlocated at path specified\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Initialize configuration database\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "/etc/dscfg_format\tFormat configuration database\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("dscfg -a file\t\t\tRestore configuration "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "database from file\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("\t\t\t\tspecified\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("dscfg -l\t\t\tList contents of configuration database"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("dscfg -L\t\t\tDisplay configuration database's\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("\t\t\t\tlock status\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("dscfg -h\t\t\tUsage message\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("\nSun Cluster Usage\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("******************\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "configuration database at DID\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("\t\t\t\tpath specified\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("dscfg -D device_group\t\t"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Check status of cluster device group\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("dscfg -C -\t\t\t"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Display location of cluster configuration\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("\t\t\t\tdatabase\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("dscfg -l -s DID_device\t\tList "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "the contents of cluster configuration\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("\t\t\t\tdatabase\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("dscfg -C - -i\t\t\tInitialize "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "cluster configuration database\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("dscfg -C - -i -p "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "/etc/dscfg_format Format cluster configuration database\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("dscfg -C - -a file\t\t"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Restore cluster configuration database from\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("\t\t\t\tfile specified\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("dscfg -C - -l\t\t\t"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "List contents of local configuration database\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("dscfg -C device_group -l\t"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "List configuration database by device group\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("dscfg -C \"-\" -l\t\t\t"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "List configuration database excluding\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("\t\t\t\tdevice groups\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Open parser config file, use default if none specified
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buff = (input_file[0]) ? input_file : DEFAULT_PARSER_LOC;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("parser config file (%s) not found\n"), buff);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * start at begining of configration database
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (((buff = fgets(inbuf, (sizeof (inbuf) - 1), fp)) != NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* overwrite newline */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = cfg_update_parser_config(cfg, buff, CFG_PARSE_CONF);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (((buff = fgets(inbuf, (sizeof (inbuf) - 1), fp)) != NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* overwrite newline */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*p && isspace(*p)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("update text config failed rc %d key %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * WARNING will robinson
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The following is using a non-exported internal interface
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use any of the following fields in MS software
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("Configuration location: %s\n"), locname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Header info:\n\t\t\tmagic: %x\tstate: %x\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Start: %x\tsize: %d offset: %d\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Start: %x\tsize:%d\tacsize: %d\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * dump current configuration section to stdout
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "parser configuration (%s): %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("# Consolidated Dataservice Configuration\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("# Do not edit out whitespace or dashes\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("# File created on: %s"), ctime(&tloc));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (fgets(pbuf, (sizeof (pbuf) - 1), fp) != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* comment */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* force a NULL terminator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * descriptive text
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * - print it (with comment leader) and move on
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * truncate the parser config in pbuf[] to just the tag
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*CONSTCOND*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* trim trailing space if necessary */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*CONSTCOND*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = open(fileloc, O_RDWR | O_CREAT, 0640)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* if this is a device, we may have to skip the vtoc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((skip = cfg_shldskip_vtoc(fd, fileloc)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (skip) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("dscfg: seek error"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * configure or return dataservice persistent configuration
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -i initialize file for first time
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -l dump current configuration to stdout in ascii
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -C node Set resource filter
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -p parser config specified input file
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -s set partition location or filename in default location
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -L print configuration lock status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -u upgrade
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -r prepend bootdir to beginning of path for cfg_open
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * no options status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte extern char *optarg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((c = getopt(argc, argv, "a:C:dD:ilLp:r:s:hvn")) != EOF) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((c = getopt(argc, argv, "a:C:dD:ilLp:r:s:h")) != EOF) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (c) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*NOTREACHED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "-p option must be used in conjunction with -i"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (argc == 1 || (argc == 2 && verbose) || (argc == 3 && (rflg|Cflg)))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Determine if the value specified is a device group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that is active on this node
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg_issuncluster() > 0) && (strlen(device_group) > 0)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte local = cfg_dgname_islocal(device_group, &other_node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Device group %s active on %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Device group %s active on this node\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "dscfg -D is only allowed in "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Sun Cluster OE\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Only allow setting location on a non-sun cluster system
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if the cluster reference file is already present.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (stat(CFG_CLUSTER_LOCATION, &dscfg_stat) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "dscfg -s is only allowed in "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Sun Cluster OE\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("dscfg", NULL, gettext("dscfg -s %s"), config_file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte locname = cfg_location(config_file, CFG_LOC_SET_CLUSTER,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* s used with l for temporarily peeking at a dscfg database */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "dscfg: cluster config not set: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the following hack forces the configuration file to initialize
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Availability Suite configuration\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (c) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'Y': break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "dscfg: configuration not initialized\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "dscfg: %d is not a valid response\n"), c);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* this is not a good config, or non-existent so.. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set cluster node if specified
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " to create new config \n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "configuration database: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte usage(gettext("-p option must be used in conjunction with -i"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s/usr/sbin/dscfg -r %s -l >"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " /var/tmp/.dscfg.bak");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "dscfg: unable to create backup\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("dscfg: %s\n"), cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set cluster node if specified
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, mustcommit? CFG_WRLOCK : CFG_RDLOCK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("cfg_lock: lock failed\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * initialize configuration
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("dscfg", NULL, gettext("dscfg -i -p %s"), input_file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "parser configuration file\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("dscfg: cannot load "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "parser configuration file\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * read asci config file and write
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("dscfg", NULL, gettext("dscfg -a %s"), input_file);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (rc == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("dscfg: unable to determin environment\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*NOTREACHED*/