fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
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 *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Utility for cache configuration
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <strings.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <locale.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <langinfo.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <libintl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <time.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/sd_bcache.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/wait.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <signal.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <fcntl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stropts.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ctype.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <libgen.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/sdbc_ioctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_s.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_s_u.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_errors.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <nsctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/cfg.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define STATS_PATH "/usr/bin/sd_stats"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _SD_FNAME /* bring in function names from sd_trace.h */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/sd_trace.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/syslog.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Since we no longer support nvram cards, the hints wrthru and nowrthru no
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * longer serve any purpose, and the system will always be in wrthru mode.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * WRTHRU_HINTS, if defined still allows the setting and reporting of write
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hints. This is defined by default on DEBUG builds.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define WRTHRU_HINTS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int sdbc_max_devices = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char alert_file[200] = "/dev/console";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Variables used to set up paramater block passed to kernel */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic _sd_cache_param_t user_level_conf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int myid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int nodes_configured = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int minidsp = 0; /* Is it a sp10 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int forced_wrthru = -1; /* 0 clear, 1 set,-1 as is */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int no_forced_wrthru = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic short node_defined[MAX_SD_NODES];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic short nodes_conf[MAX_SD_NODES];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define USAGELEN 1024
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar stats_usage[USAGELEN+128];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar scmadmUsage[USAGELEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic caddr_t progname;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Functions exported for fwcadm.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid enable_sdbc(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid disable_sdbc(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid sdbc_set_maxdev();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void buildusage(char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid print_all_options(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid get_cd_all(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint toggle_flush(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void sd_gather_alert_dumps();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int get_cd(char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int get_hint(char *, int *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void check_and_set_mirrors(int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void print_hint(const uint_t, const int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *get_device_name(char *arg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void get_version();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern struct tm *localtime_r(const time_t *, struct tm *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define PRINT_CACHE_SZ_ERR(sz) {\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("\n%s: desired cache size (%d) "\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "set to system max (%d)\n"), \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, (sz), MAX_CACHE_SIZE); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("sdbc", NULL, \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("desired cache size (%d) "\
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "set to system max (%d)\n"), \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sz), MAX_CACHE_SIZE); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_report_error(spcs_s_info_t *ustatus)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*ustatus != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_report(*ustatus, stderr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_ufree(ustatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s\n", strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return the per-cd hints for a cd.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Since the global (no)wrthru and NSC_NOCACHE hints take precedence
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * over the per-cd hints, get them as well and OR the whole lot
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * together.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_cd_hint(const int cd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustats;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int nodehint, cdhint;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodehint = SDBC_IOCTL(SDBC_GET_NODE_HINT, 0, 0, 0, 0, 0, &ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nodehint == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: get system options failed\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cdhint = SDBC_IOCTL(SDBC_GET_CD_HINT, cd, 0, 0, 0, 0, &ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cdhint == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: get cd(%d) hint failed\n"), progname, cd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef WRTHRU_HINTS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodehint &= (NSC_FORCED_WRTHRU | NSC_NO_FORCED_WRTHRU | NSC_NOCACHE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodehint &= (NSC_NOCACHE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nodehint) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set the top bit to mark it as a system override */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodehint |= 0x80000000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (cdhint | nodehint);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for a config.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If no suitable config can be found, install the default config.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Calling state:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * libcfg locked (mode describes type of lock)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconvert_config(CFGFILE *cfg, CFGLOCK mode)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buf[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *default_cfg = "128 64";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteretry:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, "scm.set1", buf, sizeof (buf)) >= 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* config exists, return */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_rewind(cfg, CFG_SEC_CONF);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: installing default config entry '%s'\n"),
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki progname, default_cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mode != CFG_WRLOCK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_unlock(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_WRLOCK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to lock configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mode = CFG_WRLOCK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: upgraded lock, retrying\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto retry;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_put_cstring(cfg, "scm", default_cfg, strlen(default_cfg)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to write configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_commit(cfg)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to write to configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mode != CFG_WRLOCK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, mode)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to relock configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_rewind(cfg, CFG_SEC_CONF);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscluster(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = cfg_iscluster();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (FALSE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (rc > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (TRUE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) fprintf(stderr,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki gettext("%s: unable to ascertain environment\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* NOTREACHED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forterestore_hints()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFGFILE *cfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY], buf[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int setnumber;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg = cfg_open(NULL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to access configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_RDLOCK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to lock configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (setnumber = 1; /*CONSTCOND*/ TRUE; setnumber++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "cache_hint.set%d.device",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, sizeof (buf)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error or not found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(buf, "system") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cd = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cd = get_cd(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cd < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "cache_hint.set%d.wrthru",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, sizeof (buf)) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (atoi(buf) == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cd == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Node hint */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SDBC_IOCTL(SDBC_SET_NODE_HINT, NSC_WRTHRU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 1, 0, 0, 0, &ustatus) == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: set system "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "option failed\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (SDBC_IOCTL(SDBC_SET_CD_HINT, cd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NSC_WRTHRU, 1, 0, 0, &ustatus) == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: set option failed\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "cache_hint.set%d.nordcache",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, sizeof (buf)) < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (atoi(buf) == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cd == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Node hint */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SDBC_IOCTL(SDBC_SET_NODE_HINT, NSC_NOCACHE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 1, 0, 0, 0, &ustatus) == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: set system "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "option failed\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (SDBC_IOCTL(SDBC_SET_CD_HINT, cd, NSC_NOCACHE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 1, 0, 0, &ustatus) == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: set option failed\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesdbc_set_maxdev()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustats;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SDBC_IOCTL(SDBC_MAXFILES, &sdbc_max_devices,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, 0, 0, 0, &ustats) == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("%s: get maxfiles failed\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortebitmapfs_print(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFGFILE *cfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY], buf[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int setnumber;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg = cfg_open(NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to access configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_RDLOCK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to lock configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (setnumber = 1; /*CSTYLED*/; setnumber++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "bitmaps.set%d.bitmap", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buf[0] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, sizeof (buf)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno == ESRCH) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* end of list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error reading configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("%s\n", buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortebitmapfs_delete(char *bitmapfs)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFGFILE *cfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY], buf[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int setnumber;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int commit = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg = cfg_open(NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to access configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_WRLOCK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to lock configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (setnumber = 1; /*CSTYLED*/; setnumber++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "bitmaps.set%d.bitmap", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buf[0] = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, sizeof (buf)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno == ESRCH) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* end of list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: %s not found "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "in configuration\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, bitmapfs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error reading configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(bitmapfs, buf) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "bitmaps.set%d", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_put_cstring(cfg, key, (char *)NULL, 0) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to delete %s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "from configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, bitmapfs, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commit++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (commit) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_commit(cfg)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to write "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "to configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commit = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * User visible configuration.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *tag; /* libcfg tag */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *name; /* user presented name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *help; /* explanation string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} sdbc_cfg_options[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "thread", "nthreads", "number of threads" },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "size", "cache_size", "total cache size" },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "write_cache", "write_cache_size", "write cache size" },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "fill_pattern", "fill_pattern", "debug fill pattern" },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "reserved1", "reserved1", "unavailable, do not use" },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "iobuf", "niobuf", "number of io buffers" },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "tdemons", "ntdeamons", "number of sd_test daemons" },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "forced_wrthru", "forced_wrthru", "override wrthru detection" },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "no_forced_wrthru", "no_forced_wrthru", "override wrthru"},
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { NULL }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconfigure_sdbc(int argc, char *argv[], int optind)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFGFILE *cfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY], buf[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *cp, option[CFG_MAX_BUF], value[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const int opt_width = 20;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int error, found, commit;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error = commit = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg = cfg_open(NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s: unable to open configuration: %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (argc == optind) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* display current user visible config */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_RDLOCK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to lock configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto out;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte convert_config(cfg, CFG_RDLOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; sdbc_cfg_options[i].tag != NULL; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "scm.set1.%s", sdbc_cfg_options[i].tag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, sizeof (buf)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno == ESRCH) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* not found */
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(buf, "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error reading "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto out;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("%-*s: %-*s /* %s */\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte opt_width, sdbc_cfg_options[i].name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte opt_width, buf, sdbc_cfg_options[i].help);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_WRLOCK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to lock configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto out;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte convert_config(cfg, CFG_WRLOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (/*CSTYLED*/; optind < argc; optind++) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(option, argv[optind], sizeof (option));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte option[sizeof (option) - 1] = '\0'; /* terminate */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp = strchr(option, '=');
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *cp = '\0'; /* terminate option */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cp++;
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(value, cp, sizeof (value));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte value[sizeof (value) - 1] = '\0';
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*value == '\0')
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(value, "-",
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki sizeof (value));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; sdbc_cfg_options[i].tag != NULL; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(option,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_cfg_options[i].name) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unknown configuration "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "parameter: %s\n"), progname, option);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "scm.set1.%s", sdbc_cfg_options[i].tag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, sizeof (buf)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: error reading "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto out;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*buf == '\0')
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(buf, "<default>", sizeof (buf));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *tmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte long val;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set to new value */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(value, "-")) { /* default ? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val = strtol(value, &tmp, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(value, tmp) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext(
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki "%s: bad value (%s) "
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki "for option %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, value, option);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto out;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* make sure cache size is valid */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(key, "scm.set1.size") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (val > MAX_CACHE_SIZE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PRINT_CACHE_SZ_ERR(val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Overwrite the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache size with
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the maximum cache
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * size.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(value,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (value),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%ld",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (long)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_CACHE_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_put_cstring(cfg, key, value,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(value)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("\n%s: error writing "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte error = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto out;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(buf, sizeof (buf),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s = %s", buf,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (strcmp(value, "-") == 0) ?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "<default>" : value);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commit = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("%-*s: %-*s /* %s */\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte opt_width, sdbc_cfg_options[i].name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte opt_width, buf, sdbc_cfg_options[i].help);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* end command line args */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteout:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (commit) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_commit(cfg)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to write "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "to configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte commit = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("\n%s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Changed configuration parameters "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "will take effect when the cache is restarted"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (error);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecd_to_device(int cd)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static _sd_stats_t *cs_cur = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustatus;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cs_cur == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cs_cur = malloc(sizeof (_sd_stats_t) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sdbc_max_devices - 1) * sizeof (_sd_shared_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cs_cur == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("%s malloc: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SDBC_IOCTL(SDBC_STATS, cs_cur, 0, 0, 0, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &ustatus) == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: stats ioctl failed\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cs_cur->st_cachesize == 0 || cd >= cs_cur->st_count)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return ("");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (cs_cur->st_shared[cd].sh_filename);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * takes either either a string containing the cd or the device name, and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * returns the device name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic char *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_device_name(char *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte long cd = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *device;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* if the arg has a leading '/', assume it's a valid device name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!arg || *arg == '/') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (arg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* treat the "all" keyword as a valid device name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(arg, "all") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (arg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Next, assume it's a cd, and try to convert it to an integer, and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * subsequently convert that cd to its corresponding device name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Since strtol returns 0 on failure, we need to make a special case
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for a cd of "0", which is valid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((cd = strtol(arg, (char **)NULL, 10)) > 0) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcmp(arg, "0") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte device = cd_to_device((int)cd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* cd_to_device returns NULL or "" on failure--check both */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (device && (strcmp(device, ""))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* it seems to be a valid device name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (device);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteremove_hint(char *device)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFGFILE *cfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY], buf[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int setnumber;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg = cfg_open(NULL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to access configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_WRLOCK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to lock configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (setnumber = 1; /*CONSTCOND*/ TRUE; setnumber++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "cache_hint.set%d.device",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, sizeof (buf)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error or not found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(device, buf) != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove config file entry */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "cache_hint.set%d", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = cfg_put_cstring(cfg, key, NULL, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to update configuration "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (!cfg_commit(cfg))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to update configuration "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: persistent hint for %s"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " removed from configuration\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, device);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesave_hint(int cd, int hint, int flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char device[NSC_MAXPATH];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFGFILE *cfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY], buf[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int setnumber;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int found;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hint != NSC_WRTHRU && hint != NSC_NOCACHE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag != 0 && flag != 1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg = cfg_open(NULL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to access configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_WRLOCK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to lock configuration: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cd == -1)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(device, "system");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(device, cd_to_device(cd), NSC_MAXPATH);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (setnumber = 1; /*CONSTCOND*/ TRUE; setnumber++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "cache_hint.set%d.device",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, sizeof (buf)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* error or not found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(device, buf) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hint == NSC_WRTHRU)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "cache_hint.set%d.wrthru", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else /* NSC_NOCACHE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "cache_hint.set%d.nordcache", setnumber);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = cfg_put_cstring(cfg, key, "0", 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = cfg_put_cstring(cfg, key, "1", 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncpy(buf, device, CFG_MAX_BUF);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (flag == 0)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncat(buf, " 0 0", CFG_MAX_BUF);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (hint == NSC_WRTHRU)
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncat(buf, " 1 0", CFG_MAX_BUF);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else /* NSC_NOCACHE */
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncat(buf, " 0 1", CFG_MAX_BUF);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = cfg_put_cstring(cfg, "cache_hint", buf, sizeof (buf));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to update configuration storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (!cfg_commit(cfg))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to update configuration storage: %s"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cfg_error(NULL));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef lint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortescmadm_lintmain(int argc, char *argv[])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemain(int argc, char *argv[])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int o = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int errflg = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int hflag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int qflag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte extern int optind;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte extern char *optarg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int hint;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int optflag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustats;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int Dopt, Lopt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int Oopt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *bitmapfs = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *exclusive = gettext(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "-d, -e, -m, -o, -C, -D, -L, and -v "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "are mutually exclusive\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) setlocale(LC_ALL, "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) textdomain("scm");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname = strdup(basename(argv[0]));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_set_maxdev();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buildusage(progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Dopt = Lopt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((c = getopt(argc, argv,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "gi:t:S"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "CD:LOa:devqhm:o:")) != EOF) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (c) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'D':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (optflag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, exclusive);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto usage;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Dopt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optflag++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bitmapfs = optarg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'L':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (optflag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, exclusive);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto usage;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Lopt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optflag++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'S':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (optflag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, exclusive);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto usage;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (putenv(stats_usage) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to putenv()\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte argv[1] = "scmadm";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (execv(STATS_PATH, &argv[1]) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: failed to execute " STATS_PATH
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Please be sure to copy sd_stats"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " from src/cmd/ns/sdbc in a development"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " workspace\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'a':
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(alert_file, optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'q':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qflag++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'O': /* restore hints */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Oopt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'C': /* configure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'e': /* enable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'd': /* disable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'v': /* get version */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'o': /* get/set options */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'm': /* get cd map */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 't': /* trace */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'i': /* inject_ioerr */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'c': /* clear_ioerr */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'g': /* toggle_flush */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (optflag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s%s", gettext("-t, -i, -c, -g, "),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exclusive);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errflg++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte optflag++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte o = c;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 'h':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hflag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case '?':
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte errflg++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errflg || hflag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto usage;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Oopt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set hints saved in persistent configuration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte restore_hints();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Dopt || Lopt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* bitmapfs control */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iscluster()) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: bitmap filesystems are not "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "allowed in a cluster\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto usage;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((Dopt + Lopt) > 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("-D and -L are"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "mutually exclusive\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto usage;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (Lopt)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bitmapfs_print();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else /* if (Dopt) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bitmapfs_delete(bitmapfs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!o) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (argc > 1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto usage;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: Printing all cd's and options:\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_all_options();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Configure */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (o == 'C') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(configure_sdbc(argc, argv, optind));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* enable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (o == 'e') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte enable_sdbc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (qflag == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sd_gather_alert_dumps();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* disable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (o == 'd') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte disable_sdbc();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get version */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (o == 'v') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte get_version();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* node_hint or cd_hint */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (o == 'o') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(strcoll(optarg, "system"))) { /* node_hint */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((optind - 1) == (argc - 1)) { /* get */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((hint = SDBC_IOCTL(SDBC_GET_NODE_HINT, 0, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, 0, 0, &ustats)) == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: get system "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "options failed\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef WRTHRU_HINTS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("System Status: "));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_hint(hint, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("System Options: "));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_hint(hint, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* set, clear */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (get_hint(argv[optind], &hint, &flag) == -1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto usage;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hint == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove hint from config */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte remove_hint("system");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SDBC_IOCTL(SDBC_SET_NODE_HINT, hint, flag,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, 0, 0, &ustats) == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: set system "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "option failed\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte save_hint(-1, hint, flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: System option %s"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " now set.\n"), progname, argv[optind]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* cd_hint */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cd = get_cd(optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((optind - 1) == (argc - 1)) { /* get */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cd < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: device %s not "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "found\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hint = get_cd_hint(cd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: cd(%d) Current "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "options are: "), progname, cd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_hint(hint, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* set, clear */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (get_hint(argv[optind], &hint, &flag) == -1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto usage;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hint == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* remove hint from config */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cd < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte remove_hint(optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte remove_hint(cd_to_device(cd));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cd < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: device %s not "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "found\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SDBC_IOCTL(SDBC_SET_CD_HINT, cd, hint,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flag, 0, 0, &ustats) == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: set option "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "failed\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte save_hint(cd, hint, flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: cd %d option %s now"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " set.\n"), progname, cd, argv[optind]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (o == 'm') { /* "get_cd" = map */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *dev_name;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(strcoll(optarg, "all"))) /* all */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) get_cd_all();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cd = get_cd(optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cd < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: device or cd %s not found\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((dev_name = get_device_name(optarg)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s: device for cd %d not found\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, cd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: diskname %s; cd %d\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, dev_name, cd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (o == 't') { /* "trace" */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int flag, value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdtr_table_t tt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((optind+1) != (argc-1))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto usage;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cd = get_cd(argv[optind]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cd < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: device or cd %s not found\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, argv[optind]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte value = strtol(argv[optind+1], 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(strcoll(optarg, gettext("size")))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flag = SD_SET_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tt.tt_max = value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (!(strcoll(optarg, gettext("mask")))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flag = SD_SET_MASK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tt.tt_mask = value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (!(strcoll(optarg, gettext("lbolt")))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flag = SD_SET_LBOLT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tt.tt_lbolt = value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (!(strcoll(optarg, gettext("good")))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flag = SD_SET_GOOD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tt.tt_good = value;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else goto usage;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SDBC_IOCTL(SDBC_ADUMP, (long)cd, &tt, NULL, 0L,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (long)flag, &ustats) == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: trace %s failed\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: trace %s processed\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cd != -1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext(" cd %d; size %d; mask 0x%04x; "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "lbolt %d; good %d;\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cd, tt.tt_max, tt.tt_mask,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tt.tt_lbolt, tt.tt_good);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (o == 'i') { /* "inject_ioerr" */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ioj_err = EIO;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int ioj_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* a cd of "-1" represents all devices */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(optarg, "-1") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cd = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((cd = get_cd(optarg)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: device or cd %s not found\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (argc == 4)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioj_err = strtol(argv[optind], 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (argc == 5)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ioj_cnt = strtol(argv[optind+1], 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SDBC_IOCTL(SDBC_INJ_IOERR, cd, ioj_err, ioj_cnt, 0, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &ustats) == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: i/o error injection for cd %s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "failed\n"), progname, optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: i/o error injection cd %d errno %d "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "processed\n"), progname, cd, ioj_err);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (o == 'c') { /* "clear_ioerr" */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* a cd of "-1" represents all devices */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(optarg, "-1") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cd = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((cd = get_cd(optarg)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: device or cd %s not found\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SDBC_IOCTL(SDBC_CLR_IOERR, cd, 0, 0, 0, 0, &ustats)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: i/o error clear %s failed\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, optarg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: i/o error clear for cd %d "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "processed\n"), progname, cd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (o == 'g') { /* "toggle_flush" */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flag = toggle_flush();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: sdbc cache flush now %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, flag ? "on" : "off");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* DEBUG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteusage:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, "%s\n", scmadmUsage);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hflag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define addusage(f__) \
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strncat(scmadmUsage, f__, sizeof (scmadmUsage));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define addusage1(f__, a__) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(fmt, sizeof (fmt), "%s%s", scmadmUsage, f__); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(scmadmUsage, sizeof (scmadmUsage), fmt, a__);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define addusage2(f__, a__, b__) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(fmt, sizeof (fmt), "%s%s", scmadmUsage, f__); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(scmadmUsage, sizeof (scmadmUsage), fmt, a__, b__);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortebuildusage(char *p)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fmt[USAGELEN];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef WRTHRU_HINTS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *hints_str = "[nordcache|rdcache|wrthru|nowrthru|forget]\n";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *hints_str = "[nordcache|rdcache|forget]\n";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(scmadmUsage, sizeof (scmadmUsage));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(fmt, sizeof (fmt));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage(gettext("Usage :\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage1(gettext("\t%s\n"), p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage1(gettext("\t%s -h\n"), p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage1(gettext("\t%s -e\n"), p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage1(gettext("\t%s -d\n"), p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage1(gettext("\t%s -v\n"), p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage1(gettext("\t%s {-L | -D bitmapfs}\n"), p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage1(gettext("\t%s -C [parameter[=[value]] ...]\n"), p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage2(gettext("\t%s -o system %s"), p, hints_str);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage2(gettext("\t%s -o <cd> %s"), p, hints_str);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage2(gettext("\t%s -o <diskname> %s"), p, hints_str);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage1(gettext("\t%s -m {<cd>|<diskname>|all}\n"), p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage1(gettext(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\t%s -S [-Mz] [-d delay_time] [-l logfile] [-r range]\n"), p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage1(gettext(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\t%s -t {size|mask|lbolt|good} <cd|diskname> <value>\n"), p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage1(gettext("\t%s -g\n"), p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage1(gettext(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "\t%s -i {cd|diskname|-1 for all} [errno [countdown]]\n"), p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage1(gettext("\t%s -c {cd|diskname|-1 for all}\n"), p);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage(gettext("\nt = trace\tg = toggle_flush\ti = inject ioerr\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "c = clear ioerr\tS = stats\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* DEBUG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage(gettext(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "e = enable\td = disable\tv=version\to = get/ set options\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage(gettext(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "m = get cd map\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage1(gettext(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "note: cd is a cache descriptor integer in the range [0-%d]\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_max_devices - 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addusage(gettext(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " bitmapfs is a block device or filesystem mount point\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(stats_usage, sizeof (stats_usage),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "SD_STATS_USAGE=%s", scmadmUsage);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_hint(char *str, int *hint, int *flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef WRTHRU_HINTS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(strcoll(str, gettext("wrthru")))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *hint = NSC_WRTHRU;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *flag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (!(strcoll(str, gettext("nowrthru")))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *hint = NSC_WRTHRU;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *flag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(strcoll(str, gettext("nordcache")))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *hint = NSC_NOCACHE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *flag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (!(strcoll(str, gettext("rdcache")))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *hint = NSC_NOCACHE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *flag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (!(strcoll(str, gettext("forget")))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *hint = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *flag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*ARGSUSED*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteprint_hint(const uint_t type, const int status)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef WRTHRU_HINTS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (type & NSC_FORCED_WRTHRU) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("Fast Writes Overridden\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* if (type & NSC_NO_FORCED_WRTHRU) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("default\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("%swrthru, %srdcache",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (type & (NSC_FORCED_WRTHRU|NSC_WRTHRU)) ? "" : "no",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (type & NSC_NOCACHE) ? "no" : "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("%srdcache", (type & NSC_NOCACHE) ? "no" : "");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (type & 0x80000000)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" (overridden by system)");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Read the configuration via libcfg
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_cache_config()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sysid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CFGFILE *cfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char buf[CFG_MAX_BUF];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char key[CFG_MAX_KEY];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((cfg = cfg_open(NULL)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Cannot open configuration file\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg_lock(cfg, CFG_RDLOCK)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Cannot lock configuration file\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte convert_config(cfg, CFG_RDLOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) memset((char *)&user_level_conf, 0, sizeof (_sd_cache_param_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the system ID */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nsc_getsystemid(&sysid) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s Unable to obtain subsystem ID: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte myid = sysid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte user_level_conf.blk_size = 8192; /* DEFAULT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte user_level_conf.procs = 16; /* DEFAULT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte user_level_conf.reserved1 = RESERVED1_DEFAULTS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(buf, CFG_MAX_BUF);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "scm.set1.thread");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte user_level_conf.threads = atoi(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte user_level_conf.threads = 128; /* DEFAULT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "scm.set1.tdemons");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte user_level_conf.test_demons = atoi(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "scm.set1.write_cache");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte user_level_conf.write_cache = atoi(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "scm.set1.size");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We need to run strtol for backwards compatibility in 3.2.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A workaround for this bug was put in 3.2 which allowed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * customers to set the cache size up to 1024 if it was
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * specified in hexadecimal. Decimal still had the limit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of 128. This change treats them both identically.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte user_level_conf.cache_mem[0] = (int)strtol(buf, NULL, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (user_level_conf.cache_mem[0] > MAX_CACHE_SIZE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "The cache size of %ld is larger than "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "the system maximum of %ld.\nUse \"scmadm -C "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "cache_size=<size>\" to set the size to a proper "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "value.\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte user_level_conf.cache_mem[0], MAX_CACHE_SIZE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte user_level_conf.cache_mem[0] = MAX_CACHE_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "scm.set1.iobuf");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte user_level_conf.iobuf = atoi(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "scm.set1.fill_pattern");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte user_level_conf.fill_pattern = atoi(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte user_level_conf.gen_pattern = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "scm.set1.no_forced_wrthru");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte no_forced_wrthru = atoi(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "scm.set1.forced_wrthru");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte forced_wrthru = atoi(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(key, sizeof (key), "scm.set1.reserved1");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte user_level_conf.reserved1 = atoi(buf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg_close(cfg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * use the default minidsp configuration if no
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * node/mirror/remote-mirror/cluster line is in the sd.cf file
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nodes_configured == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte check_and_set_mirrors(myid, _SD_NO_HOST);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if our sysid was defined */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!node_defined[myid]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("This node(%d) is not defined in config.\n"), myid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Save off number of nodes so we can calculate the point-to-point
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * segements. Code in kernel currently supports MAX_SD_NODES
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((user_level_conf.num_nodes = nodes_configured) >
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_SD_NODES) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Cache can support only %d nodes(%d).\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAX_SD_NODES, nodes_configured);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((nodes_configured % 2) && !minidsp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nodes_configured == 1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Only one node configured, "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "mirror node must be %d\n"), _SD_NO_HOST);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("Cannot configure odd number of nodes.\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Pass List of Nodes Configured to Cache */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < nodes_configured; i++)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte user_level_conf.nodes_conf[i] = nodes_conf[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Place magic number in user_level_conf. Kernel will test for it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte user_level_conf.magic = _SD_MAGIC;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sleep(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sdtr_t hdr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* function name string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_sd_fname(int f)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int fn = f & ST_FUNC;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static char c[8];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *s;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (f & ST_BCACHE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = _bcache_fname[fn];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (f & ST_BSUB)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = _bsub_fname[fn];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (f & ST_IO)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = _io_fname[fn];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (f & ST_STATS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = _stats_fname[fn];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (f & ST_CCIO)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = _ccio_fname[fn];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (f & ST_FT)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = _ft_fname[fn];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (f & ST_INFO)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte s = _info_fname[fn];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!s)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(s = c, "0x%04x", f & 0xffff);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (s);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint alerts = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Background daemon to wait for alert (on any device)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Writes the traces to "sd_alert.CD.NUM",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and writes an information message to the alert_file.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesd_gather_alert_dumps()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdtr_table_t tt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _sdtr_t *buf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cd, count, size, flag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char filename[64];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int fd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte time_t tloc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct tm tm_storage;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct tm *tm_ptr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char timebuf[80];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustats;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fork and detach daemon */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fork())
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fd = open(alert_file, O_WRONLY|O_APPEND|O_CREAT, 0644);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fd == -1)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fd = open("/dev/console", O_WRONLY);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (fd != -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) dup2(fd, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) dup2(fd, 2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) setsid();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = 10000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (size < user_level_conf.trace_size)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = user_level_conf.trace_size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte buf = (_sdtr_t *)malloc(size * sizeof (_sdtr_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!buf) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("%s malloc: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tloc = time(NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tm_ptr = (struct tm *)localtime_r(&tloc, &tm_storage);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteloop:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cd = SDT_ANY_CD; /* any device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte flag = SD_ALERT_WAIT; /* block for alert */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((count = SDBC_IOCTL(SDBC_ADUMP, cd, &tt, buf, size,
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki flag, &ustats)) == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("%s: sd_adump\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno == EIDRM) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strftime(timebuf, 80, "%x %X", tm_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: cache deconfigured at %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, timebuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno == ENOSYS)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(errno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (count == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto loop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cd = tt.tt_cd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) sprintf(filename, "%s.%d.%d", "sd_alert", cd, alerts++);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((fd = open(filename, O_CREAT | O_RDWR, 0444)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("%s: open: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(errno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * write header to identify device, write entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hdr.t_func = SDF_CD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hdr.t_len = count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hdr.t_ret = tt.tt_cd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (write(fd, &hdr, sizeof (_sdtr_t)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("%s: write: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(errno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (write(fd, buf, sizeof (_sdtr_t)*count) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("%s: write: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(errno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) close(fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strftime(timebuf, 80, "%x %X", tm_ptr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("sd alert trace dump %s at %s\n", filename, timebuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto loop;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * print list of configured cd's, diskname, options and global options
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteprint_all_options()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static _sd_stats_t *cs_cur;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustats;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int hint;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *s1 = "device name";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *s2 = "option";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fn[19];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* No corresponding free because this function exits */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cs_cur = malloc(sizeof (_sd_stats_t) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sdbc_max_devices - 1) * sizeof (_sd_shared_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cs_cur == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("%s malloc: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* node hints */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((hint = SDBC_IOCTL(SDBC_GET_NODE_HINT, 0, 0, 0, 0, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &ustats)) == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: get system option failed\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef WRTHRU_HINTS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("System Status: "));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_hint(hint, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("System Options: "));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_hint(hint, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get cds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SDBC_IOCTL(SDBC_STATS, cs_cur, 0, 0, 0, 0, &ustats)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: get_cd failed in print_all options\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cs_cur->st_cachesize == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("Cache is disabled\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (cs_cur->st_count == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("No devices are configured\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("\nConfigured cd's, disknames and options: \n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("cd\t%-28s\t%-20s\n"), s1, s2);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cd = 0; cd < cs_cur->st_count; cd++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cs_cur->st_shared[cd].sh_alloc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hint = get_cd_hint(cd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((len =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strlen(cs_cur->st_shared[cd].sh_filename))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte > 23) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(fn, "...");
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcat(fn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cs_cur->st_shared[cd].sh_filename +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len - 20);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(fn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cs_cur->st_shared[cd].sh_filename);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%d\t%-28.*s\t"), cd,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NSC_MAXPATH, fn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_hint(hint, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache device -- lookup names and cache descriptors of all configured devices
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_cd_all()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static _sd_stats_t *cs_cur;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustats;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char fn[19];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int len;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* No corresponding free because this function exits */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cs_cur = malloc(sizeof (_sd_stats_t) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sdbc_max_devices - 1) * sizeof (_sd_shared_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cs_cur == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("%s malloc: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SDBC_IOCTL(SDBC_STATS, cs_cur, 0, 0, 0, 0, &ustats)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("%s: get_cd_all"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cs_cur->st_cachesize == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("Cache is disabled\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (cs_cur->st_count == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("No devices are configured\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("\tcd\tdevice name\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cd = 0; cd < cs_cur->st_count; cd++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cs_cur->st_shared[cd].sh_alloc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((len = strlen(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cs_cur->st_shared[cd].sh_filename)) > 15) {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(fn, "...");
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcat(fn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cs_cur->st_shared[cd].sh_filename +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte len - 12);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
570de38f63910201fdd77246630b7aa8f9dc5661Surya Prakki (void) strcpy(fn,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cs_cur->st_shared[cd].sh_filename);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("\t%d\t%s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cd, fn);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * cache device -- specified by number or lookup name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_cd(char *s)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static _sd_stats_t *cs_cur = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustats;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int cd, arg_cd = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cs_cur == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * No corresponding free because the memory is reused
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * every time the function is called.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cs_cur = malloc(sizeof (_sd_stats_t) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sdbc_max_devices - 1) * sizeof (_sd_shared_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cs_cur == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("%s malloc: %s\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, strerror(errno));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SDBC_IOCTL(SDBC_STATS, cs_cur, 0, 0, 0, 0, &ustats)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("%s: get_cd\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cs_cur->st_cachesize == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("Cache is disabled\n"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*s != '/') {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Since strtol returns 0 on failure, we need to make a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * special case for a cd of "0", which is valid.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This case also deals with the difference between
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * scmadm -o system and scmadm -o 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((int)strtol(s, (char **)NULL, 10) == 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcmp(s, "0"))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Only return failure at this point, in order to allow
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * checking arg_cd against st_count later on.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((arg_cd = strtol(s, 0, 0)) < 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (arg_cd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* make sure the cd passed as an argument is alloc'd and < st_count */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (arg_cd >= 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (((arg_cd < cs_cur->st_count) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (cs_cur->st_shared[arg_cd].sh_alloc)) ? arg_cd : -1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (cd = 0; cd < cs_cur->st_count; cd++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cs_cur->st_shared[cd].sh_alloc &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte strcmp(s, cs_cur->st_shared[cd].sh_filename) == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (cd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortecheck_and_set_mirrors(int node, int mirror)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (minidsp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: minidsp defined. "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Cannot define other nodes.\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mirror == _SD_NO_HOST) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte minidsp++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if ((!(node % 2) && !(node == mirror - 1)) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (((node % 2) && !(node == mirror + 1)))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: Node and Mirror identification values "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "must be consecutive\n"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "starting at an even number (Node = %d Mirror = %d)\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname, node, mirror);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte node_defined[node]++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodes_conf[nodes_configured] = node;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nodes_configured++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (node == myid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte user_level_conf.mirror_host = mirror;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *mem_string =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%-8s Structures use approx. %8d bytes (%5d pages) of memory\n";
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteenable_sdbc()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustats;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (get_cache_config()) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: unable to read configuration file\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SDBC_IOCTL(SDBC_ENABLE, &user_level_conf, 0, 0, 0, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &ustats) == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr, gettext("%s: cache enable failed\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("scm", &ustats, gettext("%s cache enable failed"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("scm", NULL, gettext("%s cache enable succeeded"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: cache has been configured\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef WRTHRU_HINTS
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iscluster()) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Must writethru on a cluster, even if nvram configured */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte forced_wrthru = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (minidsp && forced_wrthru != -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Have minidsp with forced_wrthru hint. Set / Clear hint */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SDBC_IOCTL(SDBC_SET_NODE_HINT, NSC_FORCED_WRTHRU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte forced_wrthru, 0, 0, 0, &ustats) == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: set/clear forced_wrthru failed\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (forced_wrthru) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: Node option forced_wrthru "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "now set.\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: Node option forced_wrthru "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "now cleared.\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (no_forced_wrthru != -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SDBC_IOCTL(SDBC_SET_NODE_HINT, NSC_NO_FORCED_WRTHRU,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte no_forced_wrthru, 0, 0, 0, &ustats) == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: set/clear no_forced_wrthru "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "failed\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (no_forced_wrthru) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: Node option no_forced_wrthru"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " now set.\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: Node option no_forced_wrthru"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte " now cleared.\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* do scmadm -O to cater for manual cache disable then enable */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte restore_hints();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedisable_sdbc()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustats;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SDBC_IOCTL(SDBC_DISABLE, 0, 0, 0, 0, 0, &ustats) != SPCS_S_OK) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If it wasn't already enabled, don't appear to fail
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or users of this program might think the cache is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * configured, when it actually isn't.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (errno != SDBC_EDISABLE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("scm", &ustats,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s cache disable failed"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("%s: cache has been deconfigured\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_log("scm", NULL, gettext("%s cache disable succeeded"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteget_version()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cache_version_t version;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustats;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (SDBC_IOCTL(SDBC_VERSION, &version, 0, 0, 0, 0, &ustats) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: get cache version failed\n"), progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("Cache version %d.%d.%d.%d\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte version.major, version.minor, version.micro, version.baseline);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (version.micro) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("Cache version %d.%d.%d\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte version.major, version.minor, version.micro);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(gettext("Cache version %d.%d\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte version.major, version.minor);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DEBUG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetoggle_flush(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte spcs_s_info_t ustats;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rc = SDBC_IOCTL(SDBC_TOGGLE_FLUSH, 0, 0, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0, 0, &ustats)) == SPCS_S_ERROR) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) fprintf(stderr,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte gettext("%s: toggle sdbc cache flush failed\n"),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte progname);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sdbc_report_error(&ustats);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte exit(1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif