aboutsummaryrefslogtreecommitdiff
path: root/lib/libprocstat/libprocstat.c
Commit message (Collapse)AuthorAgeFilesLines
* inpcb: fully retire inp_ppcb pointerGleb Smirnoff2024-03-291-25/+4
| | | | | | | | | | | | | | | | | | | 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-271-1/+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-161-3/+3
| | | | | | | | | | 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
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* libprocstat: add procstat_getadvlock(3)Konstantin Belousov2022-04-091-0/+135
| | | | | | | | | | 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 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
* Remove #define _KERNEL hacks from libprocstatKonstantin Belousov2021-02-211-4/+1
| | | | | | | | | | | | | | | | | | 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-271-0/+5
| | | | | | | Submitted by: greg@unrelenting.technology Reviewed by: markj (previous version) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D26668
* Remove the cloned file descriptors for /dev/crypto.John Baldwin2020-11-251-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* libprocstat: fix kvm filedesc access after introduction of fdescenttblMateusz Guzik2020-07-151-16/+23
| | | | Notes: svn path=/head/; revision=363212
* 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
* 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
* 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
* Print type designator 'D' for the KF_TYPE_DEV files.Konstantin Belousov2018-12-031-0/+5
| | | | | | | | | | No type-specific data is provided by the kernel. Sponsored by: Mellanox Technologies MFC after: 1 week Notes: svn path=/head/; revision=341448
* 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
* spdx: initial adoption of licensing ID tags.Pedro F. Giffuni2017-11-181-0/+2
| | | | | | | | | | | | | | | | | | | | 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
* Make procstat(1) recognize process descriptors, so that it showsEdward Tomasz Napierala2017-10-031-0/+5
| | | | | | | | | | | | | "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
* procstat_getptlwpinfo(..): clarify the fact that KVM/SYSCTL supportEnji Cooper2017-06-271-0/+6
| | | | | | | | | | | | | | | isn't supported This will make the error message reported in bug 220023 a bit more intuitive for end-users that don't have access to the source code to decode the procstat->type argument. MFC after: 1 month MFC with: r316286 PR: 220023 Notes: svn path=/head/; revision=320399
* procstat(1): Add TCP socket send/recv buffer sizeConrad Meyer2017-05-261-7/+16
| | | | | | | | | | | Add TCP socket send and receive buffer size to procstat -f output. Reviewed by: kib, markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D10689 Notes: svn path=/head/; revision=318969
* Commit the 64-bit inode project.Konstantin Belousov2017-05-231-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extend the ino_t, dev_t, nlink_t types to 64-bit ints. Modify struct dirent layout to add d_off, increase the size of d_fileno to 64-bits, increase the size of d_namlen to 16-bits, and change the required alignment. Increase struct statfs f_mntfromname[] and f_mntonname[] array length MNAMELEN to 1024. ABI breakage is mitigated by providing compatibility using versioned symbols, ingenious use of the existing padding in structures, and by employing other tricks. Unfortunately, not everything can be fixed, especially outside the base system. For instance, third-party APIs which pass struct stat around are broken in backward and forward incompatible ways. Kinfo sysctl MIBs ABI is changed in backward-compatible way, but there is no general mechanism to handle other sysctl MIBS which return structures where the layout has changed. It was considered that the breakage is either in the management interfaces, where we usually allow ABI slip, or is not important. Struct xvnode changed layout, no compat shims are provided. For struct xtty, dev_t tty device member was reduced to uint32_t. It was decided that keeping ABI compat in this case is more useful than reporting 64-bit dev_t, for the sake of pstat. Update note: strictly follow the instructions in UPDATING. Build and install the new kernel with COMPAT_FREEBSD11 option enabled, then reboot, and only then install new world. Credits: The 64-bit inode project, also known as ino64, started life many years ago as a project by Gleb Kurtsou (gleb). Kirk McKusick (mckusick) then picked up and updated the patch, and acted as a flag-waver. Feedback, suggestions, and discussions were carried by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles), and Rick Macklem (rmacklem). Kris Moore (kris) performed an initial ports investigation followed by an exp-run by Antoine Brodin (antoine). Essential and all-embracing testing was done by Peter Holm (pho). The heavy lifting of coordinating all these efforts and bringing the project to completion were done by Konstantin Belousov (kib). Sponsored by: The FreeBSD Foundation (emaste, kib) Differential revision: https://reviews.freebsd.org/D10439 Notes: svn path=/head/; revision=318736
* Reorder includes to placate MIPS build.Tycho Nightingale2017-03-301-1/+1
| | | | | | | | Reported by: markj Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316304
* Add support for capturing 'struct ptrace_lwpinfo' for signalsTycho Nightingale2017-03-301-0/+44
| | | | | | | | | | | | resulting in a process dumping core in the corefile. Also extend procstat to view select members of 'struct ptrace_lwpinfo' from the contents of the note. Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316286
* Hide struct inpcb, struct tcpcb from the userland.Gleb Smirnoff2017-03-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | This is a painful change, but it is needed. On the one hand, we avoid modifying them, and this slows down some ideas, on the other hand we still eventually modify them and tools like netstat(1) never work on next version of FreeBSD. We maintain a ton of spares in them, and we already got some ifdef hell at the end of tcpcb. Details: - Hide struct inpcb, struct tcpcb under _KERNEL || _WANT_FOO. - Make struct xinpcb, struct xtcpcb pure API structures, not including kernel structures inpcb and tcpcb inside. Export into these structures the fields from inpcb and tcpcb that are known to be used, and put there a ton of spare space. - Make kernel and userland utilities compilable after these changes. - Bump __FreeBSD_version. Reviewed by: rrs, gnn Differential Revision: D10018 Notes: svn path=/head/; revision=315662
* Use nitems({mib,name}) instead of hardcoding their valueEnji Cooper2017-01-091-13/+13
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=311715
* Fix core corruption caused by race in note_procstat_vmmapConrad Meyer2015-10-061-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fix is spiritually similar to r287442 and was discovered thanks to the KASSERT added in that revision. NT_PROCSTAT_VMMAP output length, when packing kinfo structs, is tied to the length of filenames corresponding to vnodes in the process' vm map via vn_fullpath. As vnodes may move during coredump, this is racy. We do not remove the race, only prevent it from causing coredump corruption. - Add a sysctl, kern.coredump_pack_vmmapinfo, to allow users to disable kinfo packing for PROCSTAT_VMMAP notes. This avoids VMMAP corruption and truncation, even if names change, at the cost of up to PATH_MAX bytes per mapped object. The new sysctl is documented in core.5. - Fix note_procstat_vmmap to self-limit in the second pass. This addresses corruption, at the cost of sometimes producing a truncated result. - Fix PROCSTAT_VMMAP consumers libutil (and libprocstat, via copy-paste) to grok the new zero padding. Reported by: pho (https://people.freebsd.org/~pho/stress/log/datamove4-2.txt) Relnotes: yes Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D3824 Notes: svn path=/head/; revision=288944
* Detect badly behaved coredump note helpersConrad Meyer2015-09-031-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Coredump notes depend on being able to invoke dump routines twice; once in a dry-run mode to get the size of the note, and another to actually emit the note to the corefile. When a note helper emits a different length section the second time around than the length it requested the first time, the kernel produces a corrupt coredump. NT_PROCSTAT_FILES output length, when packing kinfo structs, is tied to the length of filenames corresponding to vnodes in the process' fd table via vn_fullpath. As vnodes may move around during dump, this is racy. So: - Detect badly behaved notes in putnote() and pad underfilled notes. - Add a fail point, debug.fail_point.fill_kinfo_vnode__random_path to exercise the NT_PROCSTAT_FILES corruption. It simply picks random lengths to expand or truncate paths to in fo_fill_kinfo_vnode(). - Add a sysctl, kern.coredump_pack_fileinfo, to allow users to disable kinfo packing for PROCSTAT_FILES notes. This should avoid both FILES note corruption and truncation, even if filenames change, at the cost of about 1 kiB in padding bloat per open fd. Document the new sysctl in core.5. - Fix note_procstat_files to self-limit in the 2nd pass. Since sometimes this will result in a short write, pad up to our advertised size. This addresses note corruption, at the risk of sometimes truncating the last several fd info entries. - Fix NT_PROCSTAT_FILES consumers libutil and libprocstat to grok the zero padding. With suggestions from: bjk, jhb, kib, wblock Approved by: markj (mentor) Relnotes: yes Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D3548 Notes: svn path=/head/; revision=287442
* Remove unused variable spotted by clang.Marcelo Araujo2015-06-011-2/+2
| | | | | | | | Differential Revision: D2685 Reviewed by: rodrigc, stas Notes: svn path=/head/; revision=283868
* Update most userspace consumers of capability.h to use capsicum.h instead.Robert Watson2014-03-161-1/+1
| | | | | | | | | | auditdistd is not updated as I will make the change upstream and then do a vendor import sometime in the next week or two. MFC after: 3 weeks Notes: svn path=/head/; revision=263234
* When querying a process's umask via sysctl in libprocstat(), don'tRobert Watson2014-03-021-1/+1
| | | | | | | | | | | | print a warning if EPERM is returned as this is an expected failure mode rather than error -- similar to current handling of ESRCH. This makes the output of 'procstat -as' vastly more palatable. MFC after: 3 days Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=262690
* Handle the cases where NULL is passed as cap_rightsp to thePawel Jakub Dawidek2013-10-091-10/+14
| | | | | | | | | | filestat_new_entry() function. Reported by: Alex Kozlov <spam@rm-rf.kiev.ua> Approved by: re (gjb) Notes: svn path=/head/; revision=256242
* Change the cap_rights_t type from uint64_t to a structure that we can extendPawel Jakub Dawidek2013-09-051-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in the future in a backward compatible (API and ABI) way. The cap_rights_t represents capability rights. We used to use one bit to represent one right, but we are running out of spare bits. Currently the new structure provides place for 114 rights (so 50 more than the previous cap_rights_t), but it is possible to grow the structure to hold at least 285 rights, although we can make it even larger if 285 rights won't be enough. The structure definition looks like this: struct cap_rights { uint64_t cr_rights[CAP_RIGHTS_VERSION + 2]; }; The initial CAP_RIGHTS_VERSION is 0. The top two bits in the first element of the cr_rights[] array contain total number of elements in the array - 2. This means if those two bits are equal to 0, we have 2 array elements. The top two bits in all remaining array elements should be 0. The next five bits in all array elements contain array index. Only one bit is used and bit position in this five-bits range defines array index. This means there can be at most five array elements in the future. To define new right the CAPRIGHT() macro must be used. The macro takes two arguments - an array index and a bit to set, eg. #define CAP_PDKILL CAPRIGHT(1, 0x0000000000000800ULL) We still support aliases that combine few rights, but the rights have to belong to the same array element, eg: #define CAP_LOOKUP CAPRIGHT(0, 0x0000000000000400ULL) #define CAP_FCHMOD CAPRIGHT(0, 0x0000000000002000ULL) #define CAP_FCHMODAT (CAP_FCHMOD | CAP_LOOKUP) There is new API to manage the new cap_rights_t structure: cap_rights_t *cap_rights_init(cap_rights_t *rights, ...); void cap_rights_set(cap_rights_t *rights, ...); void cap_rights_clear(cap_rights_t *rights, ...); bool cap_rights_is_set(const cap_rights_t *rights, ...); bool cap_rights_is_valid(const cap_rights_t *rights); void cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src); void cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src); bool cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little); Capability rights to the cap_rights_init(), cap_rights_set(), cap_rights_clear() and cap_rights_is_set() functions are provided by separating them with commas, eg: cap_rights_t rights; cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FSTAT); There is no need to terminate the list of rights, as those functions are actually macros that take care of the termination, eg: #define cap_rights_set(rights, ...) \ __cap_rights_set((rights), __VA_ARGS__, 0ULL) void __cap_rights_set(cap_rights_t *rights, ...); Thanks to using one bit as an array index we can assert in those functions that there are no two rights belonging to different array elements provided together. For example this is illegal and will be detected, because CAP_LOOKUP belongs to element 0 and CAP_PDKILL to element 1: cap_rights_init(&rights, CAP_LOOKUP | CAP_PDKILL); Providing several rights that belongs to the same array's element this way is correct, but is not advised. It should only be used for aliases definition. This commit also breaks compatibility with some existing Capsicum system calls, but I see no other way to do that. This should be fine as Capsicum is still experimental and this change is not going to 9.x. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=255219
* - Trim an unused and bogus Makefile for mount_smbfs.Davide Italiano2013-06-281-0/+1
| | | | | | | | | - Reconnect with some minor modifications, in particular now selsocket() internals are adapted to use sbintime units after recent'ish calloutng switch. Notes: svn path=/head/; revision=252356
* Borrow the algorithm from kvm_getprocs() to fix procstat_getprocs() toJohn Baldwin2013-06-111-7/+11
| | | | | | | | | | handle the case where the process tables grows in between the calls to fetch the size and fetch the table. MFC after: 1 week Notes: svn path=/head/; revision=251637
* Make errbuf optional, so if a caller is not interested in an errorMikolaj Golub2013-05-081-14/+30
| | | | | | | | | message she can pass NULL (procstat(1) already does this). MFC after: 2 weeks Notes: svn path=/head/; revision=250378
* Similar to 233760 and 236717, export some more useful info about theJohn Baldwin2013-05-031-0/+90
| | | | | | | | | | | | | | | | | | kernel-based POSIX semaphore descriptors to userland via procstat(1) and fstat(1): - Change sem file descriptors to track the pathname they are associated with and add a ksem_info() method to copy the path out to a caller-supplied buffer. - Use the fo_stat() method of shared memory objects and ksem_info() to export the path, mode, and value of a semaphore via struct kinfo_file. - Add a struct semstat to the libprocstat(3) interface along with a procstat_get_sem_info() to export the mode and value of a semaphore. - Teach fstat about semaphores and to display their path, mode, and value. MFC after: 2 weeks Notes: svn path=/head/; revision=250223
* procstat_getpathname: for kvm method, instead of returning the errorMikolaj Golub2013-05-011-2/+4
| | | | | | | | | | | | that the method is not supported, return an empty string. This looks more handy for callers like procstat(1), which will not abort after the failed call and still output some useful information. MFC after: 3 weeks Notes: svn path=/head/; revision=250147
* KVM method support for procstat_getgroups, procstat_getumask,Mikolaj Golub2013-05-011-8/+121
| | | | | | | | | procstat_getrlimit, and procstat_getosrel. MFC after: 3 weeks Notes: svn path=/head/; revision=250146