Re: An alternative way of populating /proc

Abramo Bagnara (abramo@alsa-project.org)
Sat, 15 Apr 2000 10:14:22 +0200


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

IMHO this is cleaner and easily extensible.
I think it solve all the problems noted but the type checking one.

struct proc_entry {
char *name;
int level;
uid_t owner;
gid_t group;
mode_t permission;
int type;
void (*func)(int action, void *data);
void *data;
};

static struct proc_entry entries[] __initdata = {
{ "test", 0, 0, 0, 0755, PROC_DIR, 0, 0 },
{ "bar", 1, 0, 0, 0755, PROC_DIR, 0, 0 },
{ "x", 2, 0, 0, 0644, PROC_INT, 0, &x },
{ "y", 2, 0, 0, 0644, PROC_INT, 0, &y },
{ "z", 2, 0, 0, 0644, PROC_INT, 0, &z },
{ "foo", 1, 0, 0, 0644, PROC_CUSTOM, foo_fun, &data}
};

create_proc_entries(basedir, entries, sizeof(entries) /
sizeof(*entries));

-- 
Abramo Bagnara                       mailto:abramo@alsa-project.org

Opera Unica Via Emilia Interna, 140 Phone: +39.0546.656023 48014 Castel Bolognese (RA) - Italy Fax: +39.0546.656023

ALSA project is http://www.alsa-project.org sponsored by SuSE Linux http://www.suse.com

It sounds good!

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