Commit Graph

15533 Commits

Author SHA1 Message Date
Dag-Erling Smørgrav
fc76ddee9b tftp: Add test cases for URL mode.
Sponsored by:	Klara, Inc.
Reviewed by:	asomers
Differential Revision:	https://reviews.freebsd.org/D39014
2023-03-13 16:16:26 +00:00
David E. O'Brien
65e9eb0701 Look in getlocalbase() for the calendar-data package data
Fix d20d655018 where getlocalbase()
wasn't used to fill out the printf(3) format of _PATH_INCLUDE_LOCAL.

Differential Revision:	https://reviews.freebsd.org/D38975
Reviewed by:	imp
2023-03-12 18:40:07 -07:00
Dag-Erling Smørgrav
64c2a712d6 tftp: Add tests.
Sponsored by:	Klara, Inc.
Reviewed by:	asomers
Differential Revision:	https://reviews.freebsd.org/D38969
2023-03-10 13:25:16 +00:00
Dag-Erling Smørgrav
92570f67c7 tftp: Correctly propagate transfer errors.
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38958
2023-03-10 13:25:16 +00:00
Brooks Davis
af0cc0b223 NgATM: Remove netgraph ATM support
Most ATM support was removed prior to FreeBSD 12.  The netgraph support
was kept as it was less intrusive, but it is presumed to be unused.

Reviewed by:	manu
Relnotes:	yes
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D38879
2023-03-09 18:04:02 +00:00
Kyle Evans
b617584942 grep: remove tautological condition
st_size is an off_t, it cannot hold values larger than OFF_MAX.

CID:		1008931
2023-03-08 23:53:10 -06:00
Kyle Evans
c816aea7ab Revert "grep: remove tautological condition"
This reverts commit f6d6c66889.

Gremlins snuck into my tree and injected some WIP.
2023-03-08 23:52:23 -06:00
Kyle Evans
f6d6c66889 grep: remove tautological condition
st_size is an off_t, it cannot hold values larger than OFF_MAX.

CID:		1008931
2023-03-08 23:34:22 -06:00
Dag-Erling Smørgrav
473a2c9a40 byacc: Disable backtracking extension.
When updating byacc to 20230201, I enabled the backtracking extension as it seemed useful and harmless.  With a little more experience, it appears to have more impact than I initially thought and I'm no longer sure how useful it really is, so turn it back off.

PR:		244149, 269425
Sponsored by:	Klara, Inc.
Reviewed by:	imp, jkim
Differential Revision:	https://reviews.freebsd.org/D38931
2023-03-07 17:20:49 +00:00
Alexander V. Chernikov
6a6f2b0ce9 netstat: fix IPv6 link-locals & custom multipath printing. 2023-03-06 15:08:09 +00:00
Kajetan Staszkiewicz
cd9e5d4333 netstat: fix pfsync stats spelling
Reviewed by:	mjg
2023-03-05 22:50:07 +00:00
Ed Maste
1b00334852 bc: remove MIPS Makefile case
MIPS support has been removed from FreeBSD.

Sponsored by: The FreeBSD Foundation
2023-03-01 10:38:12 -05:00
Dimitry Andric
ab80f0b21f Ensure .inc files are regenerated when llvm/clang tblgen binaries change
When doing a fully incremental build (with WITHOUT_CLEAN enabled), from
a commit before llvm 15 was merged (3264f6b88f), to a commit after
that, a number of .inc files were not regenerated. This could lead to
unexpected compilation errors when these .inc files were included from
llvm-project sources, similar to:

  In file included from /usr/src/contrib/llvm-project/clang/lib/CodeGen/CGBuiltin.cpp:8268:
  /usr/obj/usr/src/amd64.amd64/lib/clang/libclang/clang/Basic/arm_mve_builtin_cg.inc:279:18: error: no matching constructor for initialization of 'clang::CodeGen::Address'
    Address Val2 = Address(Val1, CharUnits::fromQuantity(2));
                   ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Work around this by making the .inc files dependent on the tblgen binary
used for generating them. E.g., we can relatively safely assume that if
the binary gets updated, the .inc files must also be updated. (Although
this is not 100% optimal, the gain by complicating things even more is
probaby not worth the effort.)

MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D38770
2023-02-26 15:56:07 +01:00
Daniel Tameling
e052829e3e uniq(1): use strtonum to parse options
Previously strtol was used and the result was directly cast to an int
without checking for an overflow. Use strtonum instead since it is
safer and tells us what went wrong.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/643
2023-02-25 10:25:51 -07:00
Piotr Kubaj
6ae90f5985 gh-bc: don't disable LTO on powerpc64
Summary:
The LTO issue has been fixed. While -flto for some reason is commented out,
since it wasn't completely removed, it may be expected to be reenabled.

