* procfs/process.c (process_gc_mounts): New function. (process_symlink_make_node): Likewise. (entries): Use the new functions to provide a symlink to ../mounts. --- procfs/process.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
diff --git a/procfs/process.c b/procfs/process.c index a9b1a59..f5da0d2 100644 --- a/procfs/process.c +++ b/procfs/process.c @@ -202,6 +202,16 @@ process_file_gc_maps (struct proc_stat *ps, char **contents) return contents_len; } +static error_t +process_gc_mounts (void *hook, char **contents, ssize_t *contents_len) +{ +#define MOUNTSLINK "../mounts" + *contents = MOUNTSLINK; + *contents_len = sizeof MOUNTSLINK - 1; +#undef MOUNTSLINK + return 0; +} + static ssize_t process_file_gc_stat (struct proc_stat *ps, char **contents) { @@ -420,6 +430,14 @@ process_stat_make_node (void *dir_hook, const void *entry_hook) return np; } +static struct node * +process_symlink_make_node (void *dir_hook, const void *entry_hook) +{ + struct node *np = procfs_make_node (entry_hook, dir_hook); + if (np) + procfs_node_chtype (np, S_IFLNK); + return np; +} /* Implementation of the process directory per se. */ @@ -450,6 +468,15 @@ static struct procfs_dir_entry entries[] = { }, }, { + .name = "mounts", + .hook = & (struct procfs_node_ops) { + .get_contents = process_gc_mounts, + }, + .ops = { + .make_node = process_symlink_make_node, + }, + }, + { .name = "stat", .hook = & (struct process_file_desc) { .get_contents = process_file_gc_stat, -- 2.1.0