summaryrefslogtreecommitdiff
path: root/lib/libkvm/kvm_proc2.c
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2011-03-12 04:54:29 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2011-03-12 04:54:29 +0000
commita79766e940b76ce3fc27af710b45145c5a8c3edf (patch)
treed1d61b3bbff4cd49d452a09b222d58400643b4ab /lib/libkvm/kvm_proc2.c
parent0b04a0ec6ae4d56e31d9ced0bf6fc0178f67fc67 (diff)
Replace the old, broken KERN_PROC ABI and its matching functions
in libkvm with the stable-ABI versions that are currently named KERN_PROC2, kvm_get{proc,argv,envv}2(). The latter names and symbols will continue to be supported for a few releases. Committing now that they ports people have had a couple releases to update pkgs that usd the old functions
Diffstat (limited to 'lib/libkvm/kvm_proc2.c')
-rw-r--r--lib/libkvm/kvm_proc2.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/lib/libkvm/kvm_proc2.c b/lib/libkvm/kvm_proc2.c
index e98c359323c..1ba2e38945c 100644
--- a/lib/libkvm/kvm_proc2.c
+++ b/lib/libkvm/kvm_proc2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_proc2.c,v 1.3 2010/07/26 01:56:27 guenther Exp $ */
+/* $OpenBSD: kvm_proc2.c,v 1.4 2011/03/12 04:54:28 guenther Exp $ */
/* $NetBSD: kvm_proc.c,v 1.30 1999/03/24 05:50:50 mrg Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -105,7 +105,7 @@ static int
kvm_proclist(kvm_t *kd, int op, int arg, struct proc *p,
char *bp, int maxcnt, size_t esize)
{
- struct kinfo_proc2 kp;
+ struct kinfo_proc kp;
struct session sess;
struct pcred pcred;
struct ucred ucred;
@@ -265,7 +265,7 @@ kvm_proclist(kvm_t *kd, int op, int arg, struct proc *p,
ps = NULL;
#define do_copy_str(_d, _s, _l) kvm_read(kd, (u_long)(_s), (_d), (_l)-1)
- FILL_KPROC2(&kp, do_copy_str, &proc, &process, &pcred, &ucred,
+ FILL_KPROC(&kp, do_copy_str, &proc, &process, &pcred, &ucred,
&pgrp, p, proc.p_p, &sess, vmp, limp, ps);
#undef do_copy_str
@@ -295,8 +295,8 @@ kvm_proclist(kvm_t *kd, int op, int arg, struct proc *p,
return (cnt);
}
-struct kinfo_proc2 *
-kvm_getproc2(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
+struct kinfo_proc *
+kvm_getprocs(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
{
int mib[6], st, nprocs;
size_t size;
@@ -304,36 +304,36 @@ kvm_getproc2(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
if ((ssize_t)esize < 0)
return (NULL);
- if (kd->procbase2 != NULL) {
- free(kd->procbase2);
+ if (kd->procbase != NULL) {
+ free(kd->procbase);
/*
* Clear this pointer in case this call fails. Otherwise,
* kvm_close() will free it again.
*/
- kd->procbase2 = 0;
+ kd->procbase = 0;
}
if (ISALIVE(kd)) {
size = 0;
mib[0] = CTL_KERN;
- mib[1] = KERN_PROC2;
+ mib[1] = KERN_PROC;
mib[2] = op;
mib[3] = arg;
mib[4] = esize;
mib[5] = 0;
st = sysctl(mib, 6, NULL, &size, NULL, 0);
if (st == -1) {
- _kvm_syserr(kd, kd->program, "kvm_getproc2");
+ _kvm_syserr(kd, kd->program, "kvm_getprocs");
return (NULL);
}
mib[5] = size / esize;
- kd->procbase2 = _kvm_malloc(kd, size);
- if (kd->procbase2 == 0)
+ kd->procbase = _kvm_malloc(kd, size);
+ if (kd->procbase == 0)
return (NULL);
- st = sysctl(mib, 6, kd->procbase2, &size, NULL, 0);
+ st = sysctl(mib, 6, kd->procbase, &size, NULL, 0);
if (st == -1) {
- _kvm_syserr(kd, kd->program, "kvm_getproc2");
+ _kvm_syserr(kd, kd->program, "kvm_getprocs");
return (NULL);
}
nprocs = size / esize;
@@ -343,9 +343,9 @@ kvm_getproc2(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
struct proc *p;
char *bp;
- if (esize > sizeof(struct kinfo_proc2)) {
+ if (esize > sizeof(struct kinfo_proc)) {
_kvm_syserr(kd, kd->program,
- "kvm_getproc2: unknown fields requested: libkvm out of date?");
+ "kvm_getprocs: unknown fields requested: libkvm out of date?");
return (NULL);
}
@@ -367,10 +367,10 @@ kvm_getproc2(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
return (NULL);
}
- kd->procbase2 = _kvm_malloc(kd, maxprocs * esize);
- if (kd->procbase2 == 0)
+ kd->procbase = _kvm_malloc(kd, maxprocs * esize);
+ if (kd->procbase == 0)
return (NULL);
- bp = (char *)kd->procbase2;
+ bp = (char *)kd->procbase;
/* allproc */
if (KREAD(kd, nl[1].n_value, &p)) {
@@ -392,6 +392,12 @@ kvm_getproc2(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
nprocs += i;
}
*cnt = nprocs;
- return (kd->procbase2);
+ 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));
}