summaryrefslogtreecommitdiff
path: root/rootdir.c
diff options
context:
space:
mode:
authorJeremie Koenig <jk@jk.fr.eu.org>2010-08-23 00:55:11 +0000
committerJeremie Koenig <jk@jk.fr.eu.org>2010-08-30 14:29:50 +0200
commitaa3bac054364aa2d3614ded28df4980639184319 (patch)
tree48eb2a358aaf6bae2e3683b2fdc1d0d829459b15 /rootdir.c
parentefb8515465dcb03526a35bf87b549cac97bbab8c (diff)
Add a fake "self" symlink
* rootdir.c: Add a fake "self" symlink which always points to init.
Diffstat (limited to 'rootdir.c')
-rw-r--r--rootdir.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/rootdir.c b/rootdir.c
index 0985b63..7992844 100644
--- a/rootdir.c
+++ b/rootdir.c
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <sys/time.h>
#include <sys/utsname.h>
+#include <sys/stat.h>
#include <ps.h>
#include "procfs.h"
#include "procfs_dir.h"
@@ -130,12 +131,30 @@ rootdir_gc_loadavg (void *hook, void **contents, size_t *contents_len)
return *contents_len >= 0 ? 0 : ENOMEM;
}
+static error_t
+rootdir_gc_fakeself (void *hook, void **contents, size_t *contents_len)
+{
+ *contents = "1";
+ *contents_len = strlen (*contents);
+ return 0;
+}
+
+
static struct node *
rootdir_file_make_node (void *dir_hook, void *entry_hook)
{
return procfs_make_node (entry_hook, dir_hook);
}
+static struct node *
+rootdir_symlink_make_node (void *dir_hook, void *entry_hook)
+{
+ struct node *np = procfs_make_node (entry_hook, dir_hook);
+ if (np)
+ procfs_node_chtype (np, S_IFLNK);
+ return np;
+}
+
static struct procfs_dir_entry rootdir_entries[] = {
{
.name = "version",
@@ -169,6 +188,13 @@ static struct procfs_dir_entry rootdir_entries[] = {
.cleanup_contents = procfs_cleanup_contents_with_free,
},
},
+ {
+ .name = "self",
+ .make_node = rootdir_symlink_make_node,
+ .hook = & (struct procfs_node_ops) {
+ .get_contents = rootdir_gc_fakeself,
+ },
+ },
{}
};