NetBSD Problem Report #36660

From yamt@mwd.biglobe.ne.jp  Tue Jul 17 14:32:48 2007
Return-Path: <yamt@mwd.biglobe.ne.jp>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id C7D1363B93E
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 17 Jul 2007 14:32:47 +0000 (UTC)
Message-Id: <20070717100456.E0F9E11702@yamt.dyndns.org>
Date: Tue, 17 Jul 2007 19:04:56 +0900 (JST)
From: yamt@mwd.biglobe.ne.jp
Reply-To: yamt@mwd.biglobe.ne.jp
To: gnats-bugs@NetBSD.org
Subject: envsys sensor names are not unique
X-Send-Pr-Version: 3.95

>Number:         36660
>Category:       kern
>Synopsis:       envsys sensor names are not unique
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 17 14:35:00 +0000 2007
>Closed-Date:    Tue Jul 17 16:47:55 +0000 2007
>Last-Modified:  Sat Jul 21 15:55:00 +0000 2007
>Originator:     YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
>Release:        NetBSD 4.99.23
>Organization:

>Environment:


Architecture: i386
Machine: i386
>Description:

	on one of my machines, envstat shows something like the following.
	(it's with ipmi(4).)
	as you see, there are some sensors with the same name.
	i consider it as a bug because the names are used as identifiers.
	eg. envstat -s
	the introduction of "envstat -m desc=..." made the situation worse.

% envstat
	Temp:     40.000 degC
	Temp:     40.000 degC
  Riser Temp:     40.000 degC
 Planar Temp:     40.000 degC
Ambient Temp:     23.000 degC
	Temp:     50.000 degC
	Temp:     50.000 degC
	Temp:     40.000 degC
	Temp:     40.000 degC
  Riser Temp:     29.000 degC
 Planar Temp:     32.000 degC
Ambient Temp:     21.000 degC
	Temp:     50.000 degC
	Temp:     34.000 degC
   FAN 8 RPM:       1800 RPM
   FAN 7 RPM:       1800 RPM
   FAN 6 RPM:       1800 RPM
   FAN 5 RPM:       1800 RPM
   FAN 4 RPM:       1800 RPM
   FAN 3 RPM:       1800 RPM
   FAN 2 RPM:       1800 RPM
   FAN 1 RPM:       1800 RPM
   FAN 6 RPM:       4950 RPM
   FAN 5 RPM:       4950 RPM
   FAN 4 RPM:       4875 RPM
   FAN 3 RPM:       4950 RPM
   FAN 2 RPM:       5025 RPM
   FAN 1 RPM:       1800 RPM
CMOS Battery:      3.096 V
CMOS Battery:      3.122 V
   Intrusion

>How-To-Repeat:

>Fix:
	- make the framework ensure that names are unique.
	- remove the "envstat -m desc=..." functionality.
	  IMO, it's a misfeature.

>Release-Note:

>Audit-Trail:
From: Juan RP <juan@xtrarom.org>
To: gnats-bugs@NetBSD.org
Cc: yamt@mwd.biglobe.ne.jp
Subject: Re: kern/36660: envsys sensor names are not unique
Date: Tue, 17 Jul 2007 16:42:44 +0200

 On Tue, 17 Jul 2007 14:35:01 +0000 (UTC)
 yamt@mwd.biglobe.ne.jp wrote:

 > 	- make the framework ensure that names are unique.

 Do you mean per device, right?

 > 	- remove the "envstat -m desc=..." functionality.
 > 	  IMO, it's a misfeature.

 A misfeature, why? it's useful if you are not happy with a description.
 Note that the problem here is ipmi that assigns those names.

 -- 
 Juan Romero Pardines	- The NetBSD Project
 http://plog.xtrarom.org	- NetBSD/pkgsrc news in Spanish

State-Changed-From-To: open->closed
State-Changed-By: xtraeme@netbsd.org
State-Changed-When: Tue, 17 Jul 2007 16:47:55 +0000
State-Changed-Why:
Description strings now must be unique per device, and -m desc
won't accept any description assigned by any other sensor.

Thanks.


From: Juan Romero Pardines <xtraeme@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: PR/36660 CVS commit: src/sys
Date: Tue, 17 Jul 2007 16:47:58 +0000 (UTC)

 Module Name:	src
 Committed By:	xtraeme
 Date:		Tue Jul 17 16:47:58 UTC 2007

 Modified Files:
 	src/sys/dev/sysmon: sysmon_envsys.c
 	src/sys/sys: envsys.h

 Log Message:
 Skip sensors with the same description on the same device at attach time,
 if the description of it is not unique, mark the sensor with
 ENVSYS_FDUPDESC, return EEXIST and continue.

 Also, when changing a description, check that the new description is not
 assigned by any other sensor, otherwise return EEXIST.

 Note that these restrictions are only per device. Fixes PR kern/36660.


 To generate a diff of this commit:
 cvs rdiff -r1.22 -r1.23 src/sys/dev/sysmon/sysmon_envsys.c
 cvs rdiff -r1.12 -r1.13 src/sys/sys/envsys.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
To: juan@xtrarom.org
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/36660: envsys sensor names are not unique
Date: Thu, 19 Jul 2007 12:22:54 +0900 (JST)

 > On Tue, 17 Jul 2007 14:35:01 +0000 (UTC)
 > yamt@mwd.biglobe.ne.jp wrote:
 > 
 > > 	- make the framework ensure that names are unique.
 > 
 > Do you mean per device, right?

 it should be unique enough so that an sensor can be specified unambiguously.
 isn't "envstat -s foo" ambiguous if there are two sensors called "foo"
 in a system, even if they belong to different devices?

 > > 	- remove the "envstat -m desc=..." functionality.
 > > 	  IMO, it's a misfeature.
 > 
 > A misfeature, why? it's useful if you are not happy with a description.
 > Note that the problem here is ipmi that assigns those names.

 keeping user-defined descriptions in kernel is a bad idea in the first place.

 besides, because they are used as identifiers as well (it's a bad design IMO),
 changing them just for user's preference is rather confusing than useful.
 do you have a way to know what your sensor with name "foo" actually was?

 YAMAMOTO Takashi

From: Juan RP <juan@xtrarom.org>
To: gnats-bugs@NetBSD.org
Cc: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
Subject: Re: kern/36660: envsys sensor names are not unique
Date: Thu, 19 Jul 2007 11:33:05 +0200

 On Thu, 19 Jul 2007 07:10:03 +0000 (UTC)
 yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) wrote:

 >  it should be unique enough so that an sensor can be specified
 > unambiguously. isn't "envstat -s foo" ambiguous if there are two sensors
 > called "foo" in a system, even if they belong to different devices?

 It's unique enough already... please see latest code.

 And envstat requires to use -d with -s, so the restriction only needs
 to be per device.

 >  keeping user-defined descriptions in kernel is a bad idea in the first
 > place. 
 >  besides, because they are used as identifiers as well (it's a bad design
 > IMO), changing them just for user's preference is rather confusing than
 > useful. do you have a way to know what your sensor with name "foo"
 > actually was? 

 When the description is changed, edata->desc is also changed. I don't see
 how you need to know its previous description.

 You can find this sensor looking at its index (edata->sensor).

 -- 
 Juan Romero Pardines	- The NetBSD Project
 http://plog.xtrarom.org	- NetBSD/pkgsrc news in Spanish

From: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
To: juan@xtrarom.org
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/36660: envsys sensor names are not unique
Date: Sat, 21 Jul 2007 19:45:33 +0900 (JST)

 > On Thu, 19 Jul 2007 07:10:03 +0000 (UTC)
 > yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) wrote:
 > 
 > >  it should be unique enough so that an sensor can be specified
 > > unambiguously. isn't "envstat -s foo" ambiguous if there are two sensors
 > > called "foo" in a system, even if they belong to different devices?
 > 
 > It's unique enough already... please see latest code.

 you asked what i meant, so i explained.

 > And envstat requires to use -d with -s, so the restriction only needs
 > to be per device.

 really?  "envstat -s Temp" without -d seems working.

 > >  keeping user-defined descriptions in kernel is a bad idea in the first
 > > place. 
 > >  besides, because they are used as identifiers as well (it's a bad design
 > > IMO), changing them just for user's preference is rather confusing than
 > > useful. do you have a way to know what your sensor with name "foo"
 > > actually was? 
 > 
 > When the description is changed, edata->desc is also changed. I don't see
 > how you need to know its previous description.

 don't you agree that identifiers and descriptions should be separated?

 > You can find this sensor looking at its index (edata->sensor).

 is it usable with the new interface?

 YAMAMOTO Takashi

 > 
 > -- 
 > Juan Romero Pardines	- The NetBSD Project
 > http://plog.xtrarom.org	- NetBSD/pkgsrc news in Spanish

