Commit graph

14847 commits

Author SHA1 Message Date
Li-Wen Hsu
f4e3cb4b6b
freebsd-tips: Use a fetchable URL as example
MFC after:	3 days

(cherry picked from commit ffe6afc4f0)

freebsd-tips: Fix the description of fetch(1) to match the command

Reported by:	jrtc27
MFC with:	ffe6afc4f0

(cherry picked from commit 1678975109)
2021-07-28 03:24:51 +08:00
Warner Losh
666abb0888 one-true-awk: import 20210221 (1e4bc42c53a1) which fixes a number of bugs
Import the latest bsd-features branch of the one-true-awk upstream:

o Move to bison for $YACC
o Set close-on-exec flag for file and pipe redirects that aren't std*
o lots of little fixes to modernize ocde base
o free sval member before setting it
o fix a bug where a{0,3} could match aaaa
o pull in systime and strftime from NetBSD awk
o pull in fixes from {Net,Free,Open}BSD (normalized our code with them)
o add BSD extensions and, or, xor, compl, lsheift, rshift (mostly a nop)

Also revert a few of the trivial FreeBSD changes that were done slightly
differently in the upstreaming process. Also, our PR database may have
been mined by upstream for these fixes, and Mikolaj Golub may deserve
credit for some of the fixes in this update.

Suggested by:		Mikolaj Golub <to.my.trociny@gmail.com>
PR:			143363, 143365, 143368, 143369, 143373, 143375, 214783
Sponsored by:		Netflix

(cherry picked from commit f39dd6a978)
2021-07-10 11:07:26 -06:00
Alex Richardson
6e2b0498aa truss: minor cleanup and pedantic warning fixes
Noticed while porting the recent truss compat32 changes to CheriBSD.
This also fixes i386 tracing by zero-extending user addresses instead
of sign-extending them.

Reviewed By:	jhb
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D30211

(cherry picked from commit 31dddc6a19)
2021-07-05 10:46:12 +01:00
Alex Richardson
ed1563aba9 truss: fix handling of 64-bit arguments/return values for compat32
Deciding whether to combine two values to a 64-bit one should be based on
the process ABI, and not dependent on whether truss is compiled for an
LP64 ABI. This is a follow-up cleanup for D27625. I found this while
looking for uses of the `__LP64__` macro (since using this is wrong for
CHERI systems).

Test Plan: truss still works. Since I tested on AMD64 and all syscalls
in the trace have their quad argument last there was no difference
in the output. Should fix output for compat32 on MIPS64 though.

Reviewed By:	jhb
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D27637

(cherry picked from commit 8ba2e89e98)
2021-07-05 10:46:12 +01:00
Alex Richardson
5694f4af79 kdump: use VIS_NOLOCALE when printing output
Attempting to parse the output as UTF-8 exposed an out-of-bounds read
in vis(3) (see https://reviews.freebsd.org/D30771). However, I don't
think it makes much sense to decode this output at all. Additionally,
passing one byte at a time will almost certainly result in incorrect
output for multi-byte characters.

Reviewed By:	brooks
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D30772

(cherry picked from commit 1a3a57d745)
2021-07-05 10:46:11 +01:00
Alan Somers
bc997ea6b8 id: sanitize arguments better
The -[AMc] flags ignore the user argument.  Better if id rejects
invocations that include a user argument along with any of those flags.

PR:		256554
Reviewed by:	trasz
Sponsored by:	Axcient
Differential Revision: https://reviews.freebsd.org/D30734

(cherry picked from commit 4a06e93773)
2021-07-03 17:29:41 -06:00
Emmanuel Vadot
624d52af5b pkgbase: Create a FreeBSD-nfs package
And move all the nfs related commands there.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D30754
Sponsored by:	Diablotin Systems
2021-06-30 09:24:32 +02:00
Jose Luis Duran
47722575d9 mkimg: Add fat32lba partition type
Syntactic sugar for a `gpart add -t '!12' ...` equivalent.

Reviewed by:	emaste
Pull Request:	https://github.com/freebsd/freebsd-src/pull/484

(cherry picked from commit d98a4eb807)
2021-06-29 10:02:11 -04:00
Andrew Turner
a0dd2317e8 Use if ... else when printing memory attributes
In vmstat there is a switch statement that converts these attributes to
a string. As some values can be duplicate we have to hide these from
userspace.

Replace this switch statement with an if ... else macro that lets us
repeat values without a compiler error.

Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D29703

(cherry picked from commit 15221c552b)
2021-06-12 02:21:12 +01:00
Michael Tuexen
fa50e98328 mend 2021-06-07 11:01:28 +02:00
Ed Maste
5ceb90aa66 elfctl: avoid touching file if no change made
Suggested by:	brooks
Reviewed by:	brooks, markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D30452

(cherry picked from commit 3f2508b7f3)
2021-06-01 22:08:54 -04:00
Mark Johnston
b98b323813 sort: Hook NetBSD tests up to the build
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 186ba88a7c)
2021-05-20 09:15:49 -04:00
Cyril Zhang
df40dcbf7c sort: Cache value of MB_CUR_MAX
Every usage of MB_CUR_MAX results in a call to __mb_cur_max.  This is
inefficient and redundant.  Caching the value of MB_CUR_MAX in a global
variable removes these calls and speeds up the runtime of sort.  For
numeric sorting, runtime is almost halved in some tests.

