From owner-freebsd-bugs@FreeBSD.ORG Tue Feb 26 23:40:02 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 769B01065678 for ; Tue, 26 Feb 2008 23:40:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 514AE13C4D9 for ; Tue, 26 Feb 2008 23:40:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m1QNe2Kb048223 for ; Tue, 26 Feb 2008 23:40:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m1QNe2at048222; Tue, 26 Feb 2008 23:40:02 GMT (envelope-from gnats) Resent-Date: Tue, 26 Feb 2008 23:40:02 GMT Resent-Message-Id: <200802262340.m1QNe2at048222@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Benjain Close Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B8B7C106566B for ; Tue, 26 Feb 2008 23:38:43 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id A2F3313C45E for ; Tue, 26 Feb 2008 23:38:43 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m1QNZwVI054661 for ; Tue, 26 Feb 2008 23:35:58 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id m1QNZw1Z054660; Tue, 26 Feb 2008 23:35:58 GMT (envelope-from nobody) Message-Id: <200802262335.m1QNZw1Z054660@www.freebsd.org> Date: Tue, 26 Feb 2008 23:35:58 GMT From: Benjain Close To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/121133: [patch] systils/wmbluecpu : Fix broken port under 8, take maintainership X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Feb 2008 23:40:02 -0000 >Number: 121133 >Category: misc >Synopsis: [patch] systils/wmbluecpu : Fix broken port under 8, take maintainership >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Feb 26 23:40:02 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Benjain Close >Release: FreeBSD 8.0-Current >Organization: ClearChain >Environment: FreeBSD wolf.clearchain.com 8.0-CURRENT FreeBSD 8.0-CURRENT #1: Fri Dec 14 14:23:25 CST 2007 root@wolf.clearchain.com:/usr/src-local/sys/amd64/compile/GENERIC amd64 >Description: sysutils/wmbluecpu builds under 8.0-Current but exits as soon as run. It fails due to a legacy kvm call being changed. (8.0 uses a sysctl, before used a kvm call). The attached patch fixes this and *should* be backward compatible under 7 and below (I've no 7 or less boxes to test on). I'm also happy to take maintainership of this port. Please not however, I've only a src commit bit. >How-To-Repeat: Run wmbluecpu on 8.0-Current >Fix: Apply attached patch Patch attached with submission follows: Index: Makefile =================================================================== RCS file: /devel/FreeBSD/ncvs/ports/sysutils/wmbluecpu/Makefile,v retrieving revision 1.5 diff -u -r1.5 Makefile --- Makefile 19 May 2007 20:23:36 -0000 1.5 +++ Makefile 26 Feb 2008 23:32:34 -0000 @@ -7,12 +7,12 @@ PORTNAME= wmbluecpu PORTVERSION= 0.4 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= sysutils windowmaker MASTER_SITES= ${MASTER_SITE_SUNSITE} MASTER_SITE_SUBDIR= X11/xutils -MAINTAINER= ports@FreeBSD.org +MAINTAINER= benjsc@FreeBSD.org COMMENT= A CPU monitoring dockapp USE_BZIP2= yes Index: files/cpu_freebsd.c =================================================================== RCS file: /devel/FreeBSD/ncvs/ports/sysutils/wmbluecpu/files/cpu_freebsd.c,v retrieving revision 1.2 diff -u -r1.2 cpu_freebsd.c --- files/cpu_freebsd.c 10 Apr 2003 09:46:22 -0000 1.2 +++ files/cpu_freebsd.c 26 Feb 2008 23:31:59 -0000 @@ -35,23 +35,17 @@ #include static kvm_t *kd; -static struct nlist nlst[] = { {"_cp_time"}, {0} }; +static int cp_time_mib[2]; +static struct nlist nlst[] = { + {"_cp_time"}, {0}}; void cpu_init(void) { - if (!(kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open"))) - { - perror("kvm_open"); - exit(1); - } - - kvm_nlist(kd, nlst); - - if (!nlst[0].n_type) - { - perror("kvm_nlist"); - exit(1); + size_t len = 2; + sysctlnametomib("kern.cp_time", cp_time_mib, &len); + if((kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) != NULL ){ + kvm_nlist(kd, nlst); } seteuid(getuid()); @@ -73,13 +67,23 @@ void cpu_getusage() { long cpu, nice, system, idle, used, total; - long cpu_time[CPUSTATES]; + long cpu_time[CPUSTATES], cpu_time_len=sizeof(cpu_time); + int error; - if (kvm_read(kd, nlst[0].n_value, &cpu_time, sizeof(cpu_time)) + if( cp_time_mib[0] != 0 ){ + error = sysctl(cp_time_mib, 2, cpu_time, &cpu_time_len, NULL, 0 ); + if ( error ){ + perror("sysctl, cpu_time_mib"); + exit(1); + } + } + else { + if (kvm_read(kd, nlst[0].n_value, &cpu_time, sizeof(cpu_time)) != sizeof(cpu_time)) - { + { perror("kvm_read"); exit(1); + } } cpu = cpu_time[CP_USER]; >Release-Note: >Audit-Trail: >Unformatted: