diff options
author | Renato Botelho <renato@netgate.com> | 2016-01-07 18:08:08 -0200 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-01-07 18:08:08 -0200 |
commit | 7a579754077b3460c9509c75cdd1b78769c1db3f (patch) | |
tree | c15015685ccb82b7db1ac19d663a3c6e41e64587 /usr.bin | |
parent | d8ff3484131f428fcc0727cd504acb5050a36490 (diff) | |
parent | bc6ee646001a22150936ff06bf11cd08195e208d (diff) | |
download | FreeBSD-src-7a579754077b3460c9509c75cdd1b78769c1db3f.zip FreeBSD-src-7a579754077b3460c9509c75cdd1b78769c1db3f.tar.gz |
Merge remote-tracking branch 'origin/stable/10' into devel
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/bmake/Makefile | 4 | ||||
-rw-r--r-- | usr.bin/calendar/parsedata.c | 2 | ||||
-rw-r--r-- | usr.bin/colldef/parse.y | 12 | ||||
-rw-r--r-- | usr.bin/dtc/dtb.hh | 2 | ||||
-rw-r--r-- | usr.bin/indent/indent.1 | 2 | ||||
-rw-r--r-- | usr.bin/locale/locale.c | 4 | ||||
-rw-r--r-- | usr.bin/mkimg/mkimg.1 | 2 | ||||
-rw-r--r-- | usr.bin/mt/mt.c | 4 | ||||
-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 | 162 | ||||
-rw-r--r-- | usr.bin/netstat/inet6.c | 77 | ||||
-rw-r--r-- | usr.bin/netstat/ipsec.c | 25 | ||||
-rw-r--r-- | usr.bin/netstat/main.c | 34 | ||||
-rw-r--r-- | usr.bin/netstat/mbuf.c | 33 | ||||
-rw-r--r-- | usr.bin/netstat/mroute.c | 12 | ||||
-rw-r--r-- | usr.bin/netstat/mroute6.c | 13 | ||||
-rw-r--r-- | usr.bin/netstat/netstat.h | 2 | ||||
-rw-r--r-- | usr.bin/netstat/sctp.c | 19 | ||||
-rw-r--r-- | usr.bin/patch/pch.c | 2 | ||||
-rw-r--r-- | usr.bin/pr/egetopt.c | 2 | ||||
-rw-r--r-- | usr.bin/sed/compile.c | 2 | ||||
-rw-r--r-- | usr.bin/sockstat/sockstat.c | 6 | ||||
-rw-r--r-- | usr.bin/vgrind/regexp.c | 2 |
24 files changed, 157 insertions, 299 deletions
diff --git a/usr.bin/bmake/Makefile b/usr.bin/bmake/Makefile index 82decdb..008a413 100644 --- a/usr.bin/bmake/Makefile +++ b/usr.bin/bmake/Makefile @@ -14,10 +14,10 @@ CFLAGS+= -I${.CURDIR} CLEANDIRS+= FreeBSD CLEANFILES+= bootstrap -# $Id: Makefile,v 1.48 2015/12/02 00:36:42 sjg Exp $ +# $Id: Makefile,v 1.49 2015/12/20 22:54:40 sjg Exp $ # Base version on src date -MAKE_VERSION= 20151201 +MAKE_VERSION= 20151220 PROG?= ${.CURDIR:T} diff --git a/usr.bin/calendar/parsedata.c b/usr.bin/calendar/parsedata.c index 4586973..1a19164 100644 --- a/usr.bin/calendar/parsedata.c +++ b/usr.bin/calendar/parsedata.c @@ -274,7 +274,7 @@ determinestyle(char *date, int *flags, /* If both the month and date are specified as numbers */ if (isonlydigits(p1, 1) && isonlydigits(p2, 0)) { - /* Now who wants to be this ambigious? :-( */ + /* Now who wants to be this ambiguous? :-( */ int m, d; if (strchr(p2, '*') != NULL) diff --git a/usr.bin/colldef/parse.y b/usr.bin/colldef/parse.y index 9f8f8a8..9867608 100644 --- a/usr.bin/colldef/parse.y +++ b/usr.bin/colldef/parse.y @@ -134,17 +134,17 @@ order : ORDER order_list { strcpy(__collate_version, COLLATE_VERSION1_2); if (fwrite(__collate_version, sizeof(__collate_version), 1, fp) != 1) err(EX_IOERR, - "IO error writting collate version to destination file %s", + "I/O error writing collate version to destination file %s", out_file); u32 = htonl(chain_index); if (fwrite(&u32, sizeof(u32), 1, fp) != 1) err(EX_IOERR, - "IO error writting chains number to destination file %s", + "I/O error writing chains number to destination file %s", out_file); if (fwrite(__collate_substitute_table, sizeof(__collate_substitute_table), 1, fp) != 1) err(EX_IOERR, - "IO error writting substitute table to destination file %s", + "I/O error writing substitution table to destination file %s", out_file); for (ch = 0; ch < UCHAR_MAX + 1; ch++) { __collate_char_pri_table[ch].prim = @@ -155,7 +155,7 @@ order : ORDER order_list { if (fwrite(__collate_char_pri_table, sizeof(__collate_char_pri_table), 1, fp) != 1) err(EX_IOERR, - "IO error writting char table to destination file %s", + "I/O error writing char table to destination file %s", out_file); for (ch = 0; ch < chain_index; ch++) { __collate_chain_pri_table[ch].prim = @@ -167,10 +167,10 @@ order : ORDER order_list { sizeof(*__collate_chain_pri_table), chain_index, fp) != (size_t)chain_index) err(EX_IOERR, - "IO error writting chain table to destination file %s", + "I/O error writing chain table to destination file %s", out_file); if (fclose(fp) != 0) - err(EX_IOERR, "IO error closing destination file %s", + err(EX_IOERR, "I/O error closing destination file %s", out_file); exit(EX_OK); } diff --git a/usr.bin/dtc/dtb.hh b/usr.bin/dtc/dtb.hh index 2c5f39e..a246e96 100644 --- a/usr.bin/dtc/dtb.hh +++ b/usr.bin/dtc/dtb.hh @@ -224,7 +224,7 @@ class asm_writer : public output_writer uint32_t bytes_written; /** - * Writes a C string directly to the ouput as-is. This is mainly used + * Writes a C string directly to the output as-is. This is mainly used * for writing directives. */ void write_string(const char *c); diff --git a/usr.bin/indent/indent.1 b/usr.bin/indent/indent.1 index fe8f1ae..3a6f893 100644 --- a/usr.bin/indent/indent.1 +++ b/usr.bin/indent/indent.1 @@ -523,7 +523,7 @@ The utility understands a substantial amount about the syntax of C, but it has a `forgiving' parser. It attempts to cope with the usual sorts of -incomplete and misformed syntax. +incomplete and malformed syntax. In particular, the use of macros like: .Pp .Dl #define forever for(;;) diff --git a/usr.bin/locale/locale.c b/usr.bin/locale/locale.c index ee9bf84..e0fe7be 100644 --- a/usr.bin/locale/locale.c +++ b/usr.bin/locale/locale.c @@ -466,10 +466,10 @@ showlocale(void) && strcmp(lang, vval)) { /* * Appropriate environment variable set, its value - * is valid and not overriden by LC_ALL + * is valid and not overridden by LC_ALL * * XXX: possible side effect: if both LANG and - * overriden environment variable are set into same + * overridden environment variable are set into same * value, then it'll be assumed as 'implied' */ printf("%s=%s\n", lcinfo[i].name, vval); diff --git a/usr.bin/mkimg/mkimg.1 b/usr.bin/mkimg/mkimg.1 index 1fecdd2..246a397 100644 --- a/usr.bin/mkimg/mkimg.1 +++ b/usr.bin/mkimg/mkimg.1 @@ -289,7 +289,7 @@ utility as follows: .Dl % mkimg -s mbr -b /boot/mbr -p freebsd:-'mkimg -s bsd -b /boot/boot \ -p freebsd-ufs:=root-file-system.ufs -p freebsd-swap::1G' -o mbr-bsd.img .Pp -To accomodate the need to have partitions named or numbered in a certain +To accommodate the need to have partitions named or numbered in a certain way, the .Nm utility allows for the specification of empty partitions. diff --git a/usr.bin/mt/mt.c b/usr.bin/mt/mt.c index 745766c..6069ec7 100644 --- a/usr.bin/mt/mt.c +++ b/usr.bin/mt/mt.c @@ -1343,7 +1343,7 @@ mt_param(int argc, char **argv, int mtfd, char *xml_str, break; case 'p': if (param_name != NULL) { - warnx("Only one paramter name may be " + warnx("Only one parameter name may be " "specified"); retval = 1; goto bailout; @@ -1355,7 +1355,7 @@ mt_param(int argc, char **argv, int mtfd, char *xml_str, break; case 's': if (param_value != NULL) { - warnx("Only one paramter value may be " + warnx("Only one parameter value may be " "specified"); retval = 1; goto bailout; diff --git a/usr.bin/netstat/flowtable.c b/usr.bin/netstat/flowtable.c index a3d5dd5..392cc0b 100644 --- a/usr.bin/netstat/flowtable.c +++ b/usr.bin/netstat/flowtable.c @@ -28,12 +28,14 @@ #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 "netstat.h" /* @@ -67,17 +69,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 4b802d4..c1ed499 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> #define _IFI_OQDROPS @@ -117,20 +116,11 @@ pfsync_acts_stats(const char *fmt, 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; printf("%s:\n", name); diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index f8ff31b..8013ebe 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -593,8 +593,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) @@ -603,16 +602,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) { - 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; printf ("%s:\n", name); @@ -755,8 +747,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 @@ -766,16 +757,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) { - 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; printf("%s:\n", name); #define p(f, m) if (udpstat.f || sflag <= 1) \ @@ -815,23 +799,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) - 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; printf("%s:\n", name); @@ -866,19 +838,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) { - 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; printf("%s:\n", name); @@ -930,19 +894,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) { - 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; printf("%s:\n", name); @@ -1015,21 +971,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) { - 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; printf("%s:\n", name); @@ -1138,43 +1086,11 @@ igmp_stats_live_old(const char *name) void igmp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) { - struct igmpstat igmpstat, zerostat; - size_t len; - -#ifndef BURN_BRIDGES - if (live) { - /* - * Detect if we are being run against a pre-IGMPv3 kernel. - * We cannot do this for a core file as the legacy - * struct igmpstat has no size field, nor does it - * export it in any readily-available symbols. - */ - len = 0; - if (sysctlbyname("net.inet.igmp.stats", NULL, &len, NULL, - 0) < 0) { - warn("sysctl: net.inet.igmp.stats"); - return; - } - if (len < sizeof(igmpstat)) { - igmp_stats_live_old(name); - return; - } - } -#endif /* !BURN_BRIDGES */ + 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) { - 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) { warnx("%s: version mismatch (%d != %d)", __func__, @@ -1221,23 +1137,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) - 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; printf("%s:\n", name); diff --git a/usr.bin/netstat/inet6.c b/usr.bin/netstat/inet6.c index 96fdcaf..4e175fc 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> @@ -360,23 +359,12 @@ 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) - 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; printf("%s:\n", name); @@ -842,23 +830,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) - 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; printf("%s:\n", name); @@ -999,23 +976,11 @@ icmp6_ifstats(char *ifname) void pim6_stats(u_long off, const char *name, int af1 __unused, int proto __unused) { - struct pim6stat pim6stat, zerostat; - size_t len = sizeof pim6stat; + struct pim6stat 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) - warn("sysctl: net.inet6.pim.stats"); - return; - } - } else { - if (off == 0) - return; - kread(off, &pim6stat, len); - } + if (fetch_stats("net.inet6.pim.stats", off, &pim6stat, + sizeof(pim6stat), kread) != 0) + return; printf("%s:\n", name); @@ -1037,22 +1002,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) - 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; printf("%s:\n", name); diff --git a/usr.bin/netstat/ipsec.c b/usr.bin/netstat/ipsec.c index af1b234..801008f 100644 --- a/usr.bin/netstat/ipsec.c +++ b/usr.bin/netstat/ipsec.c @@ -202,10 +202,17 @@ ipsec_stats(u_long off, const char *name, int af1 __unused, int proto __unused) { struct ipsecstat ipsecstat; - if (off == 0) - return; + if (strcmp(name, "ipsec6") == 0) { + if (fetch_stats("net.inet6.ipsec6.ipsecstats", off,&ipsecstat, + sizeof(ipsecstat), kread_counters) != 0) + return; + } else { + if (fetch_stats("net.inet.ipsec.ipsecstats", off, &ipsecstat, + sizeof(ipsecstat), kread_counters) != 0) + return; + } + printf ("%s:\n", name); - kread_counters(off, (char *)&ipsecstat, sizeof(ipsecstat)); print_ipsecstats(&ipsecstat); } @@ -288,10 +295,10 @@ ah_stats(u_long off, const char *name, int family __unused, int proto __unused) { struct ahstat ahstat; - if (off == 0) + if (fetch_stats("net.inet.ah.stats", off, &ahstat, + sizeof(ahstat), kread_counters) != 0) return; printf ("%s:\n", name); - kread_counters(off, (char *)&ahstat, sizeof(ahstat)); print_ahstats(&ahstat); } @@ -335,10 +342,10 @@ esp_stats(u_long off, const char *name, int family __unused, int proto __unused) { struct espstat espstat; - if (off == 0) + if (fetch_stats("net.inet.esp.stats", off, &espstat, + sizeof(espstat), kread_counters) != 0) return; printf ("%s:\n", name); - kread_counters(off, (char *)&espstat, sizeof(espstat)); print_espstats(&espstat); } @@ -380,10 +387,10 @@ ipcomp_stats(u_long off, const char *name, int family __unused, { struct ipcompstat ipcompstat; - if (off == 0) + if (fetch_stats("net.inet.ipcomp.stats", off, &ipcompstat, + sizeof(ipcompstat), kread_counters) != 0) return; printf ("%s:\n", name); - kread_counters(off, (char *)&ipcompstat, sizeof(ipcompstat)); print_ipcompstats(&ipcompstat); } diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index 6a1ab18..8ef9783 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> @@ -202,13 +203,13 @@ struct protox { igmp_stats, NULL, "igmp", 1, IPPROTO_IGMP }, #ifdef IPSEC { -1, N_IPSECSTAT, 1, NULL, /* keep as compat */ - ipsec_stats, NULL, "ipsec", 0, 0}, + ipsec_stats, NULL, "ipsec", 1, 0}, { -1, N_AHSTAT, 1, NULL, - ah_stats, NULL, "ah", 0, 0}, + ah_stats, NULL, "ah", 1, 0}, { -1, N_ESPSTAT, 1, NULL, - esp_stats, NULL, "esp", 0, 0}, + esp_stats, NULL, "esp", 1, 0}, { -1, N_IPCOMPSTAT, 1, NULL, - ipcomp_stats, NULL, "ipcomp", 0, 0}, + ipcomp_stats, NULL, "ipcomp", 1, 0}, #endif { N_RIPCBINFO, N_PIMSTAT, 1, protopr, pim_stats, NULL, "pim", 1, IPPROTO_PIM }, @@ -240,7 +241,7 @@ struct protox ip6protox[] = { #endif #ifdef IPSEC { -1, N_IPSEC6STAT, 1, NULL, - ipsec_stats, NULL, "ipsec6", 0, 0 }, + ipsec_stats, NULL, "ipsec6", 1, 0 }, #endif #ifdef notyet { -1, N_PIM6STAT, 1, NULL, @@ -643,6 +644,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) + 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 ebd843f..74c2285 100644 --- a/usr.bin/netstat/mbuf.c +++ b/usr.bin/netstat/mbuf.c @@ -294,25 +294,20 @@ mbpr(void *kvmd, u_long mbaddr) "(%juk/9k/16k)\n", 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)) - printf("%d/%d/%d sfbufs in use (current/peak/max)\n", - nsfbufsused, nsfbufspeak, nsfbufs); - mlen = sizeof(sfstat); - if (sysctlbyname("kern.ipc.sfstat", &sfstat, &mlen, NULL, 0)) { - 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) + printf("%d/%d/%d 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; + printf("%ju requests for sfbufs denied\n", (uintmax_t)sfstat.sf_allocfail); printf("%ju requests for sfbufs delayed\n", diff --git a/usr.bin/netstat/mroute.c b/usr.bin/netstat/mroute.c index 3ec716d..c53ffc1 100644 --- a/usr.bin/netstat/mroute.c +++ b/usr.bin/netstat/mroute.c @@ -370,7 +370,6 @@ mrt_stats() { struct mrtstat mrtstat; u_long mstaddr; - size_t len = sizeof(mrtstat); kresolve_list(mrl); mstaddr = mrl[N_MRTSTAT].n_value; @@ -380,14 +379,9 @@ mrt_stats() return; } - if (live) { - if (sysctlbyname("net.inet.ip.mrtstat", &mrtstat, &len, NULL, - 0) < 0) { - 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; printf("IPv4 multicast forwarding:\n"); diff --git a/usr.bin/netstat/mroute6.c b/usr.bin/netstat/mroute6.c index ac31f5e..7cde3a7 100644 --- a/usr.bin/netstat/mroute6.c +++ b/usr.bin/netstat/mroute6.c @@ -246,7 +246,6 @@ mrt6_stats() { struct mrt6stat mrtstat; u_long mstaddr; - size_t len = sizeof mrtstat; kresolve_list(mrl); mstaddr = mrl[N_MRT6STAT].n_value; @@ -255,15 +254,9 @@ mrt6_stats() fprintf(stderr, "No IPv6 MROUTING kernel support.\n"); return; } - - if (live) { - if (sysctlbyname("net.inet6.ip6.mrt6stat", &mrtstat, &len, - NULL, 0) < 0) { - warn("sysctl: net.inet6.ip6.mrt6stat"); - return; - } - } else - kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat)); + if (fetch_stats("net.inet6.ip6.mrt6stat", 0, &mrtstat, + sizeof(mrtstat), kread_counters) != 0) + return; printf("IPv6 multicast forwarding:\n"); diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h index d2e9d32..086b60c 100644 --- a/usr.bin/netstat/netstat.h +++ b/usr.bin/netstat/netstat.h @@ -60,6 +60,8 @@ extern int unit; /* unit number for above */ extern int live; /* true if we are examining a live system */ struct nlist; +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); diff --git a/usr.bin/netstat/sctp.c b/usr.bin/netstat/sctp.c index a2ef7d568..687d039 100644 --- a/usr.bin/netstat/sctp.c +++ b/usr.bin/netstat/sctp.c @@ -607,20 +607,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) - 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; printf ("%s:\n", name); diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c index 5fadf62..357c364 100644 --- a/usr.bin/patch/pch.c +++ b/usr.bin/patch/pch.c @@ -499,7 +499,7 @@ another_hunk(void) LINENUM fillcnt; /* #lines of missing ptrn or repl */ LINENUM fillsrc; /* index of first line to copy */ LINENUM filldst; /* index of first missing line */ - bool ptrn_spaces_eaten; /* ptrn was slightly misformed */ + bool ptrn_spaces_eaten; /* ptrn was slightly malformed */ bool repl_could_be_missing; /* no + or ! lines in this hunk */ bool repl_missing; /* we are now backtracking */ off_t repl_backtrack_position; /* file pos of first repl line */ diff --git a/usr.bin/pr/egetopt.c b/usr.bin/pr/egetopt.c index 4b41b4a..22a093a 100644 --- a/usr.bin/pr/egetopt.c +++ b/usr.bin/pr/egetopt.c @@ -76,7 +76,7 @@ egetopt(int nargc, char * const *nargv, const char *ostr) { static char *place = emsg; /* option letter processing */ char *oli; /* option letter list index */ - static int delim; /* which option delimeter */ + static int delim; /* which option delimiter */ char *p; static char savec = '\0'; diff --git a/usr.bin/sed/compile.c b/usr.bin/sed/compile.c index c7fbe21..68cbbc5 100644 --- a/usr.bin/sed/compile.c +++ b/usr.bin/sed/compile.c @@ -364,7 +364,7 @@ nonsel: /* Now parse the command */ } /* - * Get a delimited string. P points to the delimeter of the string; d points + * Get a delimited string. P points to the delimiter of the string; d points * to a buffer area. Newline and delimiter escapes are processed; other * escapes are ignored. * diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c index d1ec0d3..8a8afc0 100644 --- a/usr.bin/sockstat/sockstat.c +++ b/usr.bin/sockstat/sockstat.c @@ -365,7 +365,7 @@ gather_sctp(void) htons(xinpcb->local_port)); break; default: - errx(1, "adress family %d not supported", + errx(1, "address family %d not supported", xladdr->address.sa.sa_family); } laddr->next = NULL; @@ -457,7 +457,7 @@ gather_sctp(void) htons(xstcb->local_port)); break; default: - errx(1, "adress family %d not supported", + errx(1, "address family %d not supported", xladdr->address.sa.sa_family); } laddr->next = NULL; @@ -499,7 +499,7 @@ gather_sctp(void) htons(xstcb->remote_port)); break; default: - errx(1, "adress family %d not supported", + errx(1, "address family %d not supported", xraddr->address.sa.sa_family); } faddr->next = NULL; diff --git a/usr.bin/vgrind/regexp.c b/usr.bin/vgrind/regexp.c index cd57835..04d3a83 100644 --- a/usr.bin/vgrind/regexp.c +++ b/usr.bin/vgrind/regexp.c @@ -318,7 +318,7 @@ expconv() /* - * The following routine recognises an irregular expresion + * The following routine recognises an irregular expression * with the following special characters: * * \? - means last match was optional |