Commit Graph

14148 Commits

Author SHA1 Message Date
Dimitry Andric
c06e7b66a1 Merge ^/head r340126 through r340212. 2018-11-07 18:52:28 +00:00
Brooks Davis
c35530f464 elfdump: Add -E to test if a file is an ELF binary.
This is intended to replace potentially unreliable checks like:

	file -b $1 | grep -q '^ELF ..-bit .SB executable'

Reviewed by:	emaste
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D15971
2018-11-05 22:53:50 +00:00
Mariusz Zaborski
377421df96 capsicum: use a new capsicum helpers in tools
Use caph_{rights,ioctls,fcntls}_limit to simplify the code.
2018-11-04 19:24:49 +00:00
Yuri Pankov
9508f8c05c Teach man(1) about C.UTF-8.
While here, use LANG as the proper source to select man pages language/encoding,
falling back to LC_CTYPE.

Reviewed by:	bapt
Approved by:	kib (mentor, implicit)
Differential Revision:	https://reviews.freebsd.org/D17835
2018-11-04 16:58:55 +00:00
Dimitry Andric
2a22df74e9 Merge ^/head r339813 through r340125. 2018-11-04 15:49:06 +00:00
Yuri Pankov
d9e8d39f8d usr.bin/sed/tests: fix one of the regression test cases by adding its
results file to the build.

Reviewed by:	kevans
Approved by:	kib (mentor, implicit)
Differential Revision:	https://reviews.freebsd.org/D17776
2018-10-31 15:04:41 +00:00
John Baldwin
6d7f919489 Teach procstat -x about the AT_EHDRFLAGS ELF auxiliary vector.
Submitted by:	Shawn Webb <lattera@gmail.com>
Reviewed by:	brooks
Obtained from:	HardenedBSD (bb71e9889d1362df01c2e5162e84cd7a4fc029c8)
MFC after:	2 months
Differential Revision:	https://reviews.freebsd.org/D17067
2018-10-29 23:48:20 +00:00
Thomas Munro
5b05dc5a8b truss: Fix display of shm_open(SHM_ANON, ...).
Currently truss(1) shows shm_open(SHM_ANON, ...) as shm_open("(null)", ...).
Detect the special value and display it by name.

Reviewed by:    jhb, allanjude, tuexen
Approved by:    mjg (mentor)
MFC with:       r339224
Differential Revision:  https://reviews.freebsd.org/D17461
2018-10-28 10:59:49 +00:00
Yuri Pankov
2d1cfed1b1 localedef: define characters in "space" class also as "print", except
for the known conflicts ("control" characters can't be "print"able).
POSIX doesn't explicitly forbid this, and actually includes <space>
character in "print".

PR:		225692
Reviewed by:	bapt, cem (previous version), pfg (previous version)
Approved by:	kib (mentor)
Differential Revision:	https://reviews.freebsd.org/D17467
2018-10-27 23:31:42 +00:00
Dimitry Andric
c6879c6c14 Merge ^/head r339015 through r339669. 2018-10-23 21:09:37 +00:00
Mark Johnston
5d704fafcb Add an IMPLEMENTATION NOTES section to ldd.1.
PR:		231926
Reviewed by:	emaste
MFC after:	1 month
2018-10-23 13:49:53 +00:00
Ed Maste
ccd8660b86 ar: report errno on warning/error
Previously ar would report an error like "ar: fatal: Write error"
without including additional errno information.  Change warnings and
errors to include archive_errno() so that the user may have some idea
of the reason for the failure.

Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17650
2018-10-23 13:07:03 +00:00
John Baldwin
4403657034 Add a "live" mode to ktrdump.
Support a "live" mode in ktrdump enabled via the -l flag.  In this
mode, ktrdump polls the kernel's trace buffer periodically (currently
hardcoded as a 50 millisecond interval) and dumps any newly added
entries.  Fancier logic for the timeout (e.g. a command line option or
some kind of backoff based on the time since the last entry) can be
added later as the need arises.

While here, fix some bugs from when this was Capsicum-ized:
- Use caph_limit_stream() for the output stream so that isatty() works
  and the output can be line-buffered (especially useful for live
  mode).
- Use caph_limit_stderr() to permit error messages to be displayed if
  an error occurs after cap_enter().

Reviewed by:	kib, 0mp (manpage)
MFC after:	2 months
Differential Revision:	https://reviews.freebsd.org/D17315
2018-10-22 21:25:28 +00:00
Yuri Pankov
4644f9bef6 Add -b/-l options to localedef(1) to specify output endianness and use
it appropriately when building share/ctypedef and share/colldef.

This makes the resulting locale data in EL->EB (amd64->powerpc64) cross
build and in the native EB build match.  Revert the changes done to libc
in r308170 as they are no longer needed.

PR:		231965
Reviewed by:	bapt, emaste, sbruno, 0mp
Approved by:	kib (mentor)
Differential Revision:	https://reviews.freebsd.org/D17603
2018-10-20 20:51:05 +00:00
Alexandre C. Guimarães
ece228caf7 Add myself to calendar, and update mentors-mentee relationships.
Reviewed by:	mat (mentor)
Approved by:	tcberner (mentor)
Differential Revision:	https://reviews.freebsd.org/D17396
2018-10-20 17:45:42 +00:00
Benedict Reuschling
6aca7aa44b A single comma was missing to separate the "see also" items in
last.1 and lastlogin.8. Add it back.

PR:		231187
Submitted by:	david.marec@davenulle.org
2018-10-20 17:22:04 +00:00
Yuri Pankov
ceb68e4a7c Add myself to committers-src.dot and calendar.freebsd.
Approved by:	re (gjb), kib (mentor)
2018-10-10 00:20:40 +00:00
Glen Barber
7c32835287 MFH r338661 through r339253.
Sponsored by:	The FreeBSD Foundation
2018-10-09 14:27:55 +00:00
Glen Barber
fc3f42d80f MFH r339206-r339212, r339215-r339239
Sponsored by:	The FreeBSD Foundation
2018-10-08 18:06:40 +00:00
Allan Jude
24eeedb5e9 Teach truss how to display shm_open(2), shm_unlink(2)
Submitted by:	Thomas Munro <munro@ip9.org>
Reviewed by:	tuexen, kib
Approved by:	re (rgrimes)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D17457
2018-10-07 19:50:44 +00:00
Glen Barber
01d4e2149e MFH r338661 through r339200.
Sponsored by:	The FreeBSD Foundation
2018-10-05 17:53:47 +00:00
Mateusz Piotrowski
fab44dc358 top(1): Rework DESCRIPTION OF MEMORY section.
Due to markup issues, the DESCRIPTION OF MEMORY section is rather
unreadable; rework it a bit, using subsections for different lines of the
top output, and move it closer to description.

While here, pet manlint ordering other sections as expected.

Submitted by:	Yuri Pankov <yuripv@yuripv.net>
Reviewed by:	eadler
Approved by:	re (gjb), krion (mentor)
Differential Revision:	https://reviews.freebsd.org/D17369
2018-10-02 08:13:54 +00:00
Edward Tomasz Napierala
7c65532627 Remove references to the "new" NFS clients and servers. The "old"
NFS stack is long gone.

Approved by:	re (gjb)
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
2018-10-01 18:26:41 +00:00
Dimitry Andric
ce44d80853 Merge ^/head r338731 through r338987. 2018-09-27 20:00:07 +00:00
Brooks Davis
a78849183c Don't override LDFLAGS set in bsd.cpu.mk.
This is a direct commit to a generated file.  Simon plans to fix this
upstream before the next import.

PR:		231557
Approved by:	re (gjb)
Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
2018-09-25 15:25:42 +00:00
Baptiste Daroussin
61d06d6bd1 Import mandoc 1.14.4
Approved by:	re (kib)
MFC after:	1 week
2018-09-20 10:58:52 +00:00
Brad Davis
bca3325319 Move remote & phones to usr.bin/tip/tip/
Approved by:	re (blanket, pkgbase), will (mentor)
Differential Revision:	https://reviews.freebsd.org/D17219
2018-09-19 14:56:53 +00:00
Jung-uk Kim
3ce33da625 Make factor(6) buildable. 2018-09-19 07:09:09 +00:00
Jung-uk Kim
ee4526c085 Make dc(1) buildable. 2018-09-19 07:08:27 +00:00
Brad Davis
1b491096a4 Move install of locate.rc to usr.bin/locate/locate/
This leverages CONFS to handle the install and purges an old comment.

Approved by:	re (blanket, pkgbase), bapt (mentor)
Differential Revision:	https://reviews.freebsd.org/D17215
2018-09-18 20:50:07 +00:00
Brad Davis
22917b7e0e Move mail.rc install to usr.bin/mail.
This leverages CONFS to do the install

Approved by:	re (blanket, pkgbase), bapt (mentor)
Differential Revision:	https://reviews.freebsd.org/D17216
2018-09-18 20:47:06 +00:00
Dimitry Andric
c0b5e99154 Merge ^/head r338595 through r338689, and resolve conflicts. 2018-09-14 19:50:36 +00:00
Ed Maste
1ae9615a9a lld: add -z interpose support
-z interpose sets the DF_1_INTERPOSE flag, marking the object as an
interposer.

