From gahr@gahr.ch  Fri Dec 21 02:42:41 2007
Return-Path: <gahr@gahr.ch>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2322116A41A
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 21 Dec 2007 02:42:41 +0000 (UTC)
	(envelope-from gahr@gahr.ch)
Received: from cpanel03.rubas-s03.net (cpanel03.rubas-s03.net [195.182.222.73])
	by mx1.freebsd.org (Postfix) with ESMTP id 9B9A113C4D3
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 21 Dec 2007 02:42:40 +0000 (UTC)
	(envelope-from gahr@gahr.ch)
Received: from 80-218-191-236.dclient.hispeed.ch ([80.218.191.236] helo=gahrtop.localhost)
	by cpanel03.rubas-s03.net with esmtpa (Exim 4.68)
	(envelope-from <gahr@gahr.ch>)
	id 1J5XqQ-00013A-FM
	for FreeBSD-gnats-submit@freebsd.org; Fri, 21 Dec 2007 03:42:38 +0100
Received: from gahrtop.localhost (localhost [127.0.0.1])
	by gahrtop.localhost (Postfix) with ESMTP id 9C57773063
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 21 Dec 2007 03:41:02 +0100 (CET)
Message-Id: <1198204862.73012@gahrtop.localhost>
Date: Fri, 21 Dec 2007 03:41:02 +0100
From: "Pietro Cerutti" <gahr@gahr.ch>
To: "FreeBSD gnats submit" <FreeBSD-gnats-submit@freebsd.org>
Subject: [patch] sysutils/gkrellms add coretemp(4) support + fix FreeBSD sysctl code
X-Send-Pr-Version: gtk-send-pr 0.4.8 
X-GNATS-Notify:

>Number:         118916
>Category:       ports
>Synopsis:       [patch] sysutils/gkrellm - add coretemp(4) support + fix FreeBSD sysctl code
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ume
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 21 02:50:00 UTC 2007
>Closed-Date:    Tue Dec 25 15:24:27 UTC 2007
>Last-Modified:  Tue Dec 25 15:30:02 UTC 2007
>Originator:     Pietro Cerutti
>Release:        FreeBSD 8.0-CURRENT i386
>Organization:
>Environment:


System: FreeBSD 8.0-CURRENT #18: Tue Dec 18 12:48:22 CET 2007
    root@gahrtop.localhost:/usr/obj/usr/src/sys/MSI1034



>Description:


The following patch:

1) adds support for the coretemp(4) sensor
2) fixes a bug causing only one instance of a sensor type to be added

1) coretemp(4) is a kernel module allowing to sense the temperature on each core of an Intel Core Duo processor.

2) this means that if you have two sensors of an instance, e.g. two temperature sensors, only the first one is added to GKrellm's sensors list.


>How-To-Repeat:





>Fix:


--- _gkrellm2.diff begins here ---
--- Makefile.orig	2007-12-21 03:34:49.000000000 +0100
+++ Makefile	2007-12-21 03:34:58.000000000 +0100
@@ -7,7 +7,7 @@
 
 PORTNAME=	gkrellm
 PORTVERSION=	2.3.0
-#PORTREVISION=	0
+PORTREVISION=	1
 CATEGORIES=	sysutils ipv6
 MASTER_SITES=	http://members.dslextreme.com/users/billw/gkrellm/ \
 		${MASTER_SITE_LOCAL}
