Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/systat Always use_sysctl in preparation of removing ...



details:   https://anonhg.NetBSD.org/src/rev/f8fb72912db0
branches:  trunk
changeset: 329691:f8fb72912db0
user:      joerg <joerg%NetBSD.org@localhost>
date:      Tue Jun 03 22:22:41 2014 +0000

description:
Always use_sysctl in preparation of removing all kvm code.

diffstat:

 usr.bin/systat/extern.h |   3 +--
 usr.bin/systat/icmp.c   |  35 +++++------------------------------
 usr.bin/systat/ip.c     |  46 +++++++++-------------------------------------
 usr.bin/systat/ip6.c    |  35 +++++------------------------------
 usr.bin/systat/main.c   |   6 ++----
 usr.bin/systat/tcp.c    |  35 +++++------------------------------
 6 files changed, 27 insertions(+), 133 deletions(-)

diffs (truncated from 343 to 300 lines):

diff -r 12018d27c6d1 -r f8fb72912db0 usr.bin/systat/extern.h
--- a/usr.bin/systat/extern.h   Tue Jun 03 21:56:30 2014 +0000
+++ b/usr.bin/systat/extern.h   Tue Jun 03 22:22:41 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.42 2012/01/06 14:08:08 drochner Exp $     */
+/*     $NetBSD: extern.h,v 1.43 2014/06/03 22:22:41 joerg Exp $        */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -60,7 +60,6 @@
 extern int     allflag;
 extern int     turns;
 extern gid_t   egid;
-extern int     use_sysctl;
 
 struct inpcb;
 #ifdef INET6
