Messages in this thread | | | Subject | Re: procfs problems | Date | Tue, 15 Apr 1997 19:00:23 -0700 (PDT) | From | Ian Burrell <> |
| |
> > IMHO, particularly for things like /proc/cpuinfo that aren't really used > by programs, it would be nice to keep these looking neat for human > consumption (ie have the fields line up). You can probably do this > without causing too much pain for machines as well. > > If you only have one field per line, you can make your format > > <tag> ":" <arbitrary whitespace> <value> > > so > > arch: i386 > cpu: 586 > model: Pentium 75+ >
Tagged fields make alot of sense because a parsing program can easily recognize the fields it needs and ignore the rest completely. The syntax you suggest is probably best, especially since many files already use it and it is similar to mail files. More important is that whitespace be allowed before (for readability) and after the value (for padding).
What needs to be standardized for the procfs is the basic common syntax and the field names/types. Programs that read /proc data can then have a general parser that separates a file into fields. Then it can find the fields that it needs and convert the data into basic types. The atomic types could be: decimal, hex, real, string (quoted arbitrary values), and alphanumeric. We might want to come up some documentation for programmers of the standard names and types for each field in each file.
There also needs to be a syntax for tabular data. My suggestion is have the first line identify the table name and fields and each following line contain a record with each field separated by whitespace. For example:
arp(ip_addr, hw_type, flags, hw_address, mask, device) 36.178.0.1 0x1 0x2 00:00:0C:49:40:9A * eth0
This just standardizes the existing tables, some with headers and some without and names the fields.
The best way to implement this is write an interface so that most programmers don't need to worry about formatting things: print_field_alpha("cpu", "i386"); print_field_real("bogomips", bogomips);
- Ian
-- -- Ian Burrell == iburrell@leland.stanford.edu ** <URL:http://www-leland.stanford.edu/~iburrell/> Simon's Law: Everything put together falls apart sooner or later.
| |