Commit graph

175 commits

Author SHA1 Message Date
Warner Losh 5e3934b15a usr.bin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:01 -07:00
Brooks Davis 8f9f7b4a42 procstat auxv: widen COMM column to MAXCOMLEN
For reasons unknown, procstat subcommands typically display the command
in a 16+overflow column format.  However, the command may be up to
MAXCOMLEN (19) characters long causing the column to spill into the next
one. Since there's plenty of room in the auxv case, bump the column
width up to 19 to avoid this issue.  While this is a format change 1)
users who want to parse the data should use libxo output and 2) this
makes it possible to parse reliably with cut.

Reviewed by:	markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42202
2023-10-16 17:58:54 +01:00
Warner Losh fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh da5432eda8 Remove $FreeBSD$: alt two-line .c pattern
Remove /^\s*__RCSID\("\$FreeBSD\$"\);\n\n/
2023-08-16 11:54:48 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
John Baldwin 660d6c5c3d procstat: Remove set but unused variable. 2023-06-20 09:29:00 -07:00
Warner Losh 4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Simon J. Gerraty d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Konstantin Belousov 1d280f2142 procstat(1): print AT_USRSTACKBASE and AT_USRSTACKLIM
Reviewed by:	brooks, imp (previous version)
Discussed with:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D36540
2022-09-16 23:23:38 +03:00
Gleb Smirnoff 1f3d8c09be procstat: fix printing divert(4) sockets 2022-08-30 16:26:21 -07:00
Konstantin Belousov bd8701dede Document procstat(1) advlock command
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34834
2022-04-10 00:47:50 +03:00
Konstantin Belousov a5229a255e Implement procstat(1) advlocks command
to display list of the advisory file locks in the system.

Example output
$ procstat advlock
RW  TYPE   PID SYSID          FSID               RDEV   INO START LEN PATH
RO FCNTL  5836     0  0x878700ff02 0xffffffffffffffff    57     0   0 /tmp/2
RW FLOCK    -1     0  0x878700ff02 0xffffffffffffffff    13     0   0 /tmp/1

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34834
2022-04-10 00:47:50 +03:00
Konstantin Belousov e79866ddf1 procstat(1): add ability to specify subcommands not requiring pid lists
Add PS_MODE_NO_KINFO_PROC cmd modifier that indicates that neither
process list should be queried from the kernel, nor list of pids or `-a`
switch provided on the command line to filter the output.

