Re: PROPOSAL: dot-proc interface [was: /proc stuff]

Jakob Østergaard (jakob@unthought.net)
Tue, 6 Nov 2001 08:25:01 +0100


On Mon, Nov 05, 2001 at 02:41:12PM +0100, Petr Baudis wrote:
> Hi,
>
> > We want to avoid these problems:
> > 1) It is hard to parse (some) /proc files from userspace
> > 2) As /proc files change, parsers must be changed in userspace
> >
> > Still, we want to keep on offering
> > 3) Human readable /proc files with some amount of pretty-printing
> > 4) A /proc fs that can be changed as the kernel needs those changes
>
> I've read the whole thread, but i still don't get it. Your solution doesn't
> improve (1) for parsers in scripting languages, where it is frequently far
> easier to parse ASCII stuff than messing with binary things, when not almost
> impossible. So we don't make any progress here. And for languages like C,
> where this will have most use, there actually is solution and it is working.
> So, please, can you enlighten me, what's so wrong on sysctl? It actually
> provides exactly what do you want, and you even don't need to bother yourself
> with open() etc ;). So it would be maybe better improving sysctl interface,
> especially mirroring of all /proc stuff there, instead of arguing about scanf()
> :-).
>
> So can you please explain me merits of your approach against sysctl?

As far as I can see, I cannot read /proc/[pid]/* info using sysctl.

Then I need the other /proc/* files as well, not just /proc/sys/*

It seems to me that the sysctl interface does not have any type checking,
so if for example I want to read the jiffies counter and supply a 32-bit
field, sysctl will happily give me the first/last 32 bits of a field that
could as well be 64 bits (bit widths do sometimes change, even on architectures
that do not change). How am I to know ?

If you look in kernel/sysctl.c, you'll see code like

if (oldval && oldlenp) {
get_user(len, oldlenp);
if (len) {
if (len > table->maxlen)
len = table->maxlen;
if(copy_to_user(oldval, table->data, len))
return -EFAULT;
if(put_user(len, oldlenp))
return -EFAULT;
}
}
if (newval && newlen) {
len = newlen;
if (len > table->maxlen)
len = table->maxlen;
if(copy_from_user(table->data, newval, len))
return -EFAULT;
}

Now is that pretty or what - Imagine someone trying to configure a 64-bit
kernel parameter with a 32 bit value ;)

This could be tightened up of course - but the problem of knowing which
unit some number may be represented in is still there. For example,
assuming I could read out partition sizes, well are they in blocks, bytes,
kilobytes, or what ? Oh, I'm supposed to *know*, and *assume* such things
never change ?

-- 
................................................................
:   jakob@unthought.net   : And I see the elder races,         :
:.........................: putrid forms of man                :
:   Jakob Østergaard      : See him rise and claim the earth,  :
:        OZ9ABN           : his downfall is at hand.           :
:.........................:............{Konkhra}...............:
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/