Module Name: src Committed By: nakayama Date: Wed Feb 16 12:58:38 UTC 2011
Modified Files: src/usr.bin/vmstat: vmstat.c Log Message: Fix header, format and total count of system interrupt counters. To generate a diff of this commit: cvs rdiff -u -r1.179 -r1.180 src/usr.bin/vmstat/vmstat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/vmstat/vmstat.c diff -u src/usr.bin/vmstat/vmstat.c:1.179 src/usr.bin/vmstat/vmstat.c:1.180 --- src/usr.bin/vmstat/vmstat.c:1.179 Sat Feb 5 13:12:07 2011 +++ src/usr.bin/vmstat/vmstat.c Wed Feb 16 12:58:38 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: vmstat.c,v 1.179 2011/02/05 13:12:07 mlelstv Exp $ */ +/* $NetBSD: vmstat.c,v 1.180 2011/02/16 12:58:38 nakayama Exp $ */ /*- * Copyright (c) 1998, 2000, 2001, 2007 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ #if 0 static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 3/1/95"; #else -__RCSID("$NetBSD: vmstat.c,v 1.179 2011/02/05 13:12:07 mlelstv Exp $"); +__RCSID("$NetBSD: vmstat.c,v 1.180 2011/02/16 12:58:38 nakayama Exp $"); #endif #endif /* not lint */ @@ -1137,7 +1137,9 @@ counttotal = 0; uptime = getuptime(); - (void)printf("%-34s %16s %8s %s\n", "event", "total", "rate", "type"); + if (type == EVCNT_TYPE_ANY) + (void)printf("%-34s %16s %8s %s\n", "event", "total", "rate", + "type"); if (memf == NULL) do { const int mib[4] = { CTL_KERN, KERN_EVCNT, type, @@ -1175,7 +1177,9 @@ while (evs < last_evs && buflen >= sizeof(*evs)/sizeof(uint64_t) && buflen >= evs->ev_len) { - (void)printf("%s %s%*s %16"PRIu64" %8"PRIu64" %s\n", + (void)printf(type == EVCNT_TYPE_ANY ? + "%s %s%*s %16"PRIu64" %8"PRIu64" %s\n" : + "%s %s%*s %16"PRIu64" %8"PRIu64"\n", evs->ev_strings, evs->ev_strings + evs->ev_grouplen + 1, 34 - (evs->ev_grouplen + 1 + evs->ev_namelen), "", @@ -1184,8 +1188,8 @@ (evs->ev_type < __arraycount(evtypes) ? evtypes[evs->ev_type] : "?")); buflen -= evs->ev_len; + counttotal += evs->ev_count; evs = (const void *)((const uint64_t *)evs + evs->ev_len); - counttotal += evcnt.ev_count++; } free(buf); if (type != EVCNT_TYPE_ANY) @@ -1211,7 +1215,9 @@ deref_kptr(evcnt.ev_name, evname, (size_t)evcnt.ev_namelen + 1, "event chain trashed"); - (void)printf("%s %s%*s %16"PRIu64" %8"PRIu64" %s\n", + (void)printf(type == EVCNT_TYPE_ANY ? + "%s %s%*s %16"PRIu64" %8"PRIu64" %s\n" : + "%s %s%*s %16"PRIu64" %8"PRIu64"\n", evgroup, evname, 34 - (evcnt.ev_grouplen + 1 + evcnt.ev_namelen), "", evcnt.ev_count, @@ -1219,7 +1225,7 @@ (evcnt.ev_type < __arraycount(evtypes) ? evtypes[evcnt.ev_type] : "?")); - counttotal += evcnt.ev_count++; + counttotal += evcnt.ev_count; } if (type != EVCNT_TYPE_ANY) (void)printf("%-34s %16"PRIu64" %8"PRIu64"\n",