summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2021-08-11 15:23:10 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2021-08-11 15:23:10 +0200
commit9be1e099f5343e752a9fe56fba562c4f108015e7 (patch)
tree27ab3f49e7962b90fa528c5b42906afc00ad9e73
parentf71981b762336be173e76fc40b872a9dcafc3b5f (diff)
bootstrap: Fix passing proc server from FS to rumpdisk
libdiskfs was passing its own proc port, thus confusing the fsys_init call in rumpdisk.
-rw-r--r--libdiskfs/boot-start.c40
-rw-r--r--libmachdev/trivfs_server.c12
2 files changed, 29 insertions, 23 deletions
diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c
index 0ae90144..5c4c3248 100644
--- a/libdiskfs/boot-start.c
+++ b/libdiskfs/boot-start.c
@@ -489,6 +489,7 @@ diskfs_S_fsys_init (struct diskfs_control *pt,
mach_port_t host, startup;
error_t err;
mach_port_t root_pt;
+ mach_port_t bootstrap;
struct protid *rootpi;
struct peropen *rootpo;
@@ -516,9 +517,11 @@ diskfs_S_fsys_init (struct diskfs_control *pt,
mach_port_deallocate (mach_task_self (), diskfs_auth_server_port);
diskfs_auth_server_port = authhandle;
+ err = task_get_bootstrap_port (mach_task_self (), &bootstrap);
+ assert_perror_backtrace (err);
+
if (diskfs_exec_server_task != MACH_PORT_NULL)
{
- mach_port_t bootstrap;
process_t execprocess;
err = proc_task2proc (procserver, diskfs_exec_server_task, &execprocess);
@@ -535,28 +538,15 @@ diskfs_S_fsys_init (struct diskfs_control *pt,
execprocess, MACH_MSG_TYPE_COPY_SEND));
mach_port_deallocate (mach_task_self (), execprocess);
- /* Give the real bootstrap filesystem an fsys_init RPC of its own */
- err = task_get_bootstrap_port (mach_task_self (), &bootstrap);
- assert_perror_backtrace (err);
- if (bootstrap != MACH_PORT_NULL)
- {
- err = fsys_init (bootstrap, procserver, MACH_MSG_TYPE_COPY_SEND,
- authhandle);
- mach_port_deallocate (mach_task_self (), bootstrap);
- assert_perror_backtrace (err);
- }
-
/* We don't need this anymore. */
mach_port_deallocate (mach_task_self (), diskfs_exec_server_task);
diskfs_exec_server_task = MACH_PORT_NULL;
}
else
- {
- mach_port_t bootstrap;
- process_t parent_proc;
-
- assert_backtrace (parent_task != MACH_PORT_NULL);
+ assert_backtrace (parent_task != MACH_PORT_NULL);
+ if (parent_task != MACH_PORT_NULL)
+ {
/* Tell the proc server that our parent task is our child. This
makes the process hierarchy fail to represent the real order of
who created whom, but it sets the owner and authentication ids to
@@ -568,6 +558,15 @@ diskfs_S_fsys_init (struct diskfs_control *pt,
err = proc_child (procserver, parent_task);
assert_perror_backtrace (err);
+ }
+
+ if (bootstrap != MACH_PORT_NULL)
+ {
+ /* Give our parent (the real bootstrap filesystem) an fsys_init
+ RPC of its own, as init would have sent it. */
+ process_t parent_proc;
+
+ assert_backtrace (parent_task != MACH_PORT_NULL);
/* Get the parent's proc server port so we can send it in the fsys_init
RPC just as init would. */
@@ -580,15 +579,12 @@ diskfs_S_fsys_init (struct diskfs_control *pt,
proc_mark_exec (parent_proc);
- /* Give our parent (the real bootstrap filesystem) an fsys_init
- RPC of its own, as init would have sent it. */
- err = task_get_bootstrap_port (mach_task_self (), &bootstrap);
- assert_perror_backtrace (err);
err = fsys_init (bootstrap, parent_proc, MACH_MSG_TYPE_COPY_SEND,
authhandle);
+ assert_perror_backtrace (err);
+
mach_port_deallocate (mach_task_self (), parent_proc);
mach_port_deallocate (mach_task_self (), bootstrap);
- assert_perror_backtrace (err);
}
/* Get a port to the root directory to put in the library's
diff --git a/libmachdev/trivfs_server.c b/libmachdev/trivfs_server.c
index 9c604595..5d7a1300 100644
--- a/libmachdev/trivfs_server.c
+++ b/libmachdev/trivfs_server.c
@@ -289,16 +289,26 @@ trivfs_S_fsys_init (struct trivfs_control *fsys,
retry_type retry;
string_t retry_name;
mach_port_t right = MACH_PORT_NULL;
- process_t parent_proc;
/* Traverse to the bootstrapping server first */
task_get_bootstrap_port (mach_task_self (), &bootstrap);
if (bootstrap)
{
+ process_t parent_proc;
+
err = proc_task2proc (procserver, parent_task, &parent_proc);
assert_perror_backtrace (err);
+
+ /* We don't need this anymore. */
+ mach_port_deallocate (mach_task_self (), parent_task);
+ parent_task = MACH_PORT_NULL;
+
+ proc_mark_exec(parent_proc);
+
err = fsys_init (bootstrap, parent_proc, MACH_MSG_TYPE_COPY_SEND, authhandle);
assert_perror_backtrace (err);
+
+ mach_port_deallocate (mach_task_self (), parent_proc);
}
err = fsys_getroot (control_port, MACH_PORT_NULL, MACH_MSG_TYPE_COPY_SEND,
idlist, 3, idlist, 3, 0,