aboutsummaryrefslogtreecommitdiff
path: root/lib/libprocstat
Commit message (Collapse)AuthorAgeFilesLines
* libprocstat: improve conditional for 32-bit compatBrooks Davis2023-10-262-3/+8
| | | | | | | | | | | | Include support for translating 32-bit auxv vectors on non-64-bit platforms that aren't riscv (which has no 32-bit ABI support and probably never will). Reviewed by: markj Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D42201 (cherry picked from commit 248fe3d3483cb3ec2c78dd31dc02a467060a6577)
* libprocstat: copy all the 32-bit auxv entriesBrooks Davis2023-10-261-2/+2
| | | | | | | | | | | | | Use source struct size not the destination struct size so we copy all the auxv entries, not just the first half of them. Fix a style issue on an adjacent line. Reviewed by: markj Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D42200 (cherry picked from commit 8f06fabe39ac3ebca4ab448a456945008305a23f)
* libprocstat: make sv_name not staticBrooks Davis2023-10-261-1/+1
| | | | | | | | | | | | | | | Making this variable static makes is_elf32_sysctl() and callers thread unsafe. Use a less absurd length for sv_name. The longest name in the system is "FreeBSD ELF64 V2" which tips the scales at 16+1 bytes. We'll almost certainly have other problems if we exceed 32 characters. Reviewed by: markj Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D42199 (cherry picked from commit 72a4ee26a7c665ae1c31abe1c6feeaa7ccaba140)
* libprocstat: simplify auxv value conversionBrooks Davis2023-10-261-3/+11
| | | | | | | | | | | | Avoid a weird dance through the union and treat all 32-bit values as unsigned integers. This avoids sign extension of flags and userspace pointers. Reviewed by: markj Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D42198 (cherry picked from commit 9735cc0e41825bb9e95d16433d381ffe4c190f38)
* libprocstat: style: space after switchBrooks Davis2023-10-261-12/+12
| | | | | | | | | | | | | Style demands a space after the switch keyword. Noticed reviewing code in CheriBSD that propagated the style bug. Reported by: markj Sponsored by: DARPA Reviewed by: kib, markj Differential Revision: https://reviews.freebsd.org/D42041 (cherry picked from commit ccac440f7cbb013de41aa3933f3f7be77225c44f)
* libprocstat: use elf_getphdrnum rather than deprecated elf_getphnumJohn Hein2023-09-261-1/+1
| | | | | | | | PR: 273966 Reviewed by: emaste (cherry picked from commit 633094c27f0ac1b1001d5bd24a883240b4bce1dc) (cherry picked from commit fd8bf2ecc05af841aa7e8369a43861cdc122d404)
* Remove $FreeBSD$: two-line nroff patternWarner Losh2023-08-231-2/+0
| | | | | | | Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/ Similar commit in main: (cherry picked from commit fa9896e082a1)
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-234-4/+0
| | | | | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/ Similar commit in main: (cherry picked from commit d0b2dbfa0ecf)
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-239-19/+0
| | | | | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/ Similar commit in main: (cherry picked from commit 1d386b48a555)
* Remove $FreeBSD$: one-line .h patternWarner Losh2023-08-231-1/+0
| | | | | | | Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/ Similar commit in main: (cherry picked from commit 42b388439bd3)
* Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-237-14/+0
| | | | | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/ Similar commit in main: (cherry picked from commit b3e7694832e8)
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-07-2510-10/+10
| | | | | | | | | | | 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 (cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
* libprocstat: forward declare struct kinfo_procBrooks Davis2022-08-311-0/+1
| | | | | | | | | This allows libprocstat.h to be included without sys/user.h as documented in the manpage. PR: 266146 (cherry picked from commit a28f83353243e2298b5f89c0dd6705dfcbda77ea)
* libprocstat: document procstat_getadvlock(3)Konstantin Belousov2022-04-161-1/+28
| | | | (cherry picked from commit 50d3c72558f2d0c0ae0a037813a9af420935b538)
* libprocstat: add procstat_getadvlock(3)Konstantin Belousov2022-04-163-0/+166
| | | | (cherry picked from commit 039d1496b0790a27cbec18e06b9494bf41254019)
* libprocstat kstack: fix race with thread creationEric van Gyzen2022-03-021-1/+2
| | | | | | | | | | | | | | | | When collecting kernel stacks for a target process, if the process adds a thread between the two calls to sysctl, ignore the additional threads. Previously, procstat would print only a useless error message. Now, it prints a consistent snapshot of the stacks. We know that snapshot is already stale, but it could still be stale even with a more complex fix to reallocate and retry, so such a fix is hardly worth the effort. Reported by: Daniel.Mitchell@emc.com MFC after: 1 week Sponsored by: Dell EMC Isilon (cherry picked from commit 427f12f150e875c40acb84f292a80bfa0b90a1a2)
* procstat_getfiles_sysctl: do not require non-null ki_fdKonstantin Belousov2021-12-091-2/+0
| | | | | | PR: 260174 (cherry picked from commit 7a9423d6f360e3758ca67fbb25d309140ea93670)
* StyleKonstantin Belousov2021-12-091-1/+1
| | | | (cherry picked from commit 0ea3e4a27bc0d1b0fdf876c3ef89d790e29ad5b1)
* libprocstat: extend zfs_defs hack for .pieoEd Maste2021-09-201-0/+2
| | | | | | | | | | | | | | By default _pie.a archives are built only for INTERNALLIBs, so there is usually no need for zfs_defs.pieo to exist. However, some experimental work builds _pie.a archives for everything. Extend the existing set of zfs_defs hacks to build zfs_defs.pieo as well. Reviewed by: arichardson MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31924 (cherry picked from commit b9df18d6e8917a9bfb62babb7cf9efeca23aa2fc)
* Decode and report native eventfd descriptors from libprocstat and procstat.Konstantin Belousov2020-12-272-0/+6
| | | | | | | Submitted by: greg@unrelenting.technology Reviewed by: markj (previous version) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D26668
* libprocstat.3: Correct two occurrences of kvm_getprocs to procstat_getprocsMateusz Piotrowski2020-11-261-3/+3
| | | | | | | | | | Submitted by: otis_sk.freebsd.org Reviewed by: markj MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D26151 Notes: svn path=/head/; revision=368084
* Remove the cloned file descriptors for /dev/crypto.John Baldwin2020-11-252-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=368005
* Split out cwd/root/jail, cmask state from filedesc tableConrad Meyer2020-11-171-7/+13
| | | | | | | | | | | | | | | | No functional change intended. Tracking these structures separately for each proc enables future work to correctly emulate clone(2) in linux(4). __FreeBSD_version is bumped (to 1300130) for consumption by, e.g., lsof. Reviewed by: kib Discussed with: markj, mjg Differential Revision: https://reviews.freebsd.org/D27037 Notes: svn path=/head/; revision=367777
* Merge OpenZFS support in to HEAD.Matt Macy2020-08-253-20/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The primary benefit is maintaining a completely shared code base with the community allowing FreeBSD to receive new features sooner and with less effort. I would advise against doing 'zpool upgrade' or creating indispensable pools using new features until this change has had a month+ to soak. Work on merging FreeBSD support in to what was at the time "ZFS on Linux" began in August 2018. I first publicly proposed transitioning FreeBSD to (new) OpenZFS on December 18th, 2018. FreeBSD support in OpenZFS was finally completed in December 2019. A CFT for downstreaming OpenZFS support in to FreeBSD was first issued on July 8th. All issues that were reported have been addressed or, for a couple of less critical matters there are pull requests in progress with OpenZFS. iXsystems has tested and dogfooded extensively internally. The TrueNAS 12 release is based on OpenZFS with some additional features that have not yet made it upstream. Improvements include: project quotas, encrypted datasets, allocation classes, vectorized raidz, vectorized checksums, various command line improvements, zstd compression. Thanks to those who have helped along the way: Ryan Moeller, Allan Jude, Zack Welch, and many others. Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D25872 Notes: svn path=/head/; revision=364746
* Avoid adding duplicates to SRCS/OBJS/SOBJS/POBJSAlex Richardson2020-08-241-2/+0
| | | | | | | | | | | | | | | | | This is a change in preparation for stopping to use lorder.sh (D26044) and instead assume that we have a linker newer than ~1990. Without lorder.sh duplicates end up being passed to the linker when building .so files and this can result in duplicate symbol definition errors. There is one minor change: libcompiler_rt.a will no longer provide gcc_personality_v0 and instead we now only have it in libgcc_eh.a/libgcc_s.so. This matches GCC's behaviour. Reviewed By: emaste, cem Differential Revision: https://reviews.freebsd.org/D26042 Notes: svn path=/head/; revision=364649
* libprocstat: fix kvm filedesc access after introduction of fdescenttblMateusz Guzik2020-07-151-16/+23
| | | | Notes: svn path=/head/; revision=363212
* libprocstat: try to fix fallout from r361363Andriy Gapon2020-05-241-0/+4
| | | | | | | | | | | | | | | | | | | | The revision caused libprocstat to have two undefined symbols: - __start_set_pcpu - __stop_set_pcpu probably because of __GLOBL() used in sys/pcpu.h under _KERNEL. The symbols are not accessed by anything and the linker in base does not complain about them, but some ports are failing to build. Hack around the problem by providing definitions for those symbols. Probably there is a better solution, but I could not think of it yet. Reported by: zeising MFC after: 3 days X-MFC with: r361363 Sponsored by: Panzura Notes: svn path=/head/; revision=361434
* libprocstat: fix ZFS supportAndriy Gapon2020-05-225-65/+139
| | | | | | | | | | | | | | | | | | | | | | | First of all, znode_phys_t hasn't been used for storing file attributes for a long time now. Modern ZFS versions use a System Attribute table with a flexible layout. But more importantly all the required information is available in znode_t itself. It's not easy to include zfs_znode.h in userland without breaking code because the most interesting parts of the header are kernel-only. And hardcoding field offsets is too fragile. So, I created a new compilation unit that includes zfs_znode.h using some mild kludges to get it and its dependencies to compile in userland. The compilation unit exports interesting field offsets and does not have any other code. PR: 194117 Reviewed by: markj MFC after: 2 weeks Sponsored by: Panzura Differential Revision: https://reviews.freebsd.org/D24941 Notes: svn path=/head/; revision=361363
* libprocstat: fix reading of file descriptor table via kvmAndriy Gapon2020-05-211-7/+7
| | | | | | | | | | | | This seems to have been broken since r247602 (from year 2013!). Can be easily tested with fstat -N /boot/kernel/kernel -M /var/crash/vmcore.last MFC after: 1 week Sponsored by: Panzura Notes: svn path=/head/; revision=361330
* Remove the SYMVER build option.John Baldwin2020-04-301-4/+1
| | | | | | | | | | | | | | This option was added as a transition aide when symbol versioning was first added. It was enabled by default in 2007 and is supported even by the old GPLv2 binutils. Trying to disable it currently fails to build in libc and at this point it isn't worth fixing the build. Reported by: Michael Dexter Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D24637 Notes: svn path=/head/; revision=360511
* fd: use smr for managing struct pwdMateusz Guzik2020-03-081-4/+5
| | | | | | | | | | | | This has a side effect of eliminating filedesc slock/sunlock during path lookup, which in turn removes contention vs concurrent modifications to the fd table. Reviewed by: markj, kib Differential Revision: https://reviews.freebsd.org/D23889 Notes: svn path=/head/; revision=358734
* fd: move vnodes out of filedesc into a dedicated structureMateusz Guzik2020-03-011-19/+32
| | | | | | | | | | | | | | | | The new structure is copy-on-write. With the assumption that path lookups are significantly more frequent than chdirs and chrooting this is a win. This provides stable root and jail root vnodes without the need to reference them on lookup, which in turn means less work on globally shared structures. Note this also happens to fix a bug where jail vnode was never referenced, meaning subsequent access on lookup could run into use-after-free. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D23884 Notes: svn path=/head/; revision=358503
* procstat: read lo_name instead of now removed v_tagMateusz Guzik2020-01-071-3/+3
| | | | Notes: svn path=/head/; revision=356437
* Update Makefile.depend filesSimon J. Gerraty2019-12-111-1/+0
| | | | | | | | | | | | | Update a bunch of Makefile.depend files as a result of adding Makefile.depend.options files Reviewed by: bdrewery MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22494 Notes: svn path=/head/; revision=355617
* Define a vm_map method for user-space for advancing from a map entryDoug Moore2019-12-081-12/+16
| | | | | | | | | | | | | | to its successor in cases where examining a map entry requires a helper like kvm_read_all. Use that method, with kvm_read_all, to fix procstat_getfiles_kvm, which tries to find the successor now without using such a helper. This addresses a problem introduced by r355491. Reviewed by: markj (previous version) Discussed with: kib Differential Revision: https://reviews.freebsd.org/D22728 Notes: svn path=/head/; revision=355538
* Fix a type error in fixing libprocstat to be compatible with vm_map changes.Doug Moore2019-12-071-1/+1
| | | | | | | | Approved by: markj Differential Revision: https://reviews.freebsd.org/D22726 Notes: svn path=/head/; revision=355502
* r355491 broke compilation of libprocstat.c. Change that code to useDoug Moore2019-12-071-2/+2
| | | | | | | | | | new methods for accessing first, next map entries. Approved by: kib Differential Revision: https://reviews.freebsd.org/D22725 Notes: svn path=/head/; revision=355501
* pkgbase: Create a FreeBSD-utilities package and make it the default oneEmmanuel Vadot2019-09-051-1/+0
| | | | | | | | | | | | | The default package use to be FreeBSD-runtime but it should only contain binaries and libs enough to boot to single user and repair the system, it is also very handy to have a package that can be tranform to a small mfsroot. So create a new package named FreeBSD-utilities and make it the default one. Also move a few binaries and lib into this package when it make sense. Reviewed by: bapt, gjb Differential Revision: https://reviews.freebsd.org/D21506 Notes: svn path=/head/; revision=351858
* Bump SPECNAMELEN to MAXNAMLEN.Konstantin Belousov2019-01-272-7/+86
| | | | | | | | | | | | | | | | | This includes the bump for cdevsw d_version. Otherwise, the impact on the ABI (not KBI) is surprisingly low. The most important affected interface is devname(3) and ttyname(3) which already correctly handle long names (and ttyname(3) should not be affected at all). Still, due to the d_version bump, I argue that the change is not MFC-able. Requested by: mmacy Reviewed by: jhb Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D18932 Notes: svn path=/head/; revision=343485
* Print type designator 'D' for the KF_TYPE_DEV files.Konstantin Belousov2018-12-032-0/+6
| | | | | | | | | | No type-specific data is provided by the kernel. Sponsored by: Mellanox Technologies MFC after: 1 week Notes: svn path=/head/; revision=341448
* Do not blindly include illumos kernel headers instead of user-space.Alexander Motin2018-08-021-1/+0
| | | | | | | | It is not needed now, and I doubt it much helped at all, creating more confusions then good. Notes: svn path=/head/; revision=337160
* libprocstat: fix memory leakEric van Gyzen2018-05-281-0/+1
| | | | | | | | | | | Free the rlimits array on the happy path in procstat_getrlimit_core(). Reported by: Coverity CID: 1373328 Sponsored by: Dell EMC Notes: svn path=/head/; revision=334267
* lib: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-268-0/+16
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using mis-identified 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. Notes: svn path=/head/; revision=326219
* spdx: initial adoption of licensing ID tags.Pedro F. Giffuni2017-11-184-1/+9
| | | | | | | | | | | | | | | | | | | | 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. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Initially, only tag files that use BSD 4-Clause "Original" license. RelNotes: yes Differential Revision: https://reviews.freebsd.org/D13133 Notes: svn path=/head/; revision=325966
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-311-1/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* Make procstat(1) recognize process descriptors, so that it showsEdward Tomasz Napierala2017-10-032-0/+6
| | | | | | | | | | | | | "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 Notes: svn path=/head/; revision=324237
* Hide struct socket and struct unpcb from the userland.Gleb Smirnoff2017-10-021-0/+2
| | | | | | | | | | | | | | | | | | | Violators may define _WANT_SOCKET and _WANT_UNPCB respectively and are not guaranteed for stability of the structures. The violators list is the the usual one: libprocstat(3) and netstat(1) internally and lsof in ports. In struct xunpcb remove the inclusion of kernel structure and add a bunch of spare fields. The xsocket already has socket not included, but add there spares as well. Embed xsockbuf into xsocket. Sort declarations in sys/socketvar.h to separate kernel only from userland available ones. PR: 221820 (exp-run) Notes: svn path=/head/; revision=324227
* libprocstat(3): fix arguments list for procstat_getargv(3) and ↵Enji Cooper2017-07-291-2/+0
| | | | | | | | | | | | | procstat_getenvv(3) Neither libcall takes a fourth argument (`char *errbuf`). PR: 217884 Submitted by: tobik MFC after: 1 month Notes: svn path=/head/; revision=321706
* libprocstat(3): fix reference (typo) to procstat_freeenvv in description forEnji Cooper2017-07-291-1/+1
| | | | | | | | | | | procstat_getargv(3) PR: 217884 MFC after: 1 month Submitted by: tobik Notes: svn path=/head/; revision=321705
* Add sys/socket.h to SYNOPSIS for libprocstat(3)Enji Cooper2017-07-291-1/+2
| | | | | | | | | | | | sys/socket.h is required for procstat_get_socket_info(3), added in r221807. MFC after: 1 month PR: 217884 Submitted by: tobik Notes: svn path=/head/; revision=321704