Sun Oct 25 02:47:17 2015 UTC ()
extend the "tout" column to 5 characters, it's really common on a modern
machine to have eg, build output way more than 9999 chars/sec.

this doesn't affect the default disk list on an 80-char wide screen.


(mrg)
diff -r1.62 -r1.63 src/usr.sbin/iostat/iostat.c

cvs diff -r1.62 -r1.63 src/usr.sbin/iostat/iostat.c (expand / switch to unified diff)

--- src/usr.sbin/iostat/iostat.c 2015/07/09 13:26:52 1.62
+++ src/usr.sbin/iostat/iostat.c 2015/10/25 02:47:17 1.63
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: iostat.c,v 1.62 2015/07/09 13:26:52 mrg Exp $ */ 1/* $NetBSD: iostat.c,v 1.63 2015/10/25 02:47:17 mrg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 John M. Vinopal 4 * Copyright (c) 1996 John M. Vinopal
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -61,27 +61,27 @@ @@ -61,27 +61,27 @@
61 * SUCH DAMAGE. 61 * SUCH DAMAGE.
62 */ 62 */
63 63
64#include <sys/cdefs.h> 64#include <sys/cdefs.h>
65#ifndef lint 65#ifndef lint
66__COPYRIGHT("@(#) Copyright (c) 1986, 1991, 1993\ 66__COPYRIGHT("@(#) Copyright (c) 1986, 1991, 1993\
67 The Regents of the University of California. All rights reserved."); 67 The Regents of the University of California. All rights reserved.");
68#endif /* not lint */ 68#endif /* not lint */
69 69
70#ifndef lint 70#ifndef lint
71#if 0 71#if 0
72static char sccsid[] = "@(#)iostat.c 8.3 (Berkeley) 4/28/95"; 72static char sccsid[] = "@(#)iostat.c 8.3 (Berkeley) 4/28/95";
73#else 73#else
74__RCSID("$NetBSD: iostat.c,v 1.62 2015/07/09 13:26:52 mrg Exp $"); 74__RCSID("$NetBSD: iostat.c,v 1.63 2015/10/25 02:47:17 mrg Exp $");
75#endif 75#endif
76#endif /* not lint */ 76#endif /* not lint */
77 77
78#include <sys/types.h> 78#include <sys/types.h>
79#include <sys/ioctl.h> 79#include <sys/ioctl.h>
80#include <sys/sched.h> 80#include <sys/sched.h>
81#include <sys/time.h> 81#include <sys/time.h>
82 82
83#include <err.h> 83#include <err.h>
84#include <ctype.h> 84#include <ctype.h>
85#include <signal.h> 85#include <signal.h>
86#include <stdio.h> 86#include <stdio.h>
87#include <stdlib.h> 87#include <stdlib.h>
@@ -174,27 +174,27 @@ main(int argc, char *argv[]) @@ -174,27 +174,27 @@ main(int argc, char *argv[])
174 } 174 }
175 175
176 if (ioctl(STDOUT_FILENO, TIOCGSIZE, &ts) != -1) { 176 if (ioctl(STDOUT_FILENO, TIOCGSIZE, &ts) != -1) {
177 if (ts.ts_lines) 177 if (ts.ts_lines)
178 winlines = ts.ts_lines; 178 winlines = ts.ts_lines;
179 if (ts.ts_cols) 179 if (ts.ts_cols)
180 wincols = ts.ts_cols; 180 wincols = ts.ts_cols;
181 } 181 }
182 182
183 defdrives = wincols; 183 defdrives = wincols;
184 if (ISSET(todo, SHOW_CPU)) 184 if (ISSET(todo, SHOW_CPU))
185 defdrives -= 16; /* XXX magic number */ 185 defdrives -= 16; /* XXX magic number */
186 if (ISSET(todo, SHOW_TTY)) 186 if (ISSET(todo, SHOW_TTY))
187 defdrives -= 9; /* XXX magic number */ 187 defdrives -= 10; /* XXX magic number */
188 defdrives /= 18; /* XXX magic number */ 188 defdrives /= 18; /* XXX magic number */
189 189
190 drvinit(0); 190 drvinit(0);
191 cpureadstats(); 191 cpureadstats();
192 drvreadstats(); 192 drvreadstats();
193 ndrives = selectdrives(argc, argv); 193 ndrives = selectdrives(argc, argv);
194 if (ndrives == 0) { 194 if (ndrives == 0) {
195 /* No drives are selected. No need to show drive stats. */ 195 /* No drives are selected. No need to show drive stats. */
196 todo &= ~SHOW_STATS_ALL; 196 todo &= ~SHOW_STATS_ALL;
197 if (todo == 0) 197 if (todo == 0)
198 errx(1, "no drives"); 198 errx(1, "no drives");
199 } 199 }
200 if (ISSET(todo, SHOW_STATS_X)) 200 if (ISSET(todo, SHOW_STATS_X))
@@ -269,27 +269,27 @@ header(void) @@ -269,27 +269,27 @@ header(void)
269 if (ISSET(todo, SHOW_STATS_2)) { 269 if (ISSET(todo, SHOW_STATS_2)) {
270 for (i = 0; i < ndrive; i++) 270 for (i = 0; i < ndrive; i++)
271 if (cur.select[i]) 271 if (cur.select[i])
272 (void)printf(" %9.9s ", cur.name[i]); 272 (void)printf(" %9.9s ", cur.name[i]);
273 } 273 }
274 274
275 if (ISSET(todo, SHOW_CPU)) 275 if (ISSET(todo, SHOW_CPU))
276 (void)printf(" CPU"); 276 (void)printf(" CPU");
277 277
278 printf("\n"); 278 printf("\n");
279 279
280 /* Sub-Headers. */ 280 /* Sub-Headers. */
281 if (ISSET(todo, SHOW_TTY)) 281 if (ISSET(todo, SHOW_TTY))
282 printf(" tin tout"); 282 printf(" tin tout");
283 283
284 if (ISSET(todo, SHOW_STATS_1)) { 284 if (ISSET(todo, SHOW_STATS_1)) {
285 for (i = 0; i < ndrive; i++) 285 for (i = 0; i < ndrive; i++)
286 if (cur.select[i]) { 286 if (cur.select[i]) {
287 if (ISSET(todo, SHOW_TOTALS)) 287 if (ISSET(todo, SHOW_TOTALS))
288 (void)printf(" KB/t xfr MB "); 288 (void)printf(" KB/t xfr MB ");
289 else 289 else
290 (void)printf(" KB/t t/s MB/s "); 290 (void)printf(" KB/t t/s MB/s ");
291 } 291 }
292 } 292 }
293 293
294 if (ISSET(todo, SHOW_STATS_2)) { 294 if (ISSET(todo, SHOW_STATS_2)) {
295 for (i = 0; i < ndrive; i++) 295 for (i = 0; i < ndrive; i++)
@@ -458,27 +458,27 @@ display(void) @@ -458,27 +458,27 @@ display(void)
458 /* 458 /*
459 * If we're showing totals only, then don't divide by the 459 * If we're showing totals only, then don't divide by the
460 * system time. 460 * system time.
461 */ 461 */
462 if (ISSET(todo, SHOW_TOTALS)) 462 if (ISSET(todo, SHOW_TOTALS))
463 etime = 1.0; 463 etime = 1.0;
464 464
465 if (ISSET(todo, SHOW_STATS_X)) { 465 if (ISSET(todo, SHOW_STATS_X)) {
466 drive_statsx(etime); 466 drive_statsx(etime);
467 goto out; 467 goto out;
468 } 468 }
469 469
470 if (ISSET(todo, SHOW_TTY)) 470 if (ISSET(todo, SHOW_TTY))
471 printf("%4.0f %4.0f", cur.tk_nin / etime, cur.tk_nout / etime); 471 printf("%4.0f %5.0f", cur.tk_nin / etime, cur.tk_nout / etime);
472 472
473 if (ISSET(todo, SHOW_STATS_1)) { 473 if (ISSET(todo, SHOW_STATS_1)) {
474 drive_stats(etime); 474 drive_stats(etime);
475 } 475 }
476 476
477 477
478 if (ISSET(todo, SHOW_STATS_2)) { 478 if (ISSET(todo, SHOW_STATS_2)) {
479 drive_stats2(etime); 479 drive_stats2(etime);
480 } 480 }
481 481
482 482
483 if (ISSET(todo, SHOW_CPU)) 483 if (ISSET(todo, SHOW_CPU))
484 cpustats(); 484 cpustats();