summaryrefslogtreecommitdiff
path: root/startup/startup.c
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2015-01-07 16:05:48 +0100
committerJustus Winter <4winter@informatik.uni-hamburg.de>2015-01-17 18:24:59 +0100
commit1ad178fd00b675d686c2560829e9a10c5cb44f6f (patch)
tree0c2924328228307558ce52ce829274de27fde755 /startup/startup.c
parent40b354e4cc67f1fedf9d4c2ce8d050a9ac68a643 (diff)
proc: call `startup_essential_task' earlier
Previously, the proc server did not call `startup_essential_task' until it got the message port of the startup server using `proc_setmsgport'. Now that we have `/servers/startup', we can do this in main, before we start our message service loop. A complication arises because the traditional startup server is single-threaded. Handle this by tweaking startup not to bind itself to `/servers/startup' before it is ready. * proc/main.c (main): Try to lookup `/servers/startup' and send the message here, or... * proc/msg.c (S_proc_setmsgport): ... fall back to the old way here. * proc/proc.h (startup_fallback): New variable. * startup/startup.c (main): Move code installing ourself on `/servers/startup' (install_as_translator): ... here. (launch_core_servers): And use it here, just before we reply to `/hurd/auth'.
Diffstat (limited to 'startup/startup.c')
-rw-r--r--startup/startup.c44
1 files changed, 32 insertions, 12 deletions
diff --git a/startup/startup.c b/startup/startup.c
index c9fe215a..e01d2a83 100644
--- a/startup/startup.c
+++ b/startup/startup.c
@@ -514,6 +514,32 @@ demuxer (mach_msg_header_t *inp,
startup_server (inp, outp));
}
+error_t
+install_as_translator (void)
+{
+ error_t err;
+ file_t node;
+
+ node = file_name_lookup (_SERVERS_STARTUP, O_NOTRANS, 0);
+ if (! MACH_PORT_VALID (node))
+ {
+ if (errno == ENOENT)
+ {
+ /* Degrade gracefully if the node does not exist. */
+ error (0, errno, "%s", _SERVERS_STARTUP);
+ return 0;
+ }
+ return errno;
+ }
+
+ err = file_set_translator (node,
+ 0, FS_TRANS_SET, 0,
+ NULL, 0,
+ startup, MACH_MSG_TYPE_COPY_SEND);
+ mach_port_deallocate (mach_task_self (), node);
+ return err;
+}
+
static int
parse_opt (int key, char *arg, struct argp_state *state)
{
@@ -587,18 +613,6 @@ main (int argc, char **argv, char **envp)
/* Crash if the boot filesystem task dies. */
request_dead_name (fstask);
- file_t node = file_name_lookup (_SERVERS_STARTUP, O_NOTRANS, 0);
- if (node == MACH_PORT_NULL)
- error (0, errno, "%s", _SERVERS_STARTUP);
- else
- {
- file_set_translator (node,
- 0, FS_TRANS_SET, 0,
- NULL, 0,
- startup, MACH_MSG_TYPE_COPY_SEND);
- mach_port_deallocate (mach_task_self (), node);
- }
-
/* Set up the set of ports we will pass to the programs we exec. */
for (i = 0; i < INIT_PORT_MAX; i++)
switch (i)
@@ -672,6 +686,12 @@ launch_core_servers (void)
proc_task2proc (procserver, authtask, &authproc);
proc_mark_important (authproc);
proc_mark_exec (authproc);
+
+ err = install_as_translator ();
+ if (err)
+ /* Good luck. Who knows, maybe it's an old installation. */
+ error (0, err, "Failed to bind to " _SERVERS_STARTUP);
+
startup_authinit_reply (authreply, authreplytype, 0, authproc,
MACH_MSG_TYPE_COPY_SEND);
mach_port_deallocate (mach_task_self (), authproc);