summaryrefslogtreecommitdiff
path: root/procfs.h
diff options
context:
space:
mode:
authorJeremie Koenig <jk@jk.fr.eu.org>2010-08-17 09:43:29 +0000
committerJeremie Koenig <jk@jk.fr.eu.org>2010-08-30 14:14:42 +0200
commitd938e96e59a41d5eaa11040513815b757e58eb0c (patch)
tree38d1eb581cfeace88ebcd475b44f1a1459654392 /procfs.h
Basic infrastructure
* procfs.h: New file; basic interfaces for procfs nodes. * procfs.c: New file; implement the basic infrastructure. * netfs.c: New file; bridge libnetfs and the procfs interfaces. * main.c: New file; mostly a "Hello, World!" for now. * Makefile: New file; standalone for now.
Diffstat (limited to 'procfs.h')
-rw-r--r--procfs.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/procfs.h b/procfs.h
new file mode 100644
index 0000000..0557b6d
--- /dev/null
+++ b/procfs.h
@@ -0,0 +1,40 @@
+#include <hurd/hurd_types.h>
+#include <hurd/netfs.h>
+
+
+/* Interface for the procfs side. */
+
+/* Any of these callback functions can be omitted, in which case
+ reasonable defaults will be used. The initial file mode and type
+ depend on whether a lookup function is provided, but can be
+ overridden in update_stat(). */
+struct procfs_node_ops
+{
+ /* Fetch the contents of a node. A pointer to the contents should be
+ returned in *CONTENTS and their length in *CONTENTS_LEN. The exact
+ nature of these data depends on whether the node is a regular file,
+ symlink or directory, as determined by the file mode in
+ netnode->nn_stat. For regular files and symlinks, they are what
+ you would expect; for directories, they are an argz vector of the
+ names of the entries. */
+ error_t (*get_contents) (void *hook, void **contents, size_t *contents_len);
+ void (*cleanup_contents) (void *contents);
+
+ /* Lookup NAME in this directory, and store the result in *np. The
+ returned node should be created by lookup() using procfs_make_node()
+ or a derived function. */
+ error_t (*lookup) (void *hook, const char *name, struct node **np);
+
+ /* Destroy this node. */
+ void (*cleanup) (void *hook);
+};
+
+struct node *procfs_make_node (const struct procfs_node_ops *ops, void *hook);
+
+
+/* Interface for the libnetfs side. */
+
+error_t procfs_get_contents (struct node *np, void **data, size_t *data_len);
+error_t procfs_lookup (struct node *np, const char *name, struct node **npp);
+void procfs_cleanup (struct node *np);
+