summaryrefslogtreecommitdiff
path: root/debian/patches/0011-trans-fakeroot-use-the-indirection-mechanism-for-loc.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/0011-trans-fakeroot-use-the-indirection-mechanism-for-loc.patch')
-rw-r--r--debian/patches/0011-trans-fakeroot-use-the-indirection-mechanism-for-loc.patch117
1 files changed, 117 insertions, 0 deletions
diff --git a/debian/patches/0011-trans-fakeroot-use-the-indirection-mechanism-for-loc.patch b/debian/patches/0011-trans-fakeroot-use-the-indirection-mechanism-for-loc.patch
new file mode 100644
index 00000000..b9176242
--- /dev/null
+++ b/debian/patches/0011-trans-fakeroot-use-the-indirection-mechanism-for-loc.patch
@@ -0,0 +1,117 @@
+From bf7c83d9039619d40ef4f4457a6ea4c2a7e5e7af Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Fri, 16 May 2014 12:42:01 +0200
+Subject: [PATCH 11/20] trans/fakeroot: use the indirection mechanism for locp
+ values
+
+Previously, fakeroot stored struct netnode objects in the hash table,
+and kept a pointer to the associated struct node object to get that
+object.
+
+Store the struct node objects instead using the new indirection
+mechanism in libihash.
+
+* trans/fakeroot.c (struct netnode): Drop field np.
+(idport_ihash): Use HURD_IHASH_INITIALIZER_INDIRECT.
+(new_node): Store struct node objects in the hash table.
+(set_faked_attribute): Adjust accordingly.
+(netfs_S_dir_lookup): Likewise.
+---
+ trans/fakeroot.c | 34 +++++++++++++++-------------------
+ 1 file changed, 15 insertions(+), 19 deletions(-)
+
+diff --git a/trans/fakeroot.c b/trans/fakeroot.c
+index c4b95de..ca1481b 100644
+--- a/trans/fakeroot.c
++++ b/trans/fakeroot.c
+@@ -47,7 +47,6 @@ 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 */
+@@ -64,7 +63,9 @@ struct netnode
+
+ pthread_mutex_t idport_ihash_lock = PTHREAD_MUTEX_INITIALIZER;
+ struct hurd_ihash idport_ihash
+- = HURD_IHASH_INITIALIZER (offsetof (struct netnode, idport_locp));
++ = HURD_IHASH_INITIALIZER_INDIRECT (
++ offsetof (struct node, nn),
++ offsetof (struct netnode, idport_locp));
+
+
+ /* Make a new virtual node. Always consumes the ports. If
+@@ -102,25 +103,24 @@ 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, nn);
+- if (err)
+- goto lose;
+-
+- *np = nn->np = netfs_make_node (nn);
++ *np = netfs_make_node (nn);
+ if (*np == 0)
+ {
+ err = ENOMEM;
+- goto lose_hash;
++ goto lose;
+ }
+
++ if (!locked)
++ pthread_mutex_lock (&idport_ihash_lock);
++ err = hurd_ihash_add (&idport_ihash, nn->idport, *np);
++ if (err)
++ goto lose_node;
+ pthread_mutex_lock (&(*np)->lock);
+ pthread_mutex_unlock (&idport_ihash_lock);
+ return 0;
+
+- lose_hash:
+- hurd_ihash_locp_remove (&idport_ihash, nn->idport_locp);
++ lose_node:
++ free (*np);
+ lose:
+ pthread_mutex_unlock (&idport_ihash_lock);
+ mach_port_deallocate (mach_task_self (), nn->idport);
+@@ -161,8 +161,6 @@ set_faked_attribute (struct node *np, unsigned int faked)
+ void
+ netfs_node_norefs (struct node *np)
+ {
+- assert (np->nn->np == np);
+-
+ pthread_mutex_unlock (&np->lock);
+ pthread_spin_unlock (&netfs_node_refcnt_lock);
+
+@@ -358,13 +356,12 @@ netfs_S_dir_lookup (struct protid *diruser,
+ refcount lock so that, if a node is found, its reference counter cannot
+ drop to 0 before we get our own reference. */
+ pthread_spin_lock (&netfs_node_refcnt_lock);
+- struct netnode *nn = hurd_ihash_find (&idport_ihash, idport);
+- if (nn != NULL)
++ np = hurd_ihash_find (&idport_ihash, idport);
++ if (np != NULL)
+ {
+- assert (nn->np->nn == nn);
+ /* We already know about this node. */
+
+- if (nn->np->references == 0)
++ if (np->references == 0)
+ {
+ /* But it might be in the process of being released. If so,
+ unlock the hash table to give the node a chance to actually
+@@ -376,7 +373,6 @@ netfs_S_dir_lookup (struct protid *diruser,
+ }
+
+ /* Otherwise, reference it right away. */
+- np = nn->np;
+ np->references++;
+ pthread_spin_unlock (&netfs_node_refcnt_lock);
+
+--
+2.0.0.rc0
+