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 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
44c4f64b9f50f21ae3e51ad48a595c85f53db4bcJohn Levon * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This program is strictly for demonstration purposes and not for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * production use. It demonstrates how to access the dynamic memory
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * caching statistics and turning variables via the kstat library.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdarg.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stropts.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <ctype.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <unistd.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <memory.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <string.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <fcntl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <errno.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <signal.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <locale.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <kstat.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/time.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/sysinfo.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/buf.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/vfs.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/dnlc.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define TRUE 1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FALSE 0
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_KSTAT_MODULE "sdbc"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SDBC_KSTAT_DYNMEM "dynmem"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int instance;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_t *ksp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } KSTAT_INFO_DEF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_named_t *knp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char *named;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int newval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } DYNMEM_KNP_DEFN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef enum {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMONITOR = 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMAXLIST,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteAGECT1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteAGECT2,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteAGECT3,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteSEC1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteSEC2,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteSEC3,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortePCNT1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortePCNT2,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHDPCNT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteALLOC,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteDEALLOC,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHISTORY,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteNODATA,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteCAND,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteDEALLOCS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHOSTS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortePESTS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteMETAS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteHOLDS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteOTHERS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteNOTAVAIL,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteDIRECTIVE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteSIMPLECT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte} arglist_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NO_VALUE -1
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteDYNMEM_KNP_DEFN dynmem_knp[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_monitor_dynmem", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_max_dyn_list", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_cache_aging_ct1", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_cache_aging_ct2", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_cache_aging_ct3", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_cache_aging_sec1", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_cache_aging_sec2", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_cache_aging_sec3", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_cache_aging_pcnt1", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_cache_aging_pcnt2", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_max_holds_pcnt", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_alloc_cnt", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_dealloc_cnt", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_history", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_nodatas", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_candidates", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_deallocs", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_hosts", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_pests", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_metas", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_holds", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_others", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_notavail", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_process_directive", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, "sdbc_simplect", NO_VALUE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, NULL, NO_VALUE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Print Usage
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteprint_usage()
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("USAGE: wake - wakeup thread, hys - max hysteresis\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" mon 1 - monitor shutdown\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" 2 - monitor thread stats1\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" 4 - monitor thread stats2\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" age1 n - num cyc to full host aging and "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "dealloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" age2 n - num cyc to full meta aging and "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "dealloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" age3 n - num cyc to full one pg aging and "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "dealloc\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" sec1 n - sec1 aging time\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" sec2 n - sec2 aging time\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" sec3 n - sec3 aging time\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" pcnt1 n - percent to sec1/sec2 trans\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" pcnt2 n - percent to sec2/sec3 trans\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" hdpcnt n - max percent of cents for holds\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf(" list n - host+pest max len\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("No Args - print current settings only\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Main
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef lint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesd_dynmem_lintmain(int argc, char *argv[])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortemain(int argc, char *argv[])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DYNMEM_KNP_DEFN *p_dynmem_knp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_ctl_t *kctl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte KSTAT_INFO_DEF info_ksp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int val;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char **pargs, **cur_pargs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * grab and parse argument list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p_dynmem_knp = dynmem_knp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pargs = argv;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (*pargs) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("pargs=%x - %s\n", (uint_t)pargs, *pargs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cur_pargs = pargs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pargs++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(*cur_pargs, "h") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte print_usage();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(*cur_pargs, "wake") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((p_dynmem_knp+DIRECTIVE)->newval == NO_VALUE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (p_dynmem_knp+DIRECTIVE)->newval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (p_dynmem_knp+DIRECTIVE)->newval |= 0x01;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(*cur_pargs, "hys") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((p_dynmem_knp+DIRECTIVE)->newval == NO_VALUE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (p_dynmem_knp+DIRECTIVE)->newval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (p_dynmem_knp+DIRECTIVE)->newval |= 0x02;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp (*cur_pargs, "mon") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val = atoi(*pargs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pargs++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (p_dynmem_knp+MONITOR)->newval = val;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp (*cur_pargs, "age1") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val = atoi(*pargs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pargs++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (p_dynmem_knp+AGECT1)->newval = val;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(*cur_pargs, "age2") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val = atoi(*pargs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pargs++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (p_dynmem_knp+AGECT2)->newval = val;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(*cur_pargs, "age3") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val = atoi(*pargs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pargs++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (p_dynmem_knp+AGECT3)->newval = val;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp (*cur_pargs, "sec1") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val = atoi(*pargs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pargs++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (val == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (p_dynmem_knp+SEC1)->newval = val;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(*cur_pargs, "sec2") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val = atoi(*pargs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pargs++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (val == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (p_dynmem_knp+SEC2)->newval = val;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(*cur_pargs, "sec3") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val = atoi(*pargs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pargs++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (val == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (p_dynmem_knp+SEC3)->newval = val;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(*cur_pargs, "pcnt1") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val = atoi(*pargs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pargs++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (val == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (p_dynmem_knp+PCNT1)->newval = val;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(*cur_pargs, "pcnt2") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val = atoi(*pargs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pargs++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (val == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (p_dynmem_knp+PCNT2)->newval = val;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(*cur_pargs, "hdpcnt") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val = atoi(*pargs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pargs++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (val < 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (p_dynmem_knp+HDPCNT)->newval = val;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strcmp(*cur_pargs, "list") == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val = atoi(*pargs);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pargs++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("errno=%x, %s=%x\n", errno, *cur_pargs,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte val);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (val == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (p_dynmem_knp+MAXLIST)->newval = val;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* while(*pargs && cl) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * open the kstat library
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kctl = kstat_open();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (kctl == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("kstat_open() failed\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is the name module about
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte info_ksp.instance = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte info_ksp.ksp = kstat_lookup(kctl, SDBC_KSTAT_MODULE, 0,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte SDBC_KSTAT_DYNMEM);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (info_ksp.ksp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("No module to report\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * using the info get a copy of the data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (kstat_read(kctl, info_ksp.ksp, NULL) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("Can't read kstat\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * print the current data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p_dynmem_knp = dynmem_knp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (p_dynmem_knp->named) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p_dynmem_knp->knp =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kstat_data_lookup(info_ksp.ksp, p_dynmem_knp->named);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p_dynmem_knp->knp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("kstat_data_lookup(%s) failed\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p_dynmem_knp->named);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("%s: %x\n", p_dynmem_knp->named,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint_t)p_dynmem_knp->knp->value.ul);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p_dynmem_knp++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * modify the data and write it back
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p_dynmem_knp = dynmem_knp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (p_dynmem_knp->named) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (p_dynmem_knp->newval != NO_VALUE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p_dynmem_knp->knp->value.ul = p_dynmem_knp->newval;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte p_dynmem_knp++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (kstat_write(kctl, info_ksp.ksp, NULL) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("kstat_write() failed\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) printf("Finished (h for help)\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}