Module Name:    src
Committed By:   tls
Date:           Sun Aug 10 06:58:59 UTC 2014

Modified Files:
        src/usr.bin/systat [tls-earlyentropy]: extern.h icmp.c ip.c ip6.c
            main.c tcp.c vmstat.c

Log Message:
Rebase.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.42.16.1 src/usr.bin/systat/extern.h
cvs rdiff -u -r1.12 -r1.12.40.1 src/usr.bin/systat/icmp.c
cvs rdiff -u -r1.17 -r1.17.40.1 src/usr.bin/systat/ip.c
cvs rdiff -u -r1.15 -r1.15.40.1 src/usr.bin/systat/ip6.c \
    src/usr.bin/systat/tcp.c
cvs rdiff -u -r1.47 -r1.47.6.1 src/usr.bin/systat/main.c
cvs rdiff -u -r1.77 -r1.77.22.1 src/usr.bin/systat/vmstat.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.42.16.1
--- src/usr.bin/systat/extern.h:1.42	Fri Jan  6 14:08:08 2012
+++ src/usr.bin/systat/extern.h	Sun Aug 10 06:58:59 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.42 2012/01/06 14:08:08 drochner Exp $	*/
+/*	$NetBSD: extern.h,v 1.42.16.1 2014/08/10 06:58:59 tls 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.12.40.1
--- src/usr.bin/systat/icmp.c:1.12	Thu Apr 10 17:16:39 2008
+++ src/usr.bin/systat/icmp.c	Sun Aug 10 06:58:59 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: icmp.c,v 1.12 2008/04/10 17:16:39 thorpej Exp $	*/
+/*	$NetBSD: icmp.c,v 1.12.40.1 2014/08/10 06:58:59 tls 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.12.40.1 2014/08/10 06:58:59 tls 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.17.40.1
--- src/usr.bin/systat/ip.c:1.17	Thu Apr 10 17:16:39 2008
+++ src/usr.bin/systat/ip.c	Sun Aug 10 06:58:59 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip.c,v 1.17 2008/04/10 17:16:39 thorpej Exp $	*/
+/*	$NetBSD: ip.c,v 1.17.40.1 2014/08/10 06:58:59 tls 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.17.40.1 2014/08/10 06:58:59 tls 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.15.40.1
--- src/usr.bin/systat/ip6.c:1.15	Thu Apr 10 17:16:39 2008
+++ src/usr.bin/systat/ip6.c	Sun Aug 10 06:58:59 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip6.c,v 1.15 2008/04/10 17:16:39 thorpej Exp $	*/
+/*	$NetBSD: ip6.c,v 1.15.40.1 2014/08/10 06:58:59 tls 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.15.40.1 2014/08/10 06:58:59 tls 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.15.40.1
--- src/usr.bin/systat/tcp.c:1.15	Thu Apr 10 17:16:39 2008
+++ src/usr.bin/systat/tcp.c	Sun Aug 10 06:58:59 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp.c,v 1.15 2008/04/10 17:16:39 thorpej Exp $	*/
+/*	$NetBSD: tcp.c,v 1.15.40.1 2014/08/10 06:58:59 tls 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.15.40.1 2014/08/10 06:58:59 tls 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.47.6.1
--- src/usr.bin/systat/main.c:1.47	Fri Nov 23 03:47:36 2012
+++ src/usr.bin/systat/main.c	Sun Aug 10 06:58:59 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.47 2012/11/23 03:47:36 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.47.6.1 2014/08/10 06:58:59 tls 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.47.6.1 2014/08/10 06:58:59 tls 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;

Index: src/usr.bin/systat/vmstat.c
diff -u src/usr.bin/systat/vmstat.c:1.77 src/usr.bin/systat/vmstat.c:1.77.22.1
--- src/usr.bin/systat/vmstat.c:1.77	Fri Apr 30 16:21:05 2010
+++ src/usr.bin/systat/vmstat.c	Sun Aug 10 06:58:59 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmstat.c,v 1.77 2010/04/30 16:21:05 njoly Exp $	*/
+/*	$NetBSD: vmstat.c,v 1.77.22.1 2014/08/10 06:58:59 tls Exp $	*/
 
 /*-
  * Copyright (c) 1983, 1989, 1992, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 1/12/94";
 #endif
-__RCSID("$NetBSD: vmstat.c,v 1.77 2010/04/30 16:21:05 njoly Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.77.22.1 2014/08/10 06:58:59 tls Exp $");
 #endif /* not lint */
 
 /*
@@ -63,7 +63,7 @@ __RCSID("$NetBSD: vmstat.c,v 1.77 2010/0
 static struct Info {
 	struct	uvmexp_sysctl uvmexp;
 	struct	vmtotal Total;
-	struct	nchstats nchstats;
+	struct	nchstats_sysctl nchstats;
 	long	nchcount;
 	long	*intrcnt;
 	u_int64_t	*evcnt;
@@ -106,17 +106,15 @@ closevmstat(WINDOW *w)
 
 
 static struct nlist namelist[] = {
-#define	X_NCHSTATS	0
-	{ .n_name = "_nchstats" },
-#define	X_INTRNAMES	1
+#define	X_INTRNAMES	0
 	{ .n_name = "_intrnames" },
-#define	X_EINTRNAMES	2
+#define	X_EINTRNAMES	1
 	{ .n_name = "_eintrnames" },
-#define	X_INTRCNT	3
+#define	X_INTRCNT	2
 	{ .n_name = "_intrcnt" },
-#define	X_EINTRCNT	4
+#define	X_EINTRCNT	3
 	{ .n_name = "_eintrcnt" },
-#define	X_ALLEVENTS	5
+#define	X_ALLEVENTS	4
 	{ .n_name = "_allevents" },
 	{ .n_name = NULL }
 };
@@ -210,15 +208,10 @@ initvmstat(void)
 
 	if (namelist[0].n_type == 0) {
 		if (kvm_nlist(kd, namelist) &&
-		    (namelist[X_NCHSTATS].n_type == 0 ||
-		     namelist[X_ALLEVENTS].n_type == 0)) {
+		    namelist[X_ALLEVENTS].n_type == 0) {
 			nlisterr(namelist);
 			return(0);
 		}
-		if (namelist[0].n_type == 0) {
-			error("No namelist");
-			return(0);
-		}
 	}
 	hertz = stathz ? stathz : hz;
 	if (!drvinit(1))
@@ -776,7 +769,12 @@ getinfo(struct Info *stats)
 
 	cpureadstats();
 	drvreadstats();
-	NREAD(X_NCHSTATS, &stats->nchstats, sizeof stats->nchstats);
+	size = sizeof(stats->nchstats);
+	if (sysctlbyname("vfs.namecache_stats", &stats->nchstats, &size,
+	    NULL, 0) < 0) {
+		error("can't get namecache statistics: %s\n", strerror(errno));
+		memset(&stats->nchstats, 0, sizeof(stats->nchstats));
+	}
 	if (nintr)
 		NREAD(X_INTRCNT, stats->intrcnt, nintr * LONG);
 	for (i = 0; i < nevcnt; i++)

Reply via email to