diff options
author | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-17 10:10:22 +0000 |
---|---|---|
committer | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-30 14:14:48 +0200 |
commit | 0a4c7a1ca8bff458eb11322d2c94ec9ffd832524 (patch) | |
tree | 645506d2f687121d88e8012d7d21f68b6de872b0 /main.c | |
parent | d938e96e59a41d5eaa11040513815b757e58eb0c (diff) |
Add a helper module for simple regular files
* procfs_file.h: New file, declares procfs_file_make_node.
* procfs_file.c: New file, implements procfs_file_make_node.
* main.c: Use them.
* Makefile: Add the procfs_file module.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 13 |
1 files changed, 2 insertions, 11 deletions
@@ -3,14 +3,7 @@ #include <argp.h> #include <hurd/netfs.h> #include "procfs.h" - -static error_t get_contents (void *hook, void **contents, size_t *contents_len) -{ - static const char hello[] = "Hello, World!\n"; - *contents = (void *) hello; - *contents_len = sizeof hello - 1; - return 0; -} +#include "procfs_file.h" static error_t get_entries (void *hook, void **contents, size_t *contents_len) { @@ -22,12 +15,10 @@ static error_t get_entries (void *hook, void **contents, size_t *contents_len) static error_t lookup (void *hook, const char *name, struct node **np) { - static const struct procfs_node_ops ops = { .get_contents = get_contents }; - if (strcmp (name, "hello")) return ENOENT; - *np = procfs_make_node (&ops, NULL); + *np = procfs_file_make_node ("Hello, World!\n", -1, NULL); if (! *np) return ENOMEM; |