aboutsummaryrefslogtreecommitdiff
path: root/libdiskfs/boot-start.c
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2017-08-24 16:45:49 +0200
committerJustus Winter <justus@gnupg.org>2017-08-24 23:22:19 +0200
commita3254ced93e2db103d7395c4d5a727260ae69894 (patch)
treef4a0c2fb5a5517ed80a84c10dfa05b056a2263f4 /libdiskfs/boot-start.c
parent477b739fdff7b205b1b6066a2685c0924fc0ea9f (diff)
downloadhurd-a3254ced93e2db103d7395c4d5a727260ae69894.tar.gz
hurd-a3254ced93e2db103d7395c4d5a727260ae69894.tar.bz2
hurd-a3254ced93e2db103d7395c4d5a727260ae69894.zip
libdiskfs: Use control class for the singleton 'bootinfo'.
* libdiskfs/boot-start.c (bootinfo): New variable. (diskfs_start_bootstrap): Create 'bootinfo' as an instance of 'diskfs_control_class'. (diskfs_S_fsys_getpriv): Only allow operation on 'bootinfo'. (diskfs_S_fsys_init): Allow operation on any control object, but only once. * libdiskfs/diskfs.h (diskfs_initboot_class): Drop declaration. * libdiskfs/init-init.c (diskfs_initboot_class): Drop variable. (diskfs_init_diskfs): Adapt.
Diffstat (limited to 'libdiskfs/boot-start.c')
-rw-r--r--libdiskfs/boot-start.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c
index d0044478..1b76ebde 100644
--- a/libdiskfs/boot-start.c
+++ b/libdiskfs/boot-start.c
@@ -38,6 +38,10 @@
#include "fsys_S.h"
#include "fsys_reply_U.h"
+/* We use this port to communicate with startup. It is the only
+ object that fsys_getpriv and fsys_init may be invoked upon. */
+static struct port_info *bootinfo;
+
static mach_port_t diskfs_exec_ctl;
extern task_t diskfs_exec_server_task;
extern task_t diskfs_kernel_task;
@@ -104,7 +108,6 @@ diskfs_start_bootstrap ()
char *exec_argv, *exec_env;
const char *initname;
size_t exec_argvlen, exec_envlen;
- struct port_info *bootinfo;
struct protid *rootpi;
struct peropen *rootpo;
mach_port_t diskfs_exec;
@@ -282,11 +285,10 @@ diskfs_start_bootstrap ()
assert_backtrace (retry == FS_RETRY_NORMAL);
assert_backtrace (pathbuf[0] == '\0');
- err = ports_create_port (diskfs_initboot_class, diskfs_port_bucket,
+ err = ports_create_port (diskfs_control_class, diskfs_port_bucket,
sizeof (struct port_info), &bootinfo);
assert_perror_backtrace (err);
bootpt = ports_get_send_right (bootinfo);
- ports_port_deref (bootinfo);
portarray[INIT_PORT_CRDIR] = root_pt;
portarray[INIT_PORT_CWDIR] = root_pt;
@@ -461,7 +463,7 @@ diskfs_S_fsys_getpriv (struct diskfs_control *init_bootstrap_port,
error_t err;
if (!init_bootstrap_port
- || init_bootstrap_port->pi.class != diskfs_initboot_class)
+ || init_bootstrap_port != bootinfo)
return EOPNOTSUPP;
err = get_privileged_ports (host_priv, dev_master);
@@ -490,10 +492,9 @@ diskfs_S_fsys_init (struct diskfs_control *pt,
struct protid *rootpi;
struct peropen *rootpo;
- if (!pt
- || pt->pi.class != diskfs_initboot_class)
+ if (!pt)
return EOPNOTSUPP;
-
+
if (initdone)
return EOPNOTSUPP;
initdone = 1;