summaryrefslogtreecommitdiff
path: root/debian/patches/procfs-0007-procfs-provide-magic-retry-response-for-proc-self.patch
blob: abfa813696f16412428a2c5a405b09b03ae166d6 (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
From b1faf7142f061ae981f45b23d0f9731b881a622b Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Sun, 21 Sep 2014 12:03:47 +0200
Subject: [PATCH 7/7] procfs: provide magic retry response for /proc/self

* hurd/hurd_types.h: Document the magic retry string `proc/self'.
* hurd/paths.h (_HURD_MAGIC): New macro.
* procfs/main.c: Remove all code related to faking /proc/self.
* procfs/main.h: Likewise.
* procfs/rootdir.c: Likewise.  Instead, return the magic retry
response `proc/self' for the `self' node.
---
 hurd/hurd_types.h |  3 +++
 hurd/paths.h      |  1 +
 procfs/main.c     | 24 ------------------------
 procfs/main.h     |  1 -
 procfs/rootdir.c  | 23 ++++-------------------
 5 files changed, 8 insertions(+), 44 deletions(-)

diff --git a/hurd/hurd_types.h b/hurd/hurd_types.h
index 4341177..f22816d 100644
--- a/hurd/hurd_types.h
+++ b/hurd/hurd_types.h
@@ -114,6 +114,9 @@ enum retry_type
 		    as for FS_RETRY_NORMAL.
 
      "/..." means retry "...", but starting from the users root directory.
+
+     "proc/self/..." means replace `proc/self' with the PID of the current
+		     process and then retry as for FS_RETRY_NORMAL.
      */
 };
 typedef enum retry_type retry_type;
diff --git a/hurd/paths.h b/hurd/paths.h
index a13ba9b..e1b00e9 100644
--- a/hurd/paths.h
+++ b/hurd/paths.h
@@ -54,6 +54,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #define	_HURD_IFSOCK	_HURD "ifsock" /* S_IFSOCK */
 
 /* Symbolic names for all non-essential translators.  */
+#define _HURD_MAGIC	_HURD "magic"
 #define _HURD_MTAB	_HURD "mtab"
 
 #endif	/* hurd/paths.h */
diff --git a/procfs/main.c b/procfs/main.c
index 36a2d25..cec2d72 100644
--- a/procfs/main.c
+++ b/procfs/main.c
@@ -35,14 +35,12 @@
 /* Command-line options */
 int opt_clk_tck;
 mode_t opt_stat_mode;
-pid_t opt_fake_self;
 pid_t opt_kernel_pid;
 uid_t opt_anon_owner;
 
 /* Default values */
 #define OPT_CLK_TCK    sysconf(_SC_CLK_TCK)
 #define OPT_STAT_MODE  0400
-#define OPT_FAKE_SELF  -1
 #define OPT_KERNEL_PID HURD_PID_KERNEL
 #define OPT_ANON_OWNER 0
 
@@ -75,19 +73,6 @@ argp_parser (int key, char *arg, struct argp_state *state)
 	opt_stat_mode = v;
       break;
 
-    case 'S':
-      if (arg)
-        {
-	  v = strtol (arg, &endp, 0);
-	  if (*endp || ! *arg)
-	    argp_error (state, "--fake-self: PID must be an integer");
-	  else
-	    opt_fake_self = v;
-	}
-      else
-	opt_fake_self = 1;
-      break;
-
     case 'k':
       v = strtol (arg, &endp, 0);
       if (*endp || ! *arg || (signed) opt_kernel_pid < 0)
@@ -99,7 +84,6 @@ argp_parser (int key, char *arg, struct argp_state *state)
     case 'c':
       opt_clk_tck = 100;
       opt_stat_mode = 0444;
-      opt_fake_self = 1;
       break;
 
     case 'a':
@@ -149,10 +133,6 @@ struct argp_option common_options[] = {
       "You can use this option to override its mode to be more permissive "
       "for compatibility purposes.  "
       "(default: " STR (OPT_STAT_MODE) ")" },
-  { "fake-self", 'S', "PID", OPTION_ARG_OPTIONAL,
-      "Provide a fake \"self\" symlink to the given PID, for compatibility "
-      "purposes.  If PID is omitted, \"self\" will point to init.  "
-      "(default: no self link)" },
   { "kernel-process", 'k', "PID", 0,
       "Process identifier for the kernel, used to retreive its command "
       "line, as well as the global up and idle times. "
@@ -248,9 +228,6 @@ netfs_append_args (char **argz, size_t *argz_len)
   FOPT (opt_stat_mode, OPT_STAT_MODE,
         "--stat-mode=%o", opt_stat_mode);
 
-  FOPT (opt_fake_self, OPT_FAKE_SELF,
-        "--fake-self=%d", opt_fake_self);
-
   FOPT (opt_anon_owner, OPT_ANON_OWNER,
         "--anonymous-owner=%d", opt_anon_owner);
 
@@ -292,7 +269,6 @@ int main (int argc, char **argv)
 
   opt_clk_tck = OPT_CLK_TCK;
   opt_stat_mode = OPT_STAT_MODE;
-  opt_fake_self = OPT_FAKE_SELF;
   opt_kernel_pid = OPT_KERNEL_PID;
   opt_anon_owner = OPT_ANON_OWNER;
   err = argp_parse (&argp, argc, argv, 0, 0, 0);
diff --git a/procfs/main.h b/procfs/main.h
index 4e28b7e..051db95 100644
--- a/procfs/main.h
+++ b/procfs/main.h
@@ -20,6 +20,5 @@
 /* Startup options */
 extern int opt_clk_tck;
 extern mode_t opt_stat_mode;
-extern pid_t opt_fake_self;
 extern pid_t opt_kernel_pid;
 extern uid_t opt_anon_owner;
diff --git a/procfs/rootdir.c b/procfs/rootdir.c
index d68645e..d63397e 100644
--- a/procfs/rootdir.c
+++ b/procfs/rootdir.c
@@ -395,19 +395,7 @@ out:
   return err;
 }
 
-static int
-rootdir_fakeself_exists (void *dir_hook, const void *entry_hook)
-{
-  return opt_fake_self >= 0;
-}
-
-static error_t
-rootdir_gc_fakeself (void *hook, char **contents, ssize_t *contents_len)
-{
-  *contents_len = asprintf (contents, "%d", opt_fake_self);
-  return 0;
-}
-
+static struct node *rootdir_self_node;
 static struct node *rootdir_mounts_node;
 
 static error_t
@@ -624,13 +612,10 @@ rootdir_translated_node_get_translator (void *hook, char **argz,
 static const struct procfs_dir_entry rootdir_entries[] = {
   {
     .name = "self",
-    .hook = & (struct procfs_node_ops) {
-      .get_contents = rootdir_gc_fakeself,
-      .cleanup_contents = procfs_cleanup_contents_with_free,
-    },
+    .hook = ROOTDIR_DEFINE_TRANSLATED_NODE (&rootdir_self_node,
+					    _HURD_MAGIC "\0proc/self"),
     .ops = {
-      .make_node = rootdir_symlink_make_node,
-      .exists = rootdir_fakeself_exists,
+      .make_node = rootdir_make_translated_node,
     }
   },
   {
-- 
2.1.0