17836SJohn.Forte@Sun.COM /*
27836SJohn.Forte@Sun.COM * CDDL HEADER START
37836SJohn.Forte@Sun.COM *
47836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the
57836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License").
67836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License.
77836SJohn.Forte@Sun.COM *
87836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing.
107836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions
117836SJohn.Forte@Sun.COM * and limitations under the License.
127836SJohn.Forte@Sun.COM *
137836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
147836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
167836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
177836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
187836SJohn.Forte@Sun.COM *
197836SJohn.Forte@Sun.COM * CDDL HEADER END
207836SJohn.Forte@Sun.COM */
217836SJohn.Forte@Sun.COM /*
22*11576SSurya.Prakki@Sun.COM * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
237836SJohn.Forte@Sun.COM * Use is subject to license terms.
247836SJohn.Forte@Sun.COM */
257836SJohn.Forte@Sun.COM
267836SJohn.Forte@Sun.COM #include <stdio.h>
277836SJohn.Forte@Sun.COM #include <stdlib.h>
287836SJohn.Forte@Sun.COM #include <string.h>
297836SJohn.Forte@Sun.COM #include <unistd.h>
307836SJohn.Forte@Sun.COM #include <errno.h>
317836SJohn.Forte@Sun.COM
327836SJohn.Forte@Sun.COM #include <sys/mutex.h>
337836SJohn.Forte@Sun.COM
347836SJohn.Forte@Sun.COM #include <kstat.h>
357836SJohn.Forte@Sun.COM
367836SJohn.Forte@Sun.COM #include <sys/unistat/spcs_s.h>
377836SJohn.Forte@Sun.COM #include <sys/nsctl/dsw.h>
387836SJohn.Forte@Sun.COM #include "../../../uts/common/avs/ns/dsw/dsw_dev.h"
397836SJohn.Forte@Sun.COM #include <sys/nsctl/dsw_dev.h>
407836SJohn.Forte@Sun.COM
417836SJohn.Forte@Sun.COM #include "sdbc_stats.h"
427836SJohn.Forte@Sun.COM #include "ii_stats.h"
437836SJohn.Forte@Sun.COM
447836SJohn.Forte@Sun.COM #include "dsstat.h"
457836SJohn.Forte@Sun.COM #include "common.h"
467836SJohn.Forte@Sun.COM #include "report.h"
477836SJohn.Forte@Sun.COM
487836SJohn.Forte@Sun.COM static iistat_t *ii_top = NULL;
497836SJohn.Forte@Sun.COM
507836SJohn.Forte@Sun.COM void ii_add_stat(iistat_t *);
517836SJohn.Forte@Sun.COM iistat_t *ii_del_stat(iistat_t *);
527836SJohn.Forte@Sun.COM
537836SJohn.Forte@Sun.COM int ii_value_check(iistat_t *iistat);
547836SJohn.Forte@Sun.COM int ii_validate(kstat_t *ksp);
557836SJohn.Forte@Sun.COM int ii_vol_selected(kstat_t *);
567836SJohn.Forte@Sun.COM
577836SJohn.Forte@Sun.COM /*
587836SJohn.Forte@Sun.COM * ii_discover() - looks for new statistics to be monitored.
597836SJohn.Forte@Sun.COM * Verifies that any statistics found are now already being
607836SJohn.Forte@Sun.COM * monitored.
617836SJohn.Forte@Sun.COM *
627836SJohn.Forte@Sun.COM */
637836SJohn.Forte@Sun.COM int
ii_discover(kstat_ctl_t * kc)647836SJohn.Forte@Sun.COM ii_discover(kstat_ctl_t *kc)
657836SJohn.Forte@Sun.COM {
667836SJohn.Forte@Sun.COM static int validated = 0;
677836SJohn.Forte@Sun.COM
687836SJohn.Forte@Sun.COM kstat_t *ksp;
697836SJohn.Forte@Sun.COM
707836SJohn.Forte@Sun.COM /* Loop on all kstats */
717836SJohn.Forte@Sun.COM for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) {
727836SJohn.Forte@Sun.COM char *kname;
737836SJohn.Forte@Sun.COM iistat_t *cur;
747836SJohn.Forte@Sun.COM iistat_t *iistat = NULL;
757836SJohn.Forte@Sun.COM kstat_t *mst_ksp;
767836SJohn.Forte@Sun.COM kstat_t *shd_ksp;
777836SJohn.Forte@Sun.COM kstat_t *bmp_ksp;
787836SJohn.Forte@Sun.COM kstat_t *ovr_ksp;
797836SJohn.Forte@Sun.COM
807836SJohn.Forte@Sun.COM /* Search for II set */
817836SJohn.Forte@Sun.COM if (strcmp(ksp->ks_class, II_KSTAT_CLASS) != 0)
827836SJohn.Forte@Sun.COM continue;
837836SJohn.Forte@Sun.COM
847836SJohn.Forte@Sun.COM if (kstat_read(kc, ksp, NULL) == -1)
857836SJohn.Forte@Sun.COM continue;
867836SJohn.Forte@Sun.COM
877836SJohn.Forte@Sun.COM /*
887836SJohn.Forte@Sun.COM * Validate kstat structure
897836SJohn.Forte@Sun.COM */
907836SJohn.Forte@Sun.COM if (! validated) {
917836SJohn.Forte@Sun.COM if (ii_validate(ksp))
927836SJohn.Forte@Sun.COM return (EINVAL);
937836SJohn.Forte@Sun.COM
947836SJohn.Forte@Sun.COM validated++;
957836SJohn.Forte@Sun.COM }
967836SJohn.Forte@Sun.COM
977836SJohn.Forte@Sun.COM /*
987836SJohn.Forte@Sun.COM * Duplicate check
997836SJohn.Forte@Sun.COM */
1007836SJohn.Forte@Sun.COM for (cur = ii_top; cur != NULL; cur = cur->next) {
1017836SJohn.Forte@Sun.COM char *cur_vname, *tst_vname;
1027836SJohn.Forte@Sun.COM uint32_t cur_inst, tst_inst;
1037836SJohn.Forte@Sun.COM
1047836SJohn.Forte@Sun.COM cur_vname = cur->pre_set->ks_name;
1057836SJohn.Forte@Sun.COM cur_inst = cur->pre_set->ks_instance;
1067836SJohn.Forte@Sun.COM
1077836SJohn.Forte@Sun.COM tst_vname = ksp->ks_name;
1087836SJohn.Forte@Sun.COM tst_inst = ksp->ks_instance;
1097836SJohn.Forte@Sun.COM
1107836SJohn.Forte@Sun.COM if (strcmp(cur_vname, tst_vname) == 0 &&
1117836SJohn.Forte@Sun.COM cur_inst == tst_inst)
1127836SJohn.Forte@Sun.COM goto next;
1137836SJohn.Forte@Sun.COM }
1147836SJohn.Forte@Sun.COM
1157836SJohn.Forte@Sun.COM /*
1167836SJohn.Forte@Sun.COM * Initialize new record
1177836SJohn.Forte@Sun.COM */
1187836SJohn.Forte@Sun.COM iistat = (iistat_t *)calloc(1, sizeof (iistat_t));
1197836SJohn.Forte@Sun.COM
1207836SJohn.Forte@Sun.COM /*
1217836SJohn.Forte@Sun.COM * Set kstat
1227836SJohn.Forte@Sun.COM */
1237836SJohn.Forte@Sun.COM iistat->pre_set = kstat_retrieve(kc, ksp);
1247836SJohn.Forte@Sun.COM
1257836SJohn.Forte@Sun.COM if (iistat->pre_set == NULL)
1267836SJohn.Forte@Sun.COM goto next;
1277836SJohn.Forte@Sun.COM
1287836SJohn.Forte@Sun.COM iistat->collected |= GOT_SETSTAT;
1297836SJohn.Forte@Sun.COM
1307836SJohn.Forte@Sun.COM /*
1317836SJohn.Forte@Sun.COM * Master kstat
1327836SJohn.Forte@Sun.COM */
1337836SJohn.Forte@Sun.COM kname = kstat_value(iistat->pre_set, DSW_SKSTAT_MSTIO);
1347836SJohn.Forte@Sun.COM
1357836SJohn.Forte@Sun.COM mst_ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
1367836SJohn.Forte@Sun.COM iistat->pre_mst = kstat_retrieve(kc, mst_ksp);
1377836SJohn.Forte@Sun.COM
1387836SJohn.Forte@Sun.COM if (iistat->pre_mst == NULL)
1397836SJohn.Forte@Sun.COM goto next;
1407836SJohn.Forte@Sun.COM
1417836SJohn.Forte@Sun.COM iistat->collected |= GOT_MSTSTAT;
1427836SJohn.Forte@Sun.COM
1437836SJohn.Forte@Sun.COM /*
1447836SJohn.Forte@Sun.COM * Shadow kstat
1457836SJohn.Forte@Sun.COM */
1467836SJohn.Forte@Sun.COM kname = kstat_value(iistat->pre_set, DSW_SKSTAT_SHDIO);
1477836SJohn.Forte@Sun.COM
1487836SJohn.Forte@Sun.COM shd_ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
1497836SJohn.Forte@Sun.COM iistat->pre_shd = kstat_retrieve(kc, shd_ksp);
1507836SJohn.Forte@Sun.COM
1517836SJohn.Forte@Sun.COM if (iistat->pre_shd == NULL)
1527836SJohn.Forte@Sun.COM goto next;
1537836SJohn.Forte@Sun.COM
1547836SJohn.Forte@Sun.COM iistat->collected |= GOT_SHDSTAT;
1557836SJohn.Forte@Sun.COM
1567836SJohn.Forte@Sun.COM /*
1577836SJohn.Forte@Sun.COM * Bitmap kstat
1587836SJohn.Forte@Sun.COM */
1597836SJohn.Forte@Sun.COM kname = kstat_value(iistat->pre_set, DSW_SKSTAT_BMPIO);
1607836SJohn.Forte@Sun.COM
1617836SJohn.Forte@Sun.COM bmp_ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
1627836SJohn.Forte@Sun.COM iistat->pre_bmp = kstat_retrieve(kc, bmp_ksp);
1637836SJohn.Forte@Sun.COM
1647836SJohn.Forte@Sun.COM if (iistat->pre_bmp == NULL)
1657836SJohn.Forte@Sun.COM goto next;
1667836SJohn.Forte@Sun.COM
1677836SJohn.Forte@Sun.COM iistat->collected |= GOT_BMPSTAT;
1687836SJohn.Forte@Sun.COM
1697836SJohn.Forte@Sun.COM /*
1707836SJohn.Forte@Sun.COM * Overflow kstat
1717836SJohn.Forte@Sun.COM */
1727836SJohn.Forte@Sun.COM kname = kstat_value(iistat->pre_set, DSW_SKSTAT_OVRIO);
1737836SJohn.Forte@Sun.COM
1747836SJohn.Forte@Sun.COM ovr_ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
1757836SJohn.Forte@Sun.COM iistat->pre_ovr = kstat_retrieve(kc, ovr_ksp);
1767836SJohn.Forte@Sun.COM
1777836SJohn.Forte@Sun.COM if (iistat->pre_ovr == NULL)
1787836SJohn.Forte@Sun.COM goto next;
1797836SJohn.Forte@Sun.COM
1807836SJohn.Forte@Sun.COM iistat->collected |= GOT_OVRSTAT;
1817836SJohn.Forte@Sun.COM
1827836SJohn.Forte@Sun.COM next:
1837836SJohn.Forte@Sun.COM /*
1847836SJohn.Forte@Sun.COM * Check if we got a complete set of stats
1857836SJohn.Forte@Sun.COM */
1867836SJohn.Forte@Sun.COM if (iistat == NULL)
1877836SJohn.Forte@Sun.COM continue;
1887836SJohn.Forte@Sun.COM
1897836SJohn.Forte@Sun.COM if (IIMG_COMPLETE(iistat->collected)) {
1907836SJohn.Forte@Sun.COM (void) ii_del_stat(iistat);
1917836SJohn.Forte@Sun.COM continue;
1927836SJohn.Forte@Sun.COM }
1937836SJohn.Forte@Sun.COM
1947836SJohn.Forte@Sun.COM /*
1957836SJohn.Forte@Sun.COM * Add to linked list
1967836SJohn.Forte@Sun.COM */
1977836SJohn.Forte@Sun.COM ii_add_stat(iistat);
1987836SJohn.Forte@Sun.COM }
1997836SJohn.Forte@Sun.COM
2007836SJohn.Forte@Sun.COM if (ii_top == NULL)
2017836SJohn.Forte@Sun.COM return (EAGAIN);
2027836SJohn.Forte@Sun.COM
2037836SJohn.Forte@Sun.COM return (0);
2047836SJohn.Forte@Sun.COM }
2057836SJohn.Forte@Sun.COM
2067836SJohn.Forte@Sun.COM /*
2077836SJohn.Forte@Sun.COM * ii_update() - updates all of the statistics currently being monitored.
2087836SJohn.Forte@Sun.COM *
2097836SJohn.Forte@Sun.COM */
2107836SJohn.Forte@Sun.COM int
ii_update(kstat_ctl_t * kc)2117836SJohn.Forte@Sun.COM ii_update(kstat_ctl_t *kc)
2127836SJohn.Forte@Sun.COM {
2137836SJohn.Forte@Sun.COM iistat_t *cur;
2147836SJohn.Forte@Sun.COM
2157836SJohn.Forte@Sun.COM for (cur = ii_top; cur != NULL; cur = cur->next) {
2167836SJohn.Forte@Sun.COM char volname[KSTAT_STRLEN + 1];
2177836SJohn.Forte@Sun.COM char *kname;
2187836SJohn.Forte@Sun.COM
2197836SJohn.Forte@Sun.COM kstat_t *ksp = NULL;
2207836SJohn.Forte@Sun.COM
2217836SJohn.Forte@Sun.COM cur->collected = 0;
2227836SJohn.Forte@Sun.COM
2237836SJohn.Forte@Sun.COM /*
2247836SJohn.Forte@Sun.COM * Age off old stats
2257836SJohn.Forte@Sun.COM */
2267836SJohn.Forte@Sun.COM if (cur->cur_set != NULL) {
2277836SJohn.Forte@Sun.COM kstat_free(cur->pre_set);
2287836SJohn.Forte@Sun.COM kstat_free(cur->pre_mst);
2297836SJohn.Forte@Sun.COM kstat_free(cur->pre_shd);
2307836SJohn.Forte@Sun.COM kstat_free(cur->pre_bmp);
2317836SJohn.Forte@Sun.COM
2327836SJohn.Forte@Sun.COM cur->pre_set = cur->cur_set;
2337836SJohn.Forte@Sun.COM cur->pre_mst = cur->cur_mst;
2347836SJohn.Forte@Sun.COM cur->pre_shd = cur->cur_shd;
2357836SJohn.Forte@Sun.COM cur->pre_bmp = cur->cur_bmp;
2367836SJohn.Forte@Sun.COM
2377836SJohn.Forte@Sun.COM if (cur->cur_ovr != NULL) {
2387836SJohn.Forte@Sun.COM kstat_free(cur->pre_ovr);
2397836SJohn.Forte@Sun.COM cur->pre_ovr = cur->cur_ovr;
2407836SJohn.Forte@Sun.COM }
2417836SJohn.Forte@Sun.COM }
2427836SJohn.Forte@Sun.COM
2437836SJohn.Forte@Sun.COM /*
2447836SJohn.Forte@Sun.COM * Set kstat
2457836SJohn.Forte@Sun.COM */
246*11576SSurya.Prakki@Sun.COM (void) strncpy(volname, cur->pre_set->ks_name, KSTAT_STRLEN);
2477836SJohn.Forte@Sun.COM volname[KSTAT_STRLEN] = '\0';
2487836SJohn.Forte@Sun.COM
2497836SJohn.Forte@Sun.COM ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, volname);
2507836SJohn.Forte@Sun.COM
2517836SJohn.Forte@Sun.COM if ((cur->cur_set = kstat_retrieve(kc, ksp)) == NULL)
2527836SJohn.Forte@Sun.COM continue;
2537836SJohn.Forte@Sun.COM
2547836SJohn.Forte@Sun.COM cur->collected |= GOT_SETSTAT;
2557836SJohn.Forte@Sun.COM
2567836SJohn.Forte@Sun.COM /*
2577836SJohn.Forte@Sun.COM * Validate set
2587836SJohn.Forte@Sun.COM */
2597836SJohn.Forte@Sun.COM if (strcmp(cur->pre_set->ks_name, cur->cur_set->ks_name) != 0 ||
2607836SJohn.Forte@Sun.COM cur->pre_set->ks_instance != cur->cur_set->ks_instance)
2617836SJohn.Forte@Sun.COM continue;
2627836SJohn.Forte@Sun.COM
2637836SJohn.Forte@Sun.COM /*
2647836SJohn.Forte@Sun.COM * Master kstat
2657836SJohn.Forte@Sun.COM */
2667836SJohn.Forte@Sun.COM kname = kstat_value(cur->cur_set, DSW_SKSTAT_MSTIO);
2677836SJohn.Forte@Sun.COM
2687836SJohn.Forte@Sun.COM ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
2697836SJohn.Forte@Sun.COM
2707836SJohn.Forte@Sun.COM if ((cur->cur_mst = kstat_retrieve(kc, ksp)) == NULL)
2717836SJohn.Forte@Sun.COM continue;
2727836SJohn.Forte@Sun.COM
2737836SJohn.Forte@Sun.COM cur->collected |= GOT_MSTSTAT;
2747836SJohn.Forte@Sun.COM
2757836SJohn.Forte@Sun.COM /*
2767836SJohn.Forte@Sun.COM * Shadow kstat
2777836SJohn.Forte@Sun.COM */
2787836SJohn.Forte@Sun.COM kname = kstat_value(cur->cur_set, DSW_SKSTAT_SHDIO);
2797836SJohn.Forte@Sun.COM
2807836SJohn.Forte@Sun.COM ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
2817836SJohn.Forte@Sun.COM
2827836SJohn.Forte@Sun.COM if ((cur->cur_shd = kstat_retrieve(kc, ksp)) == NULL)
2837836SJohn.Forte@Sun.COM continue;
2847836SJohn.Forte@Sun.COM
2857836SJohn.Forte@Sun.COM cur->collected |= GOT_SHDSTAT;
2867836SJohn.Forte@Sun.COM
2877836SJohn.Forte@Sun.COM /*
2887836SJohn.Forte@Sun.COM * Bitmap kstat
2897836SJohn.Forte@Sun.COM */
2907836SJohn.Forte@Sun.COM kname = kstat_value(cur->pre_set, DSW_SKSTAT_BMPIO);
2917836SJohn.Forte@Sun.COM
2927836SJohn.Forte@Sun.COM ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
2937836SJohn.Forte@Sun.COM
2947836SJohn.Forte@Sun.COM if ((cur->cur_bmp = kstat_retrieve(kc, ksp)) == NULL)
2957836SJohn.Forte@Sun.COM continue;
2967836SJohn.Forte@Sun.COM
2977836SJohn.Forte@Sun.COM cur->collected |= GOT_BMPSTAT;
2987836SJohn.Forte@Sun.COM
2997836SJohn.Forte@Sun.COM /*
3007836SJohn.Forte@Sun.COM * Overflow kstat
3017836SJohn.Forte@Sun.COM */
3027836SJohn.Forte@Sun.COM kname = kstat_value(cur->cur_set, DSW_SKSTAT_OVRIO);
3037836SJohn.Forte@Sun.COM
3047836SJohn.Forte@Sun.COM ksp = kstat_lookup(kc, II_KSTAT_MODULE, -1, kname);
3057836SJohn.Forte@Sun.COM
3067836SJohn.Forte@Sun.COM if (ksp == NULL) {
3077836SJohn.Forte@Sun.COM if (cur->pre_ovr != NULL) {
3087836SJohn.Forte@Sun.COM kstat_free(cur->pre_ovr);
3097836SJohn.Forte@Sun.COM cur->pre_ovr = NULL;
3107836SJohn.Forte@Sun.COM }
3117836SJohn.Forte@Sun.COM if (cur->cur_ovr != NULL) {
3127836SJohn.Forte@Sun.COM kstat_free(cur->cur_ovr);
3137836SJohn.Forte@Sun.COM cur->cur_ovr = NULL;
3147836SJohn.Forte@Sun.COM }
3157836SJohn.Forte@Sun.COM continue;
3167836SJohn.Forte@Sun.COM }
3177836SJohn.Forte@Sun.COM
3187836SJohn.Forte@Sun.COM if (cur->pre_ovr == NULL) {
3197836SJohn.Forte@Sun.COM if ((cur->pre_ovr = kstat_retrieve(kc, ksp)) == NULL)
3207836SJohn.Forte@Sun.COM continue;
3217836SJohn.Forte@Sun.COM } else {
3227836SJohn.Forte@Sun.COM if ((cur->cur_ovr = kstat_retrieve(kc, ksp)) == NULL)
3237836SJohn.Forte@Sun.COM continue;
3247836SJohn.Forte@Sun.COM }
3257836SJohn.Forte@Sun.COM
3267836SJohn.Forte@Sun.COM cur->collected |= GOT_OVRSTAT;
3277836SJohn.Forte@Sun.COM }
3287836SJohn.Forte@Sun.COM
3297836SJohn.Forte@Sun.COM return (0);
3307836SJohn.Forte@Sun.COM }
3317836SJohn.Forte@Sun.COM
3327836SJohn.Forte@Sun.COM /*
3337836SJohn.Forte@Sun.COM * ii_report() - outputs statistics for the statistics currently being
3347836SJohn.Forte@Sun.COM * monitored. Deletes statistics for volumes that have been disabled.
3357836SJohn.Forte@Sun.COM *
3367836SJohn.Forte@Sun.COM */
3377836SJohn.Forte@Sun.COM int
ii_report()3387836SJohn.Forte@Sun.COM ii_report()
3397836SJohn.Forte@Sun.COM {
3407836SJohn.Forte@Sun.COM uint32_t *flags;
3417836SJohn.Forte@Sun.COM int padsz = 0;
3427836SJohn.Forte@Sun.COM char pad[20] = {0};
3437836SJohn.Forte@Sun.COM iistat_t *cur, *pre = NULL;
3447836SJohn.Forte@Sun.COM
3457836SJohn.Forte@Sun.COM if (ii_top == NULL) {
3467836SJohn.Forte@Sun.COM return (0);
3477836SJohn.Forte@Sun.COM }
3487836SJohn.Forte@Sun.COM
3497836SJohn.Forte@Sun.COM /* Create padding string for secondary report lines */
3507836SJohn.Forte@Sun.COM if (dflags & FLAGS) {
3517836SJohn.Forte@Sun.COM padsz += STAT_HDR_SIZE;
3527836SJohn.Forte@Sun.COM padsz += STAT_HDR_SIZE;
3537836SJohn.Forte@Sun.COM }
3547836SJohn.Forte@Sun.COM
3557836SJohn.Forte@Sun.COM if (dflags & PCTS)
3567836SJohn.Forte@Sun.COM padsz += PCT_HDR_SIZE;
3577836SJohn.Forte@Sun.COM
3587836SJohn.Forte@Sun.COM if (padsz) {
3597836SJohn.Forte@Sun.COM char fmt[20];
360*11576SSurya.Prakki@Sun.COM (void) sprintf(fmt, "%%%ds", padsz);
361*11576SSurya.Prakki@Sun.COM (void) sprintf(pad, fmt, "");
3627836SJohn.Forte@Sun.COM }
3637836SJohn.Forte@Sun.COM
3647836SJohn.Forte@Sun.COM for (cur = ii_top; cur; /* CSTYLED */) {
3657836SJohn.Forte@Sun.COM int first = 1;
3667836SJohn.Forte@Sun.COM char data[20] = {0};
3677836SJohn.Forte@Sun.COM
3687836SJohn.Forte@Sun.COM /* Check to see if this is this a complete */
3697836SJohn.Forte@Sun.COM if (IIMG_COMPLETE(cur->collected)) {
3707836SJohn.Forte@Sun.COM char *c;
3717836SJohn.Forte@Sun.COM char vol[(NAMED_LEN * 4) + 1] = {0};
3727836SJohn.Forte@Sun.COM int offset;
3737836SJohn.Forte@Sun.COM iistat_t *next;
3747836SJohn.Forte@Sun.COM
3757836SJohn.Forte@Sun.COM /* notify user of set being disabled */
3767836SJohn.Forte@Sun.COM c = kstat_value(cur->pre_set, DSW_SKSTAT_SETA);
377*11576SSurya.Prakki@Sun.COM (void) strncpy(vol, c, NAMED_LEN);
3787836SJohn.Forte@Sun.COM c = kstat_value(cur->pre_set, DSW_SKSTAT_SETB);
379*11576SSurya.Prakki@Sun.COM (void) strncat(vol, c, NAMED_LEN);
3807836SJohn.Forte@Sun.COM c = kstat_value(cur->pre_set, DSW_SKSTAT_SETC);
381*11576SSurya.Prakki@Sun.COM (void) strncat(vol, c, NAMED_LEN);
3827836SJohn.Forte@Sun.COM c = kstat_value(cur->pre_set, DSW_SKSTAT_SETD);
383*11576SSurya.Prakki@Sun.COM (void) strncat(vol, c, NAMED_LEN);
3847836SJohn.Forte@Sun.COM
3857836SJohn.Forte@Sun.COM offset = strlen(vol) - NAMED_LEN;
3867836SJohn.Forte@Sun.COM
3877836SJohn.Forte@Sun.COM if (offset < 0)
3887836SJohn.Forte@Sun.COM offset = 0;
3897836SJohn.Forte@Sun.COM
390*11576SSurya.Prakki@Sun.COM (void) printf(DATA_C16, vol + offset);
391*11576SSurya.Prakki@Sun.COM (void) printf(" %s\n", II_DISABLED);
3927836SJohn.Forte@Sun.COM
3937836SJohn.Forte@Sun.COM /* free memory and remove stat from list */
3947836SJohn.Forte@Sun.COM next = ii_del_stat(cur);
3957836SJohn.Forte@Sun.COM
3967836SJohn.Forte@Sun.COM if (! pre)
3977836SJohn.Forte@Sun.COM cur = ii_top = next;
3987836SJohn.Forte@Sun.COM else
3997836SJohn.Forte@Sun.COM cur = pre->next = next;
4007836SJohn.Forte@Sun.COM
4017836SJohn.Forte@Sun.COM continue;
4027836SJohn.Forte@Sun.COM }
4037836SJohn.Forte@Sun.COM
4047836SJohn.Forte@Sun.COM /* Check to see if the user specified this volume */
4057836SJohn.Forte@Sun.COM if (! ii_vol_selected(cur->pre_set))
4067836SJohn.Forte@Sun.COM goto next;
4077836SJohn.Forte@Sun.COM
4087836SJohn.Forte@Sun.COM /* Check to see if zflag applies */
4097836SJohn.Forte@Sun.COM if (zflag && ii_value_check(cur) == 0)
4107836SJohn.Forte@Sun.COM goto next;
4117836SJohn.Forte@Sun.COM
4127836SJohn.Forte@Sun.COM /* Calculate flags */
4137836SJohn.Forte@Sun.COM flags = kstat_value(cur->cur_set, DSW_SKSTAT_FLAGS);
4147836SJohn.Forte@Sun.COM
4157836SJohn.Forte@Sun.COM if (dflags & FLAGS) {
4167836SJohn.Forte@Sun.COM
4177836SJohn.Forte@Sun.COM char c[STAT_HDR_SIZE];
4187836SJohn.Forte@Sun.COM char vtype[STAT_HDR_SIZE];
4197836SJohn.Forte@Sun.COM char vstat[STAT_HDR_SIZE];
4207836SJohn.Forte@Sun.COM
4217836SJohn.Forte@Sun.COM if (*flags & DSW_GOLDEN)
422*11576SSurya.Prakki@Sun.COM (void) strcpy(c, II_INDEPENDENT);
4237836SJohn.Forte@Sun.COM else
424*11576SSurya.Prakki@Sun.COM (void) strcpy(c, II_DEPENDENT);
4257836SJohn.Forte@Sun.COM
426*11576SSurya.Prakki@Sun.COM (void) sprintf(vtype, DATA_C2, c);
427*11576SSurya.Prakki@Sun.COM (void) strcat(data, vtype);
4287836SJohn.Forte@Sun.COM
4297836SJohn.Forte@Sun.COM if (*flags & DSW_COPYINGP)
430*11576SSurya.Prakki@Sun.COM (void) strcpy(c, II_COPYING);
4317836SJohn.Forte@Sun.COM else
432*11576SSurya.Prakki@Sun.COM (void) strcpy(c, NO_INFO);
4337836SJohn.Forte@Sun.COM
4347836SJohn.Forte@Sun.COM
435*11576SSurya.Prakki@Sun.COM (void) sprintf(vstat, DATA_C2, c);
436*11576SSurya.Prakki@Sun.COM (void) strcat(data, vstat);
4377836SJohn.Forte@Sun.COM }
4387836SJohn.Forte@Sun.COM
4397836SJohn.Forte@Sun.COM /* Calculate sync needed precentage */
4407836SJohn.Forte@Sun.COM if (dflags & PCTS) {
4417836SJohn.Forte@Sun.COM char snpct[10];
4427836SJohn.Forte@Sun.COM uint32_t *chkbits;
4437836SJohn.Forte@Sun.COM uint32_t *cpybits;
4447836SJohn.Forte@Sun.COM uint32_t *shdbits;
4457836SJohn.Forte@Sun.COM uint32_t *volsize;
4467836SJohn.Forte@Sun.COM float pct;
4477836SJohn.Forte@Sun.COM
4487836SJohn.Forte@Sun.COM cpybits =
4497836SJohn.Forte@Sun.COM kstat_value(cur->cur_set, DSW_SKSTAT_COPYBITS);
4507836SJohn.Forte@Sun.COM
4517836SJohn.Forte@Sun.COM shdbits =
4527836SJohn.Forte@Sun.COM kstat_value(cur->cur_set, DSW_SKSTAT_SHDBITS);
4537836SJohn.Forte@Sun.COM
4547836SJohn.Forte@Sun.COM volsize =
4557836SJohn.Forte@Sun.COM kstat_value(cur->cur_set, DSW_SKSTAT_SIZE);
4567836SJohn.Forte@Sun.COM
4577836SJohn.Forte@Sun.COM *volsize /= DSW_SIZE;
4587836SJohn.Forte@Sun.COM
4597836SJohn.Forte@Sun.COM chkbits = *cpybits >= *shdbits ? cpybits : shdbits;
4607836SJohn.Forte@Sun.COM
4617836SJohn.Forte@Sun.COM pct = ((float)*chkbits / *volsize) * 100.0;
4627836SJohn.Forte@Sun.COM
463*11576SSurya.Prakki@Sun.COM (void) sprintf(snpct, DATA_F62, pct);
4647836SJohn.Forte@Sun.COM
465*11576SSurya.Prakki@Sun.COM (void) strcat(data, snpct);
4667836SJohn.Forte@Sun.COM }
4677836SJohn.Forte@Sun.COM
4687836SJohn.Forte@Sun.COM /* Master statistics */
4697836SJohn.Forte@Sun.COM if (rflags & IIMG_MST) {
4707836SJohn.Forte@Sun.COM char *c;
4717836SJohn.Forte@Sun.COM char vol[(NAMED_LEN * 4) + 1] = {0};
4727836SJohn.Forte@Sun.COM int offset;
4737836SJohn.Forte@Sun.COM
4747836SJohn.Forte@Sun.COM c = kstat_value(cur->cur_set, DSW_SKSTAT_MSTA);
475*11576SSurya.Prakki@Sun.COM (void) strncat(vol, c, NAMED_LEN);
4767836SJohn.Forte@Sun.COM c = kstat_value(cur->cur_set, DSW_SKSTAT_MSTB);
477*11576SSurya.Prakki@Sun.COM (void) strncat(vol, c, NAMED_LEN);
4787836SJohn.Forte@Sun.COM c = kstat_value(cur->cur_set, DSW_SKSTAT_MSTC);
479*11576SSurya.Prakki@Sun.COM (void) strncat(vol, c, NAMED_LEN);
4807836SJohn.Forte@Sun.COM c = kstat_value(cur->cur_set, DSW_SKSTAT_MSTD);
481*11576SSurya.Prakki@Sun.COM (void) strncat(vol, c, NAMED_LEN);
4827836SJohn.Forte@Sun.COM
4837836SJohn.Forte@Sun.COM offset = strlen(vol) - NAMED_LEN;
4847836SJohn.Forte@Sun.COM
4857836SJohn.Forte@Sun.COM if (offset < 0)
4867836SJohn.Forte@Sun.COM offset = 0;
4877836SJohn.Forte@Sun.COM
4887836SJohn.Forte@Sun.COM header();
489*11576SSurya.Prakki@Sun.COM (void) printf(DATA_C16, vol + offset);
490*11576SSurya.Prakki@Sun.COM (void) printf("%s", data);
491*11576SSurya.Prakki@Sun.COM (void) printf(ROLE_INF_FMT, II_MASTER);
4927836SJohn.Forte@Sun.COM
4937836SJohn.Forte@Sun.COM if (*flags & DSW_MSTOFFLINE) {
494*11576SSurya.Prakki@Sun.COM (void) printf(" <<offline>>");
4957836SJohn.Forte@Sun.COM linesout++;
4967836SJohn.Forte@Sun.COM } else {
49710714SThomas.Atkins@Sun.COM io_report(cur->cur_mst, cur->pre_mst,
4987836SJohn.Forte@Sun.COM sdbc_getstat(vol + offset));
4997836SJohn.Forte@Sun.COM }
5007836SJohn.Forte@Sun.COM
501*11576SSurya.Prakki@Sun.COM (void) printf("\n");
5027836SJohn.Forte@Sun.COM
5037836SJohn.Forte@Sun.COM if (first) {
504*11576SSurya.Prakki@Sun.COM (void) strcpy(data, strlen(pad) > 0 ? pad : "");
5057836SJohn.Forte@Sun.COM first = 0;
5067836SJohn.Forte@Sun.COM }
5077836SJohn.Forte@Sun.COM }
5087836SJohn.Forte@Sun.COM
5097836SJohn.Forte@Sun.COM /* Shadow statistics */
5107836SJohn.Forte@Sun.COM if (rflags & IIMG_SHD) {
5117836SJohn.Forte@Sun.COM char *c;
5127836SJohn.Forte@Sun.COM char vol[(NAMED_LEN * 4) + 1] = {0};
5137836SJohn.Forte@Sun.COM int offset;
5147836SJohn.Forte@Sun.COM
5157836SJohn.Forte@Sun.COM c = kstat_value(cur->cur_set, DSW_SKSTAT_SETA);
516*11576SSurya.Prakki@Sun.COM (void) strncat(vol, c, NAMED_LEN);
5177836SJohn.Forte@Sun.COM c = kstat_value(cur->cur_set, DSW_SKSTAT_SETB);
518*11576SSurya.Prakki@Sun.COM (void) strncat(vol, c, NAMED_LEN);
5197836SJohn.Forte@Sun.COM c = kstat_value(cur->cur_set, DSW_SKSTAT_SETC);
520*11576SSurya.Prakki@Sun.COM (void) strncat(vol, c, NAMED_LEN);
5217836SJohn.Forte@Sun.COM c = kstat_value(cur->cur_set, DSW_SKSTAT_SETD);
522*11576SSurya.Prakki@Sun.COM (void) strncat(vol, c, NAMED_LEN);
5237836SJohn.Forte@Sun.COM
5247836SJohn.Forte@Sun.COM offset = strlen(vol) - NAMED_LEN;
5257836SJohn.Forte@Sun.COM
5267836SJohn.Forte@Sun.COM if (offset < 0)
5277836SJohn.Forte@Sun.COM offset = 0;
5287836SJohn.Forte@Sun.COM
5297836SJohn.Forte@Sun.COM header();
530*11576SSurya.Prakki@Sun.COM (void) printf(DATA_C16, vol + offset);
531*11576SSurya.Prakki@Sun.COM (void) printf("%s", data);
532*11576SSurya.Prakki@Sun.COM (void) printf(ROLE_INF_FMT, II_SHADOW);
5337836SJohn.Forte@Sun.COM
5347836SJohn.Forte@Sun.COM if (*flags & DSW_SHDOFFLINE) {
535*11576SSurya.Prakki@Sun.COM (void) printf(" <<offline>>");
5367836SJohn.Forte@Sun.COM linesout++;
5377836SJohn.Forte@Sun.COM } else {
53810714SThomas.Atkins@Sun.COM io_report(cur->cur_shd, cur->pre_shd,
5397836SJohn.Forte@Sun.COM sdbc_getstat(vol + offset));
5407836SJohn.Forte@Sun.COM }
5417836SJohn.Forte@Sun.COM
542*11576SSurya.Prakki@Sun.COM (void) printf("\n");
5437836SJohn.Forte@Sun.COM
5447836SJohn.Forte@Sun.COM if (first) {
545*11576SSurya.Prakki@Sun.COM (void) strcpy(data, strlen(pad) > 0 ? pad : "");
5467836SJohn.Forte@Sun.COM first = 0;
5477836SJohn.Forte@Sun.COM }
5487836SJohn.Forte@Sun.COM }
5497836SJohn.Forte@Sun.COM
5507836SJohn.Forte@Sun.COM /* Bitmap statistics */
5517836SJohn.Forte@Sun.COM if (rflags & IIMG_BMP) {
5527836SJohn.Forte@Sun.COM char *c;
5537836SJohn.Forte@Sun.COM char vol[(NAMED_LEN * 4) + 1] = {0};
5547836SJohn.Forte@Sun.COM int offset;
5557836SJohn.Forte@Sun.COM
5567836SJohn.Forte@Sun.COM c = kstat_value(cur->cur_set, DSW_SKSTAT_BMPA);
557*11576SSurya.Prakki@Sun.COM (void) strncat(vol, c, NAMED_LEN);
5587836SJohn.Forte@Sun.COM c = kstat_value(cur->cur_set, DSW_SKSTAT_BMPB);
559*11576SSurya.Prakki@Sun.COM (void) strncat(vol, c, NAMED_LEN);
5607836SJohn.Forte@Sun.COM c = kstat_value(cur->cur_set, DSW_SKSTAT_BMPC);
561*11576SSurya.Prakki@Sun.COM (void) strncat(vol, c, NAMED_LEN);
5627836SJohn.Forte@Sun.COM c = kstat_value(cur->cur_set, DSW_SKSTAT_BMPD);
563*11576SSurya.Prakki@Sun.COM (void) strncat(vol, c, NAMED_LEN);
5647836SJohn.Forte@Sun.COM
5657836SJohn.Forte@Sun.COM offset = strlen(vol) - NAMED_LEN;
5667836SJohn.Forte@Sun.COM
5677836SJohn.Forte@Sun.COM if (offset < 0)
5687836SJohn.Forte@Sun.COM offset = 0;
5697836SJohn.Forte@Sun.COM
5707836SJohn.Forte@Sun.COM header();
571*11576SSurya.Prakki@Sun.COM (void) printf(DATA_C16, vol + offset);
572*11576SSurya.Prakki@Sun.COM (void) printf("%s", data);
573*11576SSurya.Prakki@Sun.COM (void) printf(ROLE_INF_FMT, II_BITMAP);
5747836SJohn.Forte@Sun.COM
5757836SJohn.Forte@Sun.COM if (*flags & DSW_BMPOFFLINE) {
576*11576SSurya.Prakki@Sun.COM (void) printf(" <<offline>>");
5777836SJohn.Forte@Sun.COM linesout++;
5787836SJohn.Forte@Sun.COM } else {
57910714SThomas.Atkins@Sun.COM io_report(cur->cur_bmp, cur->pre_bmp,
5807836SJohn.Forte@Sun.COM sdbc_getstat(vol + offset));
5817836SJohn.Forte@Sun.COM }
582*11576SSurya.Prakki@Sun.COM (void) printf("\n");
5837836SJohn.Forte@Sun.COM
5847836SJohn.Forte@Sun.COM if (first) {
585*11576SSurya.Prakki@Sun.COM (void) strcpy(data, strlen(pad) > 0 ? pad : "");
5867836SJohn.Forte@Sun.COM first = 0;
5877836SJohn.Forte@Sun.COM }
5887836SJohn.Forte@Sun.COM }
5897836SJohn.Forte@Sun.COM
5907836SJohn.Forte@Sun.COM /* Overflow statistics */
5917836SJohn.Forte@Sun.COM if (rflags & IIMG_OVR) {
5927836SJohn.Forte@Sun.COM char *c;
5937836SJohn.Forte@Sun.COM char msg[20] = {0};
5947836SJohn.Forte@Sun.COM char vol[(NAMED_LEN * 4) + 1] = {0};
5957836SJohn.Forte@Sun.COM int offset;
5967836SJohn.Forte@Sun.COM
5977836SJohn.Forte@Sun.COM if (cur->cur_ovr == NULL && cur->pre_ovr != NULL)
598*11576SSurya.Prakki@Sun.COM (void) strcpy(msg, " <<attached>>");
5997836SJohn.Forte@Sun.COM
6007836SJohn.Forte@Sun.COM if (! (cur->collected & GOT_OVRSTAT))
601*11576SSurya.Prakki@Sun.COM (void) strcpy(msg, " <<not attached>>");
6027836SJohn.Forte@Sun.COM
6037836SJohn.Forte@Sun.COM c = kstat_value(cur->cur_set, DSW_SKSTAT_OVRA);
604*11576SSurya.Prakki@Sun.COM (void) strncpy(vol, c, NAMED_LEN);
6057836SJohn.Forte@Sun.COM c = kstat_value(cur->cur_set, DSW_SKSTAT_OVRB);
606*11576SSurya.Prakki@Sun.COM (void) strncat(vol, c, NAMED_LEN);
6077836SJohn.Forte@Sun.COM c = kstat_value(cur->cur_set, DSW_SKSTAT_OVRC);
608*11576SSurya.Prakki@Sun.COM (void) strncat(vol, c, NAMED_LEN);
6097836SJohn.Forte@Sun.COM c = kstat_value(cur->cur_set, DSW_SKSTAT_OVRD);
610*11576SSurya.Prakki@Sun.COM (void) strncat(vol, c, NAMED_LEN);
6117836SJohn.Forte@Sun.COM
6127836SJohn.Forte@Sun.COM offset = strlen(vol) - NAMED_LEN;
6137836SJohn.Forte@Sun.COM
6147836SJohn.Forte@Sun.COM if (offset < 0)
6157836SJohn.Forte@Sun.COM offset = 0;
6167836SJohn.Forte@Sun.COM
6177836SJohn.Forte@Sun.COM header();
618*11576SSurya.Prakki@Sun.COM (void) printf(DATA_C16, vol + offset);
619*11576SSurya.Prakki@Sun.COM (void) printf("%s", data);
620*11576SSurya.Prakki@Sun.COM (void) printf(ROLE_INF_FMT, II_OVERFLOW);
6217836SJohn.Forte@Sun.COM
6227836SJohn.Forte@Sun.COM if (strlen(msg)) {
623*11576SSurya.Prakki@Sun.COM (void) printf("%s\n", msg);
6247836SJohn.Forte@Sun.COM linesout++;
6257836SJohn.Forte@Sun.COM goto next;
6267836SJohn.Forte@Sun.COM }
6277836SJohn.Forte@Sun.COM
6287836SJohn.Forte@Sun.COM if (*flags & DSW_OVROFFLINE) {
629*11576SSurya.Prakki@Sun.COM (void) printf(" <<offline>>");
6307836SJohn.Forte@Sun.COM linesout++;
6317836SJohn.Forte@Sun.COM } else {
63210714SThomas.Atkins@Sun.COM io_report(cur->cur_ovr, cur->pre_ovr,
6337836SJohn.Forte@Sun.COM sdbc_getstat(vol + offset));
6347836SJohn.Forte@Sun.COM }
6357836SJohn.Forte@Sun.COM
636*11576SSurya.Prakki@Sun.COM (void) printf("\n");
6377836SJohn.Forte@Sun.COM
6387836SJohn.Forte@Sun.COM if (first) {
639*11576SSurya.Prakki@Sun.COM (void) strcpy(data, strlen(pad) > 0 ? pad : "");
6407836SJohn.Forte@Sun.COM first = 0;
6417836SJohn.Forte@Sun.COM }
6427836SJohn.Forte@Sun.COM }
6437836SJohn.Forte@Sun.COM
6447836SJohn.Forte@Sun.COM
6457836SJohn.Forte@Sun.COM next:
6467836SJohn.Forte@Sun.COM pre = cur;
6477836SJohn.Forte@Sun.COM cur = cur->next;
6487836SJohn.Forte@Sun.COM }
6497836SJohn.Forte@Sun.COM
6507836SJohn.Forte@Sun.COM return (0);
6517836SJohn.Forte@Sun.COM }
6527836SJohn.Forte@Sun.COM
6537836SJohn.Forte@Sun.COM /*
6547836SJohn.Forte@Sun.COM * ii_add_stat() - adds a fully populated iistat_t structure
6557836SJohn.Forte@Sun.COM * to the linked list of currently monitored kstats. The structure
6567836SJohn.Forte@Sun.COM * will be added in alphabetical order, using the volume name of
6577836SJohn.Forte@Sun.COM * the shadow volume as the key.
6587836SJohn.Forte@Sun.COM *
6597836SJohn.Forte@Sun.COM */
6607836SJohn.Forte@Sun.COM void
ii_add_stat(iistat_t * iistat)6617836SJohn.Forte@Sun.COM ii_add_stat(iistat_t *iistat)
6627836SJohn.Forte@Sun.COM {
6637836SJohn.Forte@Sun.COM
6647836SJohn.Forte@Sun.COM iistat_t *cur;
6657836SJohn.Forte@Sun.COM
6667836SJohn.Forte@Sun.COM if (ii_top == NULL) {
6677836SJohn.Forte@Sun.COM ii_top = iistat;
6687836SJohn.Forte@Sun.COM return;
6697836SJohn.Forte@Sun.COM }
6707836SJohn.Forte@Sun.COM
6717836SJohn.Forte@Sun.COM for (cur = ii_top; cur != NULL; cur = cur->next) {
6727836SJohn.Forte@Sun.COM if (strcmp(cur->pre_set->ks_name,
6737836SJohn.Forte@Sun.COM iistat->pre_set->ks_name) <= 0) {
6747836SJohn.Forte@Sun.COM /*
6757836SJohn.Forte@Sun.COM * If we get to the last item in the list, then just
6767836SJohn.Forte@Sun.COM * add this one to the end
6777836SJohn.Forte@Sun.COM */
6787836SJohn.Forte@Sun.COM if (cur->next == NULL) {
6797836SJohn.Forte@Sun.COM cur->next = iistat;
6807836SJohn.Forte@Sun.COM return;
6817836SJohn.Forte@Sun.COM }
6827836SJohn.Forte@Sun.COM
6837836SJohn.Forte@Sun.COM if (strcmp(cur->next->pre_set->ks_name,
6847836SJohn.Forte@Sun.COM iistat->pre_set->ks_name) > 0) {
6857836SJohn.Forte@Sun.COM iistat->next = cur->next;
6867836SJohn.Forte@Sun.COM cur->next = iistat;
6877836SJohn.Forte@Sun.COM return;
6887836SJohn.Forte@Sun.COM }
6897836SJohn.Forte@Sun.COM } else {
6907836SJohn.Forte@Sun.COM if (cur == ii_top)
6917836SJohn.Forte@Sun.COM ii_top = iistat;
6927836SJohn.Forte@Sun.COM
6937836SJohn.Forte@Sun.COM iistat->next = cur;
6947836SJohn.Forte@Sun.COM
6957836SJohn.Forte@Sun.COM return;
6967836SJohn.Forte@Sun.COM }
6977836SJohn.Forte@Sun.COM }
6987836SJohn.Forte@Sun.COM }
6997836SJohn.Forte@Sun.COM
7007836SJohn.Forte@Sun.COM /*
7017836SJohn.Forte@Sun.COM * ii_del_stat() - deallocate memory for the structure being
7027836SJohn.Forte@Sun.COM * passed in.
7037836SJohn.Forte@Sun.COM *
7047836SJohn.Forte@Sun.COM * parameters
7057836SJohn.Forte@Sun.COM * iistat_t *iistat - structure to be deallocated
7067836SJohn.Forte@Sun.COM *
7077836SJohn.Forte@Sun.COM * returns
7087836SJohn.Forte@Sun.COM * iistat_t * - pointer to the "next" structures in the
7097836SJohn.Forte@Sun.COM * linked list. May be NULL if we are removing the last
7107836SJohn.Forte@Sun.COM * structure in the linked list.
7117836SJohn.Forte@Sun.COM *
7127836SJohn.Forte@Sun.COM */
7137836SJohn.Forte@Sun.COM iistat_t *
ii_del_stat(iistat_t * iistat)7147836SJohn.Forte@Sun.COM ii_del_stat(iistat_t *iistat)
7157836SJohn.Forte@Sun.COM {
7167836SJohn.Forte@Sun.COM
7177836SJohn.Forte@Sun.COM iistat_t *next = iistat->next;
7187836SJohn.Forte@Sun.COM
7197836SJohn.Forte@Sun.COM kstat_free(iistat->pre_set);
7207836SJohn.Forte@Sun.COM kstat_free(iistat->pre_mst);
7217836SJohn.Forte@Sun.COM kstat_free(iistat->pre_shd);
7227836SJohn.Forte@Sun.COM kstat_free(iistat->pre_bmp);
7237836SJohn.Forte@Sun.COM kstat_free(iistat->pre_ovr);
7247836SJohn.Forte@Sun.COM kstat_free(iistat->cur_set);
7257836SJohn.Forte@Sun.COM kstat_free(iistat->cur_mst);
7267836SJohn.Forte@Sun.COM kstat_free(iistat->cur_shd);
7277836SJohn.Forte@Sun.COM kstat_free(iistat->cur_bmp);
7287836SJohn.Forte@Sun.COM kstat_free(iistat->cur_ovr);
7297836SJohn.Forte@Sun.COM
7307836SJohn.Forte@Sun.COM free(iistat);
7317836SJohn.Forte@Sun.COM
7327836SJohn.Forte@Sun.COM return (next);
7337836SJohn.Forte@Sun.COM }
7347836SJohn.Forte@Sun.COM
7357836SJohn.Forte@Sun.COM int
ii_value_check(iistat_t * iistat)7367836SJohn.Forte@Sun.COM ii_value_check(iistat_t *iistat)
7377836SJohn.Forte@Sun.COM {
7387836SJohn.Forte@Sun.COM if (IIMG_COMPLETE(iistat->collected))
7397836SJohn.Forte@Sun.COM return (1);
7407836SJohn.Forte@Sun.COM
7417836SJohn.Forte@Sun.COM if (io_value_check(iistat->pre_mst->ks_data,
7427836SJohn.Forte@Sun.COM iistat->cur_mst->ks_data)) {
7437836SJohn.Forte@Sun.COM return (1);
7447836SJohn.Forte@Sun.COM }
7457836SJohn.Forte@Sun.COM
7467836SJohn.Forte@Sun.COM if (io_value_check(iistat->pre_shd->ks_data,
7477836SJohn.Forte@Sun.COM iistat->cur_shd->ks_data)) {
7487836SJohn.Forte@Sun.COM return (1);
7497836SJohn.Forte@Sun.COM }
7507836SJohn.Forte@Sun.COM
7517836SJohn.Forte@Sun.COM if (io_value_check(iistat->pre_bmp->ks_data,
7527836SJohn.Forte@Sun.COM iistat->cur_bmp->ks_data)) {
7537836SJohn.Forte@Sun.COM return (1);
7547836SJohn.Forte@Sun.COM }
7557836SJohn.Forte@Sun.COM
7567836SJohn.Forte@Sun.COM if (iistat->pre_ovr && iistat->cur_ovr) {
7577836SJohn.Forte@Sun.COM if (io_value_check(iistat->pre_ovr->ks_data,
7587836SJohn.Forte@Sun.COM iistat->cur_ovr->ks_data)) {
7597836SJohn.Forte@Sun.COM return (1);
7607836SJohn.Forte@Sun.COM }
7617836SJohn.Forte@Sun.COM }
7627836SJohn.Forte@Sun.COM
7637836SJohn.Forte@Sun.COM return (0);
7647836SJohn.Forte@Sun.COM }
7657836SJohn.Forte@Sun.COM
7667836SJohn.Forte@Sun.COM int
ii_validate(kstat_t * ksp)7677836SJohn.Forte@Sun.COM ii_validate(kstat_t *ksp)
7687836SJohn.Forte@Sun.COM {
7697836SJohn.Forte@Sun.COM if (! kstat_value(ksp, DSW_SKSTAT_MSTIO) ||
7707836SJohn.Forte@Sun.COM ! kstat_value(ksp, DSW_SKSTAT_SHDIO) ||
7717836SJohn.Forte@Sun.COM ! kstat_value(ksp, DSW_SKSTAT_BMPIO) ||
7727836SJohn.Forte@Sun.COM ! kstat_value(ksp, DSW_SKSTAT_OVRIO) ||
7737836SJohn.Forte@Sun.COM ! kstat_value(ksp, DSW_SKSTAT_FLAGS) ||
7747836SJohn.Forte@Sun.COM ! kstat_value(ksp, DSW_SKSTAT_MSTA) ||
7757836SJohn.Forte@Sun.COM ! kstat_value(ksp, DSW_SKSTAT_SETA) ||
7767836SJohn.Forte@Sun.COM ! kstat_value(ksp, DSW_SKSTAT_BMPA) ||
7777836SJohn.Forte@Sun.COM ! kstat_value(ksp, DSW_SKSTAT_OVRA) ||
7787836SJohn.Forte@Sun.COM ! kstat_value(ksp, DSW_SKSTAT_SHDBITS) ||
7797836SJohn.Forte@Sun.COM ! kstat_value(ksp, DSW_SKSTAT_COPYBITS) ||
7807836SJohn.Forte@Sun.COM ! kstat_value(ksp, DSW_SKSTAT_SIZE))
7817836SJohn.Forte@Sun.COM return (1);
7827836SJohn.Forte@Sun.COM
7837836SJohn.Forte@Sun.COM return (0);
7847836SJohn.Forte@Sun.COM }
7857836SJohn.Forte@Sun.COM
7867836SJohn.Forte@Sun.COM int
ii_vol_selected(kstat_t * ksp)7877836SJohn.Forte@Sun.COM ii_vol_selected(kstat_t *ksp)
7887836SJohn.Forte@Sun.COM {
7897836SJohn.Forte@Sun.COM vslist_t *vslist = vs_top;
7907836SJohn.Forte@Sun.COM
7917836SJohn.Forte@Sun.COM for (vslist = vs_top; vslist != NULL; vslist = vslist->next) {
7927836SJohn.Forte@Sun.COM char *vn;
7937836SJohn.Forte@Sun.COM int off = 0;
7947836SJohn.Forte@Sun.COM
7957836SJohn.Forte@Sun.COM vn = ksp->ks_name;
7967836SJohn.Forte@Sun.COM
7977836SJohn.Forte@Sun.COM if ((off = strlen(vn) - NAMED_LEN) <= 0) {
7987836SJohn.Forte@Sun.COM off = 0;
7997836SJohn.Forte@Sun.COM }
8007836SJohn.Forte@Sun.COM
8017836SJohn.Forte@Sun.COM if (strcmp(vslist->volname, &vn[off]) == 0) {
8027836SJohn.Forte@Sun.COM break;
8037836SJohn.Forte@Sun.COM }
8047836SJohn.Forte@Sun.COM }
8057836SJohn.Forte@Sun.COM
8067836SJohn.Forte@Sun.COM if (vs_top != NULL && vslist == NULL) {
8077836SJohn.Forte@Sun.COM return (0);
8087836SJohn.Forte@Sun.COM } else {
8097836SJohn.Forte@Sun.COM return (1);
8107836SJohn.Forte@Sun.COM }
8117836SJohn.Forte@Sun.COM }
812