openbsd-ports/comms/lcdproc/patches/patch-clients_lcdproc_machine_OpenBSD_c
2012-02-28 10:32:00 +00:00

71 lines
1.9 KiB
Plaintext

$OpenBSD: patch-clients_lcdproc_machine_OpenBSD_c,v 1.2 2012/02/28 10:32:00 edd Exp $
The code distributed with LCDproc for querying the process table is out of date.
--- clients/lcdproc/machine_OpenBSD.c.orig Mon Dec 27 13:32:56 2010
+++ clients/lcdproc/machine_OpenBSD.c Tue Feb 21 08:40:04 2012
@@ -49,8 +49,9 @@
#include <sys/mount.h>
#include <sys/time.h>
#include <sys/user.h>
-/* take care if $ARCH != i386! */
-#include <i386/apmvar.h>
+#ifdef WITH_APM
+#include <machine/apmvar.h>
+#endif
#include <kvm.h>
#include <errno.h>
@@ -61,7 +62,7 @@
static int pageshift;
#define pagetok(size) ((size) << pageshift)
-#define PROCSIZE(pp) ((pp).vm_tsize + (pp).vm_dsize + (pp).vm_ssize)
+#define PROCSIZE(pp) ((pp)->p_vm_tsize + (pp)->p_vm_dsize + (pp)->p_vm_ssize)
int machine_init(void)
@@ -88,6 +89,7 @@ int machine_close(void)
int machine_get_battstat(int *acstat, int *battflag, int *percent)
{
+#ifdef WITH_APM
int apmd;
struct apm_power_info api;
@@ -145,6 +147,11 @@ int machine_get_battstat(int *acstat, int *battflag, i
*percent = api.battery_life;
close(apmd);
+#else
+ *acstat = LCDP_AC_ON;
+ *battflag = LCDP_BATT_ABSENT;
+ *percent = 100;
+#endif
return(TRUE);
}
@@ -294,7 +301,7 @@ int machine_get_procs(LinkedList *procs)
return(FALSE);
}
- kprocs = kvm_getprocs(kvmd, KERN_PROC_ALL, 0, &nproc);
+ kprocs = kvm_getprocs(kvmd, KERN_PROC_ALL, 0, sizeof(struct kinfo_proc), &nproc);
if (kprocs == NULL)
{
perror("kvm_getprocs");
@@ -311,10 +318,10 @@ int machine_get_procs(LinkedList *procs)
kvm_close(kvmd);
return(FALSE);
}
- strncpy(p->name, kprocs->kp_proc.p_comm, 15);
+ strncpy(p->name, kprocs->p_comm, 15);
p->name[15] = '\0';
- p->totl = pagetok(PROCSIZE(kprocs->kp_eproc.e_vm));
- p->number = kprocs->kp_proc.p_pid;
+ p->totl = pagetok(PROCSIZE(kprocs));
+ p->number = kprocs->p_pid;
LL_Push(procs, (void *)p);
kprocs++;