Module Name:    src
Committed By:   mrg
Date:           Sat Sep  9 23:51:58 UTC 2017

Modified Files:
        src/usr.sbin/iostat: iostat.c

Log Message:
two minor fixes for -x and -y mode:
- the header is only 1 line not 2, account for this when calculating
  when to display the next header.
- when ndrives > 1, don't display the header every time, but only when
  the previous one disappears.

now i don't feel the need to run "iostat -x wd0 1 & iostat -c wd1 1"
to get less repeated header output on my display.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/usr.sbin/iostat/iostat.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.sbin/iostat/iostat.c
diff -u src/usr.sbin/iostat/iostat.c:1.65 src/usr.sbin/iostat/iostat.c:1.66
--- src/usr.sbin/iostat/iostat.c:1.65	Tue Jul  4 21:19:33 2017
+++ src/usr.sbin/iostat/iostat.c	Sat Sep  9 23:51:58 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: iostat.c,v 1.65 2017/07/04 21:19:33 mlelstv Exp $	*/
+/*	$NetBSD: iostat.c,v 1.66 2017/09/09 23:51:58 mrg Exp $	*/
 
 /*
  * Copyright (c) 1996 John M. Vinopal
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1986, 19
 #if 0
 static char sccsid[] = "@(#)iostat.c	8.3 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: iostat.c,v 1.65 2017/07/04 21:19:33 mlelstv Exp $");
+__RCSID("$NetBSD: iostat.c,v 1.66 2017/09/09 23:51:58 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -129,7 +129,7 @@ static int selectdrives(int, char *[]);
 int
 main(int argc, char *argv[])
 {
-	int ch, hdrcnt, ndrives, lines;
+	int ch, hdrcnt, hdroffset, ndrives, lines;
 	struct timespec	tv;
 	struct ttysize ts;
 
@@ -210,10 +210,13 @@ main(int argc, char *argv[])
 		if (todo == 0)
 			errx(1, "no drives");
 	}
-	if (ISSET(todo, SHOW_STATS_X | SHOW_STATS_Y))
+	if (ISSET(todo, SHOW_STATS_X | SHOW_STATS_Y)) {
 		lines = ndrives;
-	else
+		hdroffset = 3;
+	} else {
 		lines = 1;
+		hdroffset = 4;
+	}
 
 	tv.tv_sec = interval;
 	tv.tv_nsec = 0;
@@ -222,10 +225,10 @@ main(int argc, char *argv[])
 	(void)signal(SIGCONT, sig_header);
 
 	for (hdrcnt = 1;;) {
-		if (do_header || lines > 1 || (hdrcnt -= lines) <= 0) {
+		if (do_header || (hdrcnt -= lines) <= 0) {
 			do_header = 0;
 			header();
-			hdrcnt = winlines - 4;
+			hdrcnt = winlines - hdroffset;
 		}
 
 		if (!ISSET(todo, SHOW_TOTALS)) {

Reply via email to