This is intended for use by commands that query information not
neccessary attributed to specific process.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34834
2022-04-10 00:47:50 +03:00
Piotr Pawel Stefaniak 8b1f5965d9 procstat: remove set but not used variable
In an earlier version of D26310, strcmp was strncmp.
2022-03-18 10:03:56 +01:00
Konstantin Belousov 01c77a436e Pass vdso address to userspace
Reviewed by:	emaste
Discussed with:	jrtc27
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 month
Differential revision:	https://reviews.freebsd.org/D32960
2021-12-06 20:46:49 +02:00
Konstantin Belousov 0864ab3d32 procstat auxv: print out FXRNG
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2021-11-15 02:32:00 +02:00
Konstantin Belousov 25c6318c79 procstat: distinguish vm map guards in procstat vm output.
Requested and reviewed by:	rwatson (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D28658
2021-02-14 03:24:58 +02:00
Konstantin Belousov 67af9aba6b Decode and report native eventfd descriptors from libprocstat and procstat.
Submitted by:   greg@unrelenting.technology
Reviewed by:    markj (previous version)
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D26668
2020-12-27 12:57:27 +02:00
John Baldwin 688f8b822c Remove the cloned file descriptors for /dev/crypto.
Crypto file descriptors were added in the original OCF import as a way
to provide per-open data (specifically the list of symmetric
sessions).  However, this gives a bit of a confusing API where one has
to open /dev/crypto and then invoke an ioctl to obtain a second file
descriptor.  This also does not match the API used with /dev/crypto on
other BSDs or with Linux's /dev/crypto driver.

Character devices have gained support for per-open data via cdevpriv
since OCF was imported, so use cdevpriv to simplify the userland API
by permitting ioctls directly on /dev/crypto descriptors.

To provide backwards compatibility, CRIOGET now opens another
/dev/crypto descriptor via kern_openat() rather than dup'ing the
existing file descriptor.  This preserves prior semantics in case
CRIOGET is invoked multiple times on a single file descriptor.

Reviewed by:	markj
Relnotes:	yes
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D27302
2020-11-25 00:10:54 +00:00
Fernando Apesteguía fd92b91c71 procstat(1): Add EXAMPLES section
* Add some examples showing binary, arguments and file info from living
  processes.
* Show information from core dumps including an attempt using an old core file.
* While here, fix warning 'no blank before trailing delimiter' reported by igor.

Approved by:	manpages (0mp@)
Differential Revision:	https://reviews.freebsd.org/D25467
2020-10-05 14:07:32 +00:00
Konstantin Belousov 34d7dd1561 procstat: Fix regression after 365880.
Basically it reverts one chunk that reversed the parsing logic, making
legacy variants of invocation, like `procstat -a -f', non-operational.

Reported and tested by:	Dewayne Geraghty <dewayne@heuristicsystems.com.au>
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2020-09-29 00:20:58 +00:00
Konstantin Belousov b65eb2f8a8 Consistently use __FBSDID("FreeBSD") for ids in usr.bin/procstat.
Submitted by:	Juraj Lutter <juraj@lutter.sk>
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D26568
2020-09-27 23:01:54 +00:00
Konstantin Belousov 085e04945c Add pargs, penv, pwdx commands and aliases to procstat(1).
Intent is to mimic Solaris commands with the same names.

Submitted by:	Juraj Lutter <juraj@lutter.sk>
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D26310
2020-09-18 12:59:27 +00:00
Brooks Davis 3780fcd950 Add procstat support for AT_ flags added in r359988.
This includes argc, argv, envc, envv, and ps_strings.

Reviewed by:	kib
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24407
2020-04-15 20:25:38 +00:00
Konstantin Belousov 24d57fa83e Add procstat(1) sigfastblock command to show process sigfastblock word address.
Tested by:	pho
Disscussed with:	cem, emaste, jilles
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D12773
2020-02-09 12:30:50 +00:00
Konstantin Belousov 944cf37bb5 Add AT_BSDFLAGS auxv entry.
The intent is to provide bsd-specific flags relevant to interpreter
and C runtime.  I did not want to reuse AT_FLAGS which is common ELF
auxv entry.

Use bsdflags to report kernel support for sigfastblock(2).  This
allows rtld and libthr to safely infer the syscall presence without
SIGSYS.  The tunable kern.elf{32,64}.sigfastblock blocks reporting.

Tested by:	pho
Disscussed with:	cem, emaste, jilles
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D12773
2020-02-09 12:10:37 +00:00
Dimitry Andric 7bf1ff65fc Fix the following -Werror warning from clang 10.0.0 in procstat:
usr.bin/procstat/procstat_sigs.c:79:3: error: misleading indentation; statement is not part of the previous 'else' [-Werror,-Wmisleading-indentation]
                xo_close_container(name);
                ^
usr.bin/procstat/procstat_sigs.c:77:4: note: previous statement is here
        } else
          ^

The intent was to group the xo_close_container() call to the previous
snprintf() call.

MFC after:	3 days
2020-01-29 17:01:02 +00:00
Jeremie Le Hen ce0372d7e1 Remove IS_INADDR_ANY().
Requested by rgrimes@ in
https://lists.freebsd.org/pipermail/svn-src-head/2019-October/129784.html
2019-10-19 19:38:53 +00:00
Jeremie Le Hen eadfb49fe1 Add a missing macro for the previous commit (IS_INADDR_ANY()). 2019-10-09 20:05:14 +00:00
Jeremie Le Hen b9eabd15fd Use inet_ntop(3) instead of inet_ntoa(3) for AF_INET socket details.
This also makes the code closer to the one used for AF_INET6.
2019-10-09 20:01:23 +00:00
Jilles Tjoelker ddc0daea20 procstat/tests: Fix flakiness by waiting for program to start
Some of the procstat tests start a program "while1" and examine the process
using procstat, but did not wait properly for it to start (kill -0 will
succeed immediately after the child process has been created).

Instead, have "while1" write something when it starts, and use a fifo to
wait for that.

PR:		233587, 233588
Reviewed by:	ngie
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D21519
2019-09-04 16:25:41 +00:00
Gleb Smirnoff 29bf090e15 resource.h is sufficient here, no need for resoursevar.h. 2019-08-07 18:32:01 +00:00
Mitchell Horne 8a250c7568 procstat: Recognize HWCAP and HWCAP2 with auxv command
The two most recent additions to the elf auxiliary vector are
HWCAP and HWCAP2 which describe platform specific cpu capabilities.

Make procstat recognize these fields so that they aren't displayed
as UNKNOWN.

Reviewed by:	trociny, markj
Approved by:	markj (mentor)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D20582
2019-06-11 00:59:46 +00:00
Enji Cooper da5069e1f7 Update the spelling of my name
Previous spellings of my name (NGie, Ngie) weren't my legal spelling. Use Enji
instead for clarity.

While here, remove "All Rights Reserved" from copyrights I "own".

MFC after:	1 week
2019-04-22 17:52:46 +00:00
Mark Johnston 6a85590370 Show wiring state of map entries in procstat -v.
Note that only entries wired by userspace are shown as such.  In
particular, entries transiently wired by sysctl_wire_old_buffer() are
not flagged as wired in procstat -v output.

Reviewed by:	kib (previous version)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D19461
2019-03-05 19:45:37 +00:00
Li-Wen Hsu 037479ff5e Temporarily skip flakey test cases
PR:		233586, 233587, 233588
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D18362
2018-12-06 09:22:35 +00:00
Konstantin Belousov a66732de4f Print type designator 'D' for the KF_TYPE_DEV files.
No type-specific data is provided by the kernel.

Sponsored by:	Mellanox Technologies
MFC after:	1 week
2018-12-03 23:42:04 +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
Mark Johnston 0dbdecfd4f Add a rudimentary test for procstat kstack.
MFC after:	1 week
2018-08-02 16:03:47 +00:00
Brooks Davis 8b75008bea Don't escape '?'s in protocol output.
This isn't required by mandoc and is nonfunctional in groff.

PR:		224632
Reported by:	w.schwarzenfeld@utanet.at
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D13779
2018-01-23 20:07:51 +00:00
Pedro F. Giffuni 1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Andriy Gapon 6effb21323 procstat: fix a crash with -k -a options
The traditional / legacy usage should still be supported.
This fixes a regression in r324619 that introduced a nicer, verb based
interface.

Reviewed by:	brooks
X-MFC with:	r324619
2017-11-16 22:14:49 +00:00
Bryan Drewery ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Bryan Drewery 3806950135 DIRDEPS_BUILD: Connect new directories.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:04:07 +00:00
Brooks Davis 2a243b9539 Switch procstat from subcommand flags to verbs
- Use an enumerated value instead of separate flags for commands
- Look for a verb if no command flag is set
- Lookup the "xocontainer" value based on the command
- Document the new command verbs in the man-page

Submitted by:	kdrakehp@zoho.com
Differential Revision:	https://reviews.freebsd.org/D10916
2017-10-14 18:38:36 +00:00
Edward Tomasz Napierala 3cfa7c6e48 Make procstat(1) recognize process descriptors, so that it shows
"P" instead of "?" in "procstat -af" output. Note that there are
still a few more DTYPE_* kinds we don't decode yet.

Reported by:	rwatson
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D12426
2017-10-03 11:45:24 +00:00
Enji Cooper 7921075587 MFhead@r322057 2017-08-04 17:41:49 +00:00
Mark Johnston 963307726d Fix procstat --libxo -L.
- Use the title role for column headers.
- Fix a typo in a field name (lpwid -> lwpid).
- Place the fields of different threads in separate containers.
2017-08-03 22:41:34 +00:00