diff options
author | dim <dim@FreeBSD.org> | 2015-07-22 19:55:32 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-07-22 19:55:32 +0000 |
commit | 56628666d99043fba09f14aabe048c4d94871068 (patch) | |
tree | 19924b0e411ce8a595741437761c9b4fe60a9a43 /usr.bin | |
parent | 1ebfd3aba929e33294751473ec48782e765ba703 (diff) | |
parent | 606fc6cd559dcdd7115db80f7c82470ff6068a17 (diff) | |
download | FreeBSD-src-56628666d99043fba09f14aabe048c4d94871068.zip FreeBSD-src-56628666d99043fba09f14aabe048c4d94871068.tar.gz |
Merge ^/head r285341 through r285792.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/Makefile | 1 | ||||
-rw-r--r-- | usr.bin/c99/c99.1 | 11 | ||||
-rw-r--r-- | usr.bin/calendar/io.c | 9 | ||||
-rw-r--r-- | usr.bin/last/last.c | 8 | ||||
-rw-r--r-- | usr.bin/ministat/ministat.c | 2 | ||||
-rw-r--r-- | usr.bin/netstat/main.c | 24 | ||||
-rw-r--r-- | usr.bin/netstat/pfkey.c | 4 | ||||
-rw-r--r-- | usr.bin/numactl/Makefile | 5 | ||||
-rw-r--r-- | usr.bin/numactl/numactl.1 | 132 | ||||
-rw-r--r-- | usr.bin/numactl/numactl.c | 284 | ||||
-rw-r--r-- | usr.bin/patch/backupfile.c | 4 | ||||
-rw-r--r-- | usr.bin/patch/patch.1 | 10 | ||||
-rw-r--r-- | usr.bin/patch/patch.c | 9 | ||||
-rw-r--r-- | usr.bin/rctl/rctl.8 | 1 | ||||
-rw-r--r-- | usr.bin/sockstat/sockstat.1 | 7 | ||||
-rw-r--r-- | usr.bin/sockstat/sockstat.c | 38 | ||||
-rw-r--r-- | usr.bin/w/w.c | 2 | ||||
-rw-r--r-- | usr.bin/xargs/xargs.c | 19 |
18 files changed, 523 insertions, 47 deletions
diff --git a/usr.bin/Makefile b/usr.bin/Makefile index 1187dc2..fd78602 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -117,6 +117,7 @@ SUBDIR= ${_addr2line} \ nice \ nl \ ${_nm} \ + numactl \ nohup \ opieinfo \ opiekey \ diff --git a/usr.bin/c99/c99.1 b/usr.bin/c99/c99.1 index 3686495..c993397 100644 --- a/usr.bin/c99/c99.1 +++ b/usr.bin/c99/c99.1 @@ -26,7 +26,7 @@ .\" From FreeBSD: src/usr.bin/c89/c89.1,v 1.11 2007/03/10 07:10:01 ru Exp .\" $FreeBSD$ .\" -.Dd June 17, 2010 +.Dd July 13, 2015 .Dt C99 1 .Os .Sh NAME @@ -188,12 +188,3 @@ The .Nm utility interface conforms to .St -p1003.1-2001 . -Since it is a wrapper around -.Tn GCC , -it is limited to the -.Tn C99 -features that -.Tn GCC -actually implements. -See -.Pa http://gcc.gnu.org/gcc-4.2/c99status.html . diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c index 5e5c146..89863f4 100644 --- a/usr.bin/calendar/io.c +++ b/usr.bin/calendar/io.c @@ -87,11 +87,16 @@ static void trimlr(char **buf) { char *walk = *buf; + char *last; while (isspace(*walk)) walk++; - while (isspace(walk[strlen(walk) -1])) - walk[strlen(walk) -1] = '\0'; + if (*walk != '\0') { + last = walk + strlen(walk) - 1; + while (last > walk && isspace(*last)) + last--; + *(last+1) = 0; + } *buf = walk; } diff --git a/usr.bin/last/last.c b/usr.bin/last/last.c index 945cc41..1db10b3 100644 --- a/usr.bin/last/last.c +++ b/usr.bin/last/last.c @@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$"); typedef struct arg { char *name; /* argument */ +#define REBOOT_TYPE -1 #define HOST_TYPE -2 #define TTY_TYPE -3 #define USER_TYPE -4 @@ -180,6 +181,8 @@ main(int argc, char *argv[]) if (argc) { setlinebuf(stdout); for (argv += optind; *argv; ++argv) { + if (strcmp(*argv, "reboot") == 0) + addarg(REBOOT_TYPE, *argv); #define COMPATIBILITY #ifdef COMPATIBILITY /* code to allow "last p5" to work */ @@ -389,6 +392,11 @@ want(struct utmpx *bp) for (step = arglist; step; step = step->next) switch(step->type) { + case REBOOT_TYPE: + if (bp->ut_type == BOOT_TIME || + bp->ut_type == SHUTDOWN_TIME) + return (YES); + break; case HOST_TYPE: if (!strcasecmp(step->name, bp->ut_host)) return (YES); diff --git a/usr.bin/ministat/ministat.c b/usr.bin/ministat/ministat.c index 4c0ddd0..59beac7 100644 --- a/usr.bin/ministat/ministat.c +++ b/usr.bin/ministat/ministat.c @@ -487,7 +487,7 @@ ReadSet(const char *n, int column, const char *delim) d = strtod(t, &p); if (p != NULL && *p != '\0') - err(2, "Invalid data on line %d in %s\n", line, n); + errx(2, "Invalid data on line %d in %s", line, n); if (*buf != '\0') AddPoint(s, d); } diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index acc27f7..477add6 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -776,19 +776,31 @@ kread_counter(u_long addr) int kread_counters(u_long addr, void *buf, size_t size) { - uint64_t *c = buf; + uint64_t *c; + u_long *counters; + size_t i, n; if (kvmd_init() < 0) return (-1); - if (kread(addr, buf, size) < 0) + if (size % sizeof(uint64_t) != 0) { + xo_warnx("kread_counters: invalid counter set size"); return (-1); + } - while (size != 0) { - *c = kvm_counter_u64_fetch(kvmd, *c); - size -= sizeof(*c); - c++; + n = size / sizeof(uint64_t); + if ((counters = malloc(n * sizeof(u_long))) == NULL) + xo_err(-1, "malloc"); + if (kread(addr, counters, n * sizeof(u_long)) < 0) { + free(counters); + return (-1); } + + c = buf; + for (i = 0; i < n; i++) + c[i] = kvm_counter_u64_fetch(kvmd, counters[i]); + + free(counters); return (0); } diff --git a/usr.bin/netstat/pfkey.c b/usr.bin/netstat/pfkey.c index fbf330f..1a60b48 100644 --- a/usr.bin/netstat/pfkey.c +++ b/usr.bin/netstat/pfkey.c @@ -128,7 +128,7 @@ pfkey_stats(u_long off, const char *name, int family __unused, xo_emit(m, (uintmax_t)pfkeystat.f, plural(pfkeystat.f)) /* userland -> kernel */ - p(out_total, "\t{:sent-requests//%ju} " + p(out_total, "\t{:sent-requests/%ju} " "{N:/request%s sent from userland}\n"); p(out_bytes, "\t{:sent-bytes/%ju} " "{N:/byte%s sent from userland}\n"); @@ -165,7 +165,7 @@ pfkey_stats(u_long off, const char *name, int family __unused, "{N:/message%s with duplicate extension}\n"); p(out_invexttype, "\t{:dropped-bad-extension/%ju} " "{N:/message%s with invalid extension type}\n"); - p(out_invsatype, "\t:dropped-bad-sa-type/%ju} " + p(out_invsatype, "\t{:dropped-bad-sa-type/%ju} " "{N:/message%s with invalid sa type}\n"); p(out_invaddr, "\t{:dropped-bad-address-extension/%ju} " "{N:/message%s with invalid address extension}\n"); diff --git a/usr.bin/numactl/Makefile b/usr.bin/numactl/Makefile new file mode 100644 index 0000000..7158487 --- /dev/null +++ b/usr.bin/numactl/Makefile @@ -0,0 +1,5 @@ +# $FreeBSD$ + +PROG= numactl + +.include <bsd.prog.mk> diff --git a/usr.bin/numactl/numactl.1 b/usr.bin/numactl/numactl.1 new file mode 100644 index 0000000..750e23b --- /dev/null +++ b/usr.bin/numactl/numactl.1 @@ -0,0 +1,132 @@ +.\" Copyright (c) 2015 Adrian Chadd <adrian@FreeBSD.org> +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd May 9, 2015 +.Dt NUMACTL 1 +.Os +.Sh NAME +.Nm numactl +.Nd "manage NUMA policy configuration" +.Sh SYNOPSIS +.Nm +.Op Fl l Ar policy +.Op Fl m Ar domain +.Op Fl c Ar domain +.Ar cmd ... +.Nm +.Fl g +.Op Fl p Ar pid +.Op Fl t Ar tid +.Nm +.Fl s +.Op Fl l Ar policy +.Op Fl m Ar domain +.Op Fl c Ar domain +.Op Fl p Ar pid +.Op Fl t Ar tid +.Sh DESCRIPTION +The +.Nm +command can be used to assign NUMA policies to processes/threads, +run commands with a given NUMA policy, and query information +about NUMA policies on running processes. +.Pp +.Nm +requires a target to modify or query. +The target may be specified as a command, process id or a thread id. +Using +.Fl -get +the target's NUMA policy may be queried. +Using +.Fl -set +the target's NUMA policy may be queried. +If no target is specified, +.Nm +operates on itself. +Not all combinations of operations and targets are supported. +For example, +you may not set the id of an existing set or query and launch a command +at the same time. +.Pp +Each process and thread has a NUMA policy. +By default the policy is NONE. +If a thread policy is NONE, then the policy will fall back to the process. +If the process policy is NONE, then the policy will fall back to the +system default. +The policy may be queried by using +.Fl -get. +.Pp +The options are as follows: +.Bl -tag -width ".Fl -cpudomain Ar domain" +.It Fl -cpudomain Ar domain , Fl c Ar domain +Set the given CPU scheduling policy. +Constrain the the object (tid, pid, command) to run on CPUs +that belong to the given domain. +.It Fl -get , Fl g +Retrieve the NUMA policy for the given thread or process id. +.It Fl -set , Fl s +Set the NUMA policy for the given thread or process id. +.It Fl -memdomain Ar domain , Fl m Ar domain +Constrain the object (tid, pid, command) to the given +domain. +This is only valid for fixed-domain and fixed-domain-rr. +It must not be set for other policies. +.It Fl -mempolicy Ar policy , Fl l Ar policy +Set the given memory allocation policy. +Valid policies are none, rr, fixed-domain, fixed-domain-rr, +first-touch, and first-touch-rr. +A memdomain argument is required for fixed-domain and +fixed-domain-rr. +.It Fl -pid Ar pid , Fl p Ar pid +Operate on the given pid. +.It Fl -tid Ar tid , Fl t Ar tid +Operate on the given tid. +.El +.Sh EXIT STATUS +.Ex -std +.Sh EXAMPLES +Create a +.Pa /bin/sh +process with memory coming from domain 0, but +CPUs coming from domain 1: +.Dl numactl --mempolicy=fixed-domain --memdomain=0 --cpudomain=1 /bin/sh +.Pp +Query the NUMA policy for the +.Aq sh pid : +.Dl numactl --get --pid=<sh pid> +.Pp +Set the NUMA policy for the given TID to round-robin: +.Dl numactl --set --mempolicy=rr --tid=<tid> +.Sh SEE ALSO +.Xr cpuset 2 , +.Xr numa 4 +.Sh HISTORY +The +.Nm +command first appeared in +.Fx 11.0 . +.Sh AUTHORS +.An Adrian Chadd Aq Mt adrian@FreeBSD.org diff --git a/usr.bin/numactl/numactl.c b/usr.bin/numactl/numactl.c new file mode 100644 index 0000000..ce1dfae --- /dev/null +++ b/usr.bin/numactl/numactl.c @@ -0,0 +1,284 @@ +/* + * Copyright (c) 2015 Adrian Chadd <adrian@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/param.h> +#include <sys/cpuset.h> +#include <sys/numa.h> +#include <sys/resource.h> +#include <sys/time.h> + +#include <ctype.h> +#include <err.h> +#include <errno.h> +#include <getopt.h> +#include <libgen.h> +#include <limits.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sysexits.h> +#include <unistd.h> + +static struct option longopts[] = { + { "tid", required_argument, NULL, 't' }, + { "pid", required_argument, NULL, 'p' }, + { "memdomain", required_argument, NULL, 'm' }, + { "cpudomain", required_argument, NULL, 'c' }, + { "mempolicy", required_argument, NULL, 'l' }, + { "set", no_argument, NULL, 's' }, + { "get", no_argument, NULL, 'g' }, + { NULL, 0, NULL, 0 } +}; + +static const char * +policy_to_str(vm_domain_policy_type_t vt) +{ + + switch (vt) { + case VM_POLICY_NONE: + return ("none"); + case VM_POLICY_ROUND_ROBIN: + return ("rr"); + case VM_POLICY_FIXED_DOMAIN: + return ("fixed-domain"); + case VM_POLICY_FIXED_DOMAIN_ROUND_ROBIN: + return ("fixed-domain-rr"); + case VM_POLICY_FIRST_TOUCH: + return ("first-touch"); + case VM_POLICY_FIRST_TOUCH_ROUND_ROBIN: + return ("first-touch-rr"); + default: + return ("unknown"); + } +} + +static int +parse_policy(struct vm_domain_policy_entry *vd, const char *str) +{ + + if (strcmp(str, "rr") == 0) { + vd->policy = VM_POLICY_ROUND_ROBIN; + vd->domain = -1; + return (0); + } + + if (strcmp(str, "first-touch-rr") == 0) { + vd->policy = VM_POLICY_FIRST_TOUCH_ROUND_ROBIN; + vd->domain = -1; + return (0); + } + + if (strcmp(str, "first-touch") == 0) { + vd->policy = VM_POLICY_FIRST_TOUCH; + vd->domain = -1; + return (0); + } + + if (strcmp(str, "fixed-domain") == 0) { + vd->policy = VM_POLICY_FIXED_DOMAIN; + vd->domain = 0; + return (0); + } + + if (strcmp(str, "fixed-domain-rr") == 0) { + vd->policy = VM_POLICY_FIXED_DOMAIN_ROUND_ROBIN; + vd->domain = 0; + return (0); + } + + return (-1); +} + +static void +usage(void) +{ + + printf("usage: numactl --get [--tid/-t <tid>] [--pid/-p <pid>]\n"); + printf(" numactl --set [--tid=<tid>] [--pid/-p<pid>]\n"); + printf(" [--mempolicy/-l <policy>] [--memdomain/" + "-m <domain>]\n"); + printf(" [--cpudomain/-c <domain>]\n"); + printf(" numactl [--mempolicy/-l <policy>] [--memdomain/-m " + "<domain>]\n"); + printf(" [--cpudomain/-c <domain>] <cmd> ...\n"); + + exit(EX_USAGE); +} + +static int +set_numa_domain_cpuaffinity(int cpu_domain) +{ + cpuset_t set; + int error; + + error = cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_DOMAIN, + cpu_domain, sizeof(set), &set); + if (error != 0) + err(1, "cpuset_getaffinity"); + error = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, + sizeof(set), &set); + if (error != 0) + err(1, "cpuset_setaffinity"); + + return (0); +} + +int +main(int argc, char *argv[]) +{ + struct vm_domain_policy_entry vd; + lwpid_t tid; + pid_t pid; + cpuwhich_t which; + id_t id; + int error; + int is_set, is_get; + int mem_policy_set; + int ch; + int cpu_domain; + + id = -1; + which = -1; + is_set = 0; + is_get = 0; + mem_policy_set = 0; + tid = -1; + pid = -1; + cpu_domain = -1; + + while ((ch = getopt_long(argc, argv, "c:gl:m:p:st:", longopts, + NULL)) != -1) { + switch (ch) { + case 'c': + cpu_domain = atoi(optarg); + break; + case 'g': + is_get = 1; + break; + case 'l': + if (parse_policy(&vd, optarg) != 0) { + fprintf(stderr, + "Could not parse policy: '%s'\n", optarg); + exit(1); + } + mem_policy_set = 1; + break; + case 'm': + if (mem_policy_set == 0) { + fprintf(stderr, + "Error: set policy first before domain\n"); + exit(1); + } + vd.domain = atoi(optarg); + break; + case 'p': + pid = atoi(optarg); + break; + case 's': + is_set = 1; + break; + case 't': + tid = atoi(optarg); + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + + /* Handle the user wishing to run a command */ + if (argc) { + /* Ensure that a policy was set */ + if (mem_policy_set == 0) { + fprintf(stderr, "Error: no policy given\n"); + usage(); + } + + /* Set current memory process policy, will be inherited */ + if (numa_setaffinity(CPU_WHICH_PID, -1, &vd) != 0) + err(1, "numa_setaffinity"); + + /* If a CPU domain policy was given, include that too */ + if (cpu_domain != -1) + (void) set_numa_domain_cpuaffinity(cpu_domain); + + errno = 0; + execvp(*argv, argv); + err(errno == ENOENT ? 127 : 126, "%s", *argv); + } + + /* Figure out which */ + if (tid != -1) { + which = CPU_WHICH_TID; + id = tid; + } else if (pid != -1) { + which = CPU_WHICH_PID; + id = pid; + } else { + fprintf(stderr, "Error: one of tid or pid must be given\n"); + usage(); + } + + /* Sanity checks */ + if (is_set && is_get) { + fprintf(stderr, "Error: can't set both 'set' and 'get'\n"); + usage(); + } + + if (is_set && ! mem_policy_set) { + fprintf(stderr, "Error: --set given, but no policy\n"); + usage(); + } + + /* If it's get, then get the policy and return */ + if (is_get) { + error = numa_getaffinity(which, id, &vd); + if (error != 0) + err(1, "numa_getaffinity"); + printf(" Policy: %s; domain: %d\n", + policy_to_str(vd.policy), + vd.domain); + exit(0); + } + + /* Assume it's set */ + + /* Syscall */ + error = numa_setaffinity(which, id, &vd); + if (error != 0) + err(1, "numa_setaffinity"); + + /* If a CPU domain policy was given, include that too */ + if (cpu_domain != -1) + (void) set_numa_domain_cpuaffinity(cpu_domain); + + exit(0); +} diff --git a/usr.bin/patch/backupfile.c b/usr.bin/patch/backupfile.c index d22d607..ecdca19 100644 --- a/usr.bin/patch/backupfile.c +++ b/usr.bin/patch/backupfile.c @@ -219,11 +219,11 @@ invalid_arg(const char *kind, const char *value, int problem) } static const char *backup_args[] = { - "never", "simple", "nil", "existing", "t", "numbered", 0 + "none", "never", "simple", "nil", "existing", "t", "numbered", 0 }; static enum backup_type backup_types[] = { - simple, simple, numbered_existing, + none, simple, simple, numbered_existing, numbered_existing, numbered, numbered }; diff --git a/usr.bin/patch/patch.1 b/usr.bin/patch/patch.1 index aac69de..25adf5f 100644 --- a/usr.bin/patch/patch.1 +++ b/usr.bin/patch/patch.1 @@ -21,7 +21,7 @@ .\" .\" $OpenBSD: patch.1,v 1.27 2014/04/15 06:26:54 jmc Exp $ .\" $FreeBSD$ -.Dd June 15, 2014 +.Dd July 21, 2015 .Dt PATCH 1 .Os .Sh NAME @@ -39,7 +39,7 @@ .Op Fl o Ar out-file .Op Fl p Ar strip-count .Op Fl r Ar rej-name -.Op Fl V Cm t | nil | never +.Op Fl V Cm t | nil | never | none .Op Fl x Ar number .Op Fl z Ar backup-ext .Op Fl Fl posix @@ -296,8 +296,8 @@ Forces .Nm to interpret the patch file as a unified context diff (a unidiff). .It Xo -.Fl V Cm t | nil | never , -.Fl Fl version-control Cm t | nil | never +.Fl V Cm t | nil | never | none , +.Fl Fl version-control Cm t | nil | never | none .Xc Causes the next argument to be interpreted as a method for creating backup file names. @@ -328,6 +328,8 @@ Make numbered backups of files that already have them, simple backups of the others. .It Cm never , simple Always make simple backups. +.It Cm none +Do not make backups. .El .It Fl v , Fl Fl version Causes diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c index 22f3027..b061041d 100644 --- a/usr.bin/patch/patch.c +++ b/usr.bin/patch/patch.c @@ -109,6 +109,8 @@ static bool remove_empty_files = false; /* true if -R was specified on command line. */ static bool reverse_flag_specified = false; +static bool Vflag = false; + /* buffer holding the name of the rejected patch file. */ static char rejname[NAME_MAX + 1]; @@ -201,7 +203,7 @@ main(int argc, char *argv[]) Argv = argv; get_some_switches(); - if (backup_type == none) { + if (!Vflag) { if ((v = getenv("PATCH_VERSION_CONTROL")) == NULL) v = getenv("VERSION_CONTROL"); if (v != NULL || !posix) @@ -595,6 +597,7 @@ get_some_switches(void) break; case 'V': backup_type = get_version(optarg); + Vflag = true; break; #ifdef DEBUGGING case 'x': @@ -631,8 +634,8 @@ usage(void) fprintf(stderr, "usage: patch [-bCcEeflNnRstuv] [-B backup-prefix] [-D symbol] [-d directory]\n" " [-F max-fuzz] [-i patchfile] [-o out-file] [-p strip-count]\n" -" [-r rej-name] [-V t | nil | never] [-x number] [-z backup-ext]\n" -" [--posix] [origfile [patchfile]]\n" +" [-r rej-name] [-V t | nil | never | none] [-x number]\n" +" [-z backup-ext] [--posix] [origfile [patchfile]]\n" " patch <patchfile\n"); my_exit(EXIT_FAILURE); } diff --git a/usr.bin/rctl/rctl.8 b/usr.bin/rctl/rctl.8 index fe14756..bebf4fd 100644 --- a/usr.bin/rctl/rctl.8 +++ b/usr.bin/rctl/rctl.8 @@ -245,6 +245,7 @@ Enable This defaults to 1, unless .Cd "options RACCT_DEFAULT_TO_DISABLED" is set in the kernel configuration file. +.El .Sh EXIT STATUS .Ex -std .Sh EXAMPLES diff --git a/usr.bin/sockstat/sockstat.1 b/usr.bin/sockstat/sockstat.1 index 280fc2c..05faf3b 100644 --- a/usr.bin/sockstat/sockstat.1 +++ b/usr.bin/sockstat/sockstat.1 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 20, 2015 +.Dd July 14, 2015 .Dt SOCKSTAT 1 .Os .Sh NAME @@ -35,7 +35,7 @@ .Nd list open sockets .Sh SYNOPSIS .Nm -.Op Fl 46cLlu +.Op Fl 46cLlsu .Op Fl j Ar jid .Op Fl p Ar ports .Op Fl P Ar protocols @@ -83,6 +83,9 @@ The argument is a comma-separated list of protocol names, as they are defined in .Xr protocols 5 . +.It Fl s +Display the protocol state, if applicable. +This is currently only implemented for TCP. .It Fl u Show .Dv AF_LOCAL diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c index d1ec0d3..2861254 100644 --- a/usr.bin/sockstat/sockstat.c +++ b/usr.bin/sockstat/sockstat.c @@ -45,6 +45,8 @@ __FBSDID("$FreeBSD$"); #include <netinet/in_pcb.h> #include <netinet/sctp.h> #include <netinet/tcp.h> +#define TCPSTATES /* load state names */ +#include <netinet/tcp_fsm.h> #include <netinet/tcp_seq.h> #include <netinet/tcp_var.h> #include <arpa/inet.h> @@ -71,6 +73,7 @@ static int opt_c; /* Show connected sockets */ static int opt_j; /* Show specified jail */ static int opt_L; /* Don't show IPv4 or IPv6 loopback sockets */ static int opt_l; /* Show listening sockets */ +static int opt_s; /* Show protocol state if applicable */ static int opt_u; /* Show Unix domain sockets */ static int opt_v; /* Verbose mode */ @@ -101,6 +104,7 @@ struct sock { int vflag; int family; int proto; + int state; const char *protoname; struct addr *laddr; struct addr *faddr; @@ -538,9 +542,9 @@ gather_inet(int proto) const char *varname, *protoname; size_t len, bufsize; void *buf; - int hash, retry, vflag; + int hash, retry, state, vflag; - vflag = 0; + state = vflag = 0; if (opt_4) vflag |= INP_IPV4; if (opt_6) @@ -594,9 +598,10 @@ gather_inet(int proto) xig = (struct xinpgen *)(void *)((char *)xig + xig->xig_len); if (xig >= exig) break; + xip = (struct xinpcb *)xig; + xtp = (struct xtcpcb *)xig; switch (proto) { case IPPROTO_TCP: - xtp = (struct xtcpcb *)xig; if (xtp->xt_len != sizeof(*xtp)) { warnx("struct xtcpcb size mismatch"); goto out; @@ -604,10 +609,10 @@ gather_inet(int proto) inp = &xtp->xt_inp; so = &xtp->xt_socket; protoname = xtp->xt_tp.t_flags & TF_TOE ? "toe" : "tcp"; + state = xtp->xt_tp.t_state; break; case IPPROTO_UDP: case IPPROTO_DIVERT: - xip = (struct xinpcb *)xig; if (xip->xi_len != sizeof(*xip)) { warnx("struct xinpcb size mismatch"); goto out; @@ -670,6 +675,8 @@ gather_inet(int proto) sock->laddr = laddr; sock->faddr = faddr; sock->vflag = inp->inp_vflag; + if (proto == IPPROTO_TCP) + sock->state = xtp->xt_tp.t_state; sock->protoname = protoname; hash = (int)((uintptr_t)sock->socket % HASHSIZE); sock->next = sockhash[hash]; @@ -977,7 +984,14 @@ displaysock(struct sock *s, int pos) pos = 0; } } - xprintf("\n"); + if (opt_s && s->proto == IPPROTO_TCP) { + while (pos < 80) + pos += xprintf(" "); + if (s->state >= 0 && s->state < TCP_NSTATES) + pos += xprintf("%s", tcpstates[s->state]); + else + pos += xprintf("?"); + } } static void @@ -988,9 +1002,12 @@ display(void) struct sock *s; int hash, n, pos; - printf("%-8s %-10s %-5s %-2s %-6s %-21s %-21s\n", + printf("%-8s %-10s %-5s %-2s %-6s %-21s %-21s", "USER", "COMMAND", "PID", "FD", "PROTO", "LOCAL ADDRESS", "FOREIGN ADDRESS"); + if (opt_s) + printf(" %-12s", "STATE"); + printf("\n"); setpassent(1); for (xf = xfiles, n = 0; n < nxfiles; ++n, ++xf) { if (xf->xf_data == NULL) @@ -1019,6 +1036,7 @@ display(void) pos += xprintf(" "); pos += xprintf("%d ", xf->xf_fd); displaysock(s, pos); + xprintf("\n"); } } if (opt_j >= 0) @@ -1033,6 +1051,7 @@ display(void) pos += xprintf("%-8s %-10s %-5s %-2s ", "?", "?", "?", "?"); displaysock(s, pos); + xprintf("\n"); } } } @@ -1061,7 +1080,7 @@ static void usage(void) { fprintf(stderr, - "Usage: sockstat [-46cLlu] [-j jid] [-p ports] [-P protocols]\n"); + "usage: sockstat [-46cLlsu] [-j jid] [-p ports] [-P protocols]\n"); exit(1); } @@ -1072,7 +1091,7 @@ main(int argc, char *argv[]) int o, i; opt_j = -1; - while ((o = getopt(argc, argv, "46cj:Llp:P:uv")) != -1) + while ((o = getopt(argc, argv, "46cj:Llp:P:suv")) != -1) switch (o) { case '4': opt_4 = 1; @@ -1098,6 +1117,9 @@ main(int argc, char *argv[]) case 'P': protos_defined = parse_protos(optarg); break; + case 's': + opt_s = 1; + break; case 'u': opt_u = 1; break; diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index f94d8a6..4df4abd 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -120,7 +120,7 @@ static struct entry { #define W_DISPUSERSIZE 10 #define W_DISPLINESIZE 8 -#define W_DISPHOSTSIZE 24 +#define W_DISPHOSTSIZE 40 static void pr_header(time_t *, int); static struct stat *ttystat(char *); diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c index 6bd3e9f..b95c7d4 100644 --- a/usr.bin/xargs/xargs.c +++ b/usr.bin/xargs/xargs.c @@ -101,6 +101,7 @@ main(int argc, char *argv[]) int ch, Jflag, nargs, nflag, nline; size_t linelen; char *endptr; + const char *errstr; inpline = replstr = NULL; ep = environ; @@ -148,19 +149,23 @@ main(int argc, char *argv[]) replstr = optarg; break; case 'L': - Lflag = atoi(optarg); + Lflag = strtonum(optarg, 0, INT_MAX, &errstr); + if (errstr) + errx(1, "-L %s: %s", optarg, errstr); break; case 'n': nflag = 1; - if ((nargs = atoi(optarg)) <= 0) - errx(1, "illegal argument count"); + nargs = strtonum(optarg, 1, INT_MAX, &errstr); + if (errstr) + errx(1, "-n %s: %s", optarg, errstr); break; case 'o': oflag = 1; break; case 'P': - if ((maxprocs = atoi(optarg)) <= 0) - errx(1, "max. processes must be >0"); + maxprocs = strtonum(optarg, 1, INT_MAX, &errstr); + if (errstr) + errx(1, "-P %s: %s", optarg, errstr); break; case 'p': pflag = 1; @@ -179,7 +184,9 @@ main(int argc, char *argv[]) errx(1, "replsize must be a number"); break; case 's': - nline = atoi(optarg); + nline = strtonum(optarg, 0, INT_MAX, &errstr); + if (errstr) + errx(1, "-s %s: %s", optarg, errstr); break; case 't': tflag = 1; |