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 /libdiskfs/boot-start.c | |
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 'libdiskfs/boot-start.c')
-rw-r--r-- | libdiskfs/boot-start.c | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c index 0fb3e89d..f048badf 100644 --- a/libdiskfs/boot-start.c +++ b/libdiskfs/boot-start.c @@ -40,6 +40,7 @@ static mach_port_t diskfs_exec_ctl; extern task_t diskfs_exec_server_task; +extern task_t diskfs_kernel_task; static task_t parent_task = MACH_PORT_NULL; static pthread_mutex_t execstartlock; @@ -206,9 +207,6 @@ diskfs_start_bootstrap () /* We have a boot command line to run instead of init. */ err = argz_create (_diskfs_boot_command, &exec_argv, &exec_argvlen); assert_perror (err); - initname = exec_argv; - while (*initname == '/') - initname++; } else { @@ -223,10 +221,42 @@ diskfs_start_bootstrap () err = argz_add_sep (&exec_argv, &exec_argvlen, diskfs_boot_command_line, ' '); assert_perror (err); + } + + err = task_create (mach_task_self (), +#ifdef KERN_INVALID_LEDGER + NULL, 0, /* OSF Mach */ +#endif + 0, &newt); + assert_perror (err); - initname = exec_argv + 1; + if (MACH_PORT_VALID (diskfs_kernel_task)) + { + mach_port_t kernel_task_name = MACH_PORT_NULL; + char buf[20]; + int len; + + do + { + kernel_task_name += 1; + err = mach_port_insert_right (newt, kernel_task_name, + diskfs_kernel_task, MACH_MSG_TYPE_MOVE_SEND); + } + while (err == KERN_NAME_EXISTS); + diskfs_kernel_task = MACH_PORT_NULL; + + len = snprintf (buf, sizeof buf, "--kernel-task=%d", kernel_task_name); + assert (len < sizeof buf); + /* Insert as second argument. */ + err = argz_insert (&exec_argv, &exec_argvlen, + argz_next (exec_argv, exec_argvlen, exec_argv), buf); + assert_perror (err); } + initname = exec_argv; + while (*initname == '/') + initname++; + lookup_init: err = dir_lookup (root_pt, (char *) initname, O_READ, 0, &retry, pathbuf, &startup_pt); @@ -270,12 +300,6 @@ diskfs_start_bootstrap () err = argz_create (environ, &exec_env, &exec_envlen); assert_perror (err); - err = task_create (mach_task_self (), -#ifdef KERN_INVALID_LEDGER - NULL, 0, /* OSF Mach */ -#endif - 0, &newt); - assert_perror (err); if (_diskfs_boot_pause) { printf ("pausing for %s...\n", exec_argv); |