Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/iostat two minor fixes for -x and -y mode:



details:   https://anonhg.NetBSD.org/src/rev/c7a811f20c23
branches:  trunk
changeset: 826518:c7a811f20c23
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sat Sep 09 23:51:58 2017 +0000

description:
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.

diffstat:

 usr.sbin/iostat/iostat.c |  17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diffs (56 lines):

diff -r ecde695b312e -r c7a811f20c23 usr.sbin/iostat/iostat.c
--- a/usr.sbin/iostat/iostat.c  Sat Sep 09 23:21:45 2017 +0000
+++ b/usr.sbin/iostat/iostat.c  Sat Sep 09 23:51:58 2017 +0000
@@ -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 @@
 #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 @@
 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 @@
                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 @@
        (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)) {



Home | Main Index | Thread Index | Old Index