diff options
author | hrs <hrs@FreeBSD.org> | 2014-10-09 23:42:22 +0000 |
---|---|---|
committer | hrs <hrs@FreeBSD.org> | 2014-10-09 23:42:22 +0000 |
commit | a95d28f3718e978370e17d89be70d47af45f12e6 (patch) | |
tree | 091e3a02f3d90d5caabccbe4c6fc39f7502d6c1e /usr.bin | |
parent | b877e6c4f28516c1cee28839e91eb092b44962c8 (diff) | |
download | FreeBSD-src-a95d28f3718e978370e17d89be70d47af45f12e6.zip FreeBSD-src-a95d28f3718e978370e17d89be70d47af45f12e6.tar.gz |
MFC r271410:
Fix header output when -P is specified and (ncpus - 1) != maxid.
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 c089dbf..24a3f2f 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -650,6 +650,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, @@ -695,7 +697,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)); @@ -746,7 +748,7 @@ dovmstat(unsigned int interval, int reps) errx(1, "%s", devstat_errbuf); break; case 1: - printhdr(ncpus, cpumask); + printhdr(maxid, cpumask); break; default: break; @@ -815,7 +817,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; @@ -827,7 +829,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); } @@ -843,8 +845,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"); |