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

From: Olaf Titz (olaf@bigred.inka.de)
Date: Wed Apr 12 2000 - 05:42:47 EST


> And so it becomes much easier to parse, and much easier to visually
> understand, instead of a bunch of stuff indented with braces running
> down a page. Even easier would be:
>
> eth0 192.168.201.116 255.255.255.0
> eth1 192.168.201.117 255.255.255.0

_No_. This is how /proc/PID/stat, /proc/net/dev and others currently
look like, and it means that user level code will have to be adapted
whenever an item is added to the format. That is bad bad bad.

We need a tagged format, where each item is unambiguously labeled. Yes
this makes it a bit more verbose, but parsing it is just as trivial.

With this format

device=eth0;ip_address=192.168.201.116;netmask=255.255.255.0;

(note the trailing semicolon!) you can say "give me the netmask of
eth0" as

fgrep "device=eth0;" /proc/... | sed -n 's,.*;netmask=\(.*\);.*,\1,p'

in a simple, natural (to Un*xheads) way and this won't break if
sometimes the /proc entry suddenly becomes

device=eth0;mac_address=00:40:33:B0:1C:9F;ip_address=192.168.201.116;netmask=255.255.255.0;

in the next kernel version.

Olaf

-
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:18 EST