aboutsummaryrefslogtreecommitdiff
path: root/lib/libprocstat
Commit message (Collapse)AuthorAgeFilesLines
* libprocstat: Drop zfs_defs.c hack, including its _KERNEL defineJessica Clarke2025-06-166-192/+38
| | | | | | | | | | | Now that we have a _WANT_ZNODE we can use that instead of defining _KERNEL, and we're able to move the code back into zfs.c using a real znode_t pointer. Whilst here, tidy the includes. Reviewed by: imp, kib, markj Differential Revision: https://reviews.freebsd.org/D50721
* libprocstat: Drop all _KERNEL defines outside of zfs_defs.cJessica Clarke2025-06-165-20/+6
| | | | | | | | | | Defining _KERNEL is a historical hack that can often break due to the environment not actually being that of a kernel build. Now that we have other targeted macros we can define instead that don't have far-reaching implications like _KERNEL we can drop this. Reviewed by: imp, kib, markj Differential Revision: https://reviews.freebsd.org/D50719
* libprocstat: add knowledge about NT_PROCSTAT_KQUEUES core file sectionKonstantin Belousov2025-03-243-2/+36
| | | | | | | Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D49372
* libprocstat: constify psc_type_info[]Konstantin Belousov2025-03-241-1/+1
| | | | | | | | Suggested by: markj Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D49372
* libprocstat: change psc_type_info array to use designated initializersKonstantin Belousov2025-03-242-13/+49
| | | | | | | Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D49372
* libprocstat: add helper to query knotes for specific kqueueKonstantin Belousov2025-03-133-0/+72
| | | | | | | Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D49163
* protosw: this is a kernel only header, put back #ifdef _KERNELGleb Smirnoff2025-02-031-0/+1
| | | | | | | | | | The uncommented #ifdef _KERNEL originates from 1997 by wollman@ (see 57bf258e3dc9e) with no clear original reason. Since these old times two abusers of the header leak were created - libprocstat(3) and netstat(1). These two already have a lot of _WANT_FOO hacks, so satisfy them with _WANT_PROTOSW. While here, cleanup and sort forward declaraions.
* libprocstat: ZFS support: Makefile: Tidy up a bitOlivier Certner2024-12-191-7/+11
| | | | | | | | | | | | | | | | | Regroup assignments tweaking preprocessor defines/undefs, and separately those about include directories. Re-order include directories a bit more logically, and remove redundant ones. Separate logical groups by blank lines. Build artifacts have been verified to stay the same when produced with an external LLVM 18 toolchain. MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48070
* Retire MK_PROFILE infrastructureEd Maste2024-11-121-2/+0
| | | | | | | | | | It was disabled by default in fe52b7f60ef4. We planned to (but did not) remove the option before FreeBSD 14. Remove it now, for FreeBSD 15. Relnotes: Yes Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31558
* libprocstat: add procstat_getrlimitusage()Konstantin Belousov2024-09-273-0/+61
| | | | | | | Reviewed by: markj, olce Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D46747
* Remove residual blank line at start of MakefileWarner Losh2024-07-152-2/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* Prepare some build fixes in advance of more _FORTIFY_SOURCEKyle Evans2024-07-132-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | ZFS' libspl needs to be made aware that we have strlcat(3) and strlcpy(3) to avoid some more complicated declaration duplication, so go ahead and define these HAVE_ macros now. libprocstat has to define `_KERNEL` and include kernel headers in order to get what it wants, but this results in sys/cdefs.h being included too late and we pick up the build breaking version of the __RENAME definition. Just explicitly include sys/cdefs.h earlier rather than disabling _FORTIFY_SOURCE. The zfs/ subdir only builds an object that holds some structures and sizes, so just disable _FORTIFY_SOURCE there entirely rather than trying to move #define _KERNEL into the file.. While we're here, make sure that we disable _FORTIFY_SOURCE in the bootloader because we don't have the symbol renaming support today to do it as cleanly as we'd like. ssp/ssp.h needs to be pulled into the libsa environment so that other bits can understand that ssp is disabled in the consistent __SSP_FORTIFY_LEVEL way that we try to do. Reviewed by: allanjude (previous version), markj Sponsored by: Klara, Inc. Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D45676
* inpcb: fully retire inp_ppcb pointerGleb Smirnoff2024-03-293-27/+5
| | | | | | | | | | | | | | | | | | | Before a protocol specific control block started to embed inpcb in self (see 0aa120d52f3c, e68b3792440c, 483fe96511ec) this pointer used to point at it. Retain kf_sock_inpcb field in the struct kinfo_file in <sys/user.h>. The exp-run detected a minimal use of the field in ports: * sysutils/lsof - patched upstream * net-mgmt/netdata - patch accepted upstream * emulators/qemu-user-static - upstream master branch seems not using the field anymore We can keep the field around for some time, but eventually it may be reused for something else. PR: 277659 (exp-run) Reviewed by: tuexen Differential Revision: https://reviews.freebsd.org/D44491
* lib: Automated cleanup of cdefs and other formattingWarner Losh2023-11-276-6/+0
| | | | | | | | | | | | | | | | 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
* libprocstat: improve conditional for 32-bit compatBrooks Davis2023-10-162-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
* libprocstat: copy all the 32-bit auxv entriesBrooks Davis2023-10-161-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
* libprocstat: make sv_name not staticBrooks Davis2023-10-161-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
* libprocstat: simplify auxv value conversionBrooks Davis2023-10-161-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
* libprocstat: style: space after switchBrooks Davis2023-10-021-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
* libprocstat: use elf_getphdrnum rather than deprecated elf_getphnumJohn Hein2023-09-221-1/+1
| | | | | PR: 273966 Reviewed by: emaste
* Remove $FreeBSD$: two-line nroff patternWarner Losh2023-08-161-2/+0
| | | | Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-164-4/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-169-19/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Remove $FreeBSD$: one-line .h patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-167-14/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-1210-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
* Update/fix Makefile.depend for userlandSimon J. Gerraty2023-04-191-3/+0
|
* libprocstat: forward declare struct kinfo_procBrooks Davis2022-08-261-0/+1
| | | | | This allows libprocstat.h to be included without sys/user.h as documented in the manpage.
* libprocstat: document procstat_getadvlock(3)Konstantin Belousov2022-04-091-1/+28
| | | | | | | Reviewed by: markj, rmacklem Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D34756
* libprocstat: add procstat_getadvlock(3)Konstantin Belousov2022-04-093-0/+166
| | | | | | | | | | For now, only for sysctl target. This is not a new situation, for instance kstacks also work for sysctl only. Reviewed by: markj, rmacklem Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D34756
* procstat_getfiles_sysctl: do not require non-null ki_fdKonstantin Belousov2021-12-021-2/+0
| | | | | | | | | | | ki_fd is legitimately NULL when 32bit process requests process data from 64bit host kernel. The field is not used by the code for sysctl case; procstat_getfiles_kvm() checks ki_fd. PR: 260174 Reported by: Damjan Jovanovic <damjan.jov@gmail.com> Sponsored by: The FreeBSD Foundation MFC after: 1 week
* StyleKonstantin Belousov2021-12-021-1/+1
| | | | | Sponsored by: The FreeBSD Foundation MFC after: 1 week
* libprocstat: extend zfs_defs hack for .pieoEd Maste2021-09-131-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
* VFS_QUOTACTL(9): allow implementation to indicate busy state changesJason A. Harmening2021-05-304-0/+8
| | | | | | | | | | | | | | | Instead of requiring all implementations of vfs_quotactl to unbusy the mount for Q_QUOTAON and Q_QUOTAOFF, add an "mp_busy" in/out param to VFS_QUOTACTL(9). The implementation may then indicate to the caller whether it needed to unbusy the mount. Also, add stbool.h to libprocstat modules which #define _KERNEL before including sys/mount.h. Otherwise they'll pull in sys/types.h before defining _KERNEL and therefore won't have the bool definition they need for mp_busy. Reviewed By: kib, markj Differential Revision: https://reviews.freebsd.org/D30556
* libprocstat kstack: fix race with thread creationEric van Gyzen2021-05-271-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
* Fix makefs bootstrap after d485c77f203fb0f4cdc08dea5ff81631b51d8809Alex Richardson2021-02-221-0/+1
| | | | | | | | | | The makefs msdosfs code includes fs/msdosfs/denode.h which directly uses struct buf from <sys/buf.h> rather than the makefs struct m_buf. To work around this problem provide a local denode.h that includes ffs/buf.h and defines buf as an alias for m_buf. Reviewed By: kib, emaste Differential Revision: https://reviews.freebsd.org/D28835
* Remove #define _KERNEL hacks from libprocstatKonstantin Belousov2021-02-213-7/+3
| | | | | | | | | | | | | | | | | | Make sys/buf.h, sys/pipe.h, sys/fs/devfs/devfs*.h headers usable in userspace, assuming that the consumer has an idea what it is for. Unhide more material from sys/mount.h and sys/ufs/ufs/inode.h, sys/ufs/ufs/ufsmount.h for consumption of userspace tools, with the same caveat. Remove unacceptable hack from usr.sbin/makefs which relied on sys/buf.h being unusable in userspace, where it override struct buf with its own definition. Instead, provide struct m_buf and struct m_vnode and adapt code to use local variants. Reviewed by: mckusick Tested by: pho Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D28679
* 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