From a25cdf135f01ebeb64a4497df1bb5146bfdc6620 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Fri, 13 Jun 2014 11:45:53 +0530 Subject: Use common loc-touchup in fuse/server/gfapi Change-Id: Id41fb29480bb6d22c34469339163da05b98c1a98 BUG: 1115907 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/8226 Reviewed-by: Shyamsundar Ranganathan Tested-by: Gluster Build System Reviewed-by: Niels de Vos Reviewed-by: Vijay Bellur --- libglusterfs/src/xlator.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'libglusterfs/src/xlator.c') diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index 3378a35d54a..23cf89af026 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -734,6 +734,39 @@ loc_gfid_utoa (loc_t *loc) return uuid_utoa (gfid); } +int +loc_touchup (loc_t *loc, const char *name) +{ + char *path = NULL; + int ret = 0; + + if (loc->path) + goto out; + + if (loc->parent && name && strlen (name)) { + ret = inode_path (loc->parent, name, &path); + if (path) /*Guaranteed to have trailing '/' */ + loc->name = strrchr (path, '/') + 1; + + if (uuid_is_null (loc->pargfid)) + uuid_copy (loc->pargfid, loc->parent->gfid); + } else if (loc->inode) { + ret = inode_path (loc->inode, 0, &path); + if (uuid_is_null (loc->gfid)) + uuid_copy (loc->gfid, loc->inode->gfid); + } + + if (ret < 0 || !path) { + ret = -ENOMEM; + goto out; + } + + loc->path = path; + ret = 0; +out: + return ret; +} + int loc_copy_overload_parent (loc_t *dst, loc_t *src, inode_t *parent) { -- cgit