diff options
author | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-23 00:55:11 +0000 |
---|---|---|
committer | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-30 14:29:50 +0200 |
commit | 6e84b8c1182013691d3629bfc08e49f81b662a2d (patch) | |
tree | 27794e0bcd216682f3ef0956b828dce88040e34c | |
parent | 880f120da999a3217079af65ce7273087e0e0eda (diff) |
Add a fake "self" symlink
* rootdir.c: Add a fake "self" symlink which always points to
init.
-rw-r--r-- | rootdir.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -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, + }, + }, {} }; |