Committed upstream as LLVM r342239.

PR:		230604
Reported by:	jbeich
Reviewed by:	markj
Approved by:	re (kib)
MFC after:	1 week
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D17172
2018-09-14 15:15:16 +00:00
Martin Matuska
a7bc28227e MFV r338519:
Update libarchive to 3.3.3

As all important changes have already been merged from libarchive git
this is just version number bump, documentation update and some
polishing for cpio tests. Other source code changes are not relevant to
FreeBSD.

Approved by:	re (gjb)
MFC after:	1 week
2018-09-11 20:51:34 +00:00
Ed Maste
5a9066b4de remove doubled name in objcopy manpage
We generate the installed objcopy man page from ELF Tool Chain's
elfcopy, but the sed expresion used for this ended up producing
"objcopy, objcopy - copy and translate object files".

Instead of replacing the first "elfcopy" with objcopy, just remove it.

Approved by:	re (gjb)
2018-09-11 20:32:57 +00:00
Dimitry Andric
3af64f0311 Merge ^/head r338392 through r338594. 2018-09-11 18:41:00 +00:00
Dag-Erling Smørgrav
6434dda6e3 Through a combination of insufficient variable initialization and
imprudent reuse of static buffers, the end-of-transfer statistics
displayed when stdout is not a tty always ended up as 0 B / 0 Bps.
Reorganize the code to use caller-provided buffers, tweak the ETA
display a bit, and reduce the visual differences between the tty and
non-tty end-of-transfer displays.

PR:		202424
Approved by:	re (gjb@)
2018-09-10 19:39:20 +00:00
Kevin Bowling
205f11bbe4 Add kbowling to ports committer list and calendar
Approved by:	re (rgrimes), timur (mentor), krion (mentor)
Differential Revision:	https://reviews.freebsd.org/D17021
2018-09-05 01:46:27 +00:00
Brad Davis
d3b764acc6 Move fbtab, login.conf, and motd to usr.bin/login/
Approved by:	Approved by: re (gjb), bapt (mentor), will (mentor)
Differential Revision:	https://reviews.freebsd.org/D16947
2018-08-30 15:52:03 +00:00
Dimitry Andric
da2d1e9d25 Merge ^/head r338298 through r338391. 2018-08-29 20:54:56 +00:00
Mark Johnston
b480502648 sed: Fix -i option behavior with 'q' command.
Don't just exit when encountering the 'q' command if we edit file
inplace, and give mf_fgets() a chance to actually handle the
inplace case.

Also add a regression test.

Submitted by:	Yuri Pankov <yuripv@yuripv.net>
Approved by:	re (kib)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D16798
2018-08-29 17:09:03 +00:00
John Baldwin
fd036deac1 Dynamically allocate IRQ ranges on x86.
Previously, x86 used static ranges of IRQ values for different types
of I/O interrupts.  Interrupt pins on I/O APICs and 8259A PICs used
IRQ values from 0 to 254.  MSI interrupts used a compile-time-defined
range starting at 256, and Xen event channels used a
compile-time-defined range after MSI.  Some recent systems have more
than 255 I/O APIC interrupt pins which resulted in those IRQ values
overflowing into the MSI range triggering an assertion failure.

Replace statically assigned ranges with dynamic ranges.  Do a single
pass computing the sizes of the IRQ ranges (PICs, MSI, Xen) to
determine the total number of IRQs required.  Allocate the interrupt
source and interrupt count arrays dynamically once this pass has
completed.  To minimize runtime complexity these arrays are only sized
once during bootup.  The PIC range is determined by the PICs present
in the system.  The MSI and Xen ranges continue to use a fixed size,
though this does make it possible to turn the MSI range size into a
tunable in the future.

As a result, various places are updated to use dynamic limits instead
of constants.  In addition, the vmstat(8) utility has been taught to
understand that some kernels may treat 'intrcnt' and 'intrnames' as
pointers rather than arrays when extracting interrupt stats from a
crashdump.  This is determined by the presence (vs absence) of a
global 'nintrcnt' symbol.

This change reverts r189404 which worked around a buggy BIOS which
enumerated an I/O APIC twice (using the same memory mapped address for
both entries but using an IRQ base of 256 for one entry and a valid
IRQ base for the second entry).  Making the "base" of MSI IRQ values
dynamic avoids the panic that r189404 worked around, and there may now
be valid I/O APICs with an IRQ base above 256 which this workaround
would incorrectly skip.

If in the future the issue reported in PR 130483 reoccurs, we will
have to add a pass over the I/O APIC entries in the MADT to detect
duplicates using the memory mapped address and use some strategy to
choose the "correct" one.

While here, reserve room in intrcnts for the Hyper-V counters.

PR:		229429, 130483
Reviewed by:	kib, royger, cem
Tested by:	royger (Xen), kib (DMAR)
Approved by:	re (gjb)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D16861
2018-08-28 21:09:19 +00:00
Philip Paeps
c7c5d8e387 Add libxo(3) support to last(1).
Reviewed by:	kp
Approved by:	re (gjb)
MFC after:	1 week
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D16922
2018-08-28 17:10:19 +00:00
Kirk McKusick
d81347652c When doing a -S "safe copy", the install command should do an
fsync(2) system call after copying the installed file to ensure
that it is on stable storage.

PR:          230851
Reviewed by: kib
Approved by: re (marius)
2018-08-27 15:20:42 +00:00
Mark Johnston
fedded8d04 Fix column alignment in per-thread mode.
PR:		230872
Approved by:	re (marius)
MFC after:	1 week
2018-08-25 15:59:51 +00:00
Dimitry Andric
7847e04111 Merge ^/head r338026 through r338297, and resolve conflicts. 2018-08-24 18:09:23 +00:00
Alex Richardson
101db63b42 Don't use absolute path to sed when building usr.bin/join
This is required to build sort on Linux hosts since sed is in /bin there.

Approved By:	jhb (mentor)
2018-08-23 18:18:43 +00:00
Alan Somers
7dbe228c6a tftp(1): switch default transfer mode to binary
netascii is obsolete and inefficient. It isn't even supported by many
clients. Better to use binary mode by default.

Reviewed by:	cem
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D16869
2018-08-23 17:00:07 +00:00
Mark Johnston
4023442dc9 Add an lld option to emit PC-relative relocations for ifunc calls.
The current kernel ifunc implementation creates a PLT entry for each
ifunc definition.  ifunc calls therefore consist of a call to the
PLT entry followed by an indirect jump.  The jump target is written
during boot when the kernel linker resolves R_[*]_IRELATIVE relocations.
This implementation is defined by requirements for userland code, where
text relocations are avoided.  This requirement is not present for the
kernel, so the implementation has avoidable overhead (namely, an extra
indirect jump per call).

Address this for now by adding a special option to the static linker
to inhibit PLT creation for ifuncs.  Instead, relocations to ifunc call
sites are passed through to the output file, so the kernel linker can
enumerate such call sites and apply PC-relative relocations directly
to the text section.  Thus the overhead of an ifunc call becomes exactly
the same as that of an ordinary function call.  This option is only for
use by the kernel and will not work for regular programs.

The final form of this optimization is up for debate; for now, this
change is simple and static enough to be acceptable as an interim
solution.

Reviewed by:	emaste
Discussed with:	arichardson, dim
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D16748
2018-08-23 14:58:19 +00:00
Kyle Evans
67b60a1b7d dtc(1): Update to 0892ec7; HACKING and implicit header fixes
Fixes courtesy of arichardson and jmg:
- HACKING was pointing to the wrong place
- Added headers were being relied on implicitly, but libstdc++ did not
  comply with the unspoken wishes of dtc.

MFC after:	1 week
2018-08-23 02:26:40 +00:00
Eitan Adler
17be5f230a top(1): Use warnx and errx instead of fprintf
This also makes make "-v" exit without error, since it isn't.
2018-08-22 10:07:15 +00:00
Eitan Adler
eeb147d528 top(1): issue warning on invalid delay
When top -sH is run it continually updates. It should issue an warning
instead.

Reported by:	jmg
PR:		230803
2018-08-22 09:49:38 +00:00
John-Mark Gurney
9d58ffcf21 minor grammar nit, to what? between them.. 2018-08-21 15:11:43 +00:00
Mateusz Piotrowski
6ddfef55bd Adjust formatting of grep and zgrep manual pages.
grep(1) changes:
 - Pet mandoc & igor.
 - Stylize the text more with macros when appropriate.
 - Stylize equal signs in long options (e.g., "--color=auto") with
   the "Cm" macro as suggested by mdoc(7).
 - Add missing arguments to --exlude, --exclude-dir, --include and
   --include-dir.
 - Remove a duplicate entry for the --context flag.
 - Use a list in the EXAMPLES sections to make it easier to tell
   which paragraphs belong to which example.
 - Cross reference zgrep(1).

