summaryrefslogtreecommitdiffstats
path: root/usr.bin/procstat/procstat_bin.c
diff options
context:
space:
mode:
authorstas <stas@FreeBSD.org>2011-05-12 10:11:39 +0000
committerstas <stas@FreeBSD.org>2011-05-12 10:11:39 +0000
commit5f9f79547658271f3f469b6423a176831fef7683 (patch)
tree9f873599b157e2ba06c3088d82cad8a221b42d18 /usr.bin/procstat/procstat_bin.c
parentf47d00001ad33e13ec3b6fc74732b959cd485dc7 (diff)
downloadFreeBSD-src-5f9f79547658271f3f469b6423a176831fef7683.zip
FreeBSD-src-5f9f79547658271f3f469b6423a176831fef7683.tar.gz
- Commit work from libprocstat project. These patches add support for runtime
file and processes information retrieval from the running kernel via sysctl in the form of new library, libprocstat. The library also supports KVM backend for analyzing memory crash dumps. Both procstat(1) and fstat(1) utilities have been modified to take advantage of the library (as the bonus point the fstat(1) utility no longer need superuser privileges to operate), and the procstat(1) utility is now able to display information from memory dumps as well. The newly introduced fuser(1) utility also uses this library and able to operate via sysctl and kvm backends. The library is by no means complete (e.g. KVM backend is missing vnode name resolution routines, and there're no manpages for the library itself) so I plan to improve it further. I'm commiting it so it will get wider exposure and review. We won't be able to MFC this work as it relies on changes in HEAD, which was introduced some time ago, that break kernel ABI. OTOH we may be able to merge the library with KVM backend if we really need it there. Discussed with: rwatson
Diffstat (limited to 'usr.bin/procstat/procstat_bin.c')
-rw-r--r--usr.bin/procstat/procstat_bin.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/procstat/procstat_bin.c b/usr.bin/procstat/procstat_bin.c
index 8ed5efe..cf4ca5b 100644
--- a/usr.bin/procstat/procstat_bin.c
+++ b/usr.bin/procstat/procstat_bin.c
@@ -32,6 +32,7 @@
#include <err.h>
#include <errno.h>
+#include <libprocstat.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
@@ -39,7 +40,7 @@
#include "procstat.h"
void
-procstat_bin(pid_t pid, struct kinfo_proc *kipp)
+procstat_bin(struct kinfo_proc *kipp)
{
char pathname[PATH_MAX];
int error, name[4];
@@ -51,12 +52,12 @@ procstat_bin(pid_t pid, struct kinfo_proc *kipp)
name[0] = CTL_KERN;
name[1] = KERN_PROC;
name[2] = KERN_PROC_PATHNAME;
- name[3] = pid;
+ name[3] = kipp->ki_pid;
len = sizeof(pathname);
error = sysctl(name, 4, pathname, &len, NULL, 0);
if (error < 0 && errno != ESRCH) {
- warn("sysctl: kern.proc.pathname: %d", pid);
+ warn("sysctl: kern.proc.pathname: %d", kipp->ki_pid);
return;
}
if (error < 0)
@@ -64,7 +65,7 @@ procstat_bin(pid_t pid, struct kinfo_proc *kipp)
if (len == 0 || strlen(pathname) == 0)
strcpy(pathname, "-");
- printf("%5d ", pid);
+ printf("%5d ", kipp->ki_pid);
printf("%-16s ", kipp->ki_comm);
printf("%s\n", pathname);
}
OpenPOWER on IntegriCloud