From 11a19ce031932640584f8bc207274f4e08d97c5f Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Fri, 27 Apr 2012 18:43:23 +0530 Subject: Resolve: Assign correct path while resolving Change-Id: Ia17ff38a60225dd2e9115aaa298bed42f9e43f56 BUG: 812277 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.com/3248 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- libglusterfs/src/xlator.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'libglusterfs/src/xlator.c') diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index 1641a1909..16a931716 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -552,6 +552,42 @@ loc_wipe (loc_t *loc) memset (loc, 0, sizeof (*loc)); } +int +loc_path (loc_t *loc, const char *bname) +{ + int ret = 0; + + if (loc->path) + goto out; + + ret = -1; + + if (bname && !strlen (bname)) + bname = NULL; + + if (!bname) + goto inode_path; + + if (loc->parent && !uuid_is_null (loc->parent->gfid)) { + ret = inode_path (loc->parent, bname, (char**)&loc->path); + } else if (!uuid_is_null (loc->pargfid)) { + ret = gf_asprintf ((char**)&loc->path, INODE_PATH_FMT"/%s", + uuid_utoa (loc->pargfid), bname); + } + + if (loc->path) + goto out; + +inode_path: + if (loc->inode && !uuid_is_null (loc->inode->gfid)) { + ret = inode_path (loc->inode, NULL, (char **)&loc->path); + } else if (!uuid_is_null (loc->gfid)) { + ret = gf_asprintf ((char**)&loc->path, INODE_PATH_FMT, + uuid_utoa (loc->gfid)); + } +out: + return ret; +} int loc_copy (loc_t *dst, loc_t *src) -- cgit