PR:		255551
PR:		255840
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D30170

(cherry picked from commit 71ec05a212)
2021-05-20 09:15:43 -04:00
Cyril Zhang
f80d1c0035 sort: Stop "fixing" obsolete key syntax after -- flag
PR:		255798
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D30234

(cherry picked from commit fa43162c63)
2021-05-20 09:15:40 -04:00
Mark Johnston
8aed0580e4 truss: Decode FreeBSD 11 mknod(2) and mknodat(2)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit cd497bd40b)
2021-05-19 09:32:40 -04:00
Kirk McKusick
daa020139f Clean up copyright messages.
(cherry picked from commit 9e16b9530a)
2021-05-16 23:09:42 -07:00
Ceri Davies
3f5f4078b3 find(1): Document the -f option
PR:	223127
Reported by:	Mathieu Arnold <mat at FreeBSD dot org>
Reviewed by:	bcr, gbe
Differential Revision:	https://reviews.freebsd.org/D30215

(cherry picked from commit 82483ea7ad)
2021-05-16 10:36:53 +02:00
Xin LI
5a485392c4 usr.bin/patch: remove unneeded header.
(cherry picked from commit 9769f6f808)
2021-05-15 21:40:41 -07:00
Xin LI
34dad5e914 usr.bin/netstat: use roundup2 when rounding up to power of 2.
(cherry picked from commit f6b6d216ca)
2021-05-15 21:40:23 -07:00
Alex Richardson
0d0eb707b4 truss: Add missing underscore to compat_prefix for FreeBSD32
I accidentally dropped this in the final version of D27625, so it didn't
actually work as intended. I found this while testing the MFC to stable/13.

MFC after:	immediately
Fixes:		7daca4e204 ("truss: improved support for decoding compat32 arguments")

(cherry picked from commit 3cbad8287a)
2021-05-11 10:54:06 +01:00
Alex Richardson
7736adb5e6 usr.bin/lex: regenerate bootstrap files after d37f81e35b
Reviewed by:	jkim

(cherry picked from commit c6e66cbfbb)
2021-05-11 09:39:30 +01:00
Alex Richardson
46c255b632 truss: improved support for decoding compat32 arguments
Currently running `truss -a -e` does not decode any
argument values for freebsd32_* syscalls (open/readlink/etc.)

This change checks whether a syscall starts with freebsd{32,64}_ and if
so strips that prefix when looking up the syscall information. To ensure
that the truss logs include the real syscall name we create a copy of
the syscall information struct with the updated.

The other problem is that when reading string array values, truss
naively iterates over an array of char* and fetches the pointer value.
This will result in arguments not being loaded if the pointer is not
aligned to sizeof(void*), which can happens in the compat32 case. If it
happens to be aligned, we would end up printing every other value.
To fix this problem, this changes adds a pointer_size member to the
procabi struct and uses that to correctly read indirect arguments
as 64/32 bit addresses in the the compat32 case (and also compat64 on
CheriBSD).

The motivating use-case for this change is using truss for 64-bit
programs on a CHERI system, but most of the diff also applies to 32-bit
compat on a 64-bit system, so I'm upstreaming this instead of keeping it
as a local CheriBSD patch.