zgrep(1) changes:
 - Fix Nd.
 - Split synopsis into paragraphs for readability.
 - Cross reference bzip(1), grep(1) and xz(1).

Reviewed by:	bcr
Approved by:	mat (mentor)
Differential Revision:	https://reviews.freebsd.org/D16779
2018-08-20 22:23:59 +00:00
John Baldwin
7b87f99aa8 Fully retire the unimplemented -t option from vmstat(8).
It was #ifdef'd out in the 4.4BSD import and hasn't been re-enabled
since then.

Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D16804
2018-08-20 09:29:21 +00:00
Eitan Adler
4750b59aca send-pr: wave goodbye
Entering into the world of 12.x we no longer need even the placeholder
for send-pr. It has not done anything for some time.

With Hat: bugmeister
2018-08-19 07:12:35 +00:00
Kyle Evans
9488de009c diff(1): Refactor -B a little bit
Instead of doing a second pass to skip empty lines if we've specified -I, go
ahead and check both at once. Ignore critera has been split out into its own
function to try and keep the logic cleaner.
2018-08-19 04:15:38 +00:00
Kyle Evans
e68edb8cf0 diff(1): Implement -B/--ignore-blank-lines
As noted by cem in r338035, coccinelle invokes diff(1) with the -B flag.
This was not previously implemented here, so one was forced to create a link
for GNU diff to /usr/local/bin/diff

Implement the -B flag and add some primitive tests for it. It is implemented
in the same fashion that -I is implemented; each chunk's lines are scanned,
and if a non-blank line is encountered then the chunk will be output.
Otherwise, it's skipped.

MFC after:	2 weeks
2018-08-19 03:57:20 +00:00
Dimitry Andric
f42813cfc8 Merge ^/head r338015 through r338025. 2018-08-18 20:43:53 +00:00
John Baldwin
5cb9940ce2 Use 'bool' instead of 'int' for various boolean flags.
Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D16611
2018-08-18 20:23:53 +00:00
Dimitry Andric
3611ec6048 Merge ^/head r337646 through r338014. 2018-08-18 12:15:54 +00:00
Kyle Evans
1a36f105a4 dtc(1): Update to 97d2d5715eeb45108cc60367fdf6bd5b2046b050
Notable fixes:
- Overlays may now be generated properly without -@
- /__local_fixups__ were not including unit address in their structure
- The error reporting a magic token was misleading, reporting
  "Bad magic token in header.  Got d00dfeed expected 0xd00dfeed"
  if the token was missing. This has been split out into a separate message.

MFC after:	1 week
2018-08-17 13:24:48 +00:00
Pedro F. Giffuni
43daed4774 Revert r337419.
The fix is only partial and causes an asymmetry which breaks a test in
multi_test.sh.

We should consider both parts of the issue found in OpenBSD[1], but for now
just revert the change.

[1] http://undeadly.org/cgi?action=article;sid=20180728110010

Reported by: asomers
2018-08-16 18:35:39 +00:00
Piotr Pawel Stefaniak
dad19de0e6 indent(1): bug fix after r336333
The bug was that isalnum() is not exactly equivalent to previous code which
also allowed characters "$" and "_", so check for those explicitly.

Reported by:	tuexen@
2018-08-15 18:19:45 +00:00
Alan Somers
e40369745c tftp: Close a resource leak when putting files
Reported by:	Coverity
CID:		1394842
MFC after:	2 weeks
2018-08-14 17:20:31 +00:00
Jilles Tjoelker
17fffb23f6 printf: Add test for width and precision in %b format
PR:		229641
Submitted by:	pfg
2018-08-13 21:54:27 +00:00
Cy Schubert
61bbe5bf9f Chasing r337661, fix systat after arc accounting change. 2018-08-12 07:47:44 +00:00
Matt Macy
ef8e2d2d01 fix top after arc accounting change 2018-08-11 22:11:12 +00:00
Piotr Pawel Stefaniak
0dee472dd2 indent(1): revert r334640 and r334632
While STACKSIZE macro is indeed problematic on some systems, the commits
were wrong to shrink il[] and cstk[], because they need to be of the same
size as p_stack[] as they're accessed with the same index ps.tos.
2018-08-11 19:20:06 +00:00
Dimitry Andric
e35e6a3d71 Merge ^/head r337619 through r337645. 2018-08-11 16:41:08 +00:00
Alexander Leidinger
bb50c31811 - Correct the description when jobs are executed related to load avg
to match reality (slightly different to what was submitted in the
   PR: use english word instead of math-symbol).
 - Wrap the corresponding part to below 80 characters per line.

Submitted by:	yamagi@yamagi.org
PR:		202202
Sponsored by:	Essen Hackathon
2018-08-11 16:29:54 +00:00
Brad Davis
bf8a86cd14 Move cron.d/at to usr.bin/at/
This helps with pkgbase as it tags this as a config file so it is handled as
such

Approved by:	allanjude (mentor)
Sponsored by:	Essen Hackathon
Differential Revision:	https://reviews.freebsd.org/D16673
2018-08-11 13:52:23 +00:00
Dimitry Andric
8f09c33a23 Merge ^/head r336870 through r337618. 2018-08-11 11:28:51 +00:00
Jilles Tjoelker
051c7fdd5c printf: Fix \c in %b in printf builtin exiting the shell after r337458
SVN r337458 erroneously partially reverted r265885.

This is immediately visible when running the Kyua/ATF tests for
usr.bin/printf, which actually test sh's printf builtin.

PR:		229641
2018-08-11 11:13:34 +00:00
Dimitry Andric
e0cee12ebb Merge ^/head r336870 through r337615. 2018-08-11 10:49:43 +00:00
Conrad Meyer
a04ed7615e stat(1): cache id->name resolution
When invoked on a large list of files, it is most common for a small number of
uids/gids to own most of the results.

Like ls(1), use pwcache(3) to avoid repeatedly looking up the same IDs.

Example microbenchmark and non-scientific results:

$ time (find /usr/src -type f -print0 | xargs -0 stat >/dev/null)

BEFORE:
3.62s user 5.23s system 102% cpu 8.655 total
3.47s user 5.38s system 102% cpu 8.647 total

AFTER:
1.23s user 1.81s system 108% cpu 2.810 total
1.43s user 1.54s system 107% cpu 2.754 total

Does this microbenchmark have any real-world significance?  Until a use case
is demonstrated otherwise, I doubt it.  Ordinarily I would be resistant to
optimizing pointless microbenchmarks in base utilities (e.g., recent totally
gratuitous changes to yes(1)).  However, the pwcache(3) APIs actually
simplify stat(1) logic ever so slightly compared to the raw APIs they wrap,
so I think this is at worst harmless.

PR:		230491
Reported by:	Thomas Hurst <tom AT hur.st>
Discussed with:	gad@
2018-08-11 02:56:43 +00:00
Dimitry Andric
f9c0a51283 Merge ^/head r337286 through r337585. 2018-08-10 21:02:28 +00:00
Kyle Evans
f032f7b307 apply(1): Fix magic number substitution with magic character ' '
Using a space as the magic character would result in problems if the command
started with a number:

