diff options
author | dim <dim@FreeBSD.org> | 2015-09-11 17:20:03 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-09-11 17:20:03 +0000 |
commit | 5cc32d7f18f18fb3a5f4155b7f748cc7be60d2da (patch) | |
tree | 09add9017de3c98451b1eaf85a24b608cf228e4b /usr.bin | |
parent | a8fd1565ce9f3593ba962863828175715c3dede0 (diff) | |
parent | 2a0c9817c795eaf2bf7607d8cc9b36975aaca160 (diff) | |
download | FreeBSD-src-5cc32d7f18f18fb3a5f4155b7f748cc7be60d2da.zip FreeBSD-src-5cc32d7f18f18fb3a5f4155b7f748cc7be60d2da.tar.gz |
Merge ^/head r287527 through r287679.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/login/login.c | 1 | ||||
-rw-r--r-- | usr.bin/login/login_fbtab.c | 3 | ||||
-rw-r--r-- | usr.bin/netstat/flowtable.c | 13 | ||||
-rw-r--r-- | usr.bin/netstat/if.c | 20 | ||||
-rw-r--r-- | usr.bin/netstat/inet.c | 141 | ||||
-rw-r--r-- | usr.bin/netstat/inet6.c | 86 | ||||
-rw-r--r-- | usr.bin/netstat/main.c | 24 | ||||
-rw-r--r-- | usr.bin/netstat/mbuf.c | 37 | ||||
-rw-r--r-- | usr.bin/netstat/mroute.c | 12 | ||||
-rw-r--r-- | usr.bin/netstat/mroute6.c | 7 | ||||
-rw-r--r-- | usr.bin/netstat/netstat.h | 17 | ||||
-rw-r--r-- | usr.bin/netstat/sctp.c | 19 | ||||
-rw-r--r-- | usr.bin/systat/iostat.c | 22 | ||||
-rw-r--r-- | usr.bin/systat/netstat.c | 2 | ||||
-rw-r--r-- | usr.bin/systat/pigs.c | 4 | ||||
-rw-r--r-- | usr.bin/systat/vmstat.c | 9 | ||||
-rw-r--r-- | usr.bin/vmstat/vmstat.c | 2 | ||||
-rw-r--r-- | usr.bin/w/Makefile | 2 | ||||
-rw-r--r-- | usr.bin/w/w.c | 12 |
19 files changed, 137 insertions, 296 deletions
diff --git a/usr.bin/login/login.c b/usr.bin/login/login.c index d1d9bbe..525ccfc 100644 --- a/usr.bin/login/login.c +++ b/usr.bin/login/login.c @@ -63,7 +63,6 @@ __FBSDID("$FreeBSD$"); #include <err.h> #include <errno.h> #include <grp.h> -#include <libutil.h> #include <login_cap.h> #include <pwd.h> #include <setjmp.h> diff --git a/usr.bin/login/login_fbtab.c b/usr.bin/login/login_fbtab.c index f642ea7..8faee56 100644 --- a/usr.bin/login/login_fbtab.c +++ b/usr.bin/login/login_fbtab.c @@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$"); #include <sys/stat.h> #include <errno.h> #include <glob.h> -#include <paths.h> #include <stdio.h> #include <string.h> #include <syslog.h> @@ -120,7 +119,7 @@ login_fbtab(char *tty, uid_t uid, gid_t gid) /* login_protect - protect one device entry */ -void +static void login_protect(const char *table, char *pattern, int mask, uid_t uid, gid_t gid) { glob_t gl; diff --git a/usr.bin/netstat/flowtable.c b/usr.bin/netstat/flowtable.c index a232d80..c00dfd6 100644 --- a/usr.bin/netstat/flowtable.c +++ b/usr.bin/netstat/flowtable.c @@ -28,13 +28,15 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); + #include <sys/param.h> -#include <sys/sysctl.h> + #include <net/flowtable.h> -#include <err.h> + #include <stdint.h> #include <stdio.h> #include <stdbool.h> + #include "netstat.h" /* @@ -68,17 +70,18 @@ void flowtable_stats(void) { struct flowtable_stat stat; - size_t len = sizeof(stat); if (!live) return; - if (sysctlbyname("net.flowtable.ip4.stat", &stat, &len, NULL, 0) == 0) { + if (fetch_stats("net.flowtable.ip4.stat", 0, &stat, + sizeof(stat), NULL) == 0) { printf("flowtable for IPv4:\n"); print_stats(&stat); } - if (sysctlbyname("net.flowtable.ip6.stat", &stat, &len, NULL, 0) == 0) { + if (fetch_stats("net.flowtable.ip6.stat", 0, &stat, + sizeof(stat), NULL) == 0) { printf("flowtable for IPv6:\n"); print_stats(&stat); } diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c index e98b011..96606c4 100644 --- a/usr.bin/netstat/if.c +++ b/usr.bin/netstat/if.c @@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$"); #include <sys/protosw.h> #include <sys/socket.h> #include <sys/socketvar.h> -#include <sys/sysctl.h> #include <sys/time.h> #include <net/if.h> @@ -134,20 +133,11 @@ pfsync_acts_stats(const char *list, const char *desc, uint64_t *a) void pfsync_stats(u_long off, const char *name, int af1 __unused, int proto __unused) { - struct pfsyncstats pfsyncstat, zerostat; - size_t len = sizeof(struct pfsyncstats); - - if (live) { - if (zflag) - memset(&zerostat, 0, len); - if (sysctlbyname("net.pfsync.stats", &pfsyncstat, &len, - zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { - if (errno != ENOENT) - warn("sysctl: net.pfsync.stats"); - return; - } - } else - kread(off, &pfsyncstat, len); + struct pfsyncstats pfsyncstat; + + if (fetch_stats("net.pfsync.stats", off, &pfsyncstat, + sizeof(pfsyncstat), kread) != 0) + return; xo_emit("{T:/%s}:\n", name); xo_open_container(name); diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index 4c3675a..5644af3 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -627,8 +627,7 @@ protopr(u_long off, const char *name, int af1, int proto) void tcp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) { - struct tcpstat tcpstat, zerostat; - size_t len = sizeof tcpstat; + struct tcpstat tcpstat; #ifdef INET6 if (tcp_done != 0) @@ -637,16 +636,9 @@ tcp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) tcp_done = 1; #endif - if (live) { - if (zflag) - memset(&zerostat, 0, len); - if (sysctlbyname("net.inet.tcp.stats", &tcpstat, &len, - zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { - xo_warn("sysctl: net.inet.tcp.stats"); - return; - } - } else - kread_counters(off, &tcpstat, len); + if (fetch_stats("net.inet.tcp.stats", off, &tcpstat, + sizeof(tcpstat), kread_counters) != 0) + return; xo_open_container("tcp"); xo_emit("{T:/%s}:\n", name); @@ -860,8 +852,7 @@ tcp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) void udp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) { - struct udpstat udpstat, zerostat; - size_t len = sizeof udpstat; + struct udpstat udpstat; uint64_t delivered; #ifdef INET6 @@ -871,16 +862,9 @@ udp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) udp_done = 1; #endif - if (live) { - if (zflag) - memset(&zerostat, 0, len); - if (sysctlbyname("net.inet.udp.stats", &udpstat, &len, - zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { - xo_warn("sysctl: net.inet.udp.stats"); - return; - } - } else - kread_counters(off, &udpstat, len); + if (fetch_stats("net.inet.udp.stats", off, &udpstat, + sizeof(udpstat), kread_counters) != 0) + return; xo_open_container("udp"); xo_emit("{T:/%s}:\n", name); @@ -933,23 +917,11 @@ udp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) void carp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) { - struct carpstats carpstat, zerostat; - size_t len = sizeof(struct carpstats); + struct carpstats carpstat; - if (live) { - if (zflag) - memset(&zerostat, 0, len); - if (sysctlbyname("net.inet.carp.stats", &carpstat, &len, - zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { - if (errno != ENOENT) - xo_warn("sysctl: net.inet.carp.stats"); - return; - } - } else { - if (off == 0) - return; - kread_counters(off, &carpstat, len); - } + if (fetch_stats("net.inet.carp.stats", off, &carpstat, + sizeof(carpstat), kread_counters) != 0) + return; xo_open_container(name); xo_emit("{T:/%s}:\n", name); @@ -1000,19 +972,11 @@ carp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) void ip_stats(u_long off, const char *name, int af1 __unused, int proto __unused) { - struct ipstat ipstat, zerostat; - size_t len = sizeof ipstat; + struct ipstat ipstat; - if (live) { - if (zflag) - memset(&zerostat, 0, len); - if (sysctlbyname("net.inet.ip.stats", &ipstat, &len, - zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { - xo_warn("sysctl: net.inet.ip.stats"); - return; - } - } else - kread_counters(off, &ipstat, len); + if (fetch_stats("net.inet.ip.stats", off, &ipstat, + sizeof(ipstat), kread_counters) != 0) + return; xo_open_container(name); xo_emit("{T:/%s}:\n", name); @@ -1093,19 +1057,11 @@ ip_stats(u_long off, const char *name, int af1 __unused, int proto __unused) void arp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) { - struct arpstat arpstat, zerostat; - size_t len = sizeof(arpstat); + struct arpstat arpstat; - if (live) { - if (zflag) - memset(&zerostat, 0, len); - if (sysctlbyname("net.link.ether.arp.stats", &arpstat, &len, - zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { - xo_warn("sysctl: net.link.ether.arp.stats"); - return; - } - } else - kread_counters(off, &arpstat, len); + if (fetch_stats("net.link.ether.arp.stats", off, &arpstat, + sizeof(arpstat), kread_counters) != 0) + return; xo_open_container(name); xo_emit("{T:/%s}:\n", name); @@ -1186,21 +1142,13 @@ static const char *icmpnames[ICMP_MAXTYPE + 1] = { void icmp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) { - struct icmpstat icmpstat, zerostat; - int i, first; + struct icmpstat icmpstat; size_t len; + int i, first; - len = sizeof icmpstat; - if (live) { - if (zflag) - memset(&zerostat, 0, len); - if (sysctlbyname("net.inet.icmp.stats", &icmpstat, &len, - zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { - xo_warn("sysctl: net.inet.icmp.stats"); - return; - } - } else - kread_counters(off, &icmpstat, len); + if (fetch_stats("net.inet.icmp.stats", off, &icmpstat, + sizeof(icmpstat), kread_counters) != 0) + return; xo_open_container(name); xo_emit("{T:/%s}:\n", name); @@ -1300,22 +1248,11 @@ icmp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) void igmp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) { - struct igmpstat igmpstat, zerostat; - size_t len; + struct igmpstat igmpstat; - len = sizeof(igmpstat); - if (live) { - if (zflag) - memset(&zerostat, 0, len); - if (sysctlbyname("net.inet.igmp.stats", &igmpstat, &len, - zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { - xo_warn("sysctl: net.inet.igmp.stats"); - return; - } - } else { - len = sizeof(igmpstat); - kread(off, &igmpstat, len); - } + if (fetch_stats("net.inet.igmp.stats", 0, &igmpstat, + sizeof(igmpstat), kread) != 0) + return; if (igmpstat.igps_version != IGPS_VERSION_3) { xo_warnx("%s: version mismatch (%d != %d)", __func__, @@ -1380,23 +1317,11 @@ void pim_stats(u_long off __unused, const char *name, int af1 __unused, int proto __unused) { - struct pimstat pimstat, zerostat; - size_t len = sizeof pimstat; + struct pimstat pimstat; - if (live) { - if (zflag) - memset(&zerostat, 0, len); - if (sysctlbyname("net.inet.pim.stats", &pimstat, &len, - zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { - if (errno != ENOENT) - xo_warn("sysctl: net.inet.pim.stats"); - return; - } - } else { - if (off == 0) - return; - kread_counters(off, &pimstat, len); - } + if (fetch_stats("net.inet.pim.stats", off, &pimstat, + sizeof(pimstat), kread_counters) != 0) + return; xo_open_container(name); xo_emit("{T:/%s}:\n", name); diff --git a/usr.bin/netstat/inet6.c b/usr.bin/netstat/inet6.c index 6cdc46b..094d25b 100644 --- a/usr.bin/netstat/inet6.c +++ b/usr.bin/netstat/inet6.c @@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$"); #include <sys/ioctl.h> #include <sys/mbuf.h> #include <sys/protosw.h> -#include <sys/sysctl.h> #include <net/route.h> #include <net/if.h> @@ -359,23 +358,13 @@ static const char *srcrule_str[] = { void ip6_stats(u_long off, const char *name, int af1 __unused, int proto __unused) { - struct ip6stat ip6stat, zerostat; + struct ip6stat ip6stat; int first, i; - size_t len; - - len = sizeof ip6stat; - if (live) { - memset(&ip6stat, 0, len); - if (zflag) - memset(&zerostat, 0, len); - if (sysctlbyname("net.inet6.ip6.stats", &ip6stat, &len, - zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { - if (errno != ENOENT) - xo_warn("sysctl: net.inet6.ip6.stats"); - return; - } - } else - kread_counters(off, &ip6stat, len); + + if (fetch_stats("net.inet6.ip6.stats", off, &ip6stat, + sizeof(ip6stat), kread_counters) != 0) + return; + xo_open_container(name); xo_emit("{T:/%s}:\n", name); @@ -956,23 +945,12 @@ static const char *icmp6names[] = { void icmp6_stats(u_long off, const char *name, int af1 __unused, int proto __unused) { - struct icmp6stat icmp6stat, zerostat; + struct icmp6stat icmp6stat; int i, first; - size_t len; - - len = sizeof icmp6stat; - if (live) { - memset(&icmp6stat, 0, len); - if (zflag) - memset(&zerostat, 0, len); - if (sysctlbyname("net.inet6.icmp6.stats", &icmp6stat, &len, - zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { - if (errno != ENOENT) - xo_warn("sysctl: net.inet6.icmp6.stats"); - return; - } - } else - kread_counters(off, &icmp6stat, len); + + if (fetch_stats("net.inet6.icmp6.stats", off, &icmp6stat, + sizeof(icmp6stat), kread_counters) != 0) + return; xo_emit("{T:/%s}:\n", name); xo_open_container(name); @@ -1196,23 +1174,11 @@ end: void pim6_stats(u_long off, const char *name, int af1 __unused, int proto __unused) { - struct pim6stat pim6stat, zerostat; - size_t len = sizeof pim6stat; - - if (live) { - if (zflag) - memset(&zerostat, 0, len); - if (sysctlbyname("net.inet6.pim.stats", &pim6stat, &len, - zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { - if (errno != ENOENT) - xo_warn("sysctl: net.inet6.pim.stats"); - return; - } - } else { - if (off == 0) - return; - kread(off, &pim6stat, len); - } + struct pim6stat pim6stat; + + if (fetch_stats("net.inet6.pim.stats", off, &pim6stat, + sizeof(pim6stat), kread) != 0) + return; xo_emit("{T:/%s}:\n", name); xo_open_container(name); @@ -1244,22 +1210,12 @@ pim6_stats(u_long off, const char *name, int af1 __unused, int proto __unused) void rip6_stats(u_long off, const char *name, int af1 __unused, int proto __unused) { - struct rip6stat rip6stat, zerostat; + struct rip6stat rip6stat; u_quad_t delivered; - size_t len; - - len = sizeof(rip6stat); - if (live) { - if (zflag) - memset(&zerostat, 0, len); - if (sysctlbyname("net.inet6.ip6.rip6stats", &rip6stat, &len, - zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { - if (errno != ENOENT) - xo_warn("sysctl: net.inet6.ip6.rip6stats"); - return; - } - } else - kread_counters(off, &rip6stat, len); + + if (fetch_stats("net.inet6.ip6.rip6stats", off, &rip6stat, + sizeof(rip6stat), kread_counters) != 0) + return; xo_emit("{T:/%s}:\n", name); xo_open_container(name); diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index c364543..af532a6 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include <sys/protosw.h> #include <sys/socket.h> #include <sys/socketvar.h> +#include <sys/sysctl.h> #include <netinet/in.h> @@ -548,6 +549,29 @@ main(int argc, char *argv[]) exit(0); } +int +fetch_stats(const char *sysctlname, u_long off, void *stats, size_t len, + int (*kreadfn)(u_long, void *, size_t)) +{ + int error; + + if (live) { + memset(stats, 0, len); + if (zflag) + error = sysctlbyname(sysctlname, NULL, NULL, stats, + len); + else + error = sysctlbyname(sysctlname, stats, &len, NULL, 0); + if (error == -1 && errno != ENOENT) + xo_warn("sysctl %s", sysctlname); + } else { + if (off == 0) + return (1); + error = kreadfn(off, stats, len); + } + return (error); +} + /* * Print out protocol statistics or control blocks (per sflag). * If the interface was not specifically requested, and the symbol diff --git a/usr.bin/netstat/mbuf.c b/usr.bin/netstat/mbuf.c index 26b7095..baf7a65 100644 --- a/usr.bin/netstat/mbuf.c +++ b/usr.bin/netstat/mbuf.c @@ -310,27 +310,22 @@ mbpr(void *kvmd, u_long mbaddr) jumbop_failures, jumbo9_failures, jumbo16_failures, jumbop_size / 1024); - if (live) { - mlen = sizeof(nsfbufs); - if (!sysctlbyname("kern.ipc.nsfbufs", &nsfbufs, &mlen, NULL, - 0) && - !sysctlbyname("kern.ipc.nsfbufsused", &nsfbufsused, - &mlen, NULL, 0) && - !sysctlbyname("kern.ipc.nsfbufspeak", &nsfbufspeak, - &mlen, NULL, 0)) - xo_emit("{:nsfbufs-current/%d}/{:nsfbufs-peak/%d}/" - "{:nsfbufs/%d} " - "{N:sfbufs in use (current\\/peak\\/max)}\n", - nsfbufsused, nsfbufspeak, nsfbufs); - mlen = sizeof(sfstat); - if (sysctlbyname("kern.ipc.sfstat", &sfstat, &mlen, NULL, 0)) { - xo_warn("kern.ipc.sfstat"); - goto out; - } - } else { - if (kread_counters(mbaddr, (char *)&sfstat, sizeof sfstat) != 0) - goto out; - } + mlen = sizeof(nsfbufs); + if (live && + sysctlbyname("kern.ipc.nsfbufs", &nsfbufs, &mlen, NULL, 0) == 0 && + sysctlbyname("kern.ipc.nsfbufsused", &nsfbufsused, &mlen, + NULL, 0) == 0 && + sysctlbyname("kern.ipc.nsfbufspeak", &nsfbufspeak, &mlen, + NULL, 0) == 0) + xo_emit("{:nsfbufs-current/%d}/{:nsfbufs-peak/%d}/" + "{:nsfbufs/%d} " + "{N:sfbufs in use (current\\/peak\\/max)}\n", + nsfbufsused, nsfbufspeak, nsfbufs); + + if (fetch_stats("kern.ipc.sfstat", mbaddr, &sfstat, sizeof(sfstat), + kread_counters) != 0) + goto out; + xo_emit("{:sfbufs-alloc-failed/%ju} {N:requests for sfbufs denied}\n", (uintmax_t)sfstat.sf_allocfail); xo_emit("{:sfbufs-alloc-wait/%ju} {N:requests for sfbufs delayed}\n", diff --git a/usr.bin/netstat/mroute.c b/usr.bin/netstat/mroute.c index 93b640c..975473e 100644 --- a/usr.bin/netstat/mroute.c +++ b/usr.bin/netstat/mroute.c @@ -400,7 +400,6 @@ mrt_stats() { struct mrtstat mrtstat; u_long mstaddr; - size_t len = sizeof(mrtstat); mstaddr = nl[N_MRTSTAT].n_value; @@ -409,14 +408,9 @@ mrt_stats() return; } - if (live) { - if (sysctlbyname("net.inet.ip.mrtstat", &mrtstat, &len, NULL, - 0) < 0) { - xo_warn("sysctl: net.inet.ip.mrtstat failed."); - return; - } - } else - kread_counters(mstaddr, &mrtstat, len); + if (fetch_stats("net.inet.ip.mrtstat", mstaddr, &mrtstat, + sizeof(mrtstat), kread_counters) != 0) + return; xo_emit("{T:IPv4 multicast forwarding}:\n"); diff --git a/usr.bin/netstat/mroute6.c b/usr.bin/netstat/mroute6.c index 668add4..8f59c6b 100644 --- a/usr.bin/netstat/mroute6.c +++ b/usr.bin/netstat/mroute6.c @@ -231,13 +231,10 @@ void mrt6_stats() { struct mrt6stat mrtstat; - size_t len = sizeof mrtstat; - if (sysctlbyname("net.inet6.ip6.mrt6stat", &mrtstat, &len, NULL, 0) < - 0) { - xo_warn("sysctl: net.inet6.ip6.mrt6stat"); + if (fetch_stats("net.inet6.ip6.mrt6stat", 0, &mrtstat, + sizeof(mrtstat), kread_counters) != 0) return; - } xo_open_container("multicast-statistics"); xo_emit("{T:IPv6 multicast forwarding}:\n"); diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h index ca6da29..776c4d4 100644 --- a/usr.bin/netstat/netstat.h +++ b/usr.bin/netstat/netstat.h @@ -63,6 +63,8 @@ extern int unit; /* unit number for above */ extern int live; /* true if we are examining a live system */ +int fetch_stats(const char *sysctlname, u_long addr, void *stats, + size_t len, int (*kreadfn)(u_long, void *, size_t)); int kread(u_long addr, void *buf, size_t size); uint64_t kread_counter(u_long addr); int kread_counters(u_long addr, void *buf, size_t size); @@ -131,29 +133,14 @@ void flowtable_stats(void); char *routename(struct sockaddr *, int); const char *netname(struct sockaddr *, struct sockaddr *); -char *ns_print(struct sockaddr *); void routepr(int, int); -void nsprotopr(u_long, const char *, int, int); -void spp_stats(u_long, const char *, int, int); -void idp_stats(u_long, const char *, int, int); -void nserr_stats(u_long, const char *, int, int); - #ifdef NETGRAPH void netgraphprotopr(u_long, const char *, int, int); #endif void unixpr(u_long, u_long, u_long, u_long, u_long, bool *); -void esis_stats(u_long, const char *, int, int); -void clnp_stats(u_long, const char *, int, int); -void cltp_stats(u_long, const char *, int, int); -void iso_protopr(u_long, const char *, int, int); -void iso_protopr1(u_long, int); -void tp_protopr(u_long, const char *, int, int); -void tp_inproto(u_long); -void tp_stats(caddr_t, caddr_t); - void mroutepr(void); void mrt_stats(void); void bpf_stats(char *); diff --git a/usr.bin/netstat/sctp.c b/usr.bin/netstat/sctp.c index f721a96..5f609a0 100644 --- a/usr.bin/netstat/sctp.c +++ b/usr.bin/netstat/sctp.c @@ -658,20 +658,11 @@ sctp_statesprint(uint32_t state) void sctp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) { - struct sctpstat sctpstat, zerostat; - size_t len = sizeof(sctpstat); - - if (live) { - if (zflag) - memset(&zerostat, 0, len); - if (sysctlbyname("net.inet.sctp.stats", &sctpstat, &len, - zflag ? &zerostat : NULL, zflag ? len : 0) < 0) { - if (errno != ENOENT) - xo_warn("sysctl: net.inet.sctp.stats"); - return; - } - } else - kread(off, &sctpstat, len); + struct sctpstat sctpstat; + + if (fetch_stats("net.inet.sctp.stats", off, &sctpstat, + sizeof(sctpstat), kread) != 0) + return; xo_open_container(name); xo_emit("{T:/%s}:\n", name); diff --git a/usr.bin/systat/iostat.c b/usr.bin/systat/iostat.c index 3384f15..fa275eb 100644 --- a/usr.bin/systat/iostat.c +++ b/usr.bin/systat/iostat.c @@ -112,10 +112,8 @@ initiostat(void) if ((num_devices = devstat_getnumdevs(NULL)) < 0) return(0); - cur.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo)); - last.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo)); - bzero(cur.dinfo, sizeof(struct devinfo)); - bzero(last.dinfo, sizeof(struct devinfo)); + cur.dinfo = calloc(1, sizeof(struct devinfo)); + last.dinfo = calloc(1, sizeof(struct devinfo)); /* * This value for maxshowdevs (100) is bogus. I'm not sure exactly @@ -196,7 +194,7 @@ numlabels(int row) char tmpstr[10]; #define COLWIDTH 17 -#define DRIVESPERLINE ((wnd->_maxx - INSET) / COLWIDTH) +#define DRIVESPERLINE ((getmaxx(wnd) - 1 - INSET) / COLWIDTH) for (ndrives = 0, i = 0; i < num_devices; i++) if (dev_select[i].selected) ndrives++; @@ -204,7 +202,7 @@ numlabels(int row) /* * Deduct -regions for blank line after each scrolling region. */ - linesperregion = (wnd->_maxy - row - regions) / regions; + linesperregion = (getmaxy(wnd) - 1 - row - regions) / regions; /* * Minimum region contains space for two * label lines and one line of statistics. @@ -214,9 +212,9 @@ numlabels(int row) _col = INSET; for (i = 0; i < num_devices; i++) if (dev_select[i].selected) { - if (_col + COLWIDTH >= wnd->_maxx - INSET) { + if (_col + COLWIDTH >= getmaxx(wnd) - 1 - INSET) { _col = INSET, row += linesperregion + 1; - if (row > wnd->_maxy - (linesperregion + 1)) + if (row > getmaxy(wnd) - 1 - (linesperregion + 1)) break; } sprintf(tmpstr, "%s%d", dev_select[i].device_name, @@ -241,7 +239,7 @@ barlabels(int row) linesperregion = 2 + kbpt; for (i = 0; i < num_devices; i++) if (dev_select[i].selected) { - if (row > wnd->_maxy - linesperregion) + if (row > getmaxy(wnd) - 1 - linesperregion) break; sprintf(tmpstr, "%s%d", dev_select[i].device_name, dev_select[i].unit_number); @@ -276,7 +274,7 @@ showiostat(void) row += 2; for (i = 0; i < num_devices; i++) if (dev_select[i].selected) { - if (row > wnd->_maxy - linesperregion) + if (row > getmaxy(wnd) - linesperregion) break; row = devstats(row, INSET, i); } @@ -289,9 +287,9 @@ showiostat(void) winsertln(wnd); for (i = 0; i < num_devices; i++) if (dev_select[i].selected) { - if (_col + COLWIDTH >= wnd->_maxx - INSET) { + if (_col + COLWIDTH >= getmaxx(wnd) - 1 - INSET) { _col = INSET, row += linesperregion + 1; - if (row > wnd->_maxy - (linesperregion + 1)) + if (row > getmaxy(wnd) - 1 - (linesperregion + 1)) break; wmove(wnd, row + linesperregion, 0); wdeleteln(wnd); diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c index b5938eb..3f994e8 100644 --- a/usr.bin/systat/netstat.c +++ b/usr.bin/systat/netstat.c @@ -85,7 +85,7 @@ static char *inetname(struct sockaddr *); static void inetprint(struct sockaddr *, const char *); #define streq(a,b) (strcmp(a,b)==0) -#define YMAX(w) ((w)->_maxy-1) +#define YMAX(w) (getmaxy(w)-2) WINDOW * opennetstat(void) diff --git a/usr.bin/systat/pigs.c b/usr.bin/systat/pigs.c index a02a43f..d341f7d 100644 --- a/usr.bin/systat/pigs.c +++ b/usr.bin/systat/pigs.c @@ -94,8 +94,8 @@ showpigs(void) qsort(pt, nproc, sizeof (struct p_times), compar); y = 1; i = nproc; - if (i > wnd->_maxy-1) - i = wnd->_maxy-1; + if (i > getmaxy(wnd)-2) + i = getmaxy(wnd)-2; for (k = 0; i > 0 && pt[k].pt_pctcpu > 0.01; i--, y++, k++) { uname = user_from_uid(pt[k].pt_kp->ki_uid, 0); pname = pt[k].pt_kp->ki_comm; diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c index cdb26a7..258e357 100644 --- a/usr.bin/systat/vmstat.c +++ b/usr.bin/systat/vmstat.c @@ -205,12 +205,9 @@ initkre(void) return(0); } - cur.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo)); - last.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo)); - run.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo)); - bzero(cur.dinfo, sizeof(struct devinfo)); - bzero(last.dinfo, sizeof(struct devinfo)); - bzero(run.dinfo, sizeof(struct devinfo)); + cur.dinfo = calloc(1, sizeof(struct devinfo)); + last.dinfo = calloc(1, sizeof(struct devinfo)); + run.dinfo = calloc(1, sizeof(struct devinfo)); if (dsinit(MAXDRIVES, &cur, &last, &run) != 1) return(0); diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index 0a3054a..4d0224d 100644 --- a/usr.bin/vmstat/vmstat.c +++ b/usr.bin/vmstat/vmstat.c @@ -556,8 +556,6 @@ fill_vmmeter(struct vmmeter *vmmp) GET_VM_STATS(vm, v_inactive_target); GET_VM_STATS(vm, v_inactive_count); GET_VM_STATS(vm, v_cache_count); - GET_VM_STATS(vm, v_cache_min); - GET_VM_STATS(vm, v_cache_max); GET_VM_STATS(vm, v_pageout_free_min); GET_VM_STATS(vm, v_interrupt_free_min); /*GET_VM_STATS(vm, v_free_severe);*/ diff --git a/usr.bin/w/Makefile b/usr.bin/w/Makefile index 0bd09ff..c14f84a 100644 --- a/usr.bin/w/Makefile +++ b/usr.bin/w/Makefile @@ -5,8 +5,6 @@ PROG= w SRCS= fmt.c pr_time.c proc_compare.c w.c MAN= w.1 uptime.1 LIBADD= kvm sbuf xo util -#BINGRP= kmem -#BINMODE=2555 LINKS= ${BINDIR}/w ${BINDIR}/uptime .PATH: ${.CURDIR}/../../bin/ps diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index 4df4abd..0c955ac 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -135,7 +135,7 @@ main(int argc, char *argv[]) struct kinfo_proc *dkp; struct stat *stp; time_t touched; - int ch, i, nentries, nusers, wcmd, longidle, longattime, dropgid; + int ch, i, nentries, nusers, wcmd, longidle, longattime; const char *memf, *nlistf, *p, *save_p; char *x_suffix; char buf[MAXHOSTNAMELEN], errbuf[_POSIX2_LINE_MAX]; @@ -159,7 +159,6 @@ main(int argc, char *argv[]) p = "dhiflM:N:nsuw"; } - dropgid = 0; memf = _PATH_DEVNULL; nlistf = NULL; while ((ch = getopt(argc, argv, p)) != -1) @@ -176,11 +175,9 @@ main(int argc, char *argv[]) case 'M': header = 0; memf = optarg; - dropgid = 1; break; case 'N': nlistf = optarg; - dropgid = 1; break; case 'n': nflag = 1; @@ -200,13 +197,6 @@ main(int argc, char *argv[]) _res.retrans = 2; /* resolver timeout to 2 seconds per try */ _res.retry = 1; /* only try once.. */ - /* - * Discard setgid privileges if not the running kernel so that bad - * guys can't print interesting stuff from kernel memory. - */ - if (dropgid) - setgid(getgid()); - if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf)) == NULL) errx(1, "%s", errbuf); |