summaryrefslogtreecommitdiff
path: root/debian/patches/procfs-0006-procfs-reorganize-rootdir.c.patch
blob: 97aaf063aebb27a415026592070a4f2be59aa418 (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
From b4eb19fb7f1935b51c0335dcd1f957b38299af69 Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Fri, 19 Sep 2014 10:10:24 +0200
Subject: [PATCH 6/7] procfs: reorganize rootdir.c

* procfs/rootdir.c: Move the translator linkage code to the
appropriate location.
---
 procfs/rootdir.c | 153 ++++++++++++++++++++++++++++---------------------------
 1 file changed, 77 insertions(+), 76 deletions(-)

diff --git a/procfs/rootdir.c b/procfs/rootdir.c
index a04fb3e..d68645e 100644
--- a/procfs/rootdir.c
+++ b/procfs/rootdir.c
@@ -409,83 +409,7 @@ rootdir_gc_fakeself (void *hook, char **contents, ssize_t *contents_len)
 }
 
 static struct node *rootdir_mounts_node;
-
-/* Translator linkage.  */
-static pthread_spinlock_t rootdir_translated_node_lock =
-  PTHREAD_SPINLOCK_INITIALIZER;
-
-struct procfs_translated_node_ops
-{
-  struct procfs_node_ops node_ops;
-
-  struct node **npp;
-  char *argz;
-  size_t argz_len;
-};
-
-static struct node *
-rootdir_make_translated_node (void *dir_hook, const void *entry_hook)
-{
-  const struct procfs_translated_node_ops *ops = entry_hook;
-  struct node *np, *prev;
 
-  pthread_spin_lock (&rootdir_translated_node_lock);
-  np = *ops->npp;
-  pthread_spin_unlock (&rootdir_translated_node_lock);
-
-  if (np != NULL)
-    {
-      netfs_nref (np);
-      return np;
-    }
-
-  np = procfs_make_node (entry_hook, entry_hook);
-  if (np == NULL)
-    return NULL;
-
-  procfs_node_chtype (np, S_IFREG | S_IPTRANS);
-  procfs_node_chmod (np, 0444);
-
-  pthread_spin_lock (&rootdir_translated_node_lock);
-  prev = *ops->npp;
-  if (*ops->npp == NULL)
-    *ops->npp = np;
-  pthread_spin_unlock (&rootdir_translated_node_lock);
-
-  if (prev != NULL)
-    {
-      procfs_cleanup (np);
-      np = prev;
-    }
-
-  return np;
-}
-
-static error_t
-rootdir_translated_node_get_translator (void *hook, char **argz,
-					size_t *argz_len)
-{
-  const struct procfs_translated_node_ops *ops = hook;
-
-  *argz = malloc (ops->argz_len);
-  if (! *argz)
-    return ENOMEM;
-
-  memcpy (*argz, ops->argz, ops->argz_len);
-  *argz_len = ops->argz_len;
-  return 0;
-}
-
-#define ROOTDIR_DEFINE_TRANSLATED_NODE(NPP, ARGZ)		  \
-  &(struct procfs_translated_node_ops) {			  \
-    .node_ops = {						  \
-      .get_translator = rootdir_translated_node_get_translator,	  \
-    },								  \
-    .npp = NPP,							  \
-    .argz = (ARGZ),						  \
-    .argz_len = sizeof (ARGZ),					  \
-  }
-
 static error_t
 rootdir_gc_slabinfo (void *hook, char **contents, ssize_t *contents_len)
 {
@@ -619,7 +543,84 @@ rootdir_symlink_make_node (void *dir_hook, const void *entry_hook)
     procfs_node_chtype (np, S_IFLNK);
   return np;
 }
+
+/* Translator linkage.  */
+
+static pthread_spinlock_t rootdir_translated_node_lock =
+  PTHREAD_SPINLOCK_INITIALIZER;
+
+struct procfs_translated_node_ops
+{
+  struct procfs_node_ops node_ops;
+
+  struct node **npp;
+  char *argz;
+  size_t argz_len;
+};
+
+static struct node *
+rootdir_make_translated_node (void *dir_hook, const void *entry_hook)
+{
+  const struct procfs_translated_node_ops *ops = entry_hook;
+  struct node *np, *prev;
+
+  pthread_spin_lock (&rootdir_translated_node_lock);
+  np = *ops->npp;
+  pthread_spin_unlock (&rootdir_translated_node_lock);
+
+  if (np != NULL)
+    {
+      netfs_nref (np);
+      return np;
+    }
+
+  np = procfs_make_node (entry_hook, entry_hook);
+  if (np == NULL)
+    return NULL;
+
+  procfs_node_chtype (np, S_IFREG | S_IPTRANS);
+  procfs_node_chmod (np, 0444);
+
+  pthread_spin_lock (&rootdir_translated_node_lock);
+  prev = *ops->npp;
+  if (*ops->npp == NULL)
+    *ops->npp = np;
+  pthread_spin_unlock (&rootdir_translated_node_lock);
+
+  if (prev != NULL)
+    {
+      procfs_cleanup (np);
+      np = prev;
+    }
+
+  return np;
+}
+
+static error_t
+rootdir_translated_node_get_translator (void *hook, char **argz,
+					size_t *argz_len)
+{
+  const struct procfs_translated_node_ops *ops = hook;
 
+  *argz = malloc (ops->argz_len);
+  if (! *argz)
+    return ENOMEM;
+
+  memcpy (*argz, ops->argz, ops->argz_len);
+  *argz_len = ops->argz_len;
+  return 0;
+}
+
+#define ROOTDIR_DEFINE_TRANSLATED_NODE(NPP, ARGZ)		  \
+  &(struct procfs_translated_node_ops) {			  \
+    .node_ops = {						  \
+      .get_translator = rootdir_translated_node_get_translator,	  \
+    },								  \
+    .npp = NPP,							  \
+    .argz = (ARGZ),						  \
+    .argz_len = sizeof (ARGZ),					  \
+  }
+
 static const struct procfs_dir_entry rootdir_entries[] = {
   {
     .name = "self",
-- 
2.1.0