Linux-kernel mailing list archive 2000-15,: Re: Suggested dual human/binary interface for proc/devfs

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

Olaf Titz (olaf@bigred.inka.de)
Wed, 12 Apr 2000 12:42:47 +0200

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Olaf Titz: "Re: An alternative way of populating /proc"
- Previous message: Olaf Titz: "Re: Suggested dual human/binary interface for proc/devfs"
- Next in thread: Kelly French: "Re: Suggested dual human/binary interface for proc/devfs"
- Reply: Kelly French: "Re: Suggested dual human/binary interface for proc/devfs"

> 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/

- Next message: Olaf Titz: "Re: An alternative way of populating /proc"
- Previous message: Olaf Titz: "Re: Suggested dual human/binary interface for proc/devfs"
- Next in thread: Kelly French: "Re: Suggested dual human/binary interface for proc/devfs"
- Reply: Kelly French: "Re: Suggested dual human/binary interface for proc/devfs"