Reviewers: se
Approved by: se
MFC after: 3 days
Subscribers: imp
Differential Revision: https://reviews.freebsd.org/D38755
2023-02-25 00:49:27 +01:00
Stefan Eßer
77606d5a8c usr.bin/gh-bc: clean-up Makefile
Remove commented out debug options and re-enable LTO for most
architectures.
2023-02-25 00:07:25 +01:00
Thomas Munro
58e3631bd0 truss: Add preadv(2) and pwritev(2).
We already knew how to decode readv(2)/writev(2).  Add the versions with
an offset.

Reviewed by:            asomers
Differential Revision:  https://reviews.freebsd.org/D27531
MFC after:              2 weeks
2023-02-21 22:40:14 +13:00
Dag-Erling Smørgrav
8e022d3cde byacc: Update to 20230201.
Note that this enables the backtracking extension, which we had previously left disabled.

PR:		244149, 269425
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D38421
2023-02-20 23:35:32 +01:00
Fernando Apesteguía
e6ffcf4ac7 zless(1): handle uncompressed files
In the manual page for zmore(1) and zless(1) it is said that zless(1) is
equivalent to zmore(1) except that it uses less(1) as a pager. However
zmore(1) is able to handle uncompressed files transparently while zless(1)
is not.

Add another case to the switch in lesspipe.sh to handle non-compressed files.

PR:		196437
Reported by:	marquis@roble.com
Approved by:	mjg@
Differential Revision: https://reviews.freebsd.org/D38674
2023-02-20 11:15:09 +01:00
Warner Losh
ef6f20ce47 tail: Retry kevent if the system call was interrupted
kevent returns EINTR when I suspend / resume. This causes tail -f
and tail -F to exit with interrupt system call. Ignore this error
and try kevent again.

Sponsored by:		Netflix
2023-02-18 20:09:26 -07:00
Fernando Apesteguía
91706f0d6d netstat.1: Clarify -i and -I priorities
netstat(1) allows to specify both -i (all interfaces) and -I <ifname>.
However, when both are specified, -I always overrides -i.
Add a comment where appropriate the same way we do in rm(1) for -f and -i.

PR:		202708
Reported by:	demon@
Approved by:	manpages (pauamma@)
Differential Revision: https://reviews.freebsd.org/D38654
2023-02-18 18:01:34 +01:00
Mateusz Guzik
2924ae099a Revert "cpuset: add --count"
The patch introduced a behavior change coming from getopt_long, namely
the entire argument array would be parsed looking for opts, which
affected uses spawning new processes without passing '--' to delimit
where cpuset arguments end. [1]

Apart from that turns out the change had a bug: using CPU_LEVEL_ROOT
instead of CPU_LEVEL_WHICH, returning a different cpuset than intended.
[2]

The intended functionality is provided with nproc(1), which landed after
this change.

As such, revert for the time being.

This reverts commit d9d5f2c042.

Reported by:	Mark Millard [1]
Reported by:	jbeich [2]
2023-02-16 18:18:49 +00:00
Dag-Erling Smørgrav
5016d112ad wc: Make the read buffer static.
The read buffer in cnt() is 64 kB, which is a bit excessive for a stack variable.  MAXBSIZE has grown since this code was originally written, and it might grow again in the future.  Since the program is single-threaded and cnt() does not recurse, we can safely make the buffer static.

While there, constify p since it is only used to read.

Sponsored by:	Klara, Inc.
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D38608
2023-02-16 00:40:45 +00:00
Dag-Erling Smørgrav
5c870e1b48 wc: Improve test coverage.
* Add a test that causes mbrtowc() to return 0.

* Add a test that causes mbrtowc() to return -2.

Sponsored by:	Klara, Inc.
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D38605
2023-02-16 00:40:45 +00:00
Dag-Erling Smørgrav
dad64f0e7c wc: Clean up and modernize.
* Drop <err.h>, which is unnecessary since we use libxo.

* As per POSIX, report an error if output fails.

* Fix some type mismatches.

* Use bool instead of int where appropriate.

* Avoid repeatedly checking for a null filename.

* Miscellaneous other tidying.

* Add tests (partly derived from work performed by SHENG-YI HONG <i19780219111@kimo.com>).

Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D38496
2023-02-14 22:26:47 +00:00
Alan Somers
4c163a5480 Change "ctlstat -P"'s schema
It now reports stats separately for both ports and luns.

