diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2014-06-13 11:45:53 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-03-08 08:24:39 -0700 |
commit | a25cdf135f01ebeb64a4497df1bb5146bfdc6620 (patch) | |
tree | 2e97626b7b00da7865514de86b1d712e7c372580 /libglusterfs/src | |
parent | adef0c8860f57c8137382d848244009e9a584497 (diff) |
Use common loc-touchup in fuse/server/gfapi
Change-Id: Id41fb29480bb6d22c34469339163da05b98c1a98
BUG: 1115907
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/8226
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'libglusterfs/src')
-rw-r--r-- | libglusterfs/src/xlator.c | 33 | ||||
-rw-r--r-- | libglusterfs/src/xlator.h | 3 |
2 files changed, 36 insertions, 0 deletions
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 @@ -735,6 +735,39 @@ loc_gfid_utoa (loc_t *loc) } 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) { int ret = -1; diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h index c1813abe6a2..8e52bbb3010 100644 --- a/libglusterfs/src/xlator.h +++ b/libglusterfs/src/xlator.h @@ -964,4 +964,7 @@ is_graph_topology_equal (glusterfs_graph_t *graph1, glusterfs_graph_t *graph2); int glusterfs_volfile_reconfigure (int oldvollen, FILE *newvolfile_fp, glusterfs_ctx_t *ctx, const char *oldvolfile); + +int +loc_touchup (loc_t *loc, const char *name); #endif /* _XLATOR_H */ |