bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] libdiskfs: Refactor fsys_startup invokation for bootstrappin


From: Damien Zammit
Subject: [PATCH 1/2] libdiskfs: Refactor fsys_startup invokation for bootstrapping
Date: Sun, 26 Jul 2020 17:37:20 +1000

---
 libdiskfs/boot-start.c   | 11 +++++++
 libdiskfs/init-startup.c | 64 +++++++++++++++++++++++++---------------
 2 files changed, 52 insertions(+), 23 deletions(-)

diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c
index 29b8acc6..4fbd62c5 100644
--- a/libdiskfs/boot-start.c
+++ b/libdiskfs/boot-start.c
@@ -518,7 +518,9 @@ diskfs_S_fsys_init (struct diskfs_control *pt,
 
   if (diskfs_exec_server_task != MACH_PORT_NULL)
     {
+      mach_port_t bootstrap;
       process_t execprocess;
+
       err = proc_task2proc (procserver, diskfs_exec_server_task, &execprocess);
       assert_perror_backtrace (err);
 
@@ -531,7 +533,16 @@ diskfs_S_fsys_init (struct diskfs_control *pt,
       HURD_PORT_USE (&_diskfs_exec_portcell,
                     exec_init (port, authhandle,
                                execprocess, MACH_MSG_TYPE_COPY_SEND));
+
+      /* Give 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, execprocess, MACH_MSG_TYPE_COPY_SEND,
+                      authhandle);
       mach_port_deallocate (mach_task_self (), execprocess);
+      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);
diff --git a/libdiskfs/init-startup.c b/libdiskfs/init-startup.c
index a2e3638d..d28a49a1 100644
--- a/libdiskfs/init-startup.c
+++ b/libdiskfs/init-startup.c
@@ -32,12 +32,35 @@
 
 char *_diskfs_chroot_directory;
 
-mach_port_t
-diskfs_startup_diskfs (mach_port_t bootstrap, int flags)
+static void
+diskfs_call_fsys_startup (mach_port_t bootstrap, int flags,
+                          mach_port_t *realnode)
 {
   error_t err;
-  mach_port_t realnode, right;
   struct port_info *newpi;
+  mach_port_t right;
+
+  err = ports_create_port (diskfs_control_class, diskfs_port_bucket,
+                           sizeof (struct port_info), &newpi);
+  if (! err)
+    {
+      right = ports_get_send_right (newpi);
+      err = fsys_startup (bootstrap, flags, right,
+                          MACH_MSG_TYPE_COPY_SEND, realnode);
+      mach_port_deallocate (mach_task_self (), right);
+      ports_port_deref (newpi);
+    }
+  if (err)
+    error (1, err, "Translator startup failure: fsys_startup");
+
+  _diskfs_ncontrol_ports++;
+}
+
+mach_port_t
+diskfs_startup_diskfs (mach_port_t fs_bootstrap, int flags)
+{
+  error_t err;
+  mach_port_t realnode, bootstrap;
 
   if (_diskfs_chroot_directory != NULL)
     {
@@ -88,32 +111,27 @@ diskfs_startup_diskfs (mach_port_t bootstrap, int flags)
       diskfs_nput (old);
     }
 
-  if (bootstrap != MACH_PORT_NULL)
+  if (fs_bootstrap == MACH_PORT_NULL)
     {
-      err = ports_create_port (diskfs_control_class, diskfs_port_bucket,
-                              sizeof (struct port_info), &newpi);
-      if (! err)
-       {
-         right = ports_get_send_right (newpi);
-         err = fsys_startup (bootstrap, flags, right,
-                             MACH_MSG_TYPE_COPY_SEND, &realnode);
-         mach_port_deallocate (mach_task_self (), right);
-         ports_port_deref (newpi);
-       }
-      if (err)
-        error (1, err, "Translator startup failure: fsys_startup");
+      realnode = MACH_PORT_NULL;
 
-      mach_port_deallocate (mach_task_self (), bootstrap);
-      _diskfs_ncontrol_ports++;
+      /* We are the bootstrap filesystem; do special boot-time setup.  */
+      diskfs_start_bootstrap ();
 
-      _diskfs_init_completed ();
+      /* If we have a bootstrap port we must call fsys_startup */
+      task_get_bootstrap_port (mach_task_self (), &bootstrap);
+      if (bootstrap != MACH_PORT_NULL)
+        {
+          diskfs_call_fsys_startup (bootstrap, flags, &realnode);
+          mach_port_deallocate (mach_task_self (), bootstrap);
+        }
     }
   else
     {
-      realnode = MACH_PORT_NULL;
-
-      /* We are the bootstrap filesystem; do special boot-time setup.  */
-      diskfs_start_bootstrap ();
+      /* We do the startup from filesystem's bootstrap */
+      diskfs_call_fsys_startup (fs_bootstrap, flags, &realnode);
+      mach_port_deallocate (mach_task_self (), fs_bootstrap);
+      _diskfs_init_completed ();
     }
 
   if (diskfs_default_sync_interval)
-- 
2.25.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]