From 1a2f51144fcbd920a6f3769d6b2f3ceeefdc220d Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Thu, 14 Nov 2013 17:10:09 +0530 Subject: core: add dht_is_linkfile helper procedure. components other than distribute (like marker to exclude linkfiles from being accounted) also need awareness of what constitutes a linkfile. Hence its good to separate out this functionality into core. Change-Id: Ib944eeacc991bb1de464c9e73ee409fc7a689ff1 BUG: 1022995 Signed-off-by: Raghavendra G Reviewed-on: http://review.gluster.org/6152 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- libglusterfs/src/common-utils.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'libglusterfs/src/common-utils.c') diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index cb51dd175..08efb5c9f 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -3111,3 +3111,34 @@ out: fclose (file); return running; } + +static inline int +dht_is_linkfile_key (dict_t *this, char *key, data_t *value, void *data) +{ + gf_boolean_t *linkfile_key_found = NULL; + + if (!data) + goto out; + + linkfile_key_found = data; + + *linkfile_key_found = _gf_true; +out: + return 0; +} + + +inline gf_boolean_t +dht_is_linkfile (struct iatt *buf, dict_t *dict) +{ + gf_boolean_t linkfile_key_found = _gf_false; + + if (!IS_DHT_LINKFILE_MODE (buf)) + return _gf_false; + + dict_foreach_fnmatch (dict, "*."DHT_LINKFILE_STR, dht_is_linkfile_key, + &linkfile_key_found); + + return linkfile_key_found; +} + -- cgit