diff options
author | Damien Zammit <damien@zamaudio.com> | 2020-07-26 17:37:20 +1000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-07-28 01:52:45 +0200 |
commit | ce016e523b8facdfc7924cf675c2d1696c7db319 (patch) | |
tree | fc61678147e8deba489a6ec4ce552222dcb81ebf /libdiskfs | |
parent | f51bc3904efe69f69f474d9922fe0ffd3fdc16ff (diff) | |
download | hurd-ce016e523b8facdfc7924cf675c2d1696c7db319.tar.gz hurd-ce016e523b8facdfc7924cf675c2d1696c7db319.tar.bz2 hurd-ce016e523b8facdfc7924cf675c2d1696c7db319.zip |
libdiskfs: Refactor fsys_startup invokation for bootstrapping
When we will have a rump translator before the root filesystem translator,
we will want to give to the former a control port on the latter.
Message-Id: <20200726073721.202405-1-damien@zamaudio.com>
Diffstat (limited to 'libdiskfs')
-rw-r--r-- | libdiskfs/init-startup.c | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/libdiskfs/init-startup.c b/libdiskfs/init-startup.c index a2e3638d..92ef8f94 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,24 +111,11 @@ 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"); - - mach_port_deallocate (mach_task_self (), bootstrap); - _diskfs_ncontrol_ports++; - + /* 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 (); } else @@ -114,6 +124,14 @@ diskfs_startup_diskfs (mach_port_t bootstrap, int flags) /* We are the bootstrap filesystem; do special boot-time setup. */ diskfs_start_bootstrap (); + + /* 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); + } } if (diskfs_default_sync_interval) |