summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus@gnu.org>2005-07-12 15:25:49 +0000
committerMarcus Brinkmann <marcus@gnu.org>2005-07-12 15:25:49 +0000
commit0eee7f9af6d6cba106bea55a0370ef85e1a900fa (patch)
treee1f70b8655af5d2b9b1bace01f904dda60c80d2a
parent94414efd38f6a555ac97d013bd0aced76803142d (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.
-rw-r--r--trans/ChangeLog8
-rw-r--r--trans/magic.c20
2 files changed, 23 insertions, 5 deletions
diff --git a/trans/ChangeLog b/trans/ChangeLog
index 4b9e6124..94364812 100644
--- a/trans/ChangeLog
+++ b/trans/ChangeLog
@@ -1,3 +1,11 @@
+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.
+
2003-08-17 Marcus Brinkmann <marcus@gnu.org>
* fakeroot.c: Include <stddef.h>.
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);