fix after kinfo_proc2 removal

This commit is contained in:
robert 2012-01-09 16:45:20 +00:00
parent 0d8df5254b
commit 6c3edfd3f9
11 changed files with 242 additions and 11 deletions

View File

@ -1,11 +1,11 @@
# $OpenBSD: Makefile,v 1.92 2011/11/15 23:30:30 sthen Exp $
# $OpenBSD: Makefile,v 1.93 2012/01/09 16:45:20 robert Exp $
COMMENT= portable library for obtaining system information
GNOME_VERSION= 2.28.4
GNOME_PROJECT= libgtop
PKGNAME= libgtop2-${VERSION}
REVISION= 4
REVISION= 5
SHARED_LIBS= gtop-2.0 9.0 # .9.0

View File

@ -1,4 +1,4 @@
$OpenBSD: patch-sysdeps_openbsd_procargs_c,v 1.2 2011/09/18 11:46:16 jasper Exp $
$OpenBSD: patch-sysdeps_openbsd_procargs_c,v 1.3 2012/01/09 16:45:20 robert Exp $
commit dd46d6a00e4af444d423383abbc538436a170e2b
Author: Jasper Lievisse Adriaanse <jasper@humppa.nl>
@ -6,9 +6,18 @@ Date: Sun Sep 18 13:42:13 2011 +0200
Don't bother with PIDs below 20 as they are highly likely to be kernel threads anyway.
--- sysdeps/openbsd/procargs.c.orig Sat Sep 17 18:58:14 2011
+++ sysdeps/openbsd/procargs.c Sat Sep 17 18:59:23 2011
@@ -58,8 +58,11 @@ glibtop_get_proc_args_p (glibtop *server, glibtop_proc
--- sysdeps/openbsd/procargs.c.orig Sun Jul 24 13:13:56 2011
+++ sysdeps/openbsd/procargs.c Mon Jan 9 09:31:58 2012
@@ -49,7 +49,7 @@ char *
glibtop_get_proc_args_p (glibtop *server, glibtop_proc_args *buf,
pid_t pid, unsigned max_len)
{
- struct kinfo_proc2 *pinfo;
+ struct kinfo_proc *pinfo;
char *retval, **args, **ptr;
size_t size = 0, pos = 0;
int count;
@@ -58,21 +58,24 @@ glibtop_get_proc_args_p (glibtop *server, glibtop_proc
memset (buf, 0, sizeof (glibtop_proc_args));
@ -22,3 +31,19 @@ Date: Sun Sep 18 13:42:13 2011 +0200
glibtop_suid_enter (server);
/* Get the process data */
- pinfo = kvm_getproc2 (server->machine.kd, KERN_PROC_PID, pid,
+ pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid,
sizeof (*pinfo), &count);
if ((pinfo == NULL) || (count < 1)) {
glibtop_suid_leave (server);
- glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
+ glibtop_warn_io_r (server, "kvm_getprocss (%d)", pid);
return NULL;
}
- args = kvm_getargv2 (server->machine.kd, pinfo, max_len);
+ args = kvm_getargv (server->machine.kd, pinfo, max_len);
if (args == NULL) {
glibtop_suid_leave (server);
glibtop_warn_io_r (server, "kvm_getargv (%d)", pid);

View File

@ -0,0 +1,25 @@
$OpenBSD: patch-sysdeps_openbsd_prockernel_c,v 1.1 2012/01/09 16:45:20 robert Exp $
--- sysdeps/openbsd/prockernel.c.orig Mon Jan 9 09:26:48 2012
+++ sysdeps/openbsd/prockernel.c Mon Jan 9 09:31:58 2012
@@ -57,7 +57,7 @@ glibtop_get_proc_kernel_p (glibtop *server,
glibtop_proc_kernel *buf,
pid_t pid)
{
- struct kinfo_proc2 *pinfo;
+ struct kinfo_proc *pinfo;
int count;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
@@ -71,10 +71,10 @@ glibtop_get_proc_kernel_p (glibtop *server,
if (pid == 0) return;
/* Get the process information */
- pinfo = kvm_getproc2 (server->machine.kd, KERN_PROC_PID, pid,
+ pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid,
sizeof(*pinfo), &count);
if ((pinfo == NULL) || (count != 1)) {
- glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
+ glibtop_warn_io_r (server, "kvm_getprocss (%d)", pid);
return;
}

View File

@ -0,0 +1,25 @@
$OpenBSD: patch-sysdeps_openbsd_proclist_c,v 1.1 2012/01/09 16:45:20 robert Exp $
--- sysdeps/openbsd/proclist.c.orig Mon Jan 9 09:23:44 2012
+++ sysdeps/openbsd/proclist.c Mon Jan 9 09:31:58 2012
@@ -62,7 +62,7 @@ pid_t *
glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
gint64 real_which, gint64 arg)
{
- struct kinfo_proc2 *pinfo;
+ struct kinfo_proc *pinfo;
unsigned *pids = NULL;
int which, count;
int i,j;
@@ -74,10 +74,10 @@ glibtop_get_proclist_p (glibtop *server, glibtop_procl
which = (int)(real_which & GLIBTOP_KERN_PROC_MASK);
/* Get the process data */
- pinfo = kvm_getproc2 (server->machine.kd, which, arg,
+ pinfo = kvm_getprocs (server->machine.kd, which, arg,
sizeof (*pinfo), &count);
if ((pinfo == NULL) || (count < 1)) {
- glibtop_warn_io_r (server, "kvm_getprocs (proclist)");
+ glibtop_warn_io_r (server, "kvm_getprocss (proclist)");
return NULL;
}
count--;

View File

@ -1,4 +1,4 @@
$OpenBSD: patch-sysdeps_openbsd_procmap_c,v 1.2 2011/09/18 11:46:16 jasper Exp $
$OpenBSD: patch-sysdeps_openbsd_procmap_c,v 1.3 2012/01/09 16:45:20 robert Exp $
commit 7bd52fc397be0598638abae2bf71740af505d29c
Author: Jasper Lievisse Adriaanse <jasper@humppa.nl>
@ -6,9 +6,9 @@ Date: Sun Sep 18 13:41:20 2011 +0200
Extend comment a bit regarding processes dying before we get to kvm_getproc2()
--- sysdeps/openbsd/procmap.c.orig Sat Sep 17 18:59:40 2011
+++ sysdeps/openbsd/procmap.c Sat Sep 17 19:14:25 2011
@@ -64,7 +64,11 @@ _glibtop_init_proc_map_p (glibtop *server)
--- sysdeps/openbsd/procmap.c.orig Sun Jul 24 13:13:56 2011
+++ sysdeps/openbsd/procmap.c Mon Jan 9 09:31:58 2012
@@ -64,13 +64,17 @@ _glibtop_init_proc_map_p (glibtop *server)
server->sysdeps.proc_map = _glibtop_sysdeps_proc_map;
}
@ -16,11 +16,30 @@ Date: Sun Sep 18 13:41:20 2011 +0200
+/*
+ * Provides detailed information about a process.
+ * Due to the fact we are only requested info about one process, it's possible
+ * the process has been reaped before we get to kvm_getproc2. Tough luck.
+ * the process has been reaped before we get to kvm_getprocs. Tough luck.
+ */
glibtop_map_entry *
glibtop_get_proc_map_p (glibtop *server, glibtop_proc_map *buf,
pid_t pid)
{
- struct kinfo_proc2 *pinfo;
+ struct kinfo_proc *pinfo;
struct vm_map_entry entry, *first;
struct vmspace vmspace;
struct vnode vnode;
@@ -91,9 +95,9 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_
glibtop_suid_enter (server);
/* Get the process data */
- pinfo = kvm_getproc2 (server->machine.kd, KERN_PROC_PID, pid, sizeof(struct kinfo_proc2), &count);
+ pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, sizeof(struct kinfo_proc), &count);
if ((pinfo == NULL) || (count < 1)) {
- glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
+ glibtop_warn_io_r (server, "kvm_getprocss (%d)", pid);
return (glibtop_map_entry*) g_array_free(maps, TRUE);
}
@@ -124,7 +128,8 @@ glibtop_get_proc_map_p (glibtop *server, glibtop_proc_
/* I tested this a few times with `mmap'; as soon as you write

View File

@ -0,0 +1,25 @@
$OpenBSD: patch-sysdeps_openbsd_procmem_c,v 1.1 2012/01/09 16:45:20 robert Exp $
--- sysdeps/openbsd/procmem.c.orig Mon Jan 9 09:26:01 2012
+++ sysdeps/openbsd/procmem.c Mon Jan 9 09:31:58 2012
@@ -96,7 +96,7 @@ void
glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
pid_t pid)
{
- struct kinfo_proc2 *pinfo;
+ struct kinfo_proc *pinfo;
int count;
@@ -111,10 +111,10 @@ glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_
if (pid == 0) return;
/* Get the process data */
- pinfo = kvm_getproc2 (server->machine.kd, KERN_PROC_PID, pid,
+ pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid,
sizeof (*pinfo), &count);
if ((pinfo == NULL) || (count < 1)) {
- glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
+ glibtop_warn_io_r (server, "kvm_getprocss (%d)", pid);
return;
}

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-sysdeps_openbsd_procsegment_c,v 1.1 2012/01/09 16:45:20 robert Exp $
--- sysdeps/openbsd/procsegment.c.orig Mon Jan 9 09:30:52 2012
+++ sysdeps/openbsd/procsegment.c Mon Jan 9 09:31:59 2012
@@ -55,7 +55,7 @@ glibtop_get_proc_segment_p (glibtop *server,
#if 0
/* Get the process info from the kernel */
- kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid, count);
+ kvm_getprocss (server->machine.kd, KERN_PROC_PID, pid, count);
if (*count != 1) {
return; /* the zeroed-out buffer indicating no data */
}

View File

@ -0,0 +1,25 @@
$OpenBSD: patch-sysdeps_openbsd_procsignal_c,v 1.1 2012/01/09 16:45:20 robert Exp $
--- sysdeps/openbsd/procsignal.c.orig Mon Jan 9 09:26:16 2012
+++ sysdeps/openbsd/procsignal.c Mon Jan 9 09:31:59 2012
@@ -49,7 +49,7 @@ glibtop_get_proc_signal_p (glibtop *server,
glibtop_proc_signal *buf,
pid_t pid)
{
- struct kinfo_proc2 *pinfo;
+ struct kinfo_proc *pinfo;
int count = 0;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_SIGNAL), 0);
@@ -60,10 +60,10 @@ glibtop_get_proc_signal_p (glibtop *server,
if (pid == 0) return;
/* Get the process information */
- pinfo = kvm_getproc2 (server->machine.kd, KERN_PROC_PID, pid,
+ pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid,
sizeof (*pinfo), &count);
if ((pinfo == NULL) || (count != 1)) {
- glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
+ glibtop_warn_io_r (server, "kvm_getprocss (%d)", pid);
return;
}

View File

@ -0,0 +1,25 @@
$OpenBSD: patch-sysdeps_openbsd_procstate_c,v 1.1 2012/01/09 16:45:20 robert Exp $
--- sysdeps/openbsd/procstate.c.orig Mon Jan 9 09:24:38 2012
+++ sysdeps/openbsd/procstate.c Mon Jan 9 09:31:59 2012
@@ -51,7 +51,7 @@ glibtop_get_proc_state_p (glibtop *server,
glibtop_proc_state *buf,
pid_t pid)
{
- struct kinfo_proc2 *pinfo;
+ struct kinfo_proc *pinfo;
int count = 0;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_STATE), 0);
@@ -62,10 +62,10 @@ glibtop_get_proc_state_p (glibtop *server,
if (pid == 0) return;
/* Get the process information */
- pinfo = kvm_getproc2 (server->machine.kd, KERN_PROC_PID, pid,
+ pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid,
sizeof (*pinfo), &count);
if ((pinfo == NULL) || (count != 1)) {
- glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
+ glibtop_warn_io_r (server, "kvm_getprocss (%d)", pid);
return;
}

View File

@ -0,0 +1,25 @@
$OpenBSD: patch-sysdeps_openbsd_proctime_c,v 1.1 2012/01/09 16:45:20 robert Exp $
--- sysdeps/openbsd/proctime.c.orig Mon Jan 9 09:25:42 2012
+++ sysdeps/openbsd/proctime.c Mon Jan 9 09:31:59 2012
@@ -117,7 +117,7 @@ void
glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
pid_t pid)
{
- struct kinfo_proc2 *pinfo;
+ struct kinfo_proc *pinfo;
int count;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_TIME), 0);
@@ -129,10 +129,10 @@ glibtop_get_proc_time_p (glibtop *server, glibtop_proc
/* Get the process information */
- pinfo = kvm_getproc2 (server->machine.kd, KERN_PROC_PID, pid,
+ pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid,
sizeof (*pinfo), &count);
if ((pinfo == NULL) || (count != 1)) {
- glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
+ glibtop_warn_io_r (server, "kvm_getprocss (%d)", pid);
return;
}

View File

@ -0,0 +1,25 @@
$OpenBSD: patch-sysdeps_openbsd_procuid_c,v 1.1 2012/01/09 16:45:20 robert Exp $
--- sysdeps/openbsd/procuid.c.orig Mon Jan 9 09:25:04 2012
+++ sysdeps/openbsd/procuid.c Mon Jan 9 09:31:59 2012
@@ -54,7 +54,7 @@ void
glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
pid_t pid)
{
- struct kinfo_proc2 *pinfo;
+ struct kinfo_proc *pinfo;
int count = 0;
glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_PROC_UID), 0);
@@ -65,10 +65,10 @@ glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_
if (pid == 0) return;
/* Get the process information */
- pinfo = kvm_getproc2 (server->machine.kd, KERN_PROC_PID, pid,
+ pinfo = kvm_getprocs (server->machine.kd, KERN_PROC_PID, pid,
sizeof (*pinfo), &count);
if ((pinfo == NULL) || (count != 1)) {
- glibtop_warn_io_r (server, "kvm_getprocs (%d)", pid);
+ glibtop_warn_io_r (server, "kvm_getprocss (%d)", pid);
return;
}