diff options
author | Justus Winter <justus@gnupg.org> | 2017-03-12 17:16:40 +0100 |
---|---|---|
committer | Justus Winter <justus@gnupg.org> | 2017-03-12 17:41:04 +0100 |
commit | 4089f37cdd776e046d51604041c3fe62a2bc1435 (patch) | |
tree | 22a6f3203934672fd2d02b934023c8afd241fbf5 /proc | |
parent | ef729f8642cc96ddfd3f5b5db4d6aac057b1d397 (diff) | |
download | hurd-4089f37cdd776e046d51604041c3fe62a2bc1435.tar.gz hurd-4089f37cdd776e046d51604041c3fe62a2bc1435.tar.bz2 hurd-4089f37cdd776e046d51604041c3fe62a2bc1435.zip |
Pass the kernel's task port to proc.
Previously, the early server bootstrap relied upon a specific task
layout to determine the kernels task port. Explicitly pass it from
the kernel instead.
* boot/boot.c (default_boot_script): Add '--kernel-task' parameter to
ext2fs.
(main): New bootscript variable 'kernel-task'.
* libdiskfs/boot-start.c (diskfs_kernel_task): Declaration variable.
(diskfs_start_bootstrap): If '--kernel-task' was given to us, pass it
along to startup.
* libdiskfs/opts-std-startup.c (diskfs_kernel_task): New variable.
(startup_options): Add '--kernel-task' option.
(parse_startup_opt): Handle option.
* proc/main.c (kernel_task): New variable.
(OPT_KERNEL_TASK): New macro.
(options): New variable.
(parse_opt): New function.
(main): Parse options. Use 'kernel_task' if provided.
* release/servers.boot: Add '--kernel-task' parameter to ext2fs.
* startup/startup.c (OPT_KERNEL_TASK): New macro.
(options): Add '--kernel-task' option.
(kernel_task): New variable.
(insert_ports_fnc_t): New declaration.
(run): Add argument for a function that inserts rights into the newly
created task and adds arguments to the argument vector.
(argz_task_insert_right): New function.
(proc_insert_ports): Likewise.
(parse_opt): New function.
(main): Pass the kernel's task port to proc.
(frob_kernel_process): Use the kernel's task port.
Diffstat (limited to 'proc')
-rw-r--r-- | proc/main.c | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/proc/main.c b/proc/main.c index d97650fc..e615f363 100644 --- a/proc/main.c +++ b/proc/main.c @@ -123,6 +123,32 @@ open_console (mach_port_t device_master) return 0; } + + +static task_t kernel_task; + +#define OPT_KERNEL_TASK -1 + +static struct argp_option +options[] = +{ + {"kernel-task", OPT_KERNEL_TASK, "PORT"}, + {0} +}; + +static int +parse_opt (int key, char *arg, struct argp_state *state) +{ + switch (key) + { + case OPT_KERNEL_TASK: + kernel_task = atoi (arg); + break; + default: return ARGP_ERR_UNKNOWN; + } + return 0; +} + int main (int argc, char **argv, char **envp) { @@ -131,7 +157,8 @@ main (int argc, char **argv, char **envp) void *genport; process_t startup_port; mach_port_t startup; - struct argp argp = { 0, 0, 0, "Hurd process server" }; + char **original_argv; + struct argp argp = { options, parse_opt, 0, "Hurd process server" }; argp_parse (&argp, argc, argv, 0, 0, 0); @@ -191,10 +218,15 @@ main (int argc, char **argv, char **envp) if (err && err != EPERM) error (0, err, "Increasing priority failed"); - /* Get a list of all tasks to find the kernel. */ - /* XXX: I't be nice if GNU Mach would hand us the task port. */ - add_tasks (MACH_PORT_NULL); - kernel_proc = pid_find (HURD_PID_KERNEL); + /* Find the kernel. */ + if (MACH_PORT_VALID (kernel_task)) + kernel_proc = task_find (kernel_task); + else + { + /* Get a list of all tasks to find the kernel. */ + add_tasks (MACH_PORT_NULL); + kernel_proc = pid_find (HURD_PID_KERNEL); + } /* Register for new task notifications using the kernel's process as the port. */ |