diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2005-07-12 15:25:49 +0000 |
---|---|---|
committer | Marcus Brinkmann <marcus@gnu.org> | 2005-07-12 15:25:49 +0000 |
commit | 0eee7f9af6d6cba106bea55a0370ef85e1a900fa (patch) | |
tree | e1f70b8655af5d2b9b1bace01f904dda60c80d2a /trans/magic.c | |
parent | 94414efd38f6a555ac97d013bd0aced76803142d (diff) |
2005-07-12 Marcus Brinkmann <marcus@gnu.org>
* magic.c (magic_getroot): Deallocate DOTDOT if processing here.
(magic_open): Do not allocate and deallocate DOTDOT, just consume
the reference given to us.
(magic_peropen_destroy): New function.
(main): If in directory mode, install magic_peropen_destroy hook.
Diffstat (limited to 'trans/magic.c')
-rw-r--r-- | trans/magic.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/trans/magic.c b/trans/magic.c index 2e47f911..1a8427ce 100644 --- a/trans/magic.c +++ b/trans/magic.c @@ -150,6 +150,7 @@ magic_getroot (struct trivfs_control *cntl, retry_type *do_retry, char *retry_name, mach_port_t *node, mach_msg_type_name_t *node_type) { + error_t err; struct magic *const m = cntl->hook; if (m->directory) @@ -159,6 +160,10 @@ magic_getroot (struct trivfs_control *cntl, *do_retry = FS_RETRY_MAGICAL; *node = MACH_PORT_NULL; *node_type = MACH_MSG_TYPE_COPY_SEND; + + err = mach_port_deallocate (mach_task_self (), dotdot); + assert_perror (err); + return 0; } @@ -178,18 +183,21 @@ magic_open (struct trivfs_control *cntl, error_t err = trivfs_open (cntl, user, flags, realnode, cred); if (!err) { + /* We consume the reference for DOTDOT. */ (*cred)->po->hook = (void *) dotdot; - err = mach_port_mod_refs (mach_task_self (), dotdot, - MACH_PORT_RIGHT_SEND, +1); - assert_perror (err); - err = mach_port_deallocate (mach_task_self (), dotdot); - assert_perror (err); struct magic *const m = cntl->hook; m->nusers++; } return err; } +static void +magic_peropen_destroy (struct trivfs_peropen *po) +{ + mach_port_deallocate (mach_task_self (), (mach_port_t) po->hook); +} + + /* We have this hook only for simple tracking of the live user ports. */ static void magic_protid_destroy (struct trivfs_protid *cred) @@ -467,6 +475,8 @@ main (int argc, char **argv) trivfs_getroot_hook = &magic_getroot; trivfs_open_hook = &magic_open; trivfs_protid_destroy_hook = &magic_protid_destroy; + if (m->directory) + trivfs_peropen_destroy_hook = &magic_peropen_destroy; /* Reply to our parent */ err = trivfs_startup (bootstrap, 0, 0, 0, 0, 0, &fsys); |