From: Juan RP <juan@xtrarom.org>
To: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/36660: envsys sensor names are not unique
Date: Sat, 21 Jul 2007 12:51:21 +0200

 On Sat, 21 Jul 2007 19:45:33 +0900 (JST)
 yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) wrote:

 > really?  "envstat -s Temp" without -d seems working.

 How is it that it works for you but not here?


 $ envstat -s "acpibat0 charge" -dacpibat0   
         acpibat0 charge:      0.663 Ah (16.92%) critical ( 2.50%)
 $ envstat -s "acpibat0 charge"            
 envstat: unknown sensor `acpibat0 charge'
 $

 And yes, the code checks if -s is used without -d.

 > don't you agree that identifiers and descriptions should be separated?

 I don't understand you, can you explain some more?

 > > You can find this sensor looking at its index (edata->sensor).
 > 
 > is it usable with the new interface?

 Of course it is. The code relies in sme_nsensors on many places to
 refresh sensor data, create and update the dictionaries, etc.

 -- 
 Juan Romero Pardines 	- The NetBSD Project
 http://plog.xtrarom.org 	- NetBSD/pkgsrc news in Spanish

From: Juan RP <juan@xtrarom.org>
To: gnats-bugs@NetBSD.org
Cc: yamt@mwd.biglobe.ne.jp
Subject: Re: kern/36660: envsys sensor names are not unique
Date: Sat, 21 Jul 2007 12:57:02 +0200

 On Sat, 21 Jul 2007 10:55:02 +0000 (UTC)
 Juan RP <juan@xtrarom.org> wrote:

 >  $ envstat -s "acpibat0 charge" -dacpibat0   
 >          acpibat0 charge:      0.663 Ah (16.92%) critical ( 2.50%)
 >  $ envstat -s "acpibat0 charge"            
 >  envstat: unknown sensor `acpibat0 charge'
 >  $
 >   
 >  And yes, the code checks if -s is used without -d.

 Oh wait, now that I'm seeing it... this should have triggered the check.

 I'll fix.

 -- 
 Juan Romero Pardines 	- The NetBSD Project
 http://plog.xtrarom.org 	- NetBSD/pkgsrc news in Spanish