--- /dev/null	2007-12-21 03:33:00.000000000 +0100
+++ files/patch-src-sysdeps_freebsd.c	2007-12-21 03:34:16.000000000 +0100
@@ -0,0 +1,195 @@
+--- src/sysdeps/freebsd.c.orig	2007-07-07 01:53:07.000000000 +0200
++++ src/sysdeps/freebsd.c	2007-12-21 03:33:54.000000000 +0100
+@@ -32,7 +32,6 @@
+ static void scan_for_sensors();
+ #endif
+ 
+-
+ void
+ gkrellm_sys_main_init(void)
+ 	{
+@@ -63,18 +62,6 @@
+ #include <sys/param.h>
+ #include <sys/sysctl.h>
+ 
+-static int
+-gk_sysctlnametomib(const char *name, int *mibp, size_t *lenp)
+-	{
+-	static int	oid_name2oid[2] = { 0, 3 };
+-
+-	if (sysctl(oid_name2oid, 2, mibp, lenp,
+-		   (void *)name, strlen(name)) < 0)
+-		return -1;
+-	*lenp /= sizeof(int);
+-	return 0;
+-	}
+-
+ /* ===================================================================== */
+ /* CPU monitor interface */
+ 
+@@ -134,7 +121,7 @@
+ 
+ 	gkrellm_cpu_set_number_of_cpus(1);
+ 
+-	if (gk_sysctlnametomib(name, oid_cp_time, &oid_cp_time_len) < 0)
++	if (sysctlnametomib(name, oid_cp_time, &oid_cp_time_len) < 0)
+ 		return TRUE;
+ 	++have_cp_time;
+ 	return TRUE;
+@@ -186,11 +173,11 @@
+ 	static char	*rname = "vm.stats.vm.v_rforks";
+ 
+ 	/* check if vm.stats.vm.v_forks is available */
+-	if (gk_sysctlnametomib(name, oid_v_forks, &oid_v_forks_len) < 0)
++	if (sysctlnametomib(name, oid_v_forks, &oid_v_forks_len) < 0)
+ 		return TRUE;
+-	if (gk_sysctlnametomib(vname, oid_v_vforks, &oid_v_vforks_len) < 0)
++	if (sysctlnametomib(vname, oid_v_vforks, &oid_v_vforks_len) < 0)
+ 		return TRUE;
+-	if (gk_sysctlnametomib(rname, oid_v_rforks, &oid_v_rforks_len) < 0)
++	if (sysctlnametomib(rname, oid_v_rforks, &oid_v_rforks_len) < 0)
+ 		return TRUE;
+ 	++have_v_forks;
+ 	return TRUE;
+@@ -574,7 +561,7 @@
+ 
+ 	if (!initialized)
+ 		{
+-		if (gk_sysctlnametomib(name, oid_pcblist,
++		if (sysctlnametomib(name, oid_pcblist,
+ 				       &oid_pcblist_len) < 0)
+ 			return;
+ 		++initialized;
+@@ -879,7 +866,7 @@
+ 
+ 	if (!initialized)
+ 		{
+-		if (gk_sysctlnametomib(name, oid_bufspace,
++		if (sysctlnametomib(name, oid_bufspace,
+ 				       &oid_bufspace_len) < 0)
+ 			return 0;
+ 		++initialized;
+@@ -977,7 +964,7 @@
+ 			for (i = 0; mibs[i].name; ++i)
+ 				{
+ 				mibs[i].oid_len = sizeof(mibs[i].oid);
+-				if (gk_sysctlnametomib(mibs[i].name,
++				if (sysctlnametomib(mibs[i].name,
+ 						       mibs[i].oid,
+ 						       &mibs[i].oid_len) < 0)
+ 				 	return;
+@@ -1130,7 +1117,7 @@
+ 		 */
+ 		for (i = 0; name[i] != NULL; ++i)
+ 			{
+-			if (gk_sysctlnametomib(name[i], oid[i],
++			if (sysctlnametomib(name[i], oid[i],
+ 					       &oid_len[i]) < 0)
+ 				break;
+ 			}
+@@ -1286,6 +1273,7 @@
+ #define INTERFACE_IO		0
+ #define INTERFACE_SMB		1
+ #define INTERFACE_ACPI		2
++#define INTERFACE_CORETEMP 3 /* Already in Celsius */
+ 
+ /* Addresses to use for /dev/io */
+ #define WBIO1			0x295
+@@ -1363,6 +1351,17 @@
+ 			*temp = (gfloat) TZ_KELVTOC(value);
+ 		return TRUE;
+ 		}
++   if (interface == INTERFACE_CORETEMP)
++      {
++      int value;
++      size_t size = sizeof(value);
++
++      if (sysctlbyname(path, &value, &size, NULL, 0) < 0)
++         return FALSE;
++      if (temp)
++         *temp = (gfloat) value;
++      return TRUE;
++      }
+ 	if (get_data(iodev, LM78_TEMP, interface, &byte))
+ 		{
+ 		if (temp)
+@@ -1443,35 +1442,47 @@
+ 	*/
+ 	gkrellm_sys_sensors_mbmon_check(TRUE);
+ 
+-	for (id = 0;;)
++   /*
++    * ACPI Thermal
++    */
++	for (id = 0;;id++)
+ 	{
+-		snprintf(mib_name, sizeof(mib_name),
+-			 "hw.acpi.thermal.tz%d.temperature", id);
+-		if (gk_sysctlnametomib(mib_name, oid_acpi_temp,
+-				       &oid_acpi_temp_len) < 0)
++		snprintf(mib_name, sizeof(mib_name), "hw.acpi.thermal.tz%d.temperature", id);
++		if (sysctlnametomib(mib_name, oid_acpi_temp, &oid_acpi_temp_len) < 0)
+ 			break;
+ 		interface = INTERFACE_ACPI;
+-		if (!gkrellm_sys_sensors_get_temperature(mib_name, 0, 0,
+-							 interface, NULL))
++		if (!gkrellm_sys_sensors_get_temperature(mib_name, 0, 0, interface, NULL))
+ 			continue;
+ 		snprintf(label, sizeof(label), "tz%d", id);
+-		gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE, NULL,
+-					   mib_name, 0, 0,
+-					   interface, 1.0, 0.0, NULL, label);
++		gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE, NULL, mib_name, 0, 0, interface, 1.0, 0.0, NULL, label);
+ 	}
+ 
+-	if (freebsd_sensor_list)
+-		{
+-		for (list = freebsd_sensor_list; list; list = list->next)
+-			{
+-			sensor = (struct freebsd_sensor *)list->data;
+-			gkrellm_sensors_add_sensor(sensor->type, NULL,
+-					sensor->id_name, sensor->id,
+-					sensor->iodev, sensor->inter,
+-					sensor->factor, sensor->offset,
+-					NULL, sensor->default_label);
+-			}
+-		}
++   /*
++    * Coretemp
++    */
++   for (id = 0;;id++)
++	{
++		snprintf(mib_name, sizeof(mib_name), "dev.cpu.%d.temperature", id);
++		if (sysctlnametomib(mib_name, oid_acpi_temp, &oid_acpi_temp_len) < 0)
++         break;
++		interface = INTERFACE_CORETEMP;
++		if (!gkrellm_sys_sensors_get_temperature(mib_name, 0, 0, interface, NULL))
++			continue;
++		snprintf(label, sizeof(label), "cpu%d", id);
++		gkrellm_sensors_add_sensor(SENSOR_TEMPERATURE, NULL, mib_name, 0, 0, interface, 1.0, 0.0, NULL, label);
++	}
++
++
++	if (freebsd_sensor_list) {
++      for (list = freebsd_sensor_list; list; list = list->next) {
++         sensor = (struct freebsd_sensor *)list->data;
++         gkrellm_sensors_add_sensor(sensor->type, NULL,
++               sensor->id_name, sensor->id,
++               sensor->iodev, sensor->inter,
++               sensor->factor, sensor->offset,
++               NULL, sensor->default_label);
++      }
++   }
+ 
+ 	return (TRUE);
+ 	}
+@@ -1537,8 +1548,7 @@
+ 				close(iodev);
+ 				continue;
+ 				}
+-			sensors_add_sensor(SENSOR_TEMPERATURE, id_name, 0,
+-					iodev, interface, 1.0, 0.0, NULL);
++			sensors_add_sensor(SENSOR_TEMPERATURE, id_name, 0, iodev, interface, 1.0, 0.0, NULL);
+ 			found_sensors = TRUE;
+ 			break;
+ 			}
--- _gkrellm2.diff ends here ---



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->ume 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Fri Dec 21 04:36:10 UTC 2007 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=118916 
State-Changed-From-To: open->closed 
State-Changed-By: ume 
State-Changed-When: Tue Dec 25 15:23:31 UTC 2007 
State-Changed-Why:  
Thanks, committed with some modification. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=118916 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/118916: commit references a PR
Date: Tue, 25 Dec 2007 15:22:26 +0000 (UTC)

 ume         2007-12-25 15:22:21 UTC
 
   FreeBSD ports repository
 
   Modified files:
     sysutils/gkrellm2    Makefile 
   Added files:
     sysutils/gkrellm2/files patch-src::sysdeps::freebsd.c 
   Log:
   - Adds support for the coretemp(4) sensor
   - Fixes a bug causing only one instance of a sensor type to be added
   
   PR:             ports/118916
   Submitted by:   Pietro Cerutti <gahr_at_gahr.ch> with modification
   Tested by:      TAKANO Yuji <takachan_at_icmpv6.org>
   
   Revision  Changes    Path
   1.128     +1 -1      ports/sysutils/gkrellm2/Makefile
   1.9       +102 -0    ports/sysutils/gkrellm2/files/patch-src::sysdeps::freebsd.c (new)
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
