diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-09-27 18:54:31 +0200 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-09-27 22:09:58 +0200 |
commit | a5d384c333dbbe863c1515d6167d956b0c5b4852 (patch) | |
tree | 9eea055049923c5efde3dfea51e7148e3f449d0f /exec | |
parent | 9e8cb4acfd8971f691b35657e1f63a903f638996 (diff) |
exec: convert to trivfs dynamic classes and buckets
libtrivfs contains two ways of managing more than one port class and
bucket. There is the old way of using a statically allocated array
with explicit length, and the new way with dynamically allocated
vectors.
Converting all users to the new way of handling multiple classes
and/or buckets, we can simplify the code in libtrivfs. In many cases,
the code will be simpler and more expressive for the user.
This also fixes a mild bug. The classes and buckets given to
`trivfs_startup' end up in the dynamic vectors too, making the object
lookup code use the more complicated code path.
* exec/main.c: Convert to dynamic classes and buckets.
Diffstat (limited to 'exec')
-rw-r--r-- | exec/main.c | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/exec/main.c b/exec/main.c index 6553c429..beb6f61b 100644 --- a/exec/main.c +++ b/exec/main.c @@ -38,10 +38,9 @@ int trivfs_support_read = 0; int trivfs_support_write = 0; int trivfs_allow_open = 0; -struct port_class *trivfs_protid_portclasses[1]; -struct port_class *trivfs_cntl_portclasses[1]; -int trivfs_protid_nportclasses = 1; -int trivfs_cntl_nportclasses = 1; +/* Our port classes. */ +struct port_class *trivfs_protid_class; +struct port_class *trivfs_control_class; struct trivfs_control *fsys; @@ -88,11 +87,11 @@ deadboot (void *p) munmap (boot->intarray, boot->nints * sizeof (int)); /* See if we are going away and this was the last thing keeping us up. */ - if (ports_count_class (trivfs_cntl_portclasses[0]) == 0) + if (ports_count_class (trivfs_control_class) == 0) { /* We have no fsys control port, so we are detached from the parent filesystem. Maybe we have no users left either. */ - if (ports_count_class (trivfs_protid_portclasses[0]) == 0) + if (ports_count_class (trivfs_protid_class) == 0) { /* We have no user ports left. Are we still listening for exec_startup RPCs from any tasks we already started? */ @@ -101,9 +100,9 @@ deadboot (void *p) exit (0); ports_enable_class (execboot_portclass); } - ports_enable_class (trivfs_protid_portclasses[0]); + ports_enable_class (trivfs_protid_class); } - ports_enable_class (trivfs_cntl_portclasses[0]); + ports_enable_class (trivfs_control_class); } #define OPT_DEVICE_MASTER_PORT (-1) @@ -215,15 +214,29 @@ main (int argc, char **argv) S_exec_init (below). */ procserver = getproc (); - port_bucket = ports_create_bucket (); - trivfs_cntl_portclasses[0] = ports_create_class (trivfs_clean_cntl, 0); - trivfs_protid_portclasses[0] = ports_create_class (trivfs_clean_protid, 0); + err = trivfs_add_port_bucket (&port_bucket); + if (err) + error (1, 0, "error creating port bucket"); + + err = trivfs_add_control_port_class (&trivfs_control_class); + if (err) + error (1, 0, "error creating control port class"); + + err = trivfs_add_protid_port_class (&trivfs_protid_class); + if (err) + error (1, 0, "error creating protid port class"); + execboot_portclass = ports_create_class (deadboot, NULL); /* Reply to our parent. */ err = trivfs_startup (bootstrap, 0, - trivfs_cntl_portclasses[0], port_bucket, - trivfs_protid_portclasses[0], port_bucket, + trivfs_control_class, port_bucket, + trivfs_protid_class, port_bucket, &fsys); + + /* Reply to our parent. */ + err = trivfs_startup (bootstrap, 0, + trivfs_control_class, port_bucket, + trivfs_protid_class, port_bucket, &fsys); mach_port_deallocate (mach_task_self (), bootstrap); if (err) @@ -249,11 +262,11 @@ trivfs_goaway (struct trivfs_control *fsys, int flags) int count; /* Stop new requests. */ - ports_inhibit_class_rpcs (trivfs_cntl_portclasses[0]); - ports_inhibit_class_rpcs (trivfs_protid_portclasses[0]); + ports_inhibit_class_rpcs (trivfs_control_class); + ports_inhibit_class_rpcs (trivfs_protid_class); /* Are there any extant user ports for the /servers/exec file? */ - count = ports_count_class (trivfs_protid_portclasses[0]); + count = ports_count_class (trivfs_protid_class); if (count == 0 || (flags & FSYS_GOAWAY_FORCE)) { /* No users. Disconnect from the filesystem. */ @@ -276,9 +289,9 @@ trivfs_goaway (struct trivfs_control *fsys, int flags) else { /* We won't go away, so start things going again... */ - ports_enable_class (trivfs_protid_portclasses[0]); - ports_resume_class_rpcs (trivfs_cntl_portclasses[0]); - ports_resume_class_rpcs (trivfs_protid_portclasses[0]); + ports_enable_class (trivfs_protid_class); + ports_resume_class_rpcs (trivfs_control_class); + ports_resume_class_rpcs (trivfs_protid_class); return EBUSY; } |