Output of `truss -aef ldd32 /usr/bin/ldd32` before:
39113: freebsd32_mmap(0x0,0x1000,0x3,0x1002,0xffffffff,0x0,0x0) = 543440896 (0x20644000)
39113: freebsd32_ioctl(0x1,0x402c7413,0xffffd2a0) = 0 (0x0)
/usr/bin/ldd32:
39113: write(1,"/usr/bin/ldd32:\n",16)		 = 16 (0x10)
39113: fork()					 = 39114 (0x98ca)
39114: <new process>
39114: freebsd32_execve(0xffffd97e,0xffffd680,0x20634000) EJUSTRETURN
39114: freebsd32_mmap(0x0,0x20000,0x3,0x1002,0xffffffff,0x0,0x0) = 541237248 (0x2042a000)
39114: freebsd32_mprotect(0x20427000,0x1000,0x1) = 0 (0x0)
39114: issetugid()				 = 0 (0x0)
39114: openat(AT_FDCWD,"/etc/libmap32.conf",O_RDONLY|O_CLOEXEC,00) ERR#2 'No such file or directory'
39114: openat(AT_FDCWD,"/var/run/ld-elf32.so.hints",O_RDONLY|O_CLOEXEC,00) = 3 (0x3)
39114: read(3,"Ehnt\^A\0\0\0\M^@\0\0\0#\0\0\0\0"...,128) = 128 (0x80)
39114: freebsd32_fstat(0x3,0xffffbd98)		 = 0 (0x0)
39114: freebsd32_pread(0x3,0x2042f000,0x23,0x80,0x0) = 35 (0x23)
39114: close(3)					 = 0 (0x0)
39114: openat(AT_FDCWD,"/usr/lib32/libc.so.7",O_RDONLY|O_CLOEXEC|O_VERIFY,00) = 3 (0x3)
39114: freebsd32_fstat(0x3,0xffffc7d0)		 = 0 (0x0)
39114: freebsd32_mmap(0x0,0x1000,0x1,0x40002,0x3,0x0,0x0) = 541368320 (0x2044a000)

