Re: Suggested dual human/binary interface for proc/devfs

From: Alexander Viro (viro@math.psu.edu)
Date: Tue Apr 04 2000 - 17:21:57 EST


On Tue, 4 Apr 2000, Richard Gooch wrote:

> > echo 57600,8,n,1 > /dev/serial/ttyS0ctl should work.
>
> Well, time to throw back one of the old anti-devfs arguments:
> bloat. Parsing ASCII is a lot harder than dereferencing structure
> fields.

What? Excuse me, have you ever written atoi() - by hands, as a trivial
exercise? It's _one_ function. A lot harder?

> Let's also distinguish between ASCII *output* and input. ASCII output
> makes some sense, but to force everything to be input in ASCII will
> just bloat the kernel. Let's put perl into the kernel too so that
> parsing ASCII will be easier.

Richard, it's a pure bullshit.
int foo(char **p) {
        char *s=*p;
        int i;
        for(i=0;isdigit(*s);i*=10,i+=*s++-'0')
                ;
        *p=s;
        return i;
}
And yes, isdigit() is there. It's _one_ function. If you think that it's
hard - tough luck, it isn't. Comparison with Perl is somewhat, erm,
strained. We are talking about 64 bytes - compile with normal kernel flags
and use size(1). 4 cache lines. Eh, wait - what was that thing in lib/*.c?
<grepping> Aha, simple_strtoul(). In lib/vsprintf.c. So it's _ZERO_ extra
code. Where's the bloat in question? Sure, we can copy it into every
source file. The other question being, why would we do that?

> Frankly, I'm surprised that someone hasn't submitted a patch to make
> some procfs file output the right escape codes to generate a
> multi-coloured output line.
> "But it looks so *pretty*".

BS. It's not about "pretty", it's about "doesn't depend on magic constants,
is bytesex-independednt and can be used with any regular UNIX tools,
starting with echo".

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Apr 07 2000 - 21:00:13 EST