Re: An alternative way of populating /proc

From: dean gaudet (dgaudet-list-linux-kernel@arctic.org)
Date: Wed Apr 12 2000 - 02:46:25 EST


On Tue, 11 Apr 2000, Matt Aubury wrote:

> The recent debate about the multitude of possible formats for data in
> /proc caused me to think about a short-hand way of populating a /proc
> directory hierarchy. This scheme uses a format string to describe the
> hierarchical data layout, so:
>
> create_proc_entries(NULL,
> "test:{bar:{x:%d,y:%d,z:%d},foo:%f}",
> &x, &y, &z, foo_fun);

printf-style stuff sucks whenever you use more abstract types. for
example, try to printf() an off_t... there's no portable way to do it.
%u is right on some unixes, %qu on others. you have to resort to autoconf
or other config time tricks to create some garbage like:

    #define PRoff_t "qu"

and then make ugly printfs:

    printf("the search string was found at offset %" PRoff_t "\n", offs);

look in /usr/include/inttypes.h for examples of such defines...

i'm sure the kernel has examples of types whose size differs by arch.

also, varargs doesn't give you type-checking. printf works out fine
because gcc -Wall knows how to parse printf args. but that's quite
limiting, you can't extend it.

is the real concern codesize and you're totally willing to throw away
type checking and such?

-dean

-
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