After:
  783: freebsd32_mmap(0x0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 543543296 (0x2065d000)
  783: freebsd32_ioctl(1,TIOCGETA,0xffffd7b0)    = 0 (0x0)
/usr/bin/ldd32:
  783: write(1,"/usr/bin/ldd32:\n",16)           = 16 (0x10)
  784: <new process>
  783: fork()                                    = 784 (0x310)
  784: freebsd32_execve("/usr/bin/ldd32",[ "(null)" ],[ "LD_32_TRACE_LOADED_OBJECTS_PROGNAME=/usr/bin/ldd32", "LD_TRACE_LOADED_OBJECTS_PROGNAME=/usr/bin/ldd32", "LD_32_TRACE_LOADED_OBJECTS=yes", "LD_TRACE_LOADED_OBJECTS=yes", "USER=root", "LOGNAME=root", "HOME=/root", "SHELL=/bin/csh", "BLOCKSIZE=K", "MAIL=/var/mail/root", "MM_CHARSET=UTF-8", "LANG=C.UTF-8", "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin", "TERM=vt100", "HOSTTYPE=FreeBSD", "VENDOR=amd", "OSTYPE=FreeBSD", "MACHTYPE=x86_64", "SHLVL=1", "PWD=/root", "GROUP=wheel", "HOST=freebsd-amd64", "EDITOR=vi", "PAGER=less" ]) EJUSTRETURN
  784: freebsd32_mmap(0x0,135168,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 541212672 (0x20424000)
  784: freebsd32_mprotect(0x20421000,4096,PROT_READ) = 0 (0x0)
  784: issetugid()                               = 0 (0x0)
  784: sigfastblock(0x1,0x204234fc)              = 0 (0x0)
  784: open("/etc/libmap32.conf",O_RDONLY|O_CLOEXEC,00) ERR#2 'No such file or directory'
  784: open("/var/run/ld-elf32.so.hints",O_RDONLY|O_CLOEXEC,00) = 3 (0x3)
  784: read(3,"Ehnt\^A\0\0\0\M^@\0\0\0\v\0\0\0"...,128) = 128 (0x80)
  784: freebsd32_fstat(3,{ mode=-r--r--r-- ,inode=18680,size=32768,blksize=0 }) = 0 (0x0)
  784: freebsd32_pread(3,"/usr/lib32\0",11,0x80) = 11 (0xb)

Reviewed By:	jhb
Differential Revision: https://reviews.freebsd.org/D27625

(cherry picked from commit 7daca4e204)
2021-05-11 09:39:24 +01:00
Alex Richardson
eec6f94ea5 truss: split counting of syscalls and syscall calling convention
This change is a refactoring cleanup to improve support for compat32
syscalls (and compat64 on CHERI systems). Each process ABI now has it's
own struct sycall instead of using one global list. The list of all
syscalls is replaced with a list of seen syscalls. Looking up the syscall
argument passing convention now interates over the fixed-size array instead
of using a link-list that's populated on startup so we no longer need the
init_syscall() function.
The actual functional changes are in D27625.

Reviewed By:	jhb
Differential Revision: https://reviews.freebsd.org/D27636

(cherry picked from commit 6019514b0b)
2021-05-11 09:39:23 +01:00
Konstantin Belousov
32bfffcb9a gcore: add option to dump core using kernel facility
(cherry picked from commit 73e8f06ac5)
2021-05-10 04:03:19 +03:00
Konstantin Belousov
7a94e71e05 gcore: split code to open core file into helper
(cherry picked from commit c192228b73)
2021-05-10 04:03:14 +03:00
Xin LI
8c10d2979c less: upgrade to v581.2.
(cherry picked from commit 50d31dbc6e)

less: upgrade to v581.

(cherry picked from commit 2235c7feac)
2021-05-08 19:31:02 -07:00
Baptiste Daroussin
7904a2e5a8 diff: eleminitate useless macros
The diff_output was not bringing any values but was obfuscating
the code.

(cherry picked from commit 7a57c9cb5a)
2021-05-05 10:37:09 +02:00
Baptiste Daroussin
b6b26cecc0 diff: simplify the hash functions
Instead of 3 different complex case they have all been folded into a
simple on based on switch

(cherry picked from commit e43239f514)
2021-05-05 10:37:09 +02:00
Baptiste Daroussin
ffbf0225b7 diff: fix typo in a comment
(cherry picked from commit e52546a3a7)
2021-05-05 10:37:09 +02:00
Baptiste Daroussin
c5820184fe diff: remove stalled entries in headers
(cherry picked from commit 931ad51808)
2021-05-05 10:37:08 +02:00
Baptiste Daroussin
0ce985a23b diff: eliminate space at end of line
No functionnal changes

(cherry picked from commit 15abb23286)
2021-05-05 10:37:08 +02:00
Baptiste Daroussin
07d72ca905 diff: add a test case about the non regular file support
(cherry picked from commit c440e7870a)
2021-05-05 10:37:07 +02:00
Mateusz Piotrowski
061be8f939 Fix zgrep --version
"zgrep --version" is expected to print the version information in the
same way as "zgrep -V". However, the case handling the --version flag
is never reached, so "zgrep --version" prints:
    zgrep: missing pattern
instead of:
    grep (BSD grep, GNU compatible) 2.6.0-FreeBSD

Reviewed by:	yuripv
Approved by:	yuripv (src)
Differential Revision: https://reviews.freebsd.org/D29813

(cherry picked from commit 16e0391f8e)
2021-04-26 15:39:54 +02:00
Jung-uk Kim
bba9922d99 flex: Regen bootstrap files
This also partially reverts r326025 (8a16b7a18f).  I do not see any
point of adding SPDX tag in generated file.

Submitted by:	Dan McGregor <dan.mcgregor@usask.ca> (initial version)
Differential Revision:	https://reviews.freebsd.org/D28596

(cherry picked from commit 686cf5468c)
2021-04-23 11:46:30 -04:00
Alex Richardson
436fcd12f2 du_test: Skip three tests if sparse files are not supported
This fixes running the du tests with /tmp as tmpfs (which is what we do in the
CheriBSD CI).

Obtained from:	CheriBSD
Reviewed By:	ngie
Differential Revision: https://reviews.freebsd.org/D28398

(cherry picked from commit 39a1f858ad)
2021-04-22 10:41:39 +01:00
Michael Reifenberger
70a2e9a3d4 Improve size readability.
Preserve more space for swap devise names.
Prevent line overflow with long devise name.
Don't draw a bar when swap is not used at all.
Simplify and optimize code.
Change the label to end at end of 100%.
PR:		251655
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D27496

(cherry picked from commit 8d06c3e7a4)
2021-04-21 21:11:36 +02:00
Mateusz Piotrowski
51a07d6c94 systat.1: Remove Tn macros
They are no longer supported by mdoc(7).

MFC after:	1 week

(cherry picked from commit fcbaf46b76)
2021-04-17 21:01:34 +02:00
Mateusz Piotrowski
56b873b218 systat.1: Fix synopsis
systat does not have a "-display" flag. Use Ar to indicate that
"display" is meant to be substituted with an actual display command.

(cherry picked from commit e6f59be239)
2021-04-17 21:00:24 +02:00
Nathan Whitehorn
ccaa830e17 Add GPT PREP-boot type to mkimg(1) from geom_gpt.
This partition type can be used to boot some PowerKVM VMs. We don't
support it well because of some limitations in SLOF, but it's worth at
least have feature parity in geom and mkimg.

(cherry picked from commit f7aebfbe5c)
2021-04-15 09:27:41 -04:00
Gordon Bergling
f2950759b8 m4(1): Add a SEE ALSO section and reference an AT&T manual
Obtained from:	OpenBSD

(cherry picked from commit 97fa288a66)
2021-04-15 14:43:43 +02:00
Gordon Bergling
1d51d41519 sed(1): Add a reference for a 4.4BSD manual document
Obtained from:	OpenBSD

(cherry picked from commit 9048d9a933)
2021-04-15 14:43:10 +02:00
Stefan Eßer
0ca6ce5e97 [bc] Update to version 4.0.0
This version fixes an issue (missing pop of top-of-stack value in the
"P" command of the dc program).

This issue did not affect the bc program, since it does not use dc as
an back-end to actually perform the calculations as was the case with
the traditional bc and dc programs.

The major number has been bumped due to Windows support that has been
added to this version. It does not correspond to a major change that
might affect FreeBSD.

(cherry picked from commit b55a927bc8)
2021-04-10 16:18:50 +02:00
Alexander V. Chernikov
1260724822 Fix netstat -rs reporting.
rttrash (unused but not yet delete entries) were eliminated
 during routing rework. Remove reading these symbols from the kernel.

PR:		254681
Reported by:	rashey@superbox.pl

(cherry picked from commit 4084b1ab04)
2021-04-04 08:44:01 +00:00
Dmitry Chagin
b4dc951c41 Fix warning about signed comparison and drop WARNS for ktrdump(8).
Reviewed By:		jhb, imp
Differential Revision:	https://reviews.freebsd.org/D29381

(cherry picked from commit 9e5aeba51b)
2021-04-01 10:55:03 +03:00
Alan Somers
aa9ff8f760 fortune: add a tip about gstat
(cherry picked from commit 60a632f047)
2021-03-21 02:15:05 +00:00
Gordon Bergling
0f51ceaad1 find(1): Refine the HISTORY within the manual page.
A simple find command appeared in Version 1 AT&T UNIX and was removed in
Version 3 AT&T UNIX. It was rewritten for Version 5 AT&T UNIX and later
be enhanced for the Programmer's Workbench (PWB). These changes were
later incorporated in AT&T UNIX v7.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D29114

(cherry picked from commit a9275d996c)
2021-03-20 11:20:57 +01:00
Daniel Ebdrup Jensen
001d849a48 find(1): Mark -not as an extensions to POSIX
While here, change mdoc macro from Ic to Fl.

PR:		253499
Reported by:	Michael Siegel <bugcounterism at malbolge.net>

(cherry picked from commit 75e6f664c4)
2021-03-20 11:20:28 +01:00
Chuck Silvers
8c59e863e2 tail: fix "tail -F" file rotation detection
When checking if the newly opened file is the same as the old one,
we need to fstat() the new file descriptor, not the old one again.

Reviewed by:	glebius
Sponsored by:	Netflix

(cherry picked from commit 7787e7eed9)
2021-03-18 13:12:24 -07:00
Emmanuel Vadot
f21c0366f5 backlight(8): Add note that with option it print the current brightness.
MFC after:    3 days
PR: 	      253737

(cherry picked from commit 1df30489a8)
2021-03-10 11:49:31 +01:00
David Schlachter
9ba393f2ca backlight: Fix incr/decr with percent value of 0
This now does nothing instead of incr/decr by 10%

MFC After:    3 days
PR: 	      253736

(cherry picked from commit 3b005d51bd)
2021-03-10 11:49:25 +01:00