diff options
author | Miles Bader <miles@gnu.org> | 1997-02-20 04:24:07 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1997-02-20 04:24:07 +0000 |
commit | a67c0017da5523aa5368e7ab161eec824cce2c06 (patch) | |
tree | 9826e6cab817bac810eab6d3f199f860e7c88ca0 | |
parent | cdbdf7f12f62eb2e6e0de9ae5726b8d9ed72e47e (diff) |
(trivfs_create_control):
Possibly allocate and add the port classes/buckets to the list of ones
recognized by trivfs.
-rw-r--r-- | libtrivfs/cntl-create.c | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/libtrivfs/cntl-create.c b/libtrivfs/cntl-create.c index dbe261b2..f103ed48 100644 --- a/libtrivfs/cntl-create.c +++ b/libtrivfs/cntl-create.c @@ -1,6 +1,6 @@ /* Create a new trivfs control port - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996, 1997 Free Software Foundation, Inc. Written by Miles Bader <miles@gnu.ai.mit.edu> @@ -33,9 +33,34 @@ trivfs_create_control (mach_port_t underlying, struct port_bucket *protid_bucket, struct trivfs_control **control) { - error_t err = - ports_create_port (control_class, control_bucket, - sizeof (struct trivfs_control), control); + error_t err; + + /* Perhaps allocate, and perhaps add the specified port classes the ones + recognized by trivfs. */ + err = trivfs_add_control_port_class (&control_class); + if (! err) + err = trivfs_add_protid_port_class (&protid_class); + else + protid_class = 0; + + /* Perhaps allocate new port buckets. */ + if (! err) + err = trivfs_add_port_bucket (&control_bucket); + else + control_bucket = 0; + if (! err) + { + if (! protid_bucket) + /* By default, use the same port bucket for both. */ + protid_bucket = control_bucket; + err = trivfs_add_port_bucket (&protid_bucket); + } + else + protid_bucket = 0; + + if (! err) + err = ports_create_port (control_class, control_bucket, + sizeof (struct trivfs_control), control); if (! err) { @@ -47,7 +72,7 @@ trivfs_create_control (mach_port_t underlying, if (err) { ports_port_deref (*control); - return err; + goto out; } err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, @@ -56,12 +81,21 @@ trivfs_create_control (mach_port_t underlying, { mach_port_destroy (mach_task_self (), (*control)->filesys_id); ports_port_deref (*control); - return err; + goto out; } (*control)->hook = 0; mutex_init (&(*control)->lock); } +out: + if (err) + { + trivfs_remove_control_port_class (control_class); + trivfs_remove_protid_port_class (protid_class); + trivfs_remove_port_bucket (control_bucket); + trivfs_remove_port_bucket (protid_bucket); + } + return err; } |