Module Name:    src
Committed By:   joerg
Date:           Tue Jun  3 22:22:41 UTC 2014

Modified Files:
        src/usr.bin/systat: extern.h icmp.c ip.c ip6.c main.c tcp.c

Log Message:
Always use_sysctl in preparation of removing all kvm code.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/systat/extern.h
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/systat/icmp.c
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/systat/ip.c
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/systat/ip6.c src/usr.bin/systat/tcp.c
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/systat/main.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.bin/systat/extern.h
diff -u src/usr.bin/systat/extern.h:1.42 src/usr.bin/systat/extern.h:1.43
--- src/usr.bin/systat/extern.h:1.42	Fri Jan  6 14:08:08 2012
+++ src/usr.bin/systat/extern.h	Tue Jun  3 22:22:41 2014
@@ -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 char	*memf;
 extern int	allflag;
 extern int	turns;
 extern gid_t	egid;
-extern int	use_sysctl;
 
 struct inpcb;
 #ifdef INET6

Index: src/usr.bin/systat/icmp.c
diff -u src/usr.bin/systat/icmp.c:1.12 src/usr.bin/systat/icmp.c:1.13
--- src/usr.bin/systat/icmp.c:1.12	Thu Apr 10 17:16:39 2008
+++ src/usr.bin/systat/icmp.c	Tue Jun  3 22:22:41 2014
@@ -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 <a...@netbsd.org>
@@ -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 curstat[ICMP_NSTATS];
 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 @@ int
 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);

Index: src/usr.bin/systat/ip.c
diff -u src/usr.bin/systat/ip.c:1.17 src/usr.bin/systat/ip.c:1.18
--- src/usr.bin/systat/ip.c:1.17	Thu Apr 10 17:16:39 2008
+++ src/usr.bin/systat/ip.c	Tue Jun  3 22:22:41 2014
@@ -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 <a...@netbsd.org>
@@ -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 curstat;
 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 @@ int
 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)
 {
+	size_t size;
 
-	if (use_sysctl) {
-		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]);

Index: src/usr.bin/systat/ip6.c
diff -u src/usr.bin/systat/ip6.c:1.15 src/usr.bin/systat/ip6.c:1.16
--- src/usr.bin/systat/ip6.c:1.15	Thu Apr 10 17:16:39 2008
+++ src/usr.bin/systat/ip6.c	Tue Jun  3 22:22:41 2014
@@ -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 <a...@netbsd.org>
@@ -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 curstat[IP6_NSTATS];
 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 @@ showip6(void)
 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);
Index: src/usr.bin/systat/tcp.c
diff -u src/usr.bin/systat/tcp.c:1.15 src/usr.bin/systat/tcp.c:1.16
--- src/usr.bin/systat/tcp.c:1.15	Thu Apr 10 17:16:39 2008
+++ src/usr.bin/systat/tcp.c	Tue Jun  3 22:22:41 2014
@@ -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 <a...@netbsd.org>
@@ -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 curstat[TCP_NSTATS];
 static uint64_t newstat[TCP_NSTATS];
 static uint64_t oldstat[TCP_NSTATS];
 
-static struct nlist namelist[] = {
-	{ .n_name = "_tcpstat" },
-	{ .n_name = NULL }
-};
-
 WINDOW *
 opentcp(void)
 {
@@ -214,36 +209,16 @@ showtcp(void)
 int
 inittcp(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
 fetchtcp(void)
 {
-	int i;
+	size_t i, size = sizeof(newstat);
 
-	if (use_sysctl) {
-		size_t size = sizeof(newstat);
-		
-		if (sysctlbyname("net.inet.tcp.stats", newstat, &size,
-				 NULL, 0) == -1)
-			return;
-	} else {
-		KREAD((void *)namelist[0].n_value, newstat, sizeof(newstat));
-	}
+	if (sysctlbyname("net.inet.tcp.stats", newstat, &size, NULL, 0) == -1)
+		return;
 
 	for (i = 0; i < TCP_NSTATS; i++)
 		xADJINETCTR(curstat, oldstat, newstat, i);

Index: src/usr.bin/systat/main.c
diff -u src/usr.bin/systat/main.c:1.47 src/usr.bin/systat/main.c:1.48
--- src/usr.bin/systat/main.c:1.47	Fri Nov 23 03:47:36 2012
+++ src/usr.bin/systat/main.c	Tue Jun  3 22:22:41 2014
@@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #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     turns = 2;	/* stay how many refr
 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 @@ main(int argc, char **argv)
 		switch(ch) {
 		case 'M':
 			memf = optarg;
-			use_sysctl = 0;
 			break;
 		case 'N':
 			nlistf = optarg;

Reply via email to