Re: An alternative way of populating /proc

Jamie Lokier (lk@tantalophile.demon.co.uk)
Thu, 13 Apr 2000 02:00:47 +0200


Matt Aubury wrote:
> create_proc_entries(NULL,
> "test:{bar:{x:%d,y:%d,z:%d},foo:%f}",
> &x, &y, &z, foo_fun);
>
> creates a "/proc/test" directory, which further contains a
> subdirectory "bar" and a file "foo". The "bar" subdirectory contains
> three files "x", "y" and "z".

How about this instead:

"test/{bar/{x:%d,y:%d,z:%d},foo:%f}"

Now you can apply the well known shell brace expansion rules to get:

"test/bar/x:%d"
"test/bar/y:%d"
"test/bar/z:%d"
"test/foo:%f"

...and now it's consistent with the way devfs entries are created.

(As well as being more flexible).

Though by using a bit of both, you can do another wonderful thing.
Start now with this string:

"test/{bar:{x:%d,y:%d,z:%d},foo:%f}"

That expands to:

"test/bar:x:%d"
"test/bar:y:%d"
"test/bar:z:%d"
"test/foo:%f"

Have you yet imagined the warped, but quite well supported by the kernel
thing I'm imagining? That you may call read() on "test/bar" and it will
dump the contents of x, y and z complete with a standard delimited
format, and atomic snapshot if such a thing is applicable.

have a nice day,
-- Jamie

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