Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Oct 2007 11:48:58 +0100 (BST)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Max Laier <max@love2party.net>
Cc:        Poul-Henning Kamp <phk@phk.freebsd.dk>, "Constantine A. Murenin" <cnst@freebsd.org>, Julian Elischer <julian@elischer.org>, freebsd-arch@freebsd.org
Subject:   Re: sensors fun..
Message-ID:  <20071018113431.K60783@fledge.watson.org>
In-Reply-To: <200710172243.51958.max@love2party.net>
References:  <52116.1192652445@critter.freebsd.dk> <200710172243.51958.max@love2party.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 17 Oct 2007, Max Laier wrote:

> On Wednesday 17 October 2007, Poul-Henning Kamp wrote:
>> In message <47166BA5.1000100@elischer.org>, Julian Elischer writes:
>>>> Having a userland interface also makes it easier to have backends that 
>>>> are entirely in userland.
>>>
>>> maybe a loopback filesystem
>>
>> Just what is it that is so enticing about the kernel ?  Why not simply pass 
>> it to a daemon ?
>
> What I like about the OpenBSD framework is, that you can get the sensor data 
> with basic tools.  What's wrong with "everything is a file"?  With a file 
> system you don't have to jump through any hoops to provide concurrent access 
> to more than one reader.  You could easily create symlinks to map sensors to 
> location.  You have means to restrict access to certain sensors. etc. ...

Actually, experience with procfs suggests that you do have to deal with these 
problems and more.  For example, cat offers quite a small read buffer on a 
file, so what should the kernel do if the read buffer is too small to hold all 
the data from a procfs file?  I.e., with /proc/pid/map?  Should it snapshot 
the state so that iterative reads work to pull out a complete snapshot, 
requiring handling of concurrency between simultaneous openers -- perhaps 
multiple snapshots at once or limiting to one reader at a time. 
Alternatively, it could truncate the read and not report an error, or fail? 
In procfs, we fail, returning an I/O error if the buffer passed by the user 
app is too small, resulting in user confusion when a process's memory mappings 
exceed default buffer sizes for common command line tools.  Instead you have 
to run 'dd if=/proc/pid/map of=/dev/stdout bs=64k" or the like.

Sysctl offers a typed data semantic and defined atomicity model, as well as a 
decent way to query how much space is needed and handle cases where not enough 
space is available.  You won't find me arguing sysctl is perfect, but it has a 
number aspects of great value.

There was a suggestion a few years ago on linux-kernel that procfs should be 
changed to export all data in XML -- on face value, that might be read as a 
rather mean joke, but really, it's quite a sensible suggestion.  You only have 
to look at the historic linprocfs/linux procfs parts to see what can go wrong 
with free-form data representation :-).

Robert N M Watson
Computer Laboratory
University of Cambridge



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071018113431.K60783>