diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2013-12-05 19:22:03 +0100 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2013-12-09 15:07:59 +0100 |
commit | cf1cc29af12447c347a5574b4dc1568c7db61c0b (patch) | |
tree | 730bd008e06b589c35d28fe75f7323211a0b1c07 /trans | |
parent | 64b5a0f4dde23ee9b809b909bccd4ee8637364e9 (diff) |
trans: fix the use of the hash table in fakeroot.c
Previously a pointer to the node was stored in the hash table. This
writes the locp pointer into the node object overwriting the next
pointer there. Store the pointer to the netnode instead.
* trans/fakeroot.c (struct netnode): Add field np.
(new_node): Initialize field np.
(new_node): Store nn instead of np into the hash table.
(netfs_S_dir_lookup): Adjust accordingly.
Diffstat (limited to 'trans')
-rw-r--r-- | trans/fakeroot.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/trans/fakeroot.c b/trans/fakeroot.c index 1342844b..1ab32167 100644 --- a/trans/fakeroot.c +++ b/trans/fakeroot.c @@ -41,6 +41,7 @@ static auth_t fakeroot_auth_port; struct netnode { + struct node *np; /* our node */ hurd_ihash_locp_t idport_locp;/* easy removal pointer in idport ihash */ mach_port_t idport; /* port from io_identity */ int openmodes; /* O_READ | O_WRITE | O_EXEC */ @@ -93,7 +94,7 @@ new_node (file_t file, mach_port_t idport, int locked, int openmodes, return err; } } - *np = netfs_make_node (nn); + *np = nn->np = netfs_make_node (nn); if (*np == 0) { if (locked) @@ -104,7 +105,7 @@ new_node (file_t file, mach_port_t idport, int locked, int openmodes, { if (!locked) pthread_mutex_lock (&idport_ihash_lock); - err = hurd_ihash_add (&idport_ihash, nn->idport, *np); + err = hurd_ihash_add (&idport_ihash, nn->idport, nn); if (!err) netfs_nref (*np); /* Return a reference to the caller. */ pthread_mutex_unlock (&idport_ihash_lock); @@ -122,6 +123,7 @@ new_node (file_t file, mach_port_t idport, int locked, int openmodes, void netfs_node_norefs (struct node *np) { + assert (np->nn->np == np); if (np->nn->faked != 0 && netfs_validate_stat (np, 0) == 0 && np->nn_stat.st_nlink > 0) { @@ -295,9 +297,11 @@ netfs_S_dir_lookup (struct protid *diruser, else { pthread_mutex_lock (&idport_ihash_lock); - np = hurd_ihash_find (&idport_ihash, idport); - if (np != 0) + struct netnode *nn = hurd_ihash_find (&idport_ihash, idport); + if (nn != NULL) { + assert (nn->np->nn == nn); + np = nn->np; /* We already know about this node. */ mach_port_deallocate (mach_task_self (), idport); pthread_mutex_lock (&np->lock); |