ports/120142: wmcube-gdk does not work on CURRENT
KOIE Hidetaka
koie at suri.co.jp
Wed Jan 30 08:10:04 UTC 2008
>Number: 120142
>Category: ports
>Synopsis: wmcube-gdk does not work on CURRENT
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Wed Jan 30 08:10:03 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator: KOIE Hidetaka
>Release: FreeBSD 8.0-CURRENT amd64
>Organization:
surigiken
>Environment:
FreeBSD guriandgura 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Sat Jan 26 13:56
:29 JST 2008 koie at guriandgura:/usr/obj/usr/src/sys/GURIANDGURA amd64
>Description:
wmcube-gdk exits with error, because kvm_nlist("_cp_time") fails.
>How-To-Repeat:
% wmcube-gdk
kvm_open: kvm_nlist: No such file or directory
Error: unable to get nlist
%
>Fix:
use sysctl(3).
Patch attached with submission follows:
--- wmcube.c.orig2 2008-01-30 16:30:42.370561646 +0900
+++ wmcube.c 2008-01-30 16:40:51.514960568 +0900
@@ -174,6 +174,7 @@ float lum_vector[3] = { 0, 0, 100 }; /*
#ifdef FREEBSD
static kvm_t *kd;
static struct nlist nlst[] = { {"_cp_time"}, {0} };
+static int cp_time_mib[2];
#endif
void prep_digits(void)
@@ -1582,9 +1583,14 @@ int calc_cpu_total()
#include <nlist.h>
#include <fcntl.h>
#include <sys/dkstat.h>
+#include <sys/sysctl.h>
int init_calc_cpu()
{
+ size_t len = 2;
+ if (sysctlnametomib("kern.cp_time", cp_time_mib, &len) == 0)
+ goto ok;
+ printf("\nWarning: unable to sysctl kern.cp_time\n\n");
if ((kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL) {
printf("\nError: unable to open kvm\n\n");
@@ -1596,6 +1602,7 @@ int init_calc_cpu()
exit(1);
}
+ ok:
/* drop setgid & setuid (hi GOBBLES, who the fuck are you? */
seteuid(getuid());
setegid(getgid());
@@ -1615,6 +1622,13 @@ int calc_cpu_total()
int cpu, nice, system, idle;
unsigned long int cpu_time[CPUSTATES];
+ if (cp_time_mib[0] != 0) {
+ size_t cpu_time_len = sizeof (cpu_time);
+ if (sysctl(cp_time_mib, 2, cpu_time, &cpu_time_len, NULL, 0) < 0) {
+ printf("\nError sysctl\n\n");
+ exit(0);
+ }
+ } else
if (kvm_read(kd, nlst[0].n_value, &cpu_time, sizeof(cpu_time))
!= sizeof(cpu_time)) {
printf("\nError reading kvm\n\n");
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list