From: Juan RP <juan@xtrarom.org>
To: gnats-bugs@NetBSD.org
Cc: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
Subject: Re: kern/36660: envsys sensor names are not unique
Date: Sat, 21 Jul 2007 13:01:01 +0200

 On Sat, 21 Jul 2007 10:50:02 +0000 (UTC)
 yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) wrote:

 >  really?  "envstat -s Temp" without -d seems working.

 You were right... it's fixed now.

 -- 
 Juan Romero Pardines 	- The NetBSD Project
 http://plog.xtrarom.org 	- NetBSD/pkgsrc news in Spanish

From: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
To: juan@xtrarom.org
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/36660: envsys sensor names are not unique
Date: Sat, 21 Jul 2007 20:47:04 +0900 (JST)

 > > don't you agree that identifiers and descriptions should be separated?
 > 
 > I don't understand you, can you explain some more?

 i don't want to use a user-defined random string to specify a sensor.

 > > > You can find this sensor looking at its index (edata->sensor).
 > > 
 > > is it usable with the new interface?
 > 
 > Of course it is. The code relies in sme_nsensors on many places to
 > refresh sensor data, create and update the dictionaries, etc.

 in kernel, you mean?

 YAMAMOTO Takashi

From: Juan RP <juan@xtrarom.org>
To: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/36660: envsys sensor names are not unique
Date: Sat, 21 Jul 2007 13:49:27 +0200

 On Sat, 21 Jul 2007 20:47:04 +0900 (JST)
 yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) wrote:

 > in kernel, you mean?

 In kernel, yes.

 -- 
 Juan Romero Pardines 	- The NetBSD Project
 http://plog.xtrarom.org 	- NetBSD/pkgsrc news in Spanish

From: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
To: juan@xtrarom.org
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/36660: envsys sensor names are not unique
Date: Sat, 21 Jul 2007 20:50:42 +0900 (JST)

 > On Sat, 21 Jul 2007 10:50:02 +0000 (UTC)
 > yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) wrote:
 > 
 > >  really?  "envstat -s Temp" without -d seems working.
 > 
 > You were right... it's fixed now.
 > 
 > -- 
 > Juan Romero Pardines 	- The NetBSD Project
 > http://plog.xtrarom.org 	- NetBSD/pkgsrc news in Spanish

 shouldn't it be rejected by kernel as well?

 YAMAMOTO Takashi

From: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
To: juan@xtrarom.org
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/36660: envsys sensor names are not unique
Date: Sat, 21 Jul 2007 20:52:59 +0900 (JST)

 > On Sat, 21 Jul 2007 20:47:04 +0900 (JST)
 > yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) wrote:
 > 
 > > in kernel, you mean?
 > 
 > In kernel, yes.

 i was talking about the user (or userland) interface.

 YAMAMOTO Takashi

