1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
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.
Index: trans/magic.c
===================================================================
RCS file: /cvsroot/hurd/hurd/trans/magic.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- hurd/trans/magic.c 6 Mar 2003 02:24:53 -0000 1.17
+++ hurd/trans/magic.c 12 Jul 2005 15:25:49 -0000 1.18
@@ -150,6 +150,7 @@
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 @@
*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 @@
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 @@
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);
|