diff -r 12018d27c6d1 -r f8fb72912db0 usr.bin/systat/icmp.c
--- a/usr.bin/systat/icmp.c     Tue Jun 03 21:56:30 2014 +0000
+++ b/usr.bin/systat/icmp.c     Tue Jun 03 22:22:41 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: icmp.c,v 1.12 2008/04/10 17:16:39 thorpej Exp $        */
+/*     $NetBSD: icmp.c,v 1.13 2014/06/03 22:22:41 joerg Exp $  */
 
 /*
  * Copyright (c) 1999, 2000 Andrew Doran <ad%NetBSD.org@localhost>
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: icmp.c,v 1.12 2008/04/10 17:16:39 thorpej Exp $");
+__RCSID("$NetBSD: icmp.c,v 1.13 2014/06/03 22:22:41 joerg Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -65,11 +65,6 @@
 static uint64_t newstat[ICMP_NSTATS];
 static uint64_t oldstat[ICMP_NSTATS];
 
-static struct nlist namelist[] = {
-       { .n_name = "_icmpstat" },
-       { .n_name = NULL }
-};
-
 WINDOW *
 openicmp(void)
 {
@@ -160,36 +155,16 @@
 initicmp(void)
 {
 
-       if (! use_sysctl) {
-               if (namelist[0].n_type == 0) {
-                       if (kvm_nlist(kd, namelist)) {
-                               nlisterr(namelist);
-                               return(0);
-                       }
-                       if (namelist[0].n_type == 0) {
-                               error("No namelist");
-                               return(0);
-                       }
-               }
-       }
-       
        return (1);
 }
 
 void
 fetchicmp(void)
 {
-       int i;
-
-       if (use_sysctl) {
-               size_t size = sizeof(newstat);
+       size_t i, size = sizeof(newstat);
 
-               if (sysctlbyname("net.inet.icmp.stats", newstat, &size,
-                                NULL, 0) == -1)
-                       return;
-       } else {
-               KREAD((void *)namelist[0].n_value, newstat, sizeof(newstat));
-       }
+       if (sysctlbyname("net.inet.icmp.stats", newstat, &size, NULL, 0) == -1)
+               return;
 
        xADJINETCTR(curstat, oldstat, newstat, ICMP_STAT_BADCODE);
        xADJINETCTR(curstat, oldstat, newstat, ICMP_STAT_BADLEN);
diff -r 12018d27c6d1 -r f8fb72912db0 usr.bin/systat/ip.c
--- a/usr.bin/systat/ip.c       Tue Jun 03 21:56:30 2014 +0000
+++ b/usr.bin/systat/ip.c       Tue Jun 03 22:22:41 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip.c,v 1.17 2008/04/10 17:16:39 thorpej Exp $  */
+/*     $NetBSD: ip.c,v 1.18 2014/06/03 22:22:41 joerg Exp $    */
 
 /*
  * Copyright (c) 1999, 2000 Andrew Doran <ad%NetBSD.org@localhost>
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ip.c,v 1.17 2008/04/10 17:16:39 thorpej Exp $");
+__RCSID("$NetBSD: ip.c,v 1.18 2014/06/03 22:22:41 joerg Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -68,12 +68,6 @@
 static struct mystat oldstat;
 static struct mystat newstat;
 
-static struct nlist namelist[] = {
-       { .n_name = "_ipstat" },
-       { .n_name = "_udpstat" },
-       { .n_name = NULL }
-};
-
 WINDOW *
 openip(void)
 {
@@ -186,42 +180,20 @@
 initip(void)
 {
 
-       if (! use_sysctl) {
-               if (namelist[0].n_type == 0) {
-                       if (kvm_nlist(kd, namelist)) {
-                               nlisterr(namelist);
-                               return(0);
-                       }
-                       if ((namelist[0].n_type | namelist[1].n_type) == 0) {
-                               error("No namelist");
-                               return(0);
-                       }
-               }
-       }
        return 1;
 }
 
 void
 fetchip(void)
 {
-
-       if (use_sysctl) {
-               size_t size;
+       size_t size;
 
-               size = sizeof(newstat.i);
-               if (sysctlbyname("net.inet.ip.stats", newstat.i, &size,
-                                NULL, 0) == -1)
-                       return;
-               size = sizeof(newstat.u);
-               if (sysctlbyname("net.inet.udp.stats", newstat.u, &size,
-                                NULL, 0) == -1)
-                       return;
-       } else {
-               KREAD((void *)namelist[0].n_value, newstat.i, 
-                   sizeof(newstat.i));
-               KREAD((void *)namelist[1].n_value, newstat.u, 
-                   sizeof(newstat.u));
-       }
+       size = sizeof(newstat.i);
+       if (sysctlbyname("net.inet.ip.stats", newstat.i, &size, NULL, 0) == -1)
+               return;
+       size = sizeof(newstat.u);
+       if (sysctlbyname("net.inet.udp.stats", newstat.u, &size, NULL, 0) == -1)
+               return;
 
        ADJINETCTR(curstat, oldstat, newstat, i[IP_STAT_TOTAL]);
        ADJINETCTR(curstat, oldstat, newstat, i[IP_STAT_DELIVERED]);
diff -r 12018d27c6d1 -r f8fb72912db0 usr.bin/systat/ip6.c
--- a/usr.bin/systat/ip6.c      Tue Jun 03 21:56:30 2014 +0000
+++ b/usr.bin/systat/ip6.c      Tue Jun 03 22:22:41 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip6.c,v 1.15 2008/04/10 17:16:39 thorpej Exp $ */
+/*     $NetBSD: ip6.c,v 1.16 2014/06/03 22:22:41 joerg Exp $   */
 
 /*
  * Copyright (c) 1999, 2000 Andrew Doran <ad%NetBSD.org@localhost>
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ip6.c,v 1.15 2008/04/10 17:16:39 thorpej Exp $");
+__RCSID("$NetBSD: ip6.c,v 1.16 2014/06/03 22:22:41 joerg Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -61,11 +61,6 @@
 static uint64_t newstat[IP6_NSTATS];
 static uint64_t oldstat[IP6_NSTATS];
 
-static struct nlist namelist[] = {
-       { .n_name = "_ip6stat" },
-       { .n_name = NULL }
-};
-
 WINDOW *
 openip6(void)
 {
@@ -184,37 +179,17 @@
 int
 initip6(void)
 {
-       int n;
 
-       if (! use_sysctl) {
-               if (namelist[0].n_type == 0) {
-                       n = kvm_nlist(kd, namelist);
-                       if (n < 0) {
-                               nlisterr(namelist);
-                               return(0);
-                       } else if (n == sizeof(namelist) / sizeof(namelist[0]) - 1) {
-                               error("No namelist");
-                               return(0);
-                       }
-               }
-       }
        return 1;
 }
 
 void
 fetchip6(void)
 {
-       int i;
-
-       if (use_sysctl) {
-               size_t size = sizeof(newstat);
+       size_t i, size = sizeof(newstat);
 
-               if (sysctlbyname("net.inet6.ip6.stats", newstat, &size,
-                                NULL, 0) == -1)
-                       return;
-       } else {
-               KREAD((void *)namelist[0].n_value, newstat, sizeof(newstat));
-       }
+       if (sysctlbyname("net.inet6.ip6.stats", newstat, &size, NULL, 0) == -1)
+               return;
 
        for (i = 0; i < IP6_NSTATS; i++)
                xADJINETCTR(curstat, oldstat, newstat, i);
diff -r 12018d27c6d1 -r f8fb72912db0 usr.bin/systat/main.c
--- a/usr.bin/systat/main.c     Tue Jun 03 21:56:30 2014 +0000
+++ b/usr.bin/systat/main.c     Tue Jun 03 22:22:41 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.47 2012/11/23 03:47:36 christos Exp $       */
+/*     $NetBSD: main.c,v 1.48 2014/06/03 22:22:41 joerg Exp $  */
 
 /*-
  * Copyright (c) 1980, 1992, 1993
@@ -36,7 +36,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: main.c,v 1.47 2012/11/23 03:47:36 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.48 2014/06/03 22:22:41 joerg Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -78,7 +78,6 @@
 int     allflag;
 int     allcounter;
 sig_atomic_t needsredraw = 0;
-int    use_sysctl = 1;
 
 static WINDOW *wload;                  /* one line window for load average */
 
@@ -106,7 +105,6 @@
                switch(ch) {
                case 'M':
                        memf = optarg;
-                       use_sysctl = 0;
                        break;
                case 'N':
                        nlistf = optarg;
diff -r 12018d27c6d1 -r f8fb72912db0 usr.bin/systat/tcp.c
--- a/usr.bin/systat/tcp.c      Tue Jun 03 21:56:30 2014 +0000
+++ b/usr.bin/systat/tcp.c      Tue Jun 03 22:22:41 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp.c,v 1.15 2008/04/10 17:16:39 thorpej Exp $ */
+/*     $NetBSD: tcp.c,v 1.16 2014/06/03 22:22:41 joerg Exp $   */
 
 /*
  * Copyright (c) 1999, 2000 Andrew Doran <ad%NetBSD.org@localhost>
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: tcp.c,v 1.15 2008/04/10 17:16:39 thorpej Exp $");
+__RCSID("$NetBSD: tcp.c,v 1.16 2014/06/03 22:22:41 joerg Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -64,11 +64,6 @@
 static uint64_t newstat[TCP_NSTATS];
 static uint64_t oldstat[TCP_NSTATS];
 
-static struct nlist namelist[] = {
-       { .n_name = "_tcpstat" },
-       { .n_name = NULL }
-};
-



Home | Main Index | Thread Index | Old Index