diff options
author | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-17 10:26:12 +0000 |
---|---|---|
committer | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-30 14:14:48 +0200 |
commit | 56ba0ac1e3a3f32763060ab862a6f0054c8a50bf (patch) | |
tree | 5d1c05531572f8eb9e3b6508714d66f4be7ae639 /main.c | |
parent | 0a4c7a1ca8bff458eb11322d2c94ec9ffd832524 (diff) | |
download | hurd-56ba0ac1e3a3f32763060ab862a6f0054c8a50bf.tar.gz hurd-56ba0ac1e3a3f32763060ab862a6f0054c8a50bf.tar.bz2 hurd-56ba0ac1e3a3f32763060ab862a6f0054c8a50bf.zip |
Implement simple directories
* procfs_dir.h: New file; declare the procfs_dir_make_node
function, based on the procfs_dir_entry structure.
* procfs_dir.c: New file; implement simple directories.
* Makefile: Add the procfs_dir module.
* main.c: Use it.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 29 |
1 files changed, 8 insertions, 21 deletions
@@ -4,32 +4,19 @@ #include <hurd/netfs.h> #include "procfs.h" #include "procfs_file.h" +#include "procfs_dir.h" -static error_t get_entries (void *hook, void **contents, size_t *contents_len) +static struct node *make_file (void *dir_hook, void *ent_hook) { - static const char entries[] = "hello"; - *contents = (void *) entries; - *contents_len = sizeof entries; - return 0; -} - -static error_t lookup (void *hook, const char *name, struct node **np) -{ - if (strcmp (name, "hello")) - return ENOENT; - - *np = procfs_file_make_node ("Hello, World!\n", -1, NULL); - if (! *np) - return ENOMEM; - - return 0; + return procfs_file_make_node (ent_hook, -1, NULL); } int main (int argc, char **argv) { - static const struct procfs_node_ops ops = { - .get_contents = get_entries, - .lookup = lookup, + static const struct procfs_dir_entry entries[] = { + { "hello", make_file, "Hello, World!\n" }, + { "goodbye", make_file, "Goodbye, cruel World!\n" }, + { } }; mach_port_t bootstrap; @@ -40,7 +27,7 @@ int main (int argc, char **argv) error (1, 0, "Must be started as a translator"); netfs_init (); - netfs_root_node = procfs_make_node (&ops, NULL); + netfs_root_node = procfs_dir_make_node (entries, NULL); netfs_startup (bootstrap, 0); for (;;) |