From c2cf3f686f3ea0efd936d2eafc404fc9d2e0acc7 Mon Sep 17 00:00:00 2001 From: Raghavendra Bhat Date: Fri, 4 May 2018 12:25:48 -0400 Subject: make posix return errors when gfid2path key is absent Change-Id: I3a8d452d00560dac5e0b7ff0b1835d1f20a59f91 updates: bz#1570962 Signed-off-by: Raghavendra Bhat --- libglusterfs/src/syncop-utils.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'libglusterfs/src/syncop-utils.c') diff --git a/libglusterfs/src/syncop-utils.c b/libglusterfs/src/syncop-utils.c index 40ced03cb45..1ccda55e4c5 100644 --- a/libglusterfs/src/syncop-utils.c +++ b/libglusterfs/src/syncop-utils.c @@ -591,9 +591,21 @@ syncop_gfid_to_path_hard (inode_table_t *itable, xlator_t *subvol, uuid_t gfid, if (ret < 0) goto out; - ret = dict_get_str (xattr, hard_resolve ? - GFID2PATH_VIRT_XATTR_KEY : GFID_TO_PATH_KEY, - &path); + + /* + * posix will do dict_set_dynstr for GFID_TO_PATH_KEY i.e. + * for in memory search for the path. And for on disk xattr + * fetching of the path for the key GFID2PATH_VIRT_XATTR_KEY + * it uses dict_set_dynptr. So, for GFID2PATH_VIRT_XATTR_KEY + * use dict_get_ptr to avoid dict complaining about type + * mismatch (i.e. str vs ptr) + */ + if (!hard_resolve) + ret = dict_get_str (xattr, GFID_TO_PATH_KEY, &path); + else + ret = dict_get_ptr (xattr, GFID2PATH_VIRT_XATTR_KEY, + (void **)&path); + if (ret || !path) { ret = -EINVAL; goto out; -- cgit