From c8856907c294327114312c87a449f2270b4a1ac5 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sun, 5 May 2002 19:31:46 +0000 Subject: 2002-05-05 Roland McGrath * fakeroot.c (netfs_attempt_lookup): Check io_identity result for our own fsys identity port; on match, look up the existing node for the port to ourselves. --- trans/fakeroot.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'trans/fakeroot.c') diff --git a/trans/fakeroot.c b/trans/fakeroot.c index 3592d720..29f39018 100644 --- a/trans/fakeroot.c +++ b/trans/fakeroot.c @@ -364,20 +364,37 @@ netfs_attempt_lookup (struct iouser *user, struct node *dir, else { mach_port_deallocate (mach_task_self (), fsidport); - mutex_lock (&idport_ihash_lock); - *np = ihash_find (&idport_ihash, idport); - if (*np != 0) + if (fsidport == netfs_fsys_identity) { - /* We already know about this node. */ + /* Talking to ourselves! We just looked up one of our own nodes. + Find the node and return it. */ + struct protid *cred = ports_lookup_port (netfs_port_bucket, file, + netfs_protid_class); mach_port_deallocate (mach_task_self (), idport); mach_port_deallocate (mach_task_self (), file); + if (cred == 0) + return EGRATUITOUS; + *np = cred->po->np; netfs_nref (*np); - mutex_unlock (&idport_ihash_lock); + ports_port_deref (cred); } else { - mutex_unlock (&idport_ihash_lock); - err = new_node (file, idport, flags, np); + mutex_lock (&idport_ihash_lock); + *np = ihash_find (&idport_ihash, idport); + if (*np != 0) + { + /* We already know about this node. */ + mach_port_deallocate (mach_task_self (), idport); + mach_port_deallocate (mach_task_self (), file); + netfs_nref (*np); + mutex_unlock (&idport_ihash_lock); + } + else + { + mutex_unlock (&idport_ihash_lock); + err = new_node (file, idport, flags, np); + } } } } -- cgit v1.2.3