From d6c99b6134f1eb90b3a8020c3538101df266e9b5 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Thu, 6 Sep 2012 00:13:04 +0530 Subject: libglusterfs/dict: make 'dict_t' a opaque object * ie, don't dereference dict_t pointer, instead use APIs everywhere * other than dict_t only 'data_t' should be the valid export from dict.h * added 'dict_foreach_fnmatch()' API * changed dict_lookup() to use data_t, instead of data_pair_t Change-Id: I400bb0dd55519a7c5d2a107e67c8e7a7207228dc Signed-off-by: Amar Tumballi BUG: 850917 Reviewed-on: http://review.gluster.org/3829 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/mount/fuse/src/fuse-bridge.c | 37 +++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'xlators/mount/fuse/src/fuse-bridge.c') diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 619f488d7..1ad774e1b 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -2871,7 +2871,6 @@ fuse_xattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, data_t *value_data = NULL; int ret = -1; int32_t len = 0; - data_pair_t *trav = NULL; state = frame->root->state; finh = state->finh; @@ -2900,25 +2899,33 @@ fuse_xattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, /* we need to invoke fuse_filter_xattr() twice. Once * while counting size and then while filling buffer */ - trav = dict->members_list; - while (trav) { - if (!fuse_filter_xattr (this, trav->key)) - len += strlen (trav->key) + 1; - trav = trav->next; - } /* while(trav) */ + int _get_total_len (dict_t *d, char *k, data_t *v, + void *tmp) + { + if (!fuse_filter_xattr (this, k)) + len += strlen (k) + 1; + return 0; + } + dict_foreach (dict, _get_total_len, NULL); + value = alloca (len + 1); if (!value) goto out; + len = 0; - trav = dict->members_list; - while (trav) { - if (!fuse_filter_xattr (this, trav->key)) { - strcpy (value + len, trav->key); - value[len + strlen (trav->key)] = '\0'; - len += strlen (trav->key) + 1; + + int _set_listxattr_keys (dict_t *d, char *k, data_t *v, + void *tmp) + { + if (!fuse_filter_xattr (this, k)) { + strcpy (value + len, k); + value[len + strlen (k)] = '\0'; + len += strlen (k) + 1; } - trav = trav->next; - } /* while(trav) */ + return 0; + } + dict_foreach (dict, _set_listxattr_keys, NULL); + send_fuse_xattr (this, finh, value, len, state->size); } /* if(state->name)...else */ } else { -- cgit