diff options
Diffstat (limited to 'libglusterfs/src/xlator.c')
| -rw-r--r-- | libglusterfs/src/xlator.c | 36 | 
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)  | 
