summaryrefslogtreecommitdiff
path: root/trans
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2013-12-08 18:05:06 +0100
committerJustus Winter <4winter@informatik.uni-hamburg.de>2013-12-09 15:07:59 +0100
commit54ee5b628f8d4a1447670f65cc441fc32a9e96ef (patch)
treed80ff14632ce4eb687bd409eaee0bbe44afb106d /trans
parent672005782e57e049c7c8f4d6d0b2a80c0df512b4 (diff)
trans: return nodes locked when creating fake nodes in fakeroot
* trans/fakeroot.c (new_node): Acquire the nodes lock before releasing the idport_ihash_lock. Return nodes locked. (netfs_S_dir_lookup): Drop lock. (netfs_attempt_mkfile): Likewise. (main): Likewise.
Diffstat (limited to 'trans')
-rw-r--r--trans/fakeroot.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/trans/fakeroot.c b/trans/fakeroot.c
index b97b499e..12331047 100644
--- a/trans/fakeroot.c
+++ b/trans/fakeroot.c
@@ -61,7 +61,8 @@ struct hurd_ihash idport_ihash
= HURD_IHASH_INITIALIZER (offsetof (struct netnode, idport_locp));
-/* Make a new virtual node. Always consumes the ports. */
+/* Make a new virtual node. Always consumes the ports. If
+ successful, NP will be locked. */
static error_t
new_node (file_t file, mach_port_t idport, int locked, int openmodes,
struct node **np)
@@ -107,7 +108,10 @@ new_node (file_t file, mach_port_t idport, int locked, int openmodes,
pthread_mutex_lock (&idport_ihash_lock);
err = hurd_ihash_add (&idport_ihash, nn->idport, nn);
if (!err)
- netfs_nref (*np); /* Return a reference to the caller. */
+ {
+ pthread_mutex_lock (&(*np)->lock);
+ netfs_nref (*np); /* Return a reference to the caller. */
+ }
pthread_mutex_unlock (&idport_ihash_lock);
}
if (err)
@@ -330,7 +334,10 @@ netfs_S_dir_lookup (struct protid *diruser,
{
err = new_node (file, idport, 1, flags, &np);
if (!err)
- err = netfs_validate_stat (np, diruser->user);
+ {
+ pthread_mutex_unlock (&np->lock);
+ err = netfs_validate_stat (np, diruser->user);
+ }
}
}
}
@@ -616,6 +623,8 @@ netfs_attempt_mkfile (struct iouser *user, struct node *dir,
real_from_fake_mode (mode), &newfile);
if (err == 0)
err = new_node (newfile, MACH_PORT_NULL, 0, O_RDWR|O_EXEC, np);
+ if (err == 0)
+ pthread_mutex_unlock (&(*np)->lock);
pthread_mutex_unlock (&dir->lock);
return err;
}
@@ -962,6 +971,7 @@ any user to open nodes regardless of permissions as is done for root." };
netfs_root_node->nn_stat.st_mode &= ~(S_IPTRANS | S_IATRANS);
netfs_root_node->nn_stat.st_mode |= S_IROOT;
netfs_root_node->nn->faked |= FAKE_MODE;
+ pthread_mutex_unlock (&netfs_root_node->lock);
netfs_server_loop (); /* Never returns. */