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

From: George Bonser (grep@shorelink.com)
Date: Mon Apr 10 2000 - 23:07:13 EST


On Mon, 10 Apr 2000, Mike Porter wrote:

>
> group0 {
> item1=x;
> item2=y;
> };
> group0 { item1=x; item2=y; };
>
> group0 {
> item1=y
> item2=y
> }
>
> group1 {
> item1="a really long string..." -
> "that continues to the next line.";
> item2=b
> }

<snip>

> So, we end up with all white space except newline ignored, but we
> do have the line continuation character, which some people probably
> find annoying. At least it doesn't have to be in column 72.
>
> Mike

Well, you can do the conventional line continuation is an escaped newline

group1 {
        item1="a really long string ... \
                that continues to the next line"
}

In other words, newline OR a ; is a delimiter unless the newline is
escaped with a \ then it becomes whitespace. It and all following
whitespace are ignored. I really like the option of having EITHER a ; or a
newline.

Note that I do not thing any of this will ever be WRITTEN by a user but
intended to be read by either a user utility or a program and should be
easy to parse but COULD be understood if dumped directly to the user's
console.

Basic rules are a name of an item. If it is followed by a = it is an
attribute. If it is followed by a { it is a tag or the name of a list of
items. Of course

interfaces {}

Would be valid. It would be a list of no items. Or a tag with no
attributes. It might be parsed into XML as:

<interfaces>
</interfaces>

So imagine we have a procdump util or pd. One might say:

pd /proc/net/dev

And pd will assume it is parsing for text to a display.

pd --XML /proc/net/dev might produce output formatted in XML.
pd --HTML produces output formatted in HTML.

I think it could be quite useful for things such as grabbing
configurations to put into a database or for such utils as webmin or other
web based management tools.

The key is, of course, having a standard output format when dumping data
from /proc. As it stands now, the "Tower of Babel" system that has been
built makes any kind of standard interface for READING /proc nearly
impossible.

I also like the idea of having two interfaces ... one where you can go
completely down the tree and get the value of each item. This is
particularly useful for places where you need to write something like a 0
or a 1 AND having a "file" that gives the output of everything below it in
the tree in the above format. I suggest a name of dump for the file. As an
example, /proc/sys/net/ipv4/conf on my system might look like:

ls -l /proc/sys/net/ipv4/conf

-r-xr-xr-x 2 root root 0 Apr 10 20:59 dump
dr-xr-xr-x 2 root root 0 Apr 10 20:59 all
dr-xr-xr-x 2 root root 0 Apr 10 20:59 default
dr-xr-xr-x 2 root root 0 Apr 10 20:59 eth0
dr-xr-xr-x 2 root root 0 Apr 10 20:59 lo

cat dump

might produce this:

conf {
    all {
        accept_redirects=1
        accept_source_route=0
        bootp_relay=0
        ...
    }
    default {
        accept_redirects=1
        accept_source_route=0
        bootp_relay=0
        ...
    }
}

But if you

cd all
cat accept_redirects

you get

0

The dump files would be expected to be read only. You would have to write
the exact data item you want to write to. It can still be read as before.

-
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 : Sat Apr 15 2000 - 21:00:15 EST