summaryrefslogtreecommitdiffstats
path: root/usr.bin/procstat
Commit message (Collapse)AuthorAgeFilesLines
* MFC 281887:jhb2015-06-021-1/+1
| | | | | Reassign copyright statements on several files from Advanced Computing Technologies LLC to Hudson River Trading LLC.
* MFC r279842, r279875scottl2015-03-225-7/+131
| | | | | | Implement basic reporting of cpuset info via the -S option Obtained from: Netflix, Inc.
* Merge an applicable subset of r263234 from HEAD to stable/10:rwatson2015-03-191-1/+1
| | | | | | | | | | | | | Update most userspace consumers of capability.h to use capsicum.h instead. auditdistd is not updated as I will make the change upstream and then do a vendor import sometime in the next week or two. Note that a significant fraction does not apply, as FreeBSD 10 doesn't contain a Capsicumised ping, casperd, libcasper, etc. When these features are merged, the capsicum.h change will need to be merged with them. Sponsored by: Google, Inc.
* MFC r267886:delphij2014-07-111-1/+1
| | | | | | Use correct length for buffer. Submitted by: Sascha Wildner <swildner dragonflybsd org>
* MFC 266322,266323:jhb2014-07-012-3/+67
| | | | | | | | - Use 'RESOURCE' instead of the more generic 'TYPE' for the resource name column header when displaying resource usage. This more closely matches other procstat displays. - Add descriptions of the display formats for -e, -l, -r, and -x. Fix a few typos in indent settings while here.
* MFC 266293:jhb2014-06-275-13/+193
| | | | | | | | - Add support for dumping current resource usage for processes via a new -r flag to procstat. - Add an -H flag to request information about threads rather than processes when dumping statistics. Currently it is only used for -r to display resource usage for individual threads instead of the entire process.
* MFC 266296:jhb2014-06-271-5/+5
| | | | | Correct some minor nits in the per-thread signal format description such as missing posessives and misordering of fields.
* MFC 261780:jhb2014-02-192-1/+7
| | | | | Expose OBJT_MGTDEVICE VM objects used for GEM/TTM with drm2 as an explicit object type.
* MFC r258148,r258149,r258150,r258152,r258153,r258154,r258181,r258182:pjd2013-11-181-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r258148: Add a note that this file is compiled as part of the kernel and libc. Requested by: kib r258149: Change cap_rights_merge(3) and cap_rights_remove(3) to return pointer to the destination cap_rights_t structure. This already matches manual page. r258150: Sync return value with actual implementation. r258151: Style. r258152: Precisely document capability rights here too (they are already documented in rights(4)). r258153: The CAP_LINKAT, CAP_MKDIRAT, CAP_MKFIFOAT, CAP_MKNODAT, CAP_RENAMEAT, CAP_SYMLINKAT and CAP_UNLINKAT capability rights make no sense without the CAP_LOOKUP right, so include this rights. r258154: - Move CAP_EXTATTR_* and CAP_ACL_* rights to index 1 to have more room in index 0 for the future. - Move CAP_BINDAT and CAP_CONNECTAT rights to index 0 so we can include CAP_LOOKUP right in them. - Shuffle the bits around so there are no gaps. This is last chance to do that as all moved rights are not used yet. r258181: Replace CAP_POLL_EVENT and CAP_POST_EVENT capability rights (which I had a very hard time to fully understand) with much more intuitive rights: CAP_EVENT - when set on descriptor, the descriptor can be monitored with syscalls like select(2), poll(2), kevent(2). CAP_KQUEUE_EVENT - When set on a kqueue descriptor, the kevent(2) syscall can be called on this kqueue to with the eventlist argument set to non-NULL value; in other words the given kqueue descriptor can be used to monitor other descriptors. CAP_KQUEUE_CHANGE - When set on a kqueue descriptor, the kevent(2) syscall can be called on this kqueue to with the changelist argument set to non-NULL value; in other words it allows to modify events monitored with the given kqueue descriptor. Add alias CAP_KQUEUE, which allows for both CAP_KQUEUE_EVENT and CAP_KQUEUE_CHANGE. Add backward compatibility define CAP_POLL_EVENT which is equal to CAP_EVENT. r258182: Correct right names. Sponsored by: The FreeBSD Foundation Approved by: re (kib)
* MFC r257234:markj2013-11-051-3/+1
| | | | | | With r247602, the "c" flag is no longer printed as a file descriptor flag. Approved by: re (gjb)
* cap_new(2) and cap_getrights2) were replaced with cap_rights_limit(2)bdrewery2013-09-191-3/+3
| | | | | | | | and cap_rights_get(2) in r247602 Reviewed by: pjd Approved by: gjb Approved by: re (rodrigc)
* Change the cap_rights_t type from uint64_t to a structure that we can extendpjd2013-09-051-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Make the "FD" column one character wider, so that "trace" can also alignpjd2013-08-181-6/+6
| | | | properly.
* Make use of newly added libprocstat(3) ability to extract procstattrociny2013-04-202-17/+32
| | | | | | | | | | | | | | | | | | | | | | | | info from a process core file. So now one can run procstat(1) on a process core e.g. to get a list of files opened by a process when it crashed: root@lisa:/ # procstat -f /root/vi.core PID COMM FD T V FLAGS REF OFFSET PRO NAME 658 vi text v r r-------- - - - /usr/bin/vi 658 vi ctty v c rw------- - - - /dev/pts/0 658 vi cwd v d r-------- - - - /root 658 vi root v d r-------- - - - / 658 vi 0 v c rw------- 11 3208 - /dev/pts/0 658 vi 1 v c rw------- 11 3208 - /dev/pts/0 658 vi 2 v c rw------- 11 3208 - /dev/pts/0 658 vi 3 v r r----n-l- 1 0 - /tmp/vi.0AYKz3Lps7 658 vi 4 v r rw------- 1 0 - /var/tmp/vi.recover/vi.GaGYsz 658 vi 5 v r rw------- 1 0 - - PR: kern/173723 Suggested by: jhb MFC after: 1 month
* Use procstat_getkstack(3) for retrieving process kernel stackstrociny2013-04-203-55/+15
| | | | | | instead of direct sysctl calls. MFC after: 1 month
* Use libprocstat(3) to retrieve ELF auxiliary vector.trociny2013-04-203-96/+10
| | | | MFC after: 1 month
* Use libprocstat(3) to retrieve process command line arguments andtrociny2013-04-203-34/+22
| | | | | | environment variables. MFC after: 1 month
* Use libprocstat(3) when retrieving binary information for a process.trociny2013-04-203-29/+8
| | | | MFC after: 1 month
* Use procstat_getrlimit(3) for retrieving rlimit information instead oftrociny2013-04-203-18/+5
| | | | | | direct sysctl calls. MFC after: 1 month
* Use procstat_getumask(3) for retrieving umaks information instead oftrociny2013-04-201-13/+5
| | | | | | direct sysctl. MFC after: 1 month
* Use procstat_getgroups(3) for retrieving groups information instead oftrociny2013-04-203-30/+11
| | | | | | direct sysctl. MFC after: 1 month
* Use more generic procstat_getvmmap(3) for retrieving VM layout of a process.trociny2013-04-203-4/+4
| | | | MFC after: 1 month
* Use procstat_getprocs(3) for retrieving thread information instead oftrociny2013-04-204-66/+17
| | | | | | direct sysctl calls. MFC after: 1 month
* - Implement two new system calls:pjd2013-03-021-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | int bindat(int fd, int s, const struct sockaddr *addr, socklen_t addrlen); int connectat(int fd, int s, const struct sockaddr *name, socklen_t namelen); which allow to bind and connect respectively to a UNIX domain socket with a path relative to the directory associated with the given file descriptor 'fd'. - Add manual pages for the new syscalls. - Make the new syscalls available for processes in capability mode sandbox. - Add capability rights CAP_BINDAT and CAP_CONNECTAT that has to be present on the directory descriptor for the syscalls to work. - Update audit(4) to support those two new syscalls and to handle path in sockaddr_un structure relative to the given directory descriptor. - Update procstat(1) to recognize the new capability rights. - Document the new capability rights in cap_rights_limit(2). Sponsored by: The FreeBSD Foundation Discussed with: rwatson, jilles, kib, des
* Merge Capsicum overhaul:pjd2013-03-021-17/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Capability is no longer separate descriptor type. Now every descriptor has set of its own capability rights. - The cap_new(2) system call is left, but it is no longer documented and should not be used in new code. - The new syscall cap_rights_limit(2) should be used instead of cap_new(2), which limits capability rights of the given descriptor without creating a new one. - The cap_getrights(2) syscall is renamed to cap_rights_get(2). - If CAP_IOCTL capability right is present we can further reduce allowed ioctls list with the new cap_ioctls_limit(2) syscall. List of allowed ioctls can be retrived with cap_ioctls_get(2) syscall. - If CAP_FCNTL capability right is present we can further reduce fcntls that can be used with the new cap_fcntls_limit(2) syscall and retrive them with cap_fcntls_get(2). - To support ioctl and fcntl white-listing the filedesc structure was heavly modified. - The audit subsystem, kdump and procstat tools were updated to recognize new syscalls. - Capability rights were revised and eventhough I tried hard to provide backward API and ABI compatibility there are some incompatible changes that are described in detail below: CAP_CREATE old behaviour: - Allow for openat(2)+O_CREAT. - Allow for linkat(2). - Allow for symlinkat(2). CAP_CREATE new behaviour: - Allow for openat(2)+O_CREAT. Added CAP_LINKAT: - Allow for linkat(2). ABI: Reuses CAP_RMDIR bit. - Allow to be target for renameat(2). Added CAP_SYMLINKAT: - Allow for symlinkat(2). Removed CAP_DELETE. Old behaviour: - Allow for unlinkat(2) when removing non-directory object. - Allow to be source for renameat(2). Removed CAP_RMDIR. Old behaviour: - Allow for unlinkat(2) when removing directory. Added CAP_RENAMEAT: - Required for source directory for the renameat(2) syscall. Added CAP_UNLINKAT (effectively it replaces CAP_DELETE and CAP_RMDIR): - Allow for unlinkat(2) on any object. - Required if target of renameat(2) exists and will be removed by this call. Removed CAP_MAPEXEC. CAP_MMAP old behaviour: - Allow for mmap(2) with any combination of PROT_NONE, PROT_READ and PROT_WRITE. CAP_MMAP new behaviour: - Allow for mmap(2)+PROT_NONE. Added CAP_MMAP_R: - Allow for mmap(PROT_READ). Added CAP_MMAP_W: - Allow for mmap(PROT_WRITE). Added CAP_MMAP_X: - Allow for mmap(PROT_EXEC). Added CAP_MMAP_RW: - Allow for mmap(PROT_READ | PROT_WRITE). Added CAP_MMAP_RX: - Allow for mmap(PROT_READ | PROT_EXEC). Added CAP_MMAP_WX: - Allow for mmap(PROT_WRITE | PROT_EXEC). Added CAP_MMAP_RWX: - Allow for mmap(PROT_READ | PROT_WRITE | PROT_EXEC). Renamed CAP_MKDIR to CAP_MKDIRAT. Renamed CAP_MKFIFO to CAP_MKFIFOAT. Renamed CAP_MKNODE to CAP_MKNODEAT. CAP_READ old behaviour: - Allow pread(2). - Disallow read(2), readv(2) (if there is no CAP_SEEK). CAP_READ new behaviour: - Allow read(2), readv(2). - Disallow pread(2) (CAP_SEEK was also required). CAP_WRITE old behaviour: - Allow pwrite(2). - Disallow write(2), writev(2) (if there is no CAP_SEEK). CAP_WRITE new behaviour: - Allow write(2), writev(2). - Disallow pwrite(2) (CAP_SEEK was also required). Added convinient defines: #define CAP_PREAD (CAP_SEEK | CAP_READ) #define CAP_PWRITE (CAP_SEEK | CAP_WRITE) #define CAP_MMAP_R (CAP_MMAP | CAP_SEEK | CAP_READ) #define CAP_MMAP_W (CAP_MMAP | CAP_SEEK | CAP_WRITE) #define CAP_MMAP_X (CAP_MMAP | CAP_SEEK | 0x0000000000000008ULL) #define CAP_MMAP_RW (CAP_MMAP_R | CAP_MMAP_W) #define CAP_MMAP_RX (CAP_MMAP_R | CAP_MMAP_X) #define CAP_MMAP_WX (CAP_MMAP_W | CAP_MMAP_X) #define CAP_MMAP_RWX (CAP_MMAP_R | CAP_MMAP_W | CAP_MMAP_X) #define CAP_RECV CAP_READ #define CAP_SEND CAP_WRITE #define CAP_SOCK_CLIENT \ (CAP_CONNECT | CAP_GETPEERNAME | CAP_GETSOCKNAME | CAP_GETSOCKOPT | \ CAP_PEELOFF | CAP_RECV | CAP_SEND | CAP_SETSOCKOPT | CAP_SHUTDOWN) #define CAP_SOCK_SERVER \ (CAP_ACCEPT | CAP_BIND | CAP_GETPEERNAME | CAP_GETSOCKNAME | \ CAP_GETSOCKOPT | CAP_LISTEN | CAP_PEELOFF | CAP_RECV | CAP_SEND | \ CAP_SETSOCKOPT | CAP_SHUTDOWN) Added defines for backward API compatibility: #define CAP_MAPEXEC CAP_MMAP_X #define CAP_DELETE CAP_UNLINKAT #define CAP_MKDIR CAP_MKDIRAT #define CAP_RMDIR CAP_UNLINKAT #define CAP_MKFIFO CAP_MKFIFOAT #define CAP_MKNOD CAP_MKNODAT #define CAP_SOCK_ALL (CAP_SOCK_CLIENT | CAP_SOCK_SERVER) Sponsored by: The FreeBSD Foundation Reviewed by: Christoph Mallon <christoph.mallon@gmx.de> Many aspects discussed with: rwatson, benl, jonathan ABI compatibility discussed with: kib
* Capability rights for process management via process descriptors do existpjd2013-02-111-3/+2
| | | | | | already, so uncomment them. Sponsored by: The FreeBSD Foundation
* Add CAP_MKNOD right.pjd2013-02-101-0/+1
| | | | Sponsored by: The FreeBSD Foundation
* procstat: only one mode flag can be specified, but required check for 'i'mjg2013-01-121-2/+2
| | | | | | and 'j' modes was missing. Fix that. MFC after: 3 days
* add SG state typeeadler2012-10-021-0/+2
| | | | | | | PR: bin/171664 Submitted by: Jan Beich jbeich@tormail.org Approved by: cperciva MFC after: 1 week
* Handle AT_TIMEKEEP in procstat(1) -x [1]. Remove the AT_COUNT switchkib2012-09-161-2/+4
| | | | | | | | case, since AT_COUNT is not an aux vector, it is the counter of total number of defined vectors. PR: bin/171662 [1] MFC after: 1 week
* Free memory allocated by procstat_getfiles(), which may make differencetrociny2012-09-041-0/+1
| | | | | | | when procstat(1) is run with -a option. Submitted by: Daniel Dettlaff <dmilith gmail com> MFC after: 1 week
* Align the header with output.trociny2012-07-241-1/+1
| | | | MFC after: 3 days
* - Add support for displaying process stack memory regions.pgj2012-07-162-2/+8
| | | | | Approved by: rwatson MFC after: 3 days
* Fix style.trociny2012-07-031-2/+2
| | | | MFC after: 3 days
* Bring DPADD in sync with LDADD.marcel2012-05-191-1/+1
|
* Export some more useful info about shared memory objects to userlandjhb2012-04-011-8/+2
| | | | | | | | | | | | | | | | | | | via procstat(1) and fstat(1): - Change shm file descriptors to track the pathname they are associated with and add a shm_path() method to copy the path out to a caller-supplied buffer. - Use the fo_stat() method of shared memory objects and shm_path() to export the path, mode, and size of a shared memory object via struct kinfo_file. - Add a struct shmstat to the libprocstat(3) interface along with a procstat_get_shm_info() to export the mode and size of a shared memory object. - Change procstat to always print out the path for a given object if it is valid. - Teach fstat about shared memory objects and to display their path, mode, and size. MFC after: 2 weeks
* Remove trailing whitespace per mdoc lint warningeadler2012-03-291-1/+1
| | | | | | | Disussed with: gavin No objection from: doc Approved by: joel MFC after: 3 days
* When displaying binary information show also osreldate.trociny2012-03-232-3/+17
| | | | | Suggested by: kib MFC after: 2 weeks
* Update the description for -s flag after r232182.pluknet2012-02-291-1/+3
| | | | | | When displaying security credential information show also process umask. X-MFC-with: r232182
* When displaying security credential information show also process umask.trociny2012-02-261-3/+29
| | | | | | Submitted by: Dmitry Banschikov <me ubique spb ru> Discussed with: rwatson MFC after: 2 weeks
* Always return 0 if the sysctl failed.trociny2012-01-291-8/+8
| | | | | | This fixes the bug: when procstat -xa was run and the sysctl for a process returned ESRCH or EPERM, for this process procstat output the result collected for the previous successful process.
* After the recent changes there is no need in rlimit array any more.trociny2012-01-251-6/+5
| | | | | Submitted by: Andrey Zonov <andrey at zonov.org> MFC after: 1 week
* Make procstat -l to work with the new version of kern.proc.rlimit.trociny2012-01-221-10/+11
| | | | | Submitted by: Andrey Zonov <andrey at zonov.org> MFC after: 2 weeks
* Make 64-bit procstat output ELF auxiliary vectors for 32-bit processes.trociny2011-12-121-16/+87
| | | | | Reviewed by: kib MFC after: 1 week
* Make procstat -l output similar to the output of limits(1).trociny2011-12-121-10/+51
| | | | | Suggested by: jhb MFC after: 1 week
* Don't output a warning if kern.proc.auxv sysctl has returned EPERM.trociny2011-12-051-1/+1
| | | | | | After r228288 this is rather a normal situation. MFC after: 1 week
* Update SYNOPSIS to include the flags added recently.trociny2011-11-281-2/+2
| | | | Spotted by: jhb
* Cast a_val on printing. This fixes build on mips.trociny2011-11-281-14/+14
|
* Make proctstat -x output more readable.trociny2011-11-271-55/+39
| | | | | | | | This also fixes the issue, spotted by mdf, with values that were printed as decimal and had hex prefixes. Discussed with: kib, rwatson MFC after: 2 weeks
* usr.bin/procstattrociny2011-11-245-7/+95
| | | | | | | | Add -l flag to display resource limits. PR: bin/161257 Reviewed by: kib MFC after: 2 weeks
OpenPOWER on IntegriCloud