Also, prohibit using both "-p" and "-P" at the same time.

MFC after:	1 week
Sponsored by:	Axcient
Reviewed by:	mav
Differential Revision: https://reviews.freebsd.org/D38500
2023-02-13 09:18:38 -07:00
Kyle Evans
deb63adf94 top: fix sorting by pid (-o pid)
The 'pid' order was added, but the equivalent comparator was not back in
8b800d3af2 ("Add the PID column to the list of sort keys.").
`ordernames` indices need to match `compares` indices in order for this
to work.

A future commit will restructure all of this to make it less error prone
going forward (see D37083).

MFC after:	3 days
Reviewed by:	pstef (D37083)
2023-02-13 00:43:32 -06:00
Kyle Evans
7e688ed493 patch: omit filename if the prompt was ignored
When a file is missing, patch(1) will prompt for a filename to try and
patch it.  If we're doing a dry-run, we'll output that the patch to the
source file was either ignored/failed.  If you ignore the prompt in a
dry-run (i.e. just hit enter), we'll output:

X out of X hunks ignored while patching (null)

Let's improve the aesthetics a bit and just omit the last part if the
prompt was ignored:

X out of X hunks ignored

Unfortunately we can't really test this without expect(1) because both
force and batch mode will use the first best guess, which is wiped out
by the "File to patch:" prompt.  We could record the initially derived
bestguess there and use *that*, but given that this is only possible in
an interactive session I think it's fine to just omit the filename
rather than adding a fair amount of complexity (which could also break
other scenarios I haven't considered yet)..

Reviewed by:	des
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D38179
2023-02-13 00:15:08 -06:00
Simon J. Gerraty
dc1b8c9a84 Merge bmake-20230208
Merge commit 'f4d51098686d961fc03dc5aa327619d0af3c9dcd'
2023-02-09 17:23:23 -08:00
Mateusz Guzik
48bfd35976 Add nproc(1)
This program prints the number of CPU threads it can run on, while
respecting cpusets (or not, depending on switches).

It aims to be compatible with nproc as found in GNU coreutils.

Reviewed by:	des
Reviewed by:	pstef
Differential Revision:	https://reviews.freebsd.org/D38386
2023-02-08 19:47:33 +00:00
Dimitry Andric
fcaf7f8644 Merge llvm-project main llvmorg-15-init-17485-ga3e38b4a206b
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15-init-17485-ga3e38b4a206b.

PR:		265425
MFC after:	2 weeks
2023-02-08 20:04:38 +01:00
Dimitry Andric
81ad626541 Merge llvm-project main llvmorg-15-init-15358-g53dc0f10787
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-15-init-15358-g53dc0f10787.

PR:		265425
MFC after:	2 weeks
2023-02-08 20:02:26 +01:00
Emmanuel Vadot
1af3908ce6 pkgbase: Create a FreeBSD-elftoolchain package
It contain all the binaries and libs from the elftoolchain contrib
project except for libelf which is used everywhere.
All of those tools are never used by the average user.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38224
2023-02-08 08:49:12 +01:00
Emmanuel Vadot
9c1720e59a pkgbase: Create a FreeBSD-smbutils package
And put smb related programs and lib in it.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38228
2023-02-08 08:48:28 +01:00
Stefan Eßer
4fca8e0f65 contrib/bc: uodate to version 6.2.4
This update contains only documentation changes (new main repository
URL and changed mail address of the program author) and changes to
the build system that do not affect the FreeBSD base system build.

MFC after:	3 days
2023-02-06 22:33:56 +01:00
Mateusz Guzik
d9d5f2c042 cpuset: add --count
Can be used to count the number of hardware threads in the cpu set.

For example:
$ cpuset -g -p $$
pid 2440 mask: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39
pid 2440 domain policy: first-touch mask: 0, 1
$ cpuset -g --count -p $$
40

The intent is to replace calls to sysctl hw.ncpu and kern.smp.cpus which
can be found in the tree, which are not adequate given existence of
cpusets.

Right now only -g -p combination is supported to reduce complexity.
As anything else errors out, this can be expanded later as needed.

Differential Revision:	https://reviews.freebsd.org/D36351
2023-02-04 17:50:41 +00:00
Dimitry Andric
a9e0629719 gh-bc: don't force CFLAGS to -O0 -g
Otherwise, CFLAGS passed in via bsd.sys.mk or the user's environment are
not respected, and this leads to link errors on riscv64sf.
2023-02-02 19:20:18 +01:00
Mateusz Piotrowski
e7ab133648 timeout: Move from /usr/bin to /bin
timeout(1) is used by /etc/rc.d/zfskeys. Unfortunately, having
timeout(1) installed in /usr/bin causes problems when /usr is an
encrypted ZFS partition.

Implementing timeout(1) in sh(1) is not trivial. A more elegant solution
is to move timeout(1) to /bin so that it is available to early services
in the boot process.

PR:		265221
Reviewed by:	allanjude, des, imp
Approved by:	allanjude, des, imp
Reported by:	Ivan <r4@sovserv.ru>
Fixes:	33ff39796f Add zfskeys rc.d script for auto-loading encryption keys
MFC after:	1 week
Relnotes:	yes
Sponsored by:	Modirum MDPay
Sponsored by:	Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D38344
2023-02-02 18:34:35 +01:00
Dag-Erling Smørgrav
134841a7f3 cmp: Increase buffer size for non-mmap case.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	rpokala
Differential Revision:	https://reviews.freebsd.org/D38281
2023-01-31 01:29:05 +01:00
Dag-Erling Smørgrav
6673a5476d cmp: Print a summary on SIGINFO.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38280
2023-01-31 01:29:05 +01:00
Gleb Smirnoff
bcad3f96ae gh-bc: fix build with WITHOUT_NLS_CATALOGS=YES 2023-01-30 13:26:49 -08:00
Phil Shafer
ef7d10fde4 Add missing check for xo_parse_args return code. 2023-01-30 15:43:01 -05:00
Phil Shafer
e1e2080fc1 Import Juniper libxo-1.6.0
PR:		262332
2023-01-30 13:37:33 -05:00
Cameron Katri
c8abb673a5 man(1): Support zstd compressed manpages using zstdcat
Reviewed by:	emaste, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D32296
2023-01-30 13:12:36 -05:00
Jamie Landeg-Jones
37399d5bcf usr.bin/stat: Fix error message formatting.
PR:		bin/261657
MFC after:	3 days
2023-01-29 14:37:25 -08:00
Alexander V. Chernikov
15dbf5a241 netstat: export weight for single-path routes.
* Parse and export newly-added NL_RTA_WEIGHT attribute, providing path
 weight for a non-multipath route. This fixes a number of tests in
 sys/net/routing which rely on this data.
* Remove handling of NL_RTA_KNH_ID in multipath routes, as it is
 not provided.
* Improve kernel/user nexthop index export. As a result,
 for multipath routes:
  * nhg-kidx attribute represents kernel nhg index (always provided)
  * nhg-uidx attribute represents user-provided nhg index (if set)
 for non-multipath routes:
  * nhop-kidx attribute represents kernel nhop index (always provided)
  * nhop-udx attribute represents user-provided nexthop index (if set)
2023-01-29 16:27:31 +00:00
Stefan Eßer
fdd4c35832 usr.bin/gh-bc: update Makefiles for version 6.2.2
The sources of this program are in contrib/bc, but built using the
Makefiles touched in this commit, which had to be adapted to comply
with changed made to the build system of this software, which is
not used when building in the base system.
2023-01-28 23:48:34 +01:00
Xin LI
8f02c0d156 Disable sandboxing when building with WITHOUT_CAPSICUM.
PR:		bin/269185
MFC after:	3 days
2023-01-28 10:53:47 -08:00
Alexander Naumochkin
050e4bca94 stat(1): Do not pass S_IFBLK to devname unconditionally
PR:	269190
Reviewed by:	kib
MFC after:	1 week
2023-01-28 20:04:43 +02:00
Simon J. Gerraty
4fde40d9b5 Merge/update to bmake-20230126 2023-01-27 16:33:01 -08:00
Alexander V. Chernikov
79111aa26f netstat: fix format string on 32-bit archs 2023-01-27 17:45:49 +00:00
Allan Jude
5ff13fbc19 MFV: zstd 1.5.2
Merge commit 'b3392d84da5bf2162baf937c77e0557f3fd8a52b' into zstd_1.5.2

full changelog: https://github.com/facebook/zstd/compare/v1.4.8...v1.5.2

Updated sys/kern/subr_compressor.c to new API

MFC after:	3 days
Relnotes:	yes
Sponsored by:	Klara, Inc.
2023-01-27 17:22:31 +00:00
Alexander V. Chernikov
68636dcb6f netstat: make netstat -rn use netlink instead of rtsock
This change switches route listing in netstat to netlink, with fallback to rtsock.
The outputs are mostly identical, with an exception of not showing kernel
 nexthop indexes for multipath routes.

Differential Revision: https://reviews.freebsd.org/D36529
2023-01-27 15:36:10 +00:00
Ed Maste
ac4c695ad6 Retire WITHOUT_CXX option
Several important base system components are written in C++, and the
WITHOUT_CXX option produced a system that was not fully functional.
Just accept this, and remove the option to build without C++ support.

This reverts commit adc3c128c6.

Reviewed by:	brooks, kevans, jhb (earlier)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33108
2023-01-26 21:13:16 -05:00
Dag-Erling Smørgrav
6fc1bbbf62 w: Unlike err(3), xo_err(3) won't accept a null format string.
MFC after:	1 week
X-MFC-with:	d90ff31ae5
Sponsored by:	Klara, Inc.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D38192
2023-01-25 18:03:00 +01:00
Dag-Erling Smørgrav
d90ff31ae5 w: Complete libxo transition.
MFC after:	1 week
Sponsred by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38172
2023-01-25 07:22:46 +01:00
Dag-Erling Smørgrav
14ebab25e1 find: Logic nit in man page.
Arguments follow primaries, not the other way around.

MFC after:	1 week
Sponsored by:	Klara, Inc.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D38173
2023-01-24 09:53:35 +01:00
Elliott Mitchell
e5c30ac930 vmstat: fix overflow of interrupt name buffer
sysctl() provides a count of number of bytes in the buffer.  That is the
actual buffer length.  Whereas looking for an interrupt entry with an
empty name could terminate too early, or overflow the end of the buffer.
The overflow will occur if the table of interrupt names is full.

Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D36628
2023-01-20 04:51:13 +02:00
Elliott Mitchell
d4d7971849 vmstat: remove shadow variables
These appear to simply be the style of arguments are left untouched and
only local variables are modified.  While some may prefer that style
this simply serves to complicate things as they're perfectly writeable.

Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D36628
2023-01-20 04:51:12 +02:00
Alan Somers
92e978439f cal: don't print terminal control characters unless stdout is a TTY
A similar change was made in svn r223931, but it was incomplete, working
only when the utility was invoked as "ncal".  Fix the same issue when
invoking as "cal".

PR:		268936
Reported by:	Ray Bellis <ray@bellis.me.uk>
MFC after:	2 weeks
Sponsored by:	Axcient
Reviewed by:	imp
Differential Revision: https://reviews.freebsd.org/D38045
2023-01-13 14:30:00 -07:00
Gleb Smirnoff
dd2b23006c fuser: fix loop over kinfo_proc array
The previous code would skip as many entries at the end of the
array as there were zombies in the list.  While here fix type
of cnt.

Submitted by:	Ali Abdallah <ali.abdallah suse.com>
PR:		232702
MFC After:	2 weeks
2023-01-09 08:40:20 -08:00
Kyle Evans
e898a3af97 grep: properly switch EOL indicator with -z
-z is supposed to use only the NUL byte as EOL, but we were
inadvertently using both newline and NUL due to REG_NEWLINE in cflags.

The odds of anyone relying on this bsdgrep-specific bug are quite low,
so let's just fix it.  At least one port in the wild has been reported
to expect the intended behavior.

Reported by:	Hill Ma <maahiuzeon@gmail.com>
Triaged by:	the self-proclaimed peanut gallery on Discord
2023-01-03 23:37:54 -06:00
Yoshihiro Takahashi
a1f28ec729 unzip: Document optional member list
Submitted by:	Pat Maddox (man page)
PR:		267426
MFC after:	2 weeks
2023-01-02 13:17:27 +09:00
David E. O'Brien
43dc1409c1 Restricting xargs to '-n1' is much slower and isn't needed for file(1)
Also note that libc.so.6 is an older version of libc (thus why you'd
want to find files linked against it).
2022-12-28 15:54:29 -08:00
Wolfram Schneider
433c5a8ae4 do not expect mandoc(1) to terminate in finite time
PR:		266868
2022-12-27 17:04:04 +00:00
Mike Karels
c7a0637417 bspatch.1: fix missing argument
Fix typo

MFC after:	3 days
Reviewed by:	gbe
Differential Revision:	https://reviews.freebsd.org/D37727
2022-12-22 11:13:32 -06:00
Jose Luis Duran
cf7fe60e63 grep.1: Add an ENVIRONMENT section
Document the environment variables used by grep(1).

Reviewed by:	pauamma, kevans
MFC after:	5 days
Differential Revision:	https://reviews.freebsd.org/D37726
2022-12-18 08:22:24 +01:00
Gleb Smirnoff
eaabc93764 tcp: retire TCPDEBUG
This subsystem is superseded by modern debugging facilities,
e.g. DTrace probes and TCP black box logging.

We intentionally leave SO_DEBUG in place, as many utilities may
set it on a socket.  Also the tcp::debug DTrace probes look at
this flag on a socket.

Reviewed by:		gnn, tuexen
Discussed with:		rscheff, rrs, jtl
Differential revision:	https://reviews.freebsd.org/D37694
2022-12-14 09:54:06 -08:00
Kyle Evans
54d65fdd56 diff: restyle loop a bit
This is a bit more readable, and this loop is probably unlikely to gain
any `continue` or `break`s.

Suggested by:	pstef
Differential Revision:	https://reviews.freebsd.org/D37676
2022-12-13 19:31:21 -06:00
Kyle Evans
8bf187f35b diff: fix side-by-side output with tabbed input
The previous logic conflated some things... in this block:
- j: input characters rendered so far
- nc: number of characters in the line
- col: columns rendered so far
- hw: column width ((h)ard (w)idth?)

Comparing j to hw or col to nc are naturally wrong, as col and hw are
limits on their respective counters and nc is already brought down to hw
if the input line should be truncated to start with.

Right now, we end up easily truncating lines with tabs in them as we
count each tab for $tabwidth lines in the input line, but we really
should only be accounting for them in the column count.  The problem is
most easily demonstrated by the two input files added for the tests,
the two tabbed lines lose at least a word or two even though there's
plenty of space left in the row for each side.

Reviewed by:	bapt, pstef
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D37676
2022-12-13 19:31:21 -06:00
Ed Maste
86edb11e74 Always install llvm-objdump as objdump
Instead of providing no /usr/bin/objdump when LLVM_BINUTILS is false.

PR:		267854 [exp-run]
Reviewed by:	dim
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37445
2022-12-12 10:36:02 -05:00
Konstantin Belousov
1bbc510134 posixshmcontrol(1): for regular shmfd, report used pages number
Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D37097
2022-12-09 14:17:12 +02:00
Gleb Smirnoff
e68b379244 tcp: embed inpcb into tcpcb
For the TCP protocol inpcb storage specify allocation size that would
provide space to most of the data a TCP connection needs, embedding
into struct tcpcb several structures, that previously were allocated
separately.

The most import one is the inpcb itself.  With embedding we can provide
strong guarantee that with a valid TCP inpcb the tcpcb is always valid
and vice versa.  Also we reduce number of allocs/frees per connection.
The embedded inpcb is placed in the beginning of the struct tcpcb,
since in_pcballoc() requires that.  However, later we may want to move
it around for cache line efficiency, and this can be done with a little
effort.  The new intotcpcb() macro is ready for such move.

The congestion algorithm data, the TCP timers and osd(9) data are
also embedded into tcpcb, and temprorary struct tcpcb_mem goes away.
There was no extra allocation here, but we went through extra pointer
every time we accessed this data.

One interesting side effect is that now TCP data is allocated from
SMR-protected zone.  Potentially this allows the TCP stacks or other
TCP related modules to utilize that for their own synchronization.

Large part of the change was done with sed script:

s/tp->ccv->/tp->t_ccv./g
s/tp->ccv/\&tp->t_ccv/g
s/tp->cc_algo/tp->t_cc/g
s/tp->t_timers->tt_/tp->tt_/g
s/CCV\(ccv, osd\)/\&CCV(ccv, t_osd)/g

Dependency side effect is that code that needs to know struct tcpcb
should also know struct inpcb, that added several <netinet/in_pcb.h>.

Differential revision:	https://reviews.freebsd.org/D37127
2022-12-07 09:00:48 -08:00
John Baldwin
4fa1e855be rpcgen: Unindent a line not guarded by if (mtflag).
mtflag is used to add pthread mutex locking around operations to make
them thread-safe.  Setting the state to _SERVED is not conditional on
locking.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37541
2022-12-04 16:32:03 -08:00
John Baldwin
f0b58b1901 rpcgen: Don't free() a pointer after realloc().
A successful realloc() already frees the old pointer.

Reported by:	GCC -Wuse-after-free
Reviewed by:	brooks, imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37540
2022-12-04 16:31:35 -08:00
John Baldwin
42fb28cef4 Explicitly set CXXSTD to c++11 for old C++ code using std::auto_ptr<>.
GCC 12 defaults to C++17 which removes (not just deprecates)
std::auto_ptr<>.  Trying to use CXXSTD of c++03 doesn't work with
libc++ headers, but c++11 does.

Reviewed by:	brooks, imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37531
2022-12-04 16:25:21 -08:00
Gleb Smirnoff
657729a89d Retire trpt(8).
trpt(8) was utility to pull TCP debugging data from the kernel
originating back from 4.2BSD.  It is not used nowadays by TCP
developers.  We have more powerful debugging facilities, e.g.
the Dtrace probing, the TCP black box logging and siftr.

Discussed with: rscheff, tuexen, rrs, jtl and others
2022-12-02 14:10:55 -08:00
Daniel Dowse
e442917ee4 killall(1): allow sending signals to processes with control terminal on pts(4)
PR:	268093
Reviewed by:	kib
MFC after:	1 week
2022-12-01 04:42:35 +02:00
John Baldwin
f6fdf9214a systat: Fix a bunch of use after frees in fetch_ifstat().
I think this was probably just a typo.  initifstat() continues around
a similar loop if the mib data fails to fetch, and fetch_ifstat() was
already using a FOREACH_SAFE loop here so expected to keep going.
Calling clearifstat() from the fetch routine also seems wrong, and the
sort_interface_list() call triggered by the existing needsort = 1 will
itself set needclear to trigger a future clearifstat().

Reported by:	GCC 12 -Wuse-after-free
Differential Revision:	https://reviews.freebsd.org/D36823
2022-11-22 11:11:42 -08:00
Ed Maste
20a66ab4bf Retire CLANG_IS_CC option
A small reduction in build infrastructure complexity; when we had both
Clang and GCC in the tree it was useful to have both built, and choose
one or the other to install as /usr/bin/cc.  Now only Clang is in the
tree, and there is no point in building and installing base Clang but
not providing it as cc (and c++, cpp).

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37075
2022-11-21 14:56:13 -05:00
Dag-Erling Smørgrav
b9fabe997f tftp: cleanup
Sponsored by:	Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37433
2022-11-18 17:01:30 +01:00
Dag-Erling Smørgrav
b15e052e74 tftpd: Plug memory leaks in option handling code.
Sponsored by:	Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37423
2022-11-18 16:39:44 +01:00
Dag-Erling Smørgrav
bacb00ab40 tftpd: whitespace cleanup 2022-11-17 16:42:30 +00:00
Dag-Erling Smørgrav
9f9544fd92 tftp: Fix buffer overflow and fd leak in multi-file PUT.
Sponsored by:	Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37422
2022-11-17 17:26:24 +01:00
John Baldwin
7ad9aa0b93 rs: Test actual output in the tests.
Previously the tests just verified if command line arguments raised an
error or not, they did not test how command line arguments affected
the output.  This adds some sample (if simple) input and output to
each flag test as well as adding a few additional trivial tests.

Reviewed by:	brooks
Differential Revision:	https://reviews.freebsd.org/D36835
2022-11-15 21:20:18 -08:00
John Baldwin
afb4998dd4 rs: Use getopt() and strtol() instead of mannual parsing.
This uses the "::" extension to getopt() to handle options which take
an optional argument.

The updated flag tests were all wrong before and only passed because
the manual parser failed to raise errors when a required argument was
missing.  The invalid argument test now gets a better error message.

Reviewed by:	brooks, imp, emaste
Differential Revision:	https://reviews.freebsd.org/D36834
2022-11-15 21:19:35 -08:00
John Baldwin
42d10b1b56 rs: Convert to C++ to convert elem to a std::vector<char *>.
This also updates various indices and counters from int to size_t to
pacify resulting -Wsign-compare warnings.

Reviewed by:	brooks
Differential Revision:	https://reviews.freebsd.org/D36833
2022-11-15 21:03:12 -08:00
John Baldwin
6100374ccf diff: Don't (ab)use sprintf() as a kind of strcat().
Previously print_header() used sprintf() of a buffer to itself as a
kind of string builder but without checking for overflows.  This
raised -Wformat-truncation and -Wrestrict warnings in GCC.  Instead,
just conditionally print the new timestamp fields after the initial
strftime()-formatted string.  While here, use sizeof(buf) with
strftime() rather than a magic number.

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D36814
2022-11-15 19:17:36 -08:00
John Baldwin
4e0771714d diff: Don't treat null characters like carriage returns in readhash().
The implicit fall-through in the !D_FORCEASCII case caused null
characters to be treated as carriage returns honoring the D_STRIPCR,
D_FOLDBLANKS, and D_IGNOREBLANKS flags.

Reported by:	GCC -Wimplicit-fallthrough
Reviewed by:	bapt
Fixes:	 	3cbf98e2be diff: read whole files to determine if they are ASCII text
Differential Revision:	https://reviews.freebsd.org/D36813
2022-11-15 19:16:50 -08:00
Richard Scheffenegger
1a70101a87 tcp: account sent/received IP ECN markings independently
Have tcpstats (netstat -s) differentiate between received and sent
ECN-marked packets. Also account for IP ECN bits (on TCP packets)
even when the tcp session has not negotiated ECN support.

Event:			IETF 115 Hackathon
Reviewed By:		glebius, tuexen, #transport
Sponsored by:		NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D37314
2022-11-10 11:35:35 +01:00
Kyle Evans
d22f03636b mktemp: skip later TMPDIR check if -p is specified
We already did the necessary $TMPDIR fallback, if it's going to be used.
Skip the later check so that we don't accidentally override our -p
argument.

Fixes:		ac6f924e1c ("mktemp: add -p/--tmpdir argument")
Sponsored by:	Klara, Inc.
2022-11-09 00:04:04 -06:00
Gordon Bergling
9bdb5158d6 Update HISTORY and AUTHORS sections for cut(1) and paste(1)
In an e-mail Brian Walden wrote that:

"GWRL stands for Gottfried W. R. Luderer, the author of cut(1) and
paste(1), probably around 1978. Those came either from PWB or USG,
as he worked with, or for, Berkley Tague. Thus they made their way
into AT&T commercial UNIX, first into System III and the into System
V, and that's why they are missing from early BSD releases as they
didn't get into Research UNIX until the 8th Edition."

So update the HISTORY and AUTHORS sections for cut(1) and paste(1).

[1] https://minnie.tuhs.org/pipermail/tuhs/2020-January/019955.html

Reviewed by:	pauamma, imp
Obtained from:	OpenBSD (in partial)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D36048
2022-11-07 11:23:33 +01:00
Kyle Evans
a28989483e wg: drop -Wno-cast-qual from CFLAGS
The latest update fixes the warning by applying const to the correct
part of the pointer.
2022-11-04 22:46:55 -05:00
Dag-Erling Smørgrav
f9349d4274 gzip: Add support for decompressing zstd files.
Sponsored by:	Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37236
2022-11-04 13:42:09 +01:00
Kyle Evans
a6346c02f6 mktemp: don't double up on trailing slashes for -t paths
This is a minor cosmetic change; re-organize slightly to set tmpdir to
_PATH_TMP if we didn't otherwise have a tmpdir candidate, then check the
trailing char before appending another slash.

While we're here, remove some bogus whitespace and add a test case for
this change.

Obtained from:	https://github.com/apple-oss-distributions/shell_cmds
Sponsored by:	Klara, Inc.
2022-11-02 21:42:57 -05:00
Elvin Aslanov
085a42d0cf grep: correct argument name in man page
MFC after:	1 week
Fixes:		4dc88ebedf ("Add BSD grep to the base system...")
Pull Request:	https://github.com/freebsd/freebsd-src/pull/622
2022-11-01 14:36:59 -04:00
Kyle Evans
ac6f924e1c mktemp: add -p/--tmpdir argument
This matches other mktemp implementations, including OpenBSD and GNU.
The -p option can be used to provide a tmpdir prefix for specified
templates.  Precedence works out like so:

-t flag:
- $TMPDIR
- -p directory
- /tmp

Implied -t flag (no arguments or only -d flag):
- -p directory
- $TMPDIR
- /tmp

Some tests have been added for mktemp(1) in the process.

Reviewed by:	imp (earlier version), wosch
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D37121
2022-10-30 22:55:46 -05:00
Kyle Evans
cfc57d7dbe mktemp: add some GNU-compatible long options
GNU maketemp has long options for -d, -q, and -u, so let's add these
now for compatibility.

Reviewed by:	emaste, imp, wosch
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D37120
2022-10-30 22:55:46 -05:00
Gordon Bergling
514df63539 tee.1: Add a HISTORY section
The most accurate information I have found is that
tee(1) first appeared in Version 7 AT&T UNIX.

Reviewed by:	pauamma
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D37206
2022-10-30 11:29:59 +01:00
Kyle Evans
0283826706 usr.bin: hook wg(8) up to the build
wg(8) is used to manage WireGuard interfaces; see wg(4) and wg(8) both
for more details and usage examples.
2022-10-28 22:05:39 -05:00