diff options
author | hrs <hrs@FreeBSD.org> | 2014-09-10 22:34:08 +0000 |
---|---|---|
committer | hrs <hrs@FreeBSD.org> | 2014-09-10 22:34:08 +0000 |
commit | 3a5e9986076b0ba01721c639f18b17277d15b29e (patch) | |
tree | e3b8a306baaf6a7e4ce471abcf84d2b4c9cdcb07 /usr.bin | |
parent | fa53fae9e4783e35e0dfe1b2a3b7c12c507ecc7a (diff) | |
download | FreeBSD-src-3a5e9986076b0ba01721c639f18b17277d15b29e.zip FreeBSD-src-3a5e9986076b0ba01721c639f18b17277d15b29e.tar.gz |
Fix header output when -P is specified and (ncpus - 1) != maxid.
Reported by: Hiroaki Shimizu
PR: 152738
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/vmstat/vmstat.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index 227f3c2..669ac3f 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -657,6 +657,8 @@ dovmstat(unsigned int interval, int reps) uptime = getuptime(); halfuptime = uptime / 2; rate_adj = 1; + ncpus = 1; + maxid = 0; /* * If the user stops the program (control-Z) and then resumes it, @@ -702,7 +704,7 @@ dovmstat(unsigned int interval, int reps) } for (hdrcnt = 1;;) { if (!--hdrcnt) - printhdr(ncpus, cpumask); + printhdr(maxid, cpumask); if (kd != NULL) { if (kvm_getcptime(kd, cur.cp_time) < 0) errx(1, "kvm_getcptime: %s", kvm_geterr(kd)); @@ -753,7 +755,7 @@ dovmstat(unsigned int interval, int reps) errx(1, "%s", devstat_errbuf); break; case 1: - printhdr(ncpus, cpumask); + printhdr(maxid, cpumask); break; default: break; @@ -822,7 +824,7 @@ dovmstat(unsigned int interval, int reps) } static void -printhdr(int ncpus, u_long cpumask) +printhdr(int maxid, u_long cpumask) { int i, num_shown; @@ -834,7 +836,7 @@ printhdr(int ncpus, u_long cpumask) (void)printf("disk"); (void)printf(" faults "); if (Pflag) { - for (i = 0; i < ncpus; i++) { + for (i = 0; i <= maxid; i++) { if (cpumask & (1ul << i)) printf("cpu%-2d ", i); } @@ -850,8 +852,10 @@ printhdr(int ncpus, u_long cpumask) dev_select[i].unit_number); (void)printf(" in sy cs"); if (Pflag) { - for (i = 0; i < ncpus; i++) - printf(" us sy id"); + for (i = 0; i <= maxid; i++) { + if (cpumask & (1ul << i)) + printf(" us sy id"); + } printf("\n"); } else printf(" us sy id\n"); |