From e08859424e01697fe556e277283e8e1905327ce7 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Tue, 22 Aug 2017 13:07:54 +0200 Subject: libfshelp: Use node instead of name as key. Previously, libfshelp used the name of an translator as key in the hash table. This however is flawed, because a translator is bound to a node, and a node can have zero or more links in the file system. Use the nodes address (or rather, the address of the transbox embedded in the node) as key instead. * libfshelp/fshelp.h (fshelp_set_active_translator): Instead of the control port, hand the whole transbox to the function. * libfshelp/translator-list.c (struct translator): New field 'locp'. (hash): Hash pointer. (compare): Compare pointer. (translator_ihash): Use an location pointer. (fshelp_set_active_translator): Use the address of the transbox as key. (fshelp_remove_active_translator): Remove using the location pointer. * libdiskfs/dir-lookup.c (diskfs_S_dir_lookup): Fix callsite. * libdiskfs/file-set-trans.c (diskfs_S_file_set_translator): Likewise. * libnetfs/dir-lookup.c (netfs_S_dir_lookup): Likewise. * libnetfs/file-set-translator.c (netfs_S_file_set_translator): Likewise. --- libdiskfs/dir-lookup.c | 2 +- libdiskfs/file-set-trans.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'libdiskfs') diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c index a0c368b1..eafeefc3 100644 --- a/libdiskfs/dir-lookup.c +++ b/libdiskfs/dir-lookup.c @@ -315,7 +315,7 @@ diskfs_S_dir_lookup (struct protid *dircred, err = fshelp_set_active_translator (&newpi->pi, complete_path, - np->transbox.active); + &np->transbox); if (complete_path != translator_path) free(complete_path); if (err) diff --git a/libdiskfs/file-set-trans.c b/libdiskfs/file-set-trans.c index 6a73e23c..de52ba49 100644 --- a/libdiskfs/file-set-trans.c +++ b/libdiskfs/file-set-trans.c @@ -222,7 +222,7 @@ diskfs_S_file_set_translator (struct protid *cred, pthread_mutex_unlock (&np->lock); if (! err && cred->po->path && active_flags & FS_TRANS_SET) - err = fshelp_set_active_translator (&cred->pi, cred->po->path, active); + err = fshelp_set_active_translator (&cred->pi, cred->po->path, &np->transbox); return err; } -- cgit v1.2.3