diff options
author | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-18 20:44:54 +0000 |
---|---|---|
committer | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-30 14:14:49 +0200 |
commit | 56d301e212ac1964223cff8ef9c34889cb1a6e75 (patch) | |
tree | 49d27b7945c840205ef0a906fd7cc3cb25697020 /main.c | |
parent | 2fb5b93b4cd56fd68b525371ba63b0933b61d03a (diff) |
Fuse the proclist into the root node
* dircat.c, dircat.h: New files, merge directories.
* Makefile: Add the dircat module.
* main.c: Use dircat to merge the proclist into the root
directory, instead of having it as a stand-alone one.
* procfs.h, procfs.c: Add a "refresh hack" to have the
contents of the root directory recreated on each request.
* proclist.c (proclist_make_node): Enable the hack in question.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 41 |
1 files changed, 31 insertions, 10 deletions
@@ -7,25 +7,46 @@ #include "procfs_file.h" #include "procfs_dir.h" #include "proclist.h" +#include "dircat.h" -static struct node *make_file (void *dir_hook, void *ent_hook) +static struct node * +make_file (void *dir_hook, void *ent_hook) { return procfs_file_make_node (ent_hook, -1, NULL); } -static struct node *make_proclist (void *dir_hook, void *ent_hook) +error_t +root_make_node (struct node **np) { - return proclist_make_node (getproc ()); + static const struct procfs_dir_entry static_entries[] = { + { "hello", make_file, "Hello, World!\n" }, + { "goodbye", make_file, "Goodbye, cruel World!\n" }, + }; + /* We never have two root nodes alive simultaneously, so it's ok to + have this as static data. */ + static struct node *root_dirs[3]; + + root_dirs[0] = procfs_dir_make_node (static_entries, NULL, NULL); + if (! root_dirs[0]) + return ENOMEM; + + root_dirs[1] = proclist_make_node (getproc ()); + if (! root_dirs[1]) + { + netfs_nrele (root_dirs[0]); + return ENOMEM; + } + + root_dirs[2] = NULL; + *np = dircat_make_node (root_dirs); + if (! *np) + return ENOMEM; + + return 0; } int main (int argc, char **argv) { - static const struct procfs_dir_entry entries[] = { - { "hello", make_file, "Hello, World!\n" }, - { "goodbye", make_file, "Goodbye, cruel World!\n" }, - { "proclist", make_proclist, }, - { } - }; mach_port_t bootstrap; argp_parse (&netfs_std_startup_argp, argc, argv, 0, 0, 0); @@ -35,7 +56,7 @@ int main (int argc, char **argv) error (1, 0, "Must be started as a translator"); netfs_init (); - netfs_root_node = procfs_dir_make_node (entries, NULL, NULL); + root_make_node (&netfs_root_node); netfs_startup (bootstrap, 0); for (;;) |