Re: An alternative way of populating /proc

From: Oliver Xymoron (oxymoron@waste.org)
Date: Thu Apr 13 2000 - 13:02:53 EST


On Wed, 12 Apr 2000, dean gaudet wrote:

> 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);

That's what the user func is for. User funcs should take two parameter
slots so you can pass:

 generic_off_t_fun, &offset

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

Drastic simplifications can often be worth giving up compiler protections.
If there are fewer places for bugs to hide...

--
 "Love the dolphins," she advised him. "Write by W.A.S.T.E.." 

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