diff options
author | 2012-01-07 05:38:12 +0000 | |
---|---|---|
committer | 2012-01-07 05:38:12 +0000 | |
commit | a60854cd771b1242c05e54c0876427927f6cf4ce (patch) | |
tree | 03611ca589f371ecc9ea9ab27393d5e60a1e733d /lib/libkvm/kvm_proc2.c | |
parent | Add tests for IPv6 fragment reassembly. Hand-crafted ping6 (diff) | |
download | wireguard-openbsd-a60854cd771b1242c05e54c0876427927f6cf4ce.tar.xz wireguard-openbsd-a60854cd771b1242c05e54c0876427927f6cf4ce.zip |
Add rtable id and thread id to struct kinfo_proc (and fix process id)
and add an 'rtableid' keyword to ps.
Add rtable id, thread id, and socket splice info to struct kinfo_file2
and make fstat display socket splice information.
Remove old KVM_PROC2 and kinfo_proc2 interfaces; bump libkvm major
Socket splice info and corrections from bluhm@ "Lovely" deraadt@
Diffstat (limited to 'lib/libkvm/kvm_proc2.c')
-rw-r--r-- | lib/libkvm/kvm_proc2.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/libkvm/kvm_proc2.c b/lib/libkvm/kvm_proc2.c index 33052b3e6e8..f98c7db2ebc 100644 --- a/lib/libkvm/kvm_proc2.c +++ b/lib/libkvm/kvm_proc2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_proc2.c,v 1.8 2011/07/05 04:48:01 guenther Exp $ */ +/* $OpenBSD: kvm_proc2.c,v 1.9 2012/01/07 05:38:12 guenther Exp $ */ /* $NetBSD: kvm_proc.c,v 1.30 1999/03/24 05:50:50 mrg Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -118,7 +118,7 @@ kvm_proclist(kvm_t *kd, int op, int arg, struct proc *p, struct vmspace vm, *vmp; struct plimit limits, *limp; struct pstats pstats, *ps; - pid_t parent_pid, leader_pid; + pid_t process_pid, parent_pid, leader_pid; int cnt = 0; for (; cnt < maxcnt && p != NULL; p = LIST_NEXT(&proc, p_list)) { @@ -136,6 +136,17 @@ kvm_proclist(kvm_t *kd, int op, int arg, struct proc *p, process.ps_cred); return (-1); } + if ((proc.p_flag & P_THREAD) == 0) + process_pid = proc.p_pid; + else { + if (KREAD(kd, (u_long)process.ps_mainproc, &proc2)) { + _kvm_err(kd, kd->program, + "can't read proc at %x", + process.ps_mainproc); + return (-1); + } + process_pid = proc2.p_pid; + } if (KREAD(kd, (u_long)pcred.pc_ucred, &ucred)) { _kvm_err(kd, kd->program, "can't read ucred at %x", pcred.pc_ucred); @@ -282,6 +293,7 @@ kvm_proclist(kvm_t *kd, int op, int arg, struct proc *p, #undef do_copy_str /* stuff that's too painful to generalize into the macros */ + kp.p_pid = process_pid; kp.p_ppid = parent_pid; kp.p_sid = leader_pid; if ((process.ps_flags & PS_CONTROLT) && sess.s_ttyp != NULL) { @@ -406,10 +418,3 @@ kvm_getprocs(kvm_t *kd, int op, int arg, size_t esize, int *cnt) *cnt = nprocs; return (kd->procbase); } - -struct kinfo_proc * -kvm_getproc2(kvm_t *kd, int op, int arg, size_t esize, int *cnt) -{ - return (kvm_getprocs(kd, op, arg, esize, cnt)); -} - |