summaryrefslogtreecommitdiff
path: root/debian/patches/fix-receiver-lookups.patch
blob: d08862a9c06e36c66c60382b694178442d71049e (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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
diff --git a/exec/Makefile b/exec/Makefile
index 3ef742d..d332f36 100644
--- a/exec/Makefile
+++ b/exec/Makefile
@@ -30,6 +30,7 @@ HURDLIBS = trivfs fshelp iohelp ports ihash shouldbeinlibc
 OTHERLIBS = -lpthread
 
 exec-MIGSFLAGS = -imacros $(srcdir)/execmutations.h
+exec_startup-MIGSFLAGS = -imacros $(srcdir)/execmutations.h
 
 include ../Makeconf
 
diff --git a/exec/exec.c b/exec/exec.c
index e693f63..935762e 100644
--- a/exec/exec.c
+++ b/exec/exec.c
@@ -1457,7 +1457,7 @@ S_exec_setexecdata (struct trivfs_protid *protid,
 /* RPC sent on the bootstrap port.  */
 
 kern_return_t
-S_exec_startup_get_info (mach_port_t port,
+S_exec_startup_get_info (struct bootinfo *boot,
 			 vm_address_t *user_entry,
 			 vm_address_t *phdr_data, vm_size_t *phdr_size,
 			 vm_address_t *stack_base, vm_size_t *stack_size,
@@ -1472,11 +1472,8 @@ S_exec_startup_get_info (mach_port_t port,
 			 mach_msg_type_number_t *nports,
 			 int **intarray, mach_msg_type_number_t *nints)
 {
-  struct bootinfo *boot = ports_lookup_port (port_bucket, port,
-					     execboot_portclass);
   if (! boot)
     return EOPNOTSUPP;
-  ports_port_deref (boot);
 
   /* Pass back all the information we are storing.  */
 
diff --git a/exec/execmutations.h b/exec/execmutations.h
index ffcba9c..2acca7a 100644
--- a/exec/execmutations.h
+++ b/exec/execmutations.h
@@ -7,4 +7,12 @@
   import "priv.h";					\
   import "../libtrivfs/mig-decls.h";			\
 
+#define EXEC_STARTUP_INTRAN                             \
+  bootinfo_t begin_using_bootinfo_port (exec_startup_t)
+#define EXEC_STARTUP_DESTRUCTOR                         \
+  end_using_bootinfo (bootinfo_t)
+#define EXEC_STARTUP_IMPORTS                            \
+  import "priv.h";                                      \
+  import "mig-decls.h";
+
 #define SERVERCOPY 1
diff --git a/exec/mig-decls.h b/exec/mig-decls.h
new file mode 100644
index 0000000..0437414
--- /dev/null
+++ b/exec/mig-decls.h
@@ -0,0 +1,40 @@
+/*
+   Copyright (C) 2014 Free Software Foundation, Inc.
+   Written by Justus Winter.
+
+   This file is part of the GNU Hurd.
+
+   The GNU Hurd is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   The GNU Hurd is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with the GNU Hurd.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef __EXEC_MIG_DECLS_H__
+#define __EXEC_MIG_DECLS_H__
+
+#include "priv.h"
+
+/* Called by server stub functions.  */
+
+static inline struct bootinfo * __attribute__ ((unused))
+begin_using_bootinfo_port (mach_port_t port)
+{
+    return ports_lookup_port (port_bucket, port, execboot_portclass);
+}
+
+static inline void __attribute__ ((unused))
+end_using_bootinfo (struct bootinfo *b)
+{
+  if (b)
+    ports_port_deref (b);
+}
+
+#endif /* __EXEC_MIG_DECLS_H__ */
diff --git a/exec/priv.h b/exec/priv.h
index 85e03ae..733f35c 100644
--- a/exec/priv.h
+++ b/exec/priv.h
@@ -52,6 +52,7 @@ struct bootinfo
     vm_address_t phdr_addr, user_entry;
     vm_size_t phdr_size;
   };
+typedef struct bootinfo *bootinfo_t;
 
 
 /* Where to put the service ports. */
@@ -151,5 +152,4 @@ extern int *std_ints;
 extern size_t std_nports, std_nints;
 extern pthread_rwlock_t std_lock;
 
-
 #endif /* exec_priv_h */
diff --git a/hurd/exec_startup.defs b/hurd/exec_startup.defs
index 9dfb79a..697f6b2 100644
--- a/hurd/exec_startup.defs
+++ b/hurd/exec_startup.defs
@@ -23,11 +23,15 @@ subsystem exec_startup 30500;
 
 #include <hurd/hurd_types.defs>
 
+#ifdef	EXEC_STARTUP_IMPORTS
+EXEC_STARTUP_IMPORTS
+#endif
+
 /* This call is made by a new task to its bootstrap port to get its
    startup ports and information.  */
 
 routine exec_startup_get_info (
-	bootstrap: mach_port_t;
+	bootstrap: exec_startup_t;
 	/* These describe the entry point and program header data
 	   of the user program loaded into the task.  */
 	out user_entry: vm_address_t;
diff --git a/hurd/hurd_types.defs b/hurd/hurd_types.defs
index 4b32504..6060fa4 100644
--- a/hurd/hurd_types.defs
+++ b/hurd/hurd_types.defs
@@ -156,6 +156,18 @@ destructor: FS_NOTIFY_DESTRUCTOR
 #endif
 ;
 
+type exec_startup_t = mach_port_copy_send_t
+#ifdef EXEC_STARTUP_INTRAN
+intran: EXEC_STARTUP_INTRAN
+#endif
+#ifdef EXEC_STARTUP_OUTTRAN
+outtran: EXEC_STARTUP_OUTTRAN
+#endif
+#ifdef EXEC_STARTUP_DESTRUCTOR
+destructor: EXEC_STARTUP_DESTRUCTOR
+#endif
+;
+
 
 type proccoll_t = mach_port_copy_send_t;
 
diff --git a/hurd/hurd_types.h b/hurd/hurd_types.h
index 7d1bb73..d569454 100644
--- a/hurd/hurd_types.h
+++ b/hurd/hurd_types.h
@@ -46,6 +46,7 @@ typedef mach_port_t pf_t;	/* Protocol family */
 typedef mach_port_t addr_port_t;
 typedef mach_port_t startup_t;
 typedef mach_port_t fs_notify_t;
+typedef mach_port_t exec_startup_t;
 typedef mach_port_t proccoll_t;
 
 #include <errno.h>		/* Defines `error_t'.  */
diff --git a/libdiskfs/Makefile b/libdiskfs/Makefile
index aeebe4e..996e86a 100644
--- a/libdiskfs/Makefile
+++ b/libdiskfs/Makefile
@@ -68,6 +68,7 @@ fsys-MIGSFLAGS = -imacros $(srcdir)/fsmutations.h -DREPLY_PORTS
 fs-MIGSFLAGS = -imacros $(srcdir)/fsmutations.h
 io-MIGSFLAGS = -imacros $(srcdir)/fsmutations.h
 ifsock-MIGSFLAGS = -imacros $(srcdir)/fsmutations.h
+exec_startup-MIGSFLAGS = -imacros $(srcdir)/fsmutations.h
 MIGCOMSFLAGS = -prefix diskfs_
 
 include ../Makeconf
diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c
index 7b8a84f..9dd2751 100644
--- a/libdiskfs/boot-start.c
+++ b/libdiskfs/boot-start.c
@@ -299,7 +299,7 @@ diskfs_start_bootstrap ()
    call (as does any task) to get its state.  We can't give it all of
    its ports (we'll provide those with a later call to exec_init).  */
 kern_return_t
-diskfs_S_exec_startup_get_info (mach_port_t port,
+diskfs_S_exec_startup_get_info (struct bootinfo *upt,
 				vm_address_t *user_entry,
 				vm_address_t *phdr_data,
 				vm_size_t *phdr_size,
@@ -322,12 +322,10 @@ diskfs_S_exec_startup_get_info (mach_port_t port,
   error_t err;
   mach_port_t *portarray, *dtable;
   mach_port_t rootport;
-  struct ufsport *upt;
   struct protid *rootpi;
   struct peropen *rootpo;
 
-  if (!(upt = ports_lookup_port (diskfs_port_bucket, port,
-				 diskfs_execboot_class)))
+  if (! upt)
     return EOPNOTSUPP;
 
   *user_entry = 0;
@@ -368,13 +366,12 @@ diskfs_S_exec_startup_get_info (mach_port_t port,
   portarray[INIT_PORT_AUTH] = MACH_PORT_NULL;
   portarray[INIT_PORT_PROC] = MACH_PORT_NULL;
   portarray[INIT_PORT_CTTYID] = MACH_PORT_NULL;
-  portarray[INIT_PORT_BOOTSTRAP] = port; /* use the same port */
+  portarray[INIT_PORT_BOOTSTRAP] = upt->pi.port_right; /* use the same port */
 
   *portarraypoly = MACH_MSG_TYPE_MAKE_SEND;
 
   *dtablepoly = MACH_MSG_TYPE_COPY_SEND;
 
-  ports_port_deref (upt);
   return 0;
 }
 
diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h
index 359b11b..2a58bda 100644
--- a/libdiskfs/diskfs.h
+++ b/libdiskfs/diskfs.h
@@ -126,6 +126,11 @@ struct diskfs_control
   struct port_info pi;
 };
 
+struct bootinfo
+{
+  struct port_info pi;
+};
+
 /* Possibly lookup types for diskfs_lookup call */
 enum lookup_type
 {
@@ -801,9 +806,11 @@ void diskfs_finish_protid (struct protid *cred, struct iouser *user);
 
 extern struct protid * diskfs_begin_using_protid_port (file_t port);
 extern struct diskfs_control * diskfs_begin_using_control_port (fsys_t port);
+extern struct bootinfo *diskfs_begin_using_bootinfo_port (exec_startup_t port);
 
 extern void diskfs_end_using_protid_port (struct protid *cred);
 extern void diskfs_end_using_control_port (struct diskfs_control *cred);
+extern void diskfs_end_using_bootinfo (struct bootinfo *upt);
 
 #if defined(__USE_EXTERN_INLINES) || defined(DISKFS_DEFINE_EXTERN_INLINE)
 
@@ -823,6 +830,14 @@ diskfs_begin_using_control_port (fsys_t port)
   return ports_lookup_port (diskfs_port_bucket, port, NULL);
 }
 
+/* And for the exec_startup interface. */
+DISKFS_EXTERN_INLINE struct bootinfo *
+diskfs_begin_using_bootinfo_port (exec_startup_t port)
+{
+  return ports_lookup_port (diskfs_port_bucket, port, diskfs_execboot_class);
+}
+
+
 /* Called by MiG after server routines have been run; this
    balances begin_using_protid_port, and is arranged for the io
    and fs interfaces by fsmutations.h. */
@@ -841,6 +856,14 @@ diskfs_end_using_control_port (struct diskfs_control *cred)
     ports_port_deref (cred);
 }
 
+/* And for the exec_startup interface. */
+DISKFS_EXTERN_INLINE void
+diskfs_end_using_bootinfo (struct bootinfo *upt)
+{
+  if (upt)
+    ports_port_deref (upt);
+}
+
 #endif /* Use extern inlines.  */
 
 /* Called when a protid CRED has no more references.  (Because references\
diff --git a/libdiskfs/fsmutations.h b/libdiskfs/fsmutations.h
index 68b6ae3..abbd643 100644
--- a/libdiskfs/fsmutations.h
+++ b/libdiskfs/fsmutations.h
@@ -30,3 +30,10 @@
 #define IO_IMPORTS import "priv.h";
 #define FSYS_IMPORTS import "priv.h";
 #define IFSOCK_IMPORTS import "priv.h";
+
+#define EXEC_STARTUP_INTRAN                             \
+  bootinfo_t begin_using_bootinfo_port (exec_startup_t)
+#define EXEC_STARTUP_DESTRUCTOR                         \
+  end_using_bootinfo (bootinfo_t)
+#define EXEC_STARTUP_IMPORTS                            \
+  import "priv.h";
diff --git a/libdiskfs/priv.h b/libdiskfs/priv.h
index b41fa43..4363a00 100644
--- a/libdiskfs/priv.h
+++ b/libdiskfs/priv.h
@@ -74,6 +74,7 @@ extern int _diskfs_diskdirty;
 /* Needed for MiG. */
 typedef struct protid *protid_t;
 typedef struct diskfs_control *control_t;
+typedef struct bootinfo *bootinfo_t;
 
 /* Actually read or write a file.  The file size must already permit
    the requested access.  NP is the file to read/write.  DATA is a buffer