summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/main.c b/main.c
index 4350eff..e08bbdb 100644
--- a/main.c
+++ b/main.c
@@ -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 (;;)