aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/cp/tests/Makefile2
-rwxr-xr-xbin/cp/tests/cp_test.sh10
-rw-r--r--bin/cp/tests/sparse.c73
-rw-r--r--bin/cpuset/Makefile2
-rw-r--r--bin/cpuset/cpuset.c153
-rw-r--r--bin/date/date.18
-rw-r--r--bin/freebsd-version/freebsd-version.14
-rw-r--r--bin/ln/tests/ln_test.sh2
-rw-r--r--bin/pwait/pwait.c30
-rw-r--r--bin/sh/Makefile7
-rw-r--r--bin/sh/dot.profile2
-rw-r--r--bin/timeout/tests/timeout_test.sh2
-rw-r--r--bin/uuidgen/uuidgen.117
13 files changed, 45 insertions, 267 deletions
diff --git a/bin/cp/tests/Makefile b/bin/cp/tests/Makefile
index 3fa9ae8f0685..a1917ada8fbf 100644
--- a/bin/cp/tests/Makefile
+++ b/bin/cp/tests/Makefile
@@ -1,7 +1,5 @@
PACKAGE= tests
ATF_TESTS_SH= cp_test
-PROGS+= sparse
-BINDIR= ${TESTSDIR}
.include <bsd.test.mk>
diff --git a/bin/cp/tests/cp_test.sh b/bin/cp/tests/cp_test.sh
index 999993bfad67..b637f862b7d3 100755
--- a/bin/cp/tests/cp_test.sh
+++ b/bin/cp/tests/cp_test.sh
@@ -90,7 +90,7 @@ hardlink_body()
echo "foo" >foo
atf_check cp -l foo bar
atf_check -o inline:"foo\n" cat bar
- atf_check_equal "$(stat -f%d,%i foo)" "$(stat -f%d,%i bar)"
+ atf_check test foo -ef bar
}
atf_test_case hardlink_exists
@@ -105,7 +105,7 @@ hardlink_exists_body()
echo "bar" >bar
atf_check -s not-exit:0 -e match:exists cp -l foo bar
atf_check -o inline:"bar\n" cat bar
- atf_check_not_equal "$(stat -f%d,%i foo)" "$(stat -f%d,%i bar)"
+ atf_check test ! foo -ef bar
}
atf_test_case hardlink_exists_force
@@ -120,7 +120,7 @@ hardlink_exists_force_body()
echo "bar" >bar
atf_check cp -fl foo bar
atf_check -o inline:"foo\n" cat bar
- atf_check_equal "$(stat -f%d,%i foo)" "$(stat -f%d,%i bar)"
+ atf_check test foo -ef bar
}
atf_test_case matching_srctgt
@@ -384,12 +384,12 @@ samefile_body()
file_is_sparse()
{
- atf_check ${0%/*}/sparse "$1"
+ atf_check -o match:"^[0-9]+-[0-9]" stat -h "$1"
}
files_are_equal()
{
- atf_check_not_equal "$(stat -f%d,%i "$1")" "$(stat -f%d,%i "$2")"
+ atf_check test ! "$1" -ef "$2"
atf_check cmp "$1" "$2"
}
diff --git a/bin/cp/tests/sparse.c b/bin/cp/tests/sparse.c
deleted file mode 100644
index 78957581a56c..000000000000
--- a/bin/cp/tests/sparse.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-
- * Copyright (c) 2023 Klara, Inc.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <err.h>
-#include <fcntl.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sysexits.h>
-#include <unistd.h>
-
-static bool verbose;
-
-/*
- * Returns true if the file named by its argument is sparse, i.e. if
- * seeking to SEEK_HOLE returns a different value than seeking to
- * SEEK_END.
- */
-static bool
-sparse(const char *filename)
-{
- off_t hole, end;
- int fd;
-
- if ((fd = open(filename, O_RDONLY)) < 0 ||
- (hole = lseek(fd, 0, SEEK_HOLE)) < 0 ||
- (end = lseek(fd, 0, SEEK_END)) < 0)
- err(1, "%s", filename);
- close(fd);
- if (end > hole) {
- if (verbose)
- printf("%s: hole at %zu\n", filename, (size_t)hole);
- return (true);
- }
- return (false);
-}
-
-static void
-usage(void)
-{
-
- fprintf(stderr, "usage: sparse [-v] file [...]\n");
- exit(EX_USAGE);
-}
-
-int
-main(int argc, char *argv[])
-{
- int opt, rv;
-
- while ((opt = getopt(argc, argv, "v")) != -1) {
- switch (opt) {
- case 'v':
- verbose = true;
- break;
- default:
- usage();
- break;
- }
- }
- argc -= optind;
- argv += optind;
- if (argc == 0)
- usage();
- rv = EXIT_SUCCESS;
- while (argc-- > 0)
- if (!sparse(*argv++))
- rv = EXIT_FAILURE;
- exit(rv);
-}
diff --git a/bin/cpuset/Makefile b/bin/cpuset/Makefile
index d6f58db62901..639dd9812171 100644
--- a/bin/cpuset/Makefile
+++ b/bin/cpuset/Makefile
@@ -1,6 +1,6 @@
PROG= cpuset
-LIBADD= jail
+LIBADD= jail util
SYMLINKS+= ../..${BINDIR}/cpuset /usr/bin/cpuset
diff --git a/bin/cpuset/cpuset.c b/bin/cpuset/cpuset.c
index 82ffcaeec252..7416e100a3c6 100644
--- a/bin/cpuset/cpuset.c
+++ b/bin/cpuset/cpuset.c
@@ -43,6 +43,7 @@
#include <err.h>
#include <errno.h>
#include <jail.h>
+#include <libutil.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
@@ -69,154 +70,6 @@ static cpuwhich_t which;
static void usage(void) __dead2;
-struct numa_policy {
- const char *name;
- int policy;
-};
-
-static struct numa_policy policies[] = {
- { "round-robin", DOMAINSET_POLICY_ROUNDROBIN },
- { "rr", DOMAINSET_POLICY_ROUNDROBIN },
- { "first-touch", DOMAINSET_POLICY_FIRSTTOUCH },
- { "ft", DOMAINSET_POLICY_FIRSTTOUCH },
- { "prefer", DOMAINSET_POLICY_PREFER },
- { "interleave", DOMAINSET_POLICY_INTERLEAVE},
- { "il", DOMAINSET_POLICY_INTERLEAVE},
- { NULL, DOMAINSET_POLICY_INVALID }
-};
-
-static void printset(struct bitset *mask, int size);
-
-static void
-parselist(char *list, struct bitset *mask, int size)
-{
- enum { NONE, NUM, DASH } state;
- int lastnum;
- int curnum;
- char *l;
-
- state = NONE;
- curnum = lastnum = 0;
- for (l = list; *l != '\0';) {
- if (isdigit(*l)) {
- curnum = atoi(l);
- if (curnum >= size)
- errx(EXIT_FAILURE,
- "List entry %d exceeds maximum of %d",
- curnum, size - 1);
- while (isdigit(*l))
- l++;
- switch (state) {
- case NONE:
- lastnum = curnum;
- state = NUM;
- break;
- case DASH:
- for (; lastnum <= curnum; lastnum++)
- BIT_SET(size, lastnum, mask);
- state = NONE;
- break;
- case NUM:
- default:
- goto parserr;
- }
- continue;
- }
- switch (*l) {
- case ',':
- switch (state) {
- case NONE:
- break;
- case NUM:
- BIT_SET(size, curnum, mask);
- state = NONE;
- break;
- case DASH:
- goto parserr;
- break;
- }
- break;
- case '-':
- if (state != NUM)
- goto parserr;
- state = DASH;
- break;
- default:
- goto parserr;
- }
- l++;
- }
- switch (state) {
- case NONE:
- break;
- case NUM:
- BIT_SET(size, curnum, mask);
- break;
- case DASH:
- goto parserr;
- }
- return;
-parserr:
- errx(EXIT_FAILURE, "Malformed list %s", list);
-}
-
-static void
-parsecpulist(char *list, cpuset_t *mask)
-{
-
- if (strcasecmp(list, "all") == 0) {
- if (cpuset_getaffinity(CPU_LEVEL_ROOT, CPU_WHICH_PID, -1,
- sizeof(*mask), mask) != 0)
- err(EXIT_FAILURE, "getaffinity");
- return;
- }
- parselist(list, (struct bitset *)mask, CPU_SETSIZE);
-}
-
-/*
- * permissively parse policy:domain list
- * allow:
- * round-robin:0-4 explicit
- * round-robin:all explicit root domains
- * 0-4 implicit root policy
- * round-robin implicit root domains
- * all explicit root domains and implicit policy
- */
-static void
-parsedomainlist(char *list, domainset_t *mask, int *policyp)
-{
- domainset_t rootmask;
- struct numa_policy *policy;
- char *l;
- int p;
-
- /*
- * Use the rootset's policy as the default for unspecified policies.
- */
- if (cpuset_getdomain(CPU_LEVEL_ROOT, CPU_WHICH_PID, -1,
- sizeof(rootmask), &rootmask, &p) != 0)
- err(EXIT_FAILURE, "getdomain");
-
- l = list;
- for (policy = &policies[0]; policy->name != NULL; policy++) {
- if (strncasecmp(l, policy->name, strlen(policy->name)) == 0) {
- p = policy->policy;
- l += strlen(policy->name);
- if (*l != ':' && *l != '\0')
- errx(EXIT_FAILURE, "Malformed list %s", list);
- if (*l == ':')
- l++;
- break;
- }
- }
- *policyp = p;
- if (strcasecmp(l, "all") == 0 || *l == '\0') {
- DOMAINSET_COPY(&rootmask, mask);
- return;
- }
- parselist(l, (struct bitset *)mask, DOMAINSET_SETSIZE);
-}
-
static void
printset(struct bitset *mask, int size)
{
@@ -327,11 +180,11 @@ main(int argc, char *argv[])
break;
case 'l':
lflag = 1;
- parsecpulist(optarg, &mask);
+ cpuset_parselist(optarg, &mask);
break;
case 'n':
nflag = 1;
- parsedomainlist(optarg, &domains, &policy);
+ domainset_parselist(optarg, &domains, &policy);
break;
case 'p':
pflag = 1;
diff --git a/bin/date/date.1 b/bin/date/date.1
index 62d28a7df0a0..b86a660a924d 100644
--- a/bin/date/date.1
+++ b/bin/date/date.1
@@ -29,7 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd September 10, 2024
+.Dd September 1, 2025
.Dt DATE 1
.Os
.Sh NAME
@@ -129,7 +129,7 @@ format.
Parsing is done using
.Xr strptime 3 .
.It Fl I Ns Op Ar FMT
-Use
+Use extended
.St -iso8601
output format.
.Ar FMT
@@ -154,9 +154,9 @@ is
.Cm seconds ,
or
.Cm ns Pc ,
-the
+the extended
.St -iso8601
-format includes the timezone.
+format includes the timezone offset.
.It Fl j
Do not try to set the date.
This allows you to use the
diff --git a/bin/freebsd-version/freebsd-version.1 b/bin/freebsd-version/freebsd-version.1
index 82ea9c707d69..c2b3241d0434 100644
--- a/bin/freebsd-version/freebsd-version.1
+++ b/bin/freebsd-version/freebsd-version.1
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd October 1, 2021
+.Dd August 27, 2025
.Dt FREEBSD-VERSION 1
.Os
.Sh NAME
@@ -73,7 +73,7 @@ If several of the above options are specified,
will print the installed kernel version first, then the running kernel
version, next the userland version, and finally the userland version
of the specified jails, on separate lines.
-If neither is specified, it will print the userland version only.
+If no option is specified, it will print the userland version only.
.Sh IMPLEMENTATION NOTES
The
.Nm
diff --git a/bin/ln/tests/ln_test.sh b/bin/ln/tests/ln_test.sh
index 78b4074aea18..ac9d785ba1fc 100644
--- a/bin/ln/tests/ln_test.sh
+++ b/bin/ln/tests/ln_test.sh
@@ -28,7 +28,7 @@
atf_check_same_file()
{
- atf_check_equal "$(stat -f %d,%i "$1")" "$(stat -f %d,%i "$2")"
+ atf_check test "$1" -ef "$2"
}
atf_check_symlink_to()
diff --git a/bin/pwait/pwait.c b/bin/pwait/pwait.c
index 0fae22562607..a78c0bb84ca8 100644
--- a/bin/pwait/pwait.c
+++ b/bin/pwait/pwait.c
@@ -39,6 +39,7 @@
#include <err.h>
#include <errno.h>
#include <signal.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -48,7 +49,6 @@
static void
usage(void)
{
-
fprintf(stderr, "usage: pwait [-t timeout] [-ov] pid ...\n");
exit(EX_USAGE);
}
@@ -61,15 +61,15 @@ main(int argc, char *argv[])
{
struct itimerval itv;
struct kevent *e;
- int oflag, tflag, verbose;
- int i, kq, n, nleft, opt, status;
- long pid;
char *end, *s;
double timeout;
+ long pid;
+ int i, kq, n, nleft, opt, status;
+ bool oflag, tflag, verbose;
- oflag = 0;
- tflag = 0;
- verbose = 0;
+ oflag = false;
+ tflag = false;
+ verbose = false;
memset(&itv, 0, sizeof(itv));
while ((opt = getopt(argc, argv, "ot:v")) != -1) {
@@ -78,25 +78,31 @@ main(int argc, char *argv[])
oflag = 1;
break;
case 't':
- tflag = 1;
+ tflag = true;
errno = 0;
timeout = strtod(optarg, &end);
if (end == optarg || errno == ERANGE || timeout < 0) {
errx(EX_DATAERR, "timeout value");
}
- switch(*end) {
- case 0:
+ switch (*end) {
+ case '\0':
+ break;
case 's':
+ end++;
break;
case 'h':
timeout *= 60;
/* FALLTHROUGH */
case 'm':
timeout *= 60;
+ end++;
break;
default:
errx(EX_DATAERR, "timeout unit");
}
+ if (*end != '\0') {
+ errx(EX_DATAERR, "timeout unit");
+ }
if (timeout > 100000000L) {
errx(EX_DATAERR, "timeout value");
}
@@ -106,7 +112,7 @@ main(int argc, char *argv[])
(suseconds_t)(timeout * 1000000UL);
break;
case 'v':
- verbose = 1;
+ verbose = true;
break;
default:
usage();
@@ -134,7 +140,7 @@ main(int argc, char *argv[])
for (n = 0; n < argc; n++) {
s = argv[n];
/* Undocumented Solaris compat */
- if (!strncmp(s, "/proc/", 6)) {
+ if (strncmp(s, "/proc/", 6) == 0) {
s += 6;
}
errno = 0;
diff --git a/bin/sh/Makefile b/bin/sh/Makefile
index 087dbf40c3bd..2b1eca8e4b31 100644
--- a/bin/sh/Makefile
+++ b/bin/sh/Makefile
@@ -69,11 +69,4 @@ token.h: mktokens
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
-beforeinstallconfig:
- rm -f ${DESTDIR}/.profile
-
-LINKMODE=${CONFMODE}
-afterinstallconfig:
- ${INSTALL_LINK} ${TAG_ARGS} ${DESTDIR}/root/.profile ${DESTDIR}/.profile
-
.include <bsd.prog.mk>
diff --git a/bin/sh/dot.profile b/bin/sh/dot.profile
index d27a2ae2fdbe..cba9bcf18ad9 100644
--- a/bin/sh/dot.profile
+++ b/bin/sh/dot.profile
@@ -1,6 +1,4 @@
#
-HOME=/root
-export HOME
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:~/bin
export PATH
TERM=${TERM:-xterm}
diff --git a/bin/timeout/tests/timeout_test.sh b/bin/timeout/tests/timeout_test.sh
index b1bf69968e84..88dbaa808043 100644
--- a/bin/timeout/tests/timeout_test.sh
+++ b/bin/timeout/tests/timeout_test.sh
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2014 Baptiste Daroussin <bapt@FreeBSD.org>
atf_test_case nominal
nominal_head()
diff --git a/bin/uuidgen/uuidgen.1 b/bin/uuidgen/uuidgen.1
index 1c2e7cce91d3..f7911b408f36 100644
--- a/bin/uuidgen/uuidgen.1
+++ b/bin/uuidgen/uuidgen.1
@@ -1,3 +1,6 @@
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
.\" Copyright (c) 2002 Marcel Moolenaar
.\" All rights reserved.
.\"
@@ -22,7 +25,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd March 1, 2023
+.Dd August 27, 2025
.Dt UUIDGEN 1
.Os
.Sh NAME
@@ -30,9 +33,7 @@
.Nd generate universally unique identifiers
.Sh SYNOPSIS
.Nm
-.Op Fl 1
-.Op Fl r
-.Op Fl c
+.Op Fl 1cr
.Op Fl n Ar count
.Op Fl o Ar filename
.Sh DESCRIPTION
@@ -50,8 +51,6 @@ This option only has effect if multiple identifiers are to be generated and
instructs
.Nm
to not generate them in batch, but one at a time.
-.It Fl r
-This option controls creation of random UUID (version 4).
.It Fl c
This option controls creation of compact UUID (without hyphen).
.It Fl n
@@ -65,6 +64,8 @@ The upper hard limit is 2048
Redirect output to
.Ar filename
instead of stdout.
+.It Fl r
+This option controls creation of random UUID (version 4).
.El
.Pp
Batched generation yields a dense set of identifiers in such a way that there
@@ -80,11 +81,11 @@ reflected in the distance between two successive identifiers.
.Sh EXAMPLES
Generate a batch of three UUIDs.
Notice the similarity of the string before the first hyphen of the UUID
-(known as
+.Po known as
.Em time_low
in
.Em rfc4122
-):
+.Pc :
.Bd -literal -offset indent
$ uuidgen -n3
8bc44345-4d90-11ee-88c7-b42e991fc52e