- For a 'valid' number n, n < size of argv, it would erroneously get
  replaced with that argument; e.g. `apply -a ' ' -d 1rm x => `execxrm x`

- For an 'invalid' number n, n >= size of argv, it would segfault.
  e.g. `apply -a ' ' 2to3 test.py` would try to access argv[2]

This problem occurred because apply(1) would prepend "exec " to the command
string before doing the actual magic number replacements, so it would come
across "exec 2to3 1" and assume that the " 2" is also a magic number to be
replaced.

Re-work this to instead just append "exec " to the command sbuf and
workaround the ugliness. This also simplifies stuff in the process.

PR:		226948
Submitted by:	Tobias Stoeckmann <tobias@stoeckmann.org>
MFC after:	1 week
2018-08-08 21:21:28 +00:00
Alan Somers
47cc9ee1b1 Switch the default pager for most commands to less
Finally, a pager for the nineties.

MFC after:	Never
Relnotes:	Yes
Differential Revision:	https://reviews.freebsd.org/D13465
Poll:		https://reviews.freebsd.org/V7
2018-08-08 19:24:20 +00:00
Pedro F. Giffuni
702da35288 Fix printf(1) ignores width and precision in %b format.
The precision with the conversion specifier b is specified by POSIX: see
point 7 in the reference documentation.

This corrects previous wrong log in r337440.

Reference: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html

PR:	229641
Reported by:	Rudolf Cejka
Submitted by:	Garrett D'Amore (illumos)
MFC after:	1 week
2018-08-08 15:25:01 +00:00
Pedro F. Giffuni
94e460157d Revert r337440: the log message is wrong. 2018-08-08 15:12:32 +00:00
Eitan Adler
550ddd16ed top(1): hide THR column in separate-thread mode.
It does not make sense to show a "thread count" column when displaying
threads separately. In fact we don't, but do show the header for this
column. Fix this.
2018-08-08 06:31:46 +00:00
Pedro F. Giffuni
e21ce9d742 Fix printf(1) ignores width and precision in %b format.
The precision with behavior is "unspecified" by POSIX (as of 2018), but
most implementations seem to have taken it to be treated the same as for
"s"; applied after the unescaping.
Adopt the same treatment on our printf.

PR:	229641
Submitted by:	Garrett D'Amore (illumos)
2018-08-07 23:03:50 +00:00
Pedro F. Giffuni
5102499601 sed(1): partial fix for the case of the regex delimited with '['.
We don't generally support the weird case of regular expresions delimited
by an opening square bracket ('[') but POSIX says that inside
bracket expressions, escaping is not possible and both '[' and '\'
represent themselves.

PR:		230198 (exp-run)
Obtained from:	OpenBSD
2018-08-07 14:47:39 +00:00
John Baldwin
7cf2ca3b01 Remove spurious ABI tags from kdump output.
The abidump routine output an ABI tag when -A was specified for records
that were not displayed due to type or pid filtering.  To fix, split
the code to lookup the ABI from the code to display the ABI, move the
code to display the ABI into dumpheader(), and move dumpheader() later
in the main loop as a simplification.  Previously dumpheader() was
called under a condition that repeated conditions made later in the
main loop.

Reviewed by:	kib
MFC after:	1 month
Sponsored by:	DARPA / AFRL
Differential Revision:	https://reviews.freebsd.org/D16608
2018-08-07 00:10:58 +00:00
Dimitry Andric
bbd7a9298f Merge ^/head r336870 through r337285, and resolve conflicts. 2018-08-04 11:53:41 +00:00
Conrad Meyer
84b851c23f wc(1): Fix 'wc -L'
I inadvertently broke 'wc -L' in r326736.  We must skip the fast path if -L
was specified, in addition to the existing check for the -l option.

Document long-standing -L behavior (count varies depending on whether wc(1)
is run with the -m option or not) in wc.1.  That behavior dates back to the
introduction of the -L option, but was not documented.

PR:		230300
Reported by:	<amstrnad+bugzilla AT gmail.com>
Sponsored by:	Dell EMC Isilon
2018-08-02 23:45:14 +00:00
Ed Maste
899fb13bf4 lld: use now-upstream ld.lld.1 2018-08-02 20:31:54 +00:00
Dimitry Andric
e837c321f9 Regenerate clang.1. 2018-08-02 19:19:53 +00:00
Dimitry Andric
5c00527519 Update llvm tool manpages, and llvm-mca.1. 2018-08-02 19:11:56 +00:00
Mark Johnston
0dbdecfd4f Add a rudimentary test for procstat kstack.
MFC after:	1 week
2018-08-02 16:03:47 +00:00
Dimitry Andric
29a348fe99 Update build glue to make WITH_LLD work. 2018-08-02 06:26:51 +00:00
Dimitry Andric
67b158f6ad Update build blue to make WITH_CLANG_EXTRAS and WITH_CLANG_FULL work. 2018-08-01 20:46:06 +00:00
Dimitry Andric
9f6e9a9f35 Make the minimal clang executable build. 2018-07-31 21:07:20 +00:00
Dimitry Andric
d1efe5165c Remove SRCS for files that have been deleted upstream. 2018-07-31 18:32:57 +00:00
Dimitry Andric
25194b54ad Make llvm-tblgen and clang-tblgen build. 2018-07-31 18:25:33 +00:00
Pedro F. Giffuni
1a68918570 sed: compile with the default WARNS level. 2018-07-30 19:41:54 +00:00
Pedro F. Giffuni
0649b6706f sed: unsign some indexes to fix sign-compare warnings.
Hinted by:	OpenBSD (CVS 1.32)

MFC after:	 1 week
2018-07-30 18:29:46 +00:00
Alan Somers
6040822c4e Make timespecadd(3) and friends public
The timespecadd(3) family of macros were imported from NetBSD back in
r35029. However, they were initially guarded by #ifdef _KERNEL. In the
meantime, we have grown at least 28 syscalls that use timespecs in some
way, leading many programs both inside and outside of the base system to
redefine those macros. It's better just to make the definitions public.

Our kernel currently defines two-argument versions of timespecadd and
timespecsub.  NetBSD, OpenBSD, and FreeDesktop.org's libbsd, however, define
three-argument versions.  Solaris also defines a three-argument version, but
only in its kernel.  This revision changes our definition to match the
common three-argument version.

Bump _FreeBSD_version due to the breaking KPI change.

Discussed with:	cem, jilles, ian, bde
Differential Revision:	https://reviews.freebsd.org/D14725
2018-07-30 15:46:40 +00:00
Eitan Adler
ec9eb99714 truncate: delintify 2018-07-29 07:51:42 +00:00
Eitan Adler
c517ae76c1 truncate: use better type for 'round' 2018-07-29 07:51:40 +00:00
Martin Matuska
f1951fd745 MFV r336851:
Update vendor/libarchive/dist to git 2c8c83b9731ff822fad6cc8c670ea5519c366a14

Important vendor changes:
  PR #993: Chdir to -C directory for metalog processing
  OSS-Fuzz #4969: Check size of the extended time field in zip archives
  PR #973: Record informational compression level in gzip header

MFC after:	1 week
2018-07-29 00:12:16 +00:00
Daichi GOTO
08092a9b8f top(1): fix a buffer overflow copying states to display while they were incremented
- fix an AddressSanitizer error

Submitted by:	devnexen@gmail.com
Reviewed by:	eadler
Approved by:	gnn (mentor)
Differential Revision:	https://reviews.freebsd.org/D16183
2018-07-27 07:05:50 +00:00
Xin LI
9977c7b512 Improve --strip-trailing-cr handling:
- Advance ctold for f1 and ctnew for f2
 - ungetc() if the character is unexpected
 - Don't break early when we hit the combination on one side

PR:		230049
Reported by:	maskray <emacsray gmail com>
Reviewed by:	bapt, maskray
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D16451
2018-07-27 05:21:20 +00:00
Daichi GOTO
324976739f top(1): fixed the empty output problem in non-interactive mode (-n, -b) regressed in r336028
PR:		229842
Reported by:	Ali Abdallah <aliovx@gmail.com>
Reviewed by:	eadler, cy
Approved by:	gnn (mentor)
Differential Revision:	https://reviews.freebsd.org/D16455
2018-07-27 01:20:34 +00:00
Daichi GOTO
cfb27362b1 top(1): forgot in r336160
Approved by:	gnn (mentor)
Differential Revision:	https://reviews.freebsd.org/D16452
2018-07-26 13:53:22 +00:00
Eitan Adler
10550f0b0a top(1): increase number of columns for memory
The original intention was 4 columns but with a usable a result. In
practice this was not the case. Increase the number of columns to 5
until humanize_number learns alternative ways of presenting the number.

Requested by:	many
Ref D15801
2018-07-25 14:05:17 +00:00
Eitan Adler
2da6fd55d9 find(1): remove empty else condition
reported by:	brooks
2018-07-25 03:42:07 +00:00
John Hixson
d7aabdd96c Add jhixson to committers-ports.dot and calendar.freebsd
Approved by:	miwi (mentor), kmoore (mentor), araujo (mentor)
Differential Revision:	https://reviews.freebsd.org/D16424
2018-07-24 18:33:26 +00:00
Alan Somers
ca2d3691c3 Fix several Coverity warnings in tftp
Some of the changes are in the libexec/tftpd directory, but to functions that
are only used by tftp(1) (they share some code).

* strcpy => strlcpy (1006793, 1006794, 1006796, 1006741)
* Unchecked return value and TOCTTOU (1009314)
* NULL pointer dereference (1018035, 1018036)

Reported by:	Coverity
CID:		1006793, 1006794, 1006796, 1006741, 1009314, 1018035
CID:		1018036
MFC after:	2 weeks
2018-07-22 17:10:12 +00:00
Konstantin Belousov
abbe7d5acd Move mostly useless examples binaries from OFED, as well as the Subnet
Manager, under the new option WITH_OFED_EXTRA, disabled by default.

Reviewed by:	bdrewery, hselasky (previous version)
Sponsored by:	Mellanox Technologies
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D16230
2018-07-20 23:52:11 +00:00
Zach Leslie
3d718b884f Add myself (zleslie) to calendar.freebsd
PR:		D15896
Approved by:	swills(mentor)
2018-07-19 04:31:41 +00:00
Piotr Pawel Stefaniak
01c66110e1 indent(1): rewrite the integer/floating constant scanning part of lexi.c
Remove procedural code that did the scanning, which was faulty and didn't
support complex constants such as 0x1p-61. Replace it with a finite state
machine expressed as a transition table. The table was rewritten by hand
from lx's output, given parts of grammar expressed as regular expressions.

lx is Katherine Flavel's lexer generator, currently available at
https://github.com/katef/libfsm and the parts of grammar were taken from
http://quut.com/c/ANSI-C-grammar-l-2011.html and extended to support binary
integer constants which are a popular GCC extension.

Reported by:	bde
2018-07-16 05:46:50 +00:00
Piotr Pawel Stefaniak
89463812e3 indent(1): move case_indent from parser state to the options struct
This was missed in r334927.
2018-07-15 21:04:21 +00:00
Konstantin Belousov
b3042426d0 Remove bits of the old NUMA.
Remove numactl(1), edit numa(4) to bring it some closer to reality,
provide libc ABI shims for old NUMA syscalls.

Noted and reviewed by:	brooks (previous version)
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D16142
2018-07-10 22:00:20 +00:00
Mark Johnston
04354d577d Fix thread state summary line display after r334918. 2018-07-10 17:20:27 +00:00
Brooks Davis
3a20f06a1c Use uintptr_t alone when assigning to kvaddr_t variables.
Suggested by:	jhb
2018-07-10 13:03:06 +00:00
Daichi GOTO
7452122499 top(1): rollback r335836
Encoding-specific processing introduced in r335836 is not recommended.
And doing getenv("LANG") and assuming an encoding based on it is a
very bad practice to internationalize software.

Submitted by:	hrs
Differential Revision:	https://reviews.freebsd.org/D16203
2018-07-10 03:49:48 +00:00
Xin LI
34e314e794 Use endian.h le32dec() instead of rolling our own.
Suggested by:	phk
Reviewed by:	imp, pfg
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D16192
2018-07-10 01:42:28 +00:00
Daichi GOTO
5c48c1ee57 top(1): Fix the prompt bug and core dump problem in o / p mode that occurred by r336028
Reviewed by:	cy
Approved by:	gnn (mentor)
Differential Revision:	https://reviews.freebsd.org/D16174
2018-07-10 00:19:52 +00:00
Pedro F. Giffuni
add14e43f8 localedef(1): remove duplicated includes.
Hinted by:	DragonFlyBSD
2018-07-09 20:38:47 +00:00
Pedro F. Giffuni
51a8f735f8 sed(1): Suppress implicit-fallthrough.
Apparently some tools are not able to determine if all the cases of a
switch are covered. Make use of the attribute for cases like this.

Hinted by:	DragonFlyBSD GGC8 (but fixed differently)

CID:	976552
2018-07-09 20:27:31 +00:00
Emmanuel Vadot
1017327049 truncate: Add support for -s % and /
% round up to the multiple size and / round down
This is compatible with gnu truncate.
Add tests and document in the man page.
2018-07-09 19:03:30 +00:00
Emmanuel Vadot
dde27dbc9b truncate: style(9) some parts 2018-07-09 19:02:05 +00:00
Conrad Meyer
e76247cd60 gzip(1): Don't shadow global 'err'
Unbreak work build on ppc due to -Werror=shadow.  Introduced in r336121.

X-MFC-With:		r336121
2018-07-09 08:37:55 +00:00
Xin LI
b393a8ace6 Don't delete outfile unconditionally.
MFC after:	1 month
2018-07-09 06:19:33 +00:00
Pedro F. Giffuni
3fcbc83d04 gzip: fix for undefined behavior.
Unportable left shift reported with MKSANITIZER=yes
USE_SANITIZER=undefined:

# progress -zf ./games.tgz  tar -xp -C "./" -f -
/public/src.git/usr.bin/gzip/gzip.c:2126:33: runtime error: left shift of
251 by 24 places cannot be represented in type 'int'
100%
|****************************************************************************************************************|
44500 KiB  119.69 MiB/s    00:00 ETA

Refactor the following code into something that is more clear
and fix signed integer shift, by casting all buf[] elements to
(unsigned int):

unsigned char buf[8];
uint32_t usize;
[...]
else {
    usize = buf[4] | buf[5] << 8 |
            buf[6] << 16 | buf[7] << 24;
[...]

New version:

    usize = buf[4];
    usize |= (unsigned int)buf[5] << 8;
    usize |= (unsigned int)buf[6] << 16;
    usize |= (unsigned int)buf[7] << 24;

Only the "<< 24" part needs explicit cast, but for consistency make the
integer promotion explicit and clear to a code reader.

Sponsored by <The NetBSD Foundation>

Obtained from:	NetBSD (CVS rev. 1.113)
MFC after:	1 week
2018-07-08 22:39:33 +00:00
Jamie Gritton
8169574768 Missed a bit of doc change from r335921.
PR:		229266
2018-07-06 16:23:30 +00:00
Ben Widawsky
29e44344da Adding myself to committers-src.dot and calendar.freebsd
Approved by: emaste (mentor)
Differential Revision: https://reviews.freebsd.org/D16154
2018-07-06 16:22:26 +00:00
Sean Bruno
9d5352cb63 r336028 changed next_msg to a char * from char [] of fixed size. Change
2nd argument of vsnprintf() to get the strlen of next_msg so that the
appropriate size is used.

Found with gcc.

/usr.bin/top/display.c: In function 'new_message':
/usr.bin/top/display.c:963:31: error:
argument to 'sizeof' in 'vsnprintf' call is the same expression as the
destination; did you mean to provide an explicit length?
[-Werror=sizeof-pointer-memaccess]
     vsnprintf(next_msg, sizeof(next_msg), msgfmt, args);

Reviewed by:	daichi
2018-07-06 13:22:44 +00:00
Daichi GOTO
0a59db87e3 Changed to eliminate the upper limit of command length displayed
by "-a" and expand to match terminal width

Reviewed by:	eadler
Approved by:	gnn (mentor)
Differential Revision:	https://reviews.freebsd.org/D16083
2018-07-06 12:07:06 +00:00
Sean Eric Fagan
aad5531e71 This exposes ZFS user and group quotas via the normal
quatactl(2) mechanism.  (Read-only at this point, however.)
In particular, this is to allow rpc.rquotad query quotas
for NFS mounts, allowing users to see their quotas on the
hosts using the datasets.

The changes specifically:

* Add new RPC entry points for querying quotas.
* Changes the library routines to allow non-UFS quotas.
* Changes rquotad to check for quotas on mounted filesystems,
rather than being limited to entries in /etc/fstab
* Lastly, adds a VFS entry-point for ZFS to query quotas.

Note that this makes one unavoidable behavioural change: if quotas
are enabled, then they can be queried, as opposed to the current
method of checking for quotas being specified in fstab.  (With
ZFS, if there are user or group quotas, they're used, always.)

Reviewed by:	delphij, mav
Approved by:	mav
Sponsored by:	iXsystems Inc
Differential Revision:	https://reviews.freebsd.org/D15886
2018-07-05 22:56:13 +00:00
Brooks Davis
f6293d7296 Work around lame warnings in ancient gcc on 32-bit platforms.
Fixes r335979.
2018-07-05 17:02:10 +00:00
Brooks Davis
f38b68ae8a Make struct xinpcb and friends word-size independent.
Replace size_t members with ksize_t (uint64_t) and pointer members
(never used as pointers in userspace, but instead as unique
idenitifiers) with kvaddr_t (uint64_t). This makes the structs
identical between 32-bit and 64-bit ABIs.

On 64-bit bit systems, the ABI is maintained. On 32-bit systems,
this is an ABI breaking change. The ABI of most of these structs
was previously broken in r315662.  This also imposes a small API
change on userspace consumers who must handle kernel pointers
becoming virtual addresses.

PR:		228301 (exp-run by antoine)
Reviewed by:	jtl, kib, rwatson (various versions)
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D15386
2018-07-05 13:13:48 +00:00
Konstantin Belousov
f87a5f036b top: do not fall to the thread name if kernel cache of the process
args is empty.

Instead, use kvm_getargv() unconditionally to obtain the process
arguments.  It means that one additional sysctl(2) is performed there.

Submitted by:	Thomas Munro
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D16111
2018-07-04 13:28:16 +00:00
Jamie Gritton
de68a3200a Allow jail names (not just IDs) to be specified for: cpuset(1), ipfw(8),
sockstat(1), ugidfw(8)
These are the last of the jail-aware userland utilities that didn't work
 with names.

PR:		229266
MFC after:	3 days
Differential Revision:	D16047
2018-07-03 23:47:20 +00:00
Jilles Tjoelker
8f8092f8e7 rup: Fix -Wcast-align warnings
Fix possible strict aliasing issue (if time_t is the same size as int but
not int but for example long) which also resulted in a false positive
warning on systems with 64-bit time_t. Pointer casts are bad; we can just
copy the time_t.

Elsewhere, avoid casting char * to int * by using memcpy().

Reviewed by:	eadler
Differential Revision:	https://reviews.freebsd.org/D16075
2018-07-03 19:09:46 +00:00
Ruslan Bukin
c6dc704e84 Fix build: utf8strvisx() does signed data comparisons, but 'char' type
is unsigned in riscv GCC, so use guaranted signed char type.

Sponsored by:	DARPA, AFRL
2018-07-03 14:32:15 +00:00
Cy Schubert
4ee90e6e20 When toggling the display using the "m" command to toggle from 'cpu'
mode to 'io' mode, an artifact remains because the buffer is not
"finished" with a NULL terminator using sbuf_finish().

An example of this is, when the "m" command is entered, the title line
will contain COMMANDND instead of COMMAND. This commit fixes this.
2018-07-03 02:54:32 +00:00
Eitan Adler
9fe7e0020a find(1): use correct type for readlink 2018-07-01 20:09:56 +00:00
Eitan Adler
b422540a99 find(1): deLINTify 2018-07-01 20:09:52 +00:00
Eitan Adler
39d2eb75fc top(1): permit infinite length for command
There isn't any need to limit the size of the screen. Utilities like
'less -S' don't have a (meaningful) limit anyways.  This also makes the
way to dynamically changing the column widths based on the screen width.
2018-07-01 19:44:29 +00:00
Eitan Adler
06668f7f65 find(1): remove portability ifdefs
This code isn't designed to be particularly portable outside of FreeBSD.
To be more specific it doesn't make much sense to support compiling
find(1) on VMS.
2018-07-01 19:44:26 +00:00
Daichi GOTO
4417ed2dbf top(1) - support UTF-8 display
Reviewed by:	eadler
Approved by:	gnn (mentor)
Differential Revision:	https://reviews.freebsd.org/D16006
2018-07-01 05:32:03 +00:00
Brad Davis
f59e535254 Simplify using bsd.endian.mk and have it provide CAP_MKDB_ENDIAN, since it is
the most common usage.

Approved by:	bapt (mentor)
2018-06-28 13:48:59 +00:00
Bryan Drewery
96a0acc4ce Don't use CCACHE for linking.
MFC after:	2 weeks
Sponsored by:	Dell EMC
2018-06-27 19:29:15 +00:00
Daichi GOTO
612e0030b6 top(1): increased the maximum length of command shown by "-a"
Reviewed by:	eadler
Approved by:	gnn (mentor)
Differential Revision:	https://reviews.freebsd.org/D16006
2018-06-27 02:55:30 +00:00
Eitan Adler
b1ba4c4472 rusers: modernize a bit 2018-06-25 11:44:56 +00:00
Eitan Adler
7f08b09a0e rup: compile with WARNS=6 2018-06-25 11:44:53 +00:00
Eitan Adler
bec6dc30e1 users(1): Use capsicum helpers for users
In doing so also fix the libcasper.h header to work in C++.
2018-06-25 11:44:41 +00:00
Eitan Adler
8d3f65e767 top(1): increase field with width for W/CPU column
This allows 3 digit CPU columns to look nice

Reported by:	feld
2018-06-24 13:14:04 +00:00
Eitan Adler
aa571745a6 Makefiles: remove outdated comments 2018-06-24 09:39:40 +00:00
Eitan Adler
db36566345 top(1): Restructure printing of process states
This avoids the need to have separate buffers and calls to sprintf for
various calls.
2018-06-23 22:45:22 +00:00
Eitan Adler
0515b88e77 top(1): Convert process listing to sbuf too
This also fixes -mio with 'T' set (thread-id instead of process-id).

This can go further by removing the existing sprintf, and using sbuf
directly. This will be done in a followup commit.
2018-06-23 22:45:20 +00:00
Eitan Adler
ac8f40ea78 top(1): Use basename instead of a homegrown alternative 2018-06-23 22:45:18 +00:00
Eitan Adler
becfb1625c top(1): show CPU state breakdown on first run
There is no documented reason for this not to be shown on the first run.
I can't find any good reason, and it breaks batch mode.

PR:		218889
Submitted by:	"Jeremy C. Reed" <reed@reedmedia.net>
2018-06-23 03:17:11 +00:00
Eitan Adler
00abcb6acd top(1): increase warnings
top(1) now builds without cast-qual warnings, so remove the exemption
for that.

Tested with clang, gcc7, gcc9
2018-06-22 10:20:21 +00:00
Eitan Adler
8caf462ef6 top(1): garbage collect
- remove a now-unused function
- remove needless indirection of handle type
2018-06-22 10:17:12 +00:00
Eitan Adler
d9cf8a13ca top(1): increase size of 'C' column
On machines with more than 99 CPUs make room to display the entire
number.

Requested by:	cperciva
2018-06-22 10:17:10 +00:00
Eitan Adler
5c66dcc072 top(1): remove special handling of load > 5
When the load is "high" (an arbitrary value) top(1) previously moved the
cursor to the top-left of the screen as an acknowledgment. In practice,
on modern machines, even relatively slow ones, it looked more like a
glitch. Remove the logic.
2018-06-22 09:45:18 +00:00
Eitan Adler
51c834c490 top(1): reimplement header formatting as sbuf
The current header formatting is a giant format string that changes
global state during the format process.

Make the following changes:
- use sbuf to build up the header rather than use the above
pseudo-dynamic one
- Change name length to 10
- Reduce size of RES and SIZE by making humanize more aggressive
- Restore a version number line to the copyright. This may be required
by the copyright (and may not be; its unclear)

This is also a pre-req to implementing TOPCOLOR from newer versions of
top(1)

Discussed with:	allanjude, rpolka, danfe, rgrimes
Differential Revision: https://reviews.freebsd.org/D15801
2018-06-22 09:21:01 +00:00
Eitan Adler
520c8e1852 su(1): build with WARNS=6
Tested with full make universe
2018-06-22 09:10:50 +00:00
Eitan Adler
57ad79afd6 top(1): behave as documented for -t
Show top itself by default, unless -t is specified.
2018-06-22 00:02:36 +00:00
Ed Maste
9b844631a6 Rename usr.bin/elfcopy to usr.bin/objcopy
We always install ELF Tool Chain's elfcopy as objcopy, so to avoid
confusion rename the src directory containing our reach-over Makefile
to match.

Requested by:	jhb
Sponsored by:	The FreeBSD Foundation
2018-06-21 14:28:20 +00:00
Xin LI
80cb4b11eb Don't leak tmpstr.
MFC after:	2 weeks
2018-06-21 07:42:28 +00:00
Ed Maste
be72428e54 usr.bin/ar: use standard 2-Clause FreeBSD license
Many licenses on ar files contained small variations from the standard
FreeBSD license text. To avoid license proliferation switch to the usual
2-clause FreeBSD license after obtaining permission from all copyright
holders.

Approved by:	jkoshy, kaiw, kientzle
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D14561
2018-06-20 18:43:17 +00:00
Bryan Drewery
d74021d65b Rework how the ld link is handled in WORLDTMP from r322811.
LLD_BOOTSTRAP (build) is independent of LLD_IS_LD (installed) so they
should not be based on each other.

This is related to upcoming WITH_SYSTEM_LINKER work.

Reviewed by:	emaste
Sponsored by:	Dell EMC
Differential Revision:	https://reviews.freebsd.org/D15836
2018-06-20 16:10:02 +00:00
Kyle Evans
7137597e15 sort(1): Fix -m when only implicit stdin is used for input
Observe:

printf "a\nb\nc\n" > /tmp/foo
# Next command results in no output
cat /tmp/foo | sort -m
# Next command results in proper output
cat /tmp/foo | sort -m -
# Also works:
sort -m /tmp/foo

Some const'ification was done to simplify the actual solution of adding "-"
explicitly to the file list if we didn't have any file arguments left over.

PR:		190099
MFC after:	1 week
2018-06-20 03:31:19 +00:00
Kyle Evans
36180cd53d sort(1): Add bits to allow easy checking against NetBSD tests
I'm looking at sort(1) failures, for better or worse.
2018-06-20 03:10:49 +00:00
Mariusz Zaborski
a3552326dc Use capsicum helpers to cache NLS data. 2018-06-20 00:13:09 +00:00
Mariusz Zaborski
7672a0148f Convert cap_enter() < 0 && errno != ENOSYS to caph_enter() < 0.
No functional change intended.
2018-06-19 23:43:14 +00:00
Eitan Adler
3edda95c9d top(1): fix top -mio 2018-06-19 23:30:55 +00:00
Alan Somers
aa9d9bfa90 top(1): Fix Coverity warning
Don't call strerror on negative errnos

Reported by:	Coverity
CID:		976708
Reviewed by:	eadler
Differential Revision:	https://reviews.freebsd.org/D15909
2018-06-19 18:32:06 +00:00
Ed Maste
9befbe457c usr.bin/ar: remove incorrect SPDX tags
Three ar files have a non-standard variation of the BSD license, so
remove their SPDX tags.

Sponsored by:	The FreeBSD Foundation
2018-06-19 17:30:11 +00:00
Ed Maste
25f82d56c7 usr.bin/ar: use standard 2-Clause FreeBSD license
Many licenses on ar files contained small variations from the standard
FreeBSD license text. To avoid license proliferation switch to the usual
standard 2-clause FreeBSD license for those files where I have obtained
permission from all of the listed copyright holders.

Approved by:	jkoshy, kaiw
Differential Revision:	https://reviews.freebsd.org/D14561
2018-06-19 17:28:05 +00:00
Eitan Adler
cc11473037 top(1): correct assertion 2018-06-19 05:01:07 +00:00
Eitan Adler
e59ba74961 top(1): correct header in UP mode
Fix an oversight from r334869 which made the same change, but only for
SMP systems. This avoids a segfault while D15801 is being reviewed.

Reviewed by:	kevans
2018-06-19 04:18:23 +00:00
Eitan Adler
31b998816c dc: make use of caph_enter
We already use caph library so this makes sense.
2018-06-18 04:54:09 +00:00
Eitan Adler
6bb0d5cf77 top(1): use more modern signal code
Rather than manually build signal masks use functions designed for that
reason. Also use sigprocmask instead of sigblock.
2018-06-18 02:06:16 +00:00
Eitan Adler
943a127c89 units: fix some nits
- prefer braces to abusing the `,` operator
- mark dead function as dead
- remove dead break
2018-06-16 21:07:46 +00:00
Konstantin Belousov
f39bffc62c Rework ofed build.
Aligns the build with the FreeBSD traditional approach to not build in
contrib/, and to track inter-dependencies between libraries.

With help from:	bdrewery
Reviewed by:	bdrewery, hselasky
Sponsored by:	Mellanox Technologies
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D15648
2018-06-16 15:05:05 +00:00
Ed Maste
fd897a5340 ldd: reference readelf instead of objdump in warning message
We have an obsolete GNU objdump 2.17.50 in the base system, which will
be removed in the future.  Suggest readelf(1) for examining ELF files
instead; for most use cases it is the preferred tool anyhow.

PR:		229046
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2018-06-15 16:28:50 +00:00
Kyle Evans
031f92f512 bsdgrep(1): Remove redundant initialization; unconditionally assigned later 2018-06-15 03:31:30 +00:00
Eitan Adler
ef8dcce3c2 top(1): remove myself from top.1
I wrote some, but not enough for the man page.
2018-06-14 12:14:51 +00:00
Allan Jude
21e289d49b Fix top(1) support for displaying ZFS Compressed ARC statistics
Broken in r334514

sysctlbyname("vfs.zfs.compressed_arc_enabled", ...) would return ENOMEM
while trying to read the sysctl (a boolean_t) into a bool, which is too small.

Reviewed by:	jhb (on irc)
Sponsored by:	Klara Systems
2018-06-14 00:10:16 +00:00
Eitan Adler
f764243341 top(1): remove unneeded logic
- remove __pure annotations I added earlier for some functions. One
writes to the the arguments as "out" pointers. The
other reads from an array, which while const within the function might
be mutated externally.
- total_change is modified to be at 1, if previously 0, so no if check
is needed.
2018-06-13 11:12:52 +00:00
Eitan Adler
1de6384221 top(1): style(9)
- split return type from function name
- Sprinkle a __pure where possible.
2018-06-13 08:52:22 +00:00
Eitan Adler
d18626664a top(1): add myself to authors
At this point I've mucked enough with top(1) that all bugs should be
blamed on me rather than William LeFebvre.
2018-06-13 08:52:19 +00:00
Eitan Adler
c655e639c2 top(1): shift from atoi to non-deprecated function 2018-06-13 08:52:14 +00:00
Eitan Adler
704daa9b87 top(1): replace homegrown itoa with sprintf
Much of this should be inlined to the callsite, but leave it here for
now to make it easier to make it easier bisect later.
2018-06-13 08:52:12 +00:00
Eitan Adler
8e4b205ea5 top(1): format_time, format_k, etc.
- Use humanize_number for format_k and format_k2
- Fix some style nits in format_time
2018-06-13 08:52:09 +00:00
Eitan Adler
e7cb1c0776 top(1): format help more nicely
For entries that are duplicates present them nicely rather than showing
two identical help entries. For ' ' present it as SPC
2018-06-13 08:52:06 +00:00
Eitan Adler
baab2cf821 vmstat(1): various nits
Continue my parade on introspection tools by fixing:
- failed to check for null after reallocf
- avoid the comma operator
- mark usage as dead
- correct size of len
2018-06-13 08:52:04 +00:00
Eitan Adler
59c50d8277 top(1): several small bugfixes and nits
- initialize all maybe uninitialized vars with bogus values. This shuts
up the compiler, and causes crashes if it changes later.
- mark noreturn as noreturn
- removed unused macro
- handle x_procstate as runtime rather than pre-processor
- avoid using void functions in condtionals

Tested with clang, gcc 7, gcc 9
2018-06-13 00:45:38 +00:00
Baptiste Daroussin
43d7b1c097 Fix memory leak
CID:		1393352
2018-06-12 16:42:11 +00:00
Baptiste Daroussin
5a43dca273 Correctly test return value of pipe(2)
CID:		1393351
2018-06-12 16:40:22 +00:00
Eitan Adler
0ff79d817c top(1): remove trailing whitespace 2018-06-12 07:31:59 +00:00
Eitan Adler
ccf22059e0 top(1): style and related
- style(9)
- remove now-defunct comments
- remove getuid check for low delay
- expand range of format_k
2018-06-12 07:14:12 +00:00
Eitan Adler
c8aa5e526f top(1): move command mapping to commands.c
This eliminates the difficult to follow mapping of a string list. It
moves numbers from "#define" into (more) debuggable enums. More
generally, it follows the trend of moving more data into a more central
mechanism.

The help output is a little worse: " " is not rendered well, and there
are duplicate entries, but that will be fixed in a followup.
2018-06-12 06:53:31 +00:00
Piotr Pawel Stefaniak
bb92a28b2f indent(1): rename -nsac/-sac ("space after cast") to -ncs/-cs
Also update tests and the manpage.

GNU indent had the option earlier as -cs, let's not diverge unnecessarily.
2018-06-11 05:35:57 +00:00
Eitan Adler
fb7b896cd8 top(1): handle 0 in "digits" functions 2018-06-11 05:05:20 +00:00
Piotr Pawel Stefaniak
7e53aaedd3 indent(1): group global option variables into an options structure
It's clearer now when a variable represents a toggable command line option.

Many options were stored in the parser's state structure, so fix also that.
2018-06-10 16:44:18 +00:00
Eitan Adler
a01160996b top(1): use modern interfaces for nice and related
- attempt and fail, rather than check for permission.
- use macro rather than explicit "-20"
2018-06-10 09:15:13 +00:00
Eitan Adler
1a8f56dd3a top(1): add command aliases; correct dumb support 2018-06-10 09:04:56 +00:00
Eitan Adler
561b0720cf top(1): use sys_signame instead of hard coding signals
This enables the removal of the signal.h awk script. Shamelessly stolen
from kill(1).
2018-06-10 09:00:01 +00:00
Eitan Adler
b26cf3d06c top(1): bring some structure to commands
Right now this is only used for help text but it'll eventually be used
to build up long options array, dispatch commands, etc.
2018-06-10 08:59:57 +00:00
Eitan Adler
4eef480b46 top(1): use correct word when displaying threads
PR:		182204
Reported by:	"Brodey Dover" <doverosx@gmail.com>
2018-06-10 06:33:49 +00:00
Eitan Adler
b4aadfd27e top(1): filter fewer warnings; clean up
- remove WARNS?=6. It is default
- we no longer have cast-qual problems
- remove unused macros
- remove unneeded casts
- add include guard for loadavg.h
2018-06-10 06:21:51 +00:00
Eitan Adler
da446b10ed top(1): permit sending signal with any case 2018-06-10 06:21:45 +00:00
Michael Dexter
c1192502cb Add myself to calendar.freebsd
Approved by:	bcr (mentor)
2018-06-10 05:48:03 +00:00
Eitan Adler
468910cd7a top(1): permit sub-second delay times
This removes the getuid check for delay==0. It didn't prevent users from
writing similar programs in the general case. In theory, if top(1) is
among one of the few restricted programs you're allowed to run, it may
have helped a little, but there are better ways of handling that case.
2018-06-10 00:02:56 +00:00
Eitan Adler
6e0632db3d top(1): correctly reset per-cpu counters
I had changed this from a for loop to a memset during an earlier
cleanup. This change was incorrect so revert it.

While here, clean up

Reported by:	flo
2018-06-09 23:24:08 +00:00
Eitan Adler
ef436ca6a6 top(1): handle specific pids better
When told to watch a specific pid, don't filter idle, system, or self
processes. The summary at the top will still flip correctly though.
2018-06-09 23:08:02 +00:00
Eitan Adler
d73bfd43b2 top(1): implement additional missing long options 2018-06-09 22:30:10 +00:00
Eitan Adler
9d6cce02a7 top(1): initial pass to freebsdize the man page
The previous man page used many conventions not typical in FreeBSD.
Since we've forked top completely, convert the man page too.
2018-06-09 21:40:33 +00:00
Eitan Adler
c388909b8d top(1): Implement long options
This also documents some reserved or differing options from top's
original upstream.
2018-06-09 21:40:24 +00:00
Baptiste Daroussin
e620f7fb56 diff: Import fixes from OpenBSD
original commit log by miller@OpenBSD  r1.46:
Fix exit value when diffing directories with missing files and the -N
or -P options are not used.  From Ibrahim Khalifa
2018-06-09 21:09:24 +00:00
Guangyuan Yang
2b77102934 Add myself to the calendar
Requested by:	mckusick
Reviewed by:	emaste
2018-06-09 21:05:25 +00:00
Baptiste Daroussin
6fa5bf0832 Isolate the pr(1) related code in its own source files
This keeps diffreg.c closer to what it is supposed to do:
diffing regular files.

It also allows my code to get a proper license
2018-06-09 20:24:17 +00:00
Eitan Adler
dd0bdd6b45 top(1): allow starting with -T flag 2018-06-09 20:06:06 +00:00
Kyle Evans
be13c0f967 bsdgrep(1): Some more int -> bool conversions and name changes
Again motivated by upcoming work to rewrite a bunch of this- single-letter
variable names and slightly misleading variable names ("lastmatches" to
indicate that the last matched) are not helpful.
2018-06-09 18:11:46 +00:00
Eitan Adler
7fe961ff48 ncal: correct history section
originally reported Todd C. Miller[0]
Additional data see [1][2].

While here, pet igor.

Closes #152 (github pr)
Sbmitted by:	Raf Czlonka

[0]
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/cal/cal.1?rev=1.28&content-type=text/x-cvsweb-markup
[1] https://www.bell-labs.com/usr/dmr/www/1stEdman.html
[2] https://www.bell-labs.com/usr/dmr/www/man61.pdf
2018-06-09 04:40:17 +00:00
Eitan Adler
e3225dcf12 top(1): correct header, align it.
THR is always 6 digits or longer. Now that the PID/THR change is
separated, use correct headers.

PR:		228823
Reported by:	Trond.Endrestol@ximalas.info
2018-06-09 02:47:02 +00:00
Eitan Adler
4e08f2f53c top(1): actually make change for tid vs pid 2018-06-09 02:18:15 +00:00
Eitan Adler
fc36f5a7cb top(1): use a different command to toggle tid vs pid
- By popular demand, implement a different switch ("T") for toggling
between thread id and process id.
- Add an assert that the size of command chars is as expected.
- Also clean up some messiness I found when implementing this.
- Further document the new flag.

Requested by:	flo, ronald-lists@klop.ws, bapt
PR:		139389 (for the record)
X-MFC-With:	r334474
2018-06-09 02:14:33 +00:00
Kyle Evans
d1a920b48f bsdgrep(1): Evict character sequence that moved in
Reported by:	trasz
2018-06-08 12:58:55 +00:00
Eitan Adler
4fb80c7008 top(1): remove some unneeded indirection 2018-06-08 02:03:51 +00:00
Eitan Adler
d408c8f742 top(1): fix several style & const related issues
- use parens for return
- put function names on newline
- sprinkle const where possible
2018-06-08 01:55:47 +00:00
Kyle Evans
bd60b9b499 bsdgrep(1): Slooowly peel away the chunky onion
(or peel off the band-aid, whatever floats your boat)

This addresses two separate issues:

1.) Nothing within bsdgrep actually knew whether it cared about line numbers
  or not.

2.) The file layer knew nothing about the context in which it was being
  called.

#1 is only important when we're *not* processing line-by-line. #2 is
debatably a good idea; the parsing context is only handy because that's
where we store current offset information and, as of this commit, whether or
not it needs to be line-aware.
2018-06-08 01:25:07 +00:00
Kyle Evans
66f780aee0 bsdgrep(1): Don't initialize fts_flags twice
Admittedly, this is a clang-scan complaint... but it wasn't wrong. fts_flags
is initialized by all cases in the switch(), which should be fairly obvious.
Annotate this anyways.
2018-06-07 18:38:48 +00:00
Kyle Evans
40f0e0b100 bsdgrep(1): whoops, garbage collect the now write-only variable 2018-06-07 18:36:12 +00:00
Kyle Evans
cbfff13fa2 bsdgrep(1): Do some less dirty things with return types
Neither procfile nor grep_tree return anything meaningful to their callers.
None of the callers actually care about how many lines were matched in all
of the files they processed; it's all about "did anything match?"

This is generally just a light refactoring to remind me of what actually
matters as I'm rewriting these bits to care less about 'stuff'.
2018-06-07 18:27:58 +00:00
Baptiste Daroussin
30dc95029e Remove NLS support from BSD grep
GNU grep as in actually in base does not have any translations support
compiled in, so no functionnality loss.

We do support 193 locales in base, we will never catch up on that number of
translation with bsd grep.

Removing NLS support make bsd grep consistent with the other binaries in base
which are not translated, and also reduce a little bit the code.

Reviewed by:	kevans
Approved by:	kevans
Discussed with:	kevans @BSDCan
Differential Revision:	https://reviews.freebsd.org/D15682
2018-06-06 23:12:35 +00:00
Eitan Adler
59c8d5dc27 top(1): fix err again
I am amazed at my ability to get a one-line error reporting line wrong
thrice.
2018-06-06 07:13:27 +00:00
Eitan Adler
bca1b45bb1 top(1): make error message happy
We don't use a "size" variable, so just don't report it.

Reported by:	bapt
2018-06-06 06:42:12 +00:00
Piotr Pawel Stefaniak
0929b3d971 indent(1): fix buildworld after r334632
Fix
error: comparison of integers of different signs: 'int' and 'unsigned long'
by casting nitems() to int.

Reported by:	mjg
2018-06-04 21:21:55 +00:00
Piotr Pawel Stefaniak
d0f86f663f indent(1): add --version option
There exist multi-platform programs that check indent's version in order to
know what they can expect from it. GNU indent provides that via --version,
so implement the same option here.
2018-06-04 21:05:56 +00:00
Piotr Pawel Stefaniak
88b24a62d1 indent(1): remove the STACKSIZE macro and all of its use
It conflicts with a system-provided macro of the same name on another OS.
2018-06-04 20:39:58 +00:00
Piotr Pawel Stefaniak
4d0c622816 indent(1): remove static const char copyright[]
It repeats what is already said in the heading comment and it's optimized out
so serves no purpose.
2018-06-04 20:24:31 +00:00
Piotr Pawel Stefaniak
03e6aeef3a indent(1): replace BSD bcopy() with C memmove() 2018-06-04 19:47:24 +00:00
Eitan Adler
cda7a5d5ed top(1): some nitpicks
- prefer fully spelled names to "u_long"
- fix speeling
2018-06-04 05:27:00 +00:00
Eitan Adler
8d0d26767b top(1): include what you use
- Change headers to more closely match what we use
- use more standard functions instead of bzero, bcmp, bcopy
- Add myself to authors.

Tested with: base clang (amd64), gcc 9 (amd64), base clang (i386), base
gcc (mips)
2018-06-04 04:59:32 +00:00
Eitan Adler
5dc98aeeaa top(1): Prefer memcpy over bcopy 2018-06-04 04:59:24 +00:00
Eitan Adler
a9a99372d9 top(1): Use strsep instead of homegrown alternative
This replaces some complex, and not quite correct logic, with a more
common strsep pattern.

Reviewed by:	mmacy (older version)
2018-06-04 03:16:24 +00:00
Eitan Adler
eae589f1ce top(1): another pass of cleanup
- avoid the need to call a function to get size of known array. I'll
likely re-arrange some of the indirect in a later to avoid the magic
constants.
- use correct type
- add const
- replace caddr_t with void*. This corrects an alignment warning.
- remove duplicated include from immediately prior commit

Under base clang we're now down to:
- 3 warning in top.c, 1 warning in mahcine.c,  4 warning in display.c,
- 1 warning in utils.c

Tested with base clang, gcc7, gcc9, base gcc (mips)
2018-06-03 23:40:54 +00:00
Eitan Adler
9f8096e339 top(1): top warnings and cleanup
- Add const where helpful
- add missing 'static' for file-local functions
- use nitems where possible
- convert manual abort() to assert
- use strndup instead of homegrown version

Tested with clang, gcc7, and gcc9
2018-06-03 22:42:54 +00:00
Piotr Pawel Stefaniak
aac30b753f indent(1): new option -lpl
With -lpl, code surrounded by parentheses in continuation lines is lined up
even if it would extend past the right margin.

With -nlpl (the default), such a line that would extend past the right
margin is moved left to keep it within the margin, if that does not require
placing it to the left of the prevailing indentation level.

These switches have no effect if -nlp is selected.

Submitted by:	Tom Lane
2018-06-03 21:40:38 +00:00
Piotr Pawel Stefaniak
50a2976094 indent(1): revert introduction of -lpl
That was committed with the wrong message. Will be re-added.
2018-06-03 21:34:29 +00:00
Piotr Pawel Stefaniak
971e1c47ec indent(1): new option -lpl (always line up to parenthesis)
With -lp, if a line has an opening paren which is not closed on that line,
then continuation lines will be lined up to start at the character position
just after the opening paren.

Submitted by:	Tom Lane
2018-06-03 20:59:59 +00:00
Piotr Pawel Stefaniak
5834814ee8 indent(1): manual page corretions
Add missing options, synchronize syntax summary with the actual option list,
and other fixes.

Submitted by:	Tom Lane
2018-06-03 20:48:58 +00:00