From: Juan RP <juan@xtrarom.org>
To: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/36660: envsys sensor names are not unique
Date: Sat, 21 Jul 2007 13:53:31 +0200

 On Sat, 21 Jul 2007 20:50:42 +0900 (JST)
 yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) wrote:

 > shouldn't it be rejected by kernel as well?

 It is already, see envsys(4), sysmon_envsys(9) and the code
 in ENVSYS_SETDICTIONARY and sme_userret_dictionary().

 If you specify a sensor without a driver name, it will return an error.

 -- 
 Juan Romero Pardines 	- The NetBSD Project
 http://plog.xtrarom.org 	- NetBSD/pkgsrc news in Spanish

From: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
To: juan@xtrarom.org
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/36660: envsys sensor names are not unique
Date: Sun, 22 Jul 2007 00:17:11 +0900 (JST)

 > On Sat, 21 Jul 2007 20:50:42 +0900 (JST)
 > yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) wrote:
 > 
 > > shouldn't it be rejected by kernel as well?
 > 
 > It is already, see envsys(4), sysmon_envsys(9) and the code
 > in ENVSYS_SETDICTIONARY and sme_userret_dictionary().
 > 
 > If you specify a sensor without a driver name, it will return an error.

 % ./obj/envstat -s Temp
         Temp:     40.000 degC

 (with envstat.c rev.1.38)

 YAMAMOTO Takashi

From: Juan RP <juan@xtrarom.org>
To: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/36660: envsys sensor names are not unique
Date: Sat, 21 Jul 2007 17:20:53 +0200

 On Sun, 22 Jul 2007 00:17:11 +0900 (JST)
 yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) wrote:

 > % ./obj/envstat -s Temp
 >         Temp:     40.000 degC
 > 
 > (with envstat.c rev.1.38)

 Use revision 1.40. Also I fixed more things that you said in your PR
 (all in the kernel part), please check what's wrong now.

 -- 
 Juan Romero Pardines 	- The NetBSD Project
 http://plog.xtrarom.org 	- NetBSD/pkgsrc news in Spanish

From: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
To: juan@xtrarom.org
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/36660: envsys sensor names are not unique
Date: Sun, 22 Jul 2007 00:43:06 +0900 (JST)

 > On Sun, 22 Jul 2007 00:17:11 +0900 (JST)
 > yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) wrote:
 > 
 > > % ./obj/envstat -s Temp
 > >         Temp:     40.000 degC
 > > 
 > > (with envstat.c rev.1.38)
 > 
 > Use revision 1.40.

 sorry?  we are talking if kernel checks it or not.
 how the version of userland matters?

 YAMAMOTO Takashi

From: Juan RP <juan@xtrarom.org>
To: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/36660: envsys sensor names are not unique
Date: Sat, 21 Jul 2007 17:47:41 +0200

 On Sun, 22 Jul 2007 00:43:06 +0900 (JST)
 yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) wrote:

 > sorry?  we are talking if kernel checks it or not.
 > how the version of userland matters?

 The kernel is not used for -s... you can see all that in the envstat(8)
 source. 

 I was talking about the -m flag (that uses ENVSYS_SETDICTIONARY)
 and I don't see why you should ask the kernel for the -s flag.

 The -s flag what it does is:

 	- Receive global dictionary, check if specified sensor or
            sensors are found in the array with key "device name".
 	- Return error if any of these sensors were not found.

 -- 
 Juan Romero Pardines 	- The NetBSD Project
 http://plog.xtrarom.org 	- NetBSD/pkgsrc news in Spanish

From: yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi)
To: juan@xtrarom.org
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/36660: envsys sensor names are not unique
Date: Sun, 22 Jul 2007 00:54:37 +0900 (JST)

 > On Sun, 22 Jul 2007 00:43:06 +0900 (JST)
 > yamt@mwd.biglobe.ne.jp (YAMAMOTO Takashi) wrote:
 > 
 > > sorry?  we are talking if kernel checks it or not.
 > > how the version of userland matters?
 > 
 > The kernel is not used for -s... you can see all that in the envstat(8)
 > source. 
 > 
 > I was talking about the -m flag (that uses ENVSYS_SETDICTIONARY)
 > and I don't see why you should ask the kernel for the -s flag.
 > 
 > The -s flag what it does is:
 > 
 > 	- Receive global dictionary, check if specified sensor or
 >            sensors are found in the array with key "device name".
 > 	- Return error if any of these sensors were not found.

 ok, it makes sense.  thanks for explanation.

 YAMAMOTO Takashi

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.