1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
From 815204e71cde5b6c6e09edd8e46337f264206908 Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Fri, 19 Sep 2014 07:54:04 +0200
Subject: [PATCH 3/7] procfs: implement /proc/N/mounts
* 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
|