summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/xlator.c
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2012-04-27 18:43:23 +0530
committerAnand Avati <avati@redhat.com>2012-05-08 13:39:01 -0700
commit11a19ce031932640584f8bc207274f4e08d97c5f (patch)
treeee5a986280dfaac50c5868e38d28fdde13123a9a /libglusterfs/src/xlator.c
parentf233e26f99decc0b2552ed10cd81c30c684139ac (diff)
Resolve: Assign correct path while resolving
Change-Id: Ia17ff38a60225dd2e9115aaa298bed42f9e43f56 BUG: 812277 Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Reviewed-on: http://review.gluster.com/3248 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'libglusterfs/src/xlator.c')
-rw-r--r--libglusterfs/src/xlator.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index 1641a1909f6..16a931716f5 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)