summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/src/glfs-resolve.c29
-rw-r--r--libglusterfs/src/xlator.c33
-rw-r--r--libglusterfs/src/xlator.h3
-rw-r--r--xlators/mount/fuse/src/fuse-resolve.c18
-rw-r--r--xlators/protocol/server/src/server-resolve.c14
5 files changed, 45 insertions, 52 deletions
diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c
index 9aeac57b75e..3c69d78e487 100644
--- a/api/src/glfs-resolve.c
+++ b/api/src/glfs-resolve.c
@@ -139,30 +139,15 @@ __glfs_refresh_inode (struct glfs *fs, xlator_t *subvol, inode_t *inode)
int
priv_glfs_loc_touchup (loc_t *loc)
{
- char *path = NULL;
- int ret = -1;
- char *bn = NULL;
+ int ret = 0;
- if (loc->parent)
- ret = inode_path (loc->parent, loc->name, &path);
- else
- ret = inode_path (loc->inode, 0, &path);
-
- loc->path = path;
-
- if (ret < 0 || !path) {
- ret = -1;
- errno = ENOMEM;
- goto out;
- }
+ ret = loc_touchup (loc, loc->name);
+ if (ret < 0) {
+ errno = -ret;
+ ret = -1;
+ }
- bn = strrchr (path, '/');
- if (bn)
- bn++;
- loc->name = bn;
- ret = 0;
-out:
- return ret;
+ return ret;
}
GFAPI_SYMVER_PRIVATE_DEFAULT(glfs_loc_touchup, 3.4.0);
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 */
diff --git a/xlators/mount/fuse/src/fuse-resolve.c b/xlators/mount/fuse/src/fuse-resolve.c
index 25abe162e6c..5aaa32ea660 100644
--- a/xlators/mount/fuse/src/fuse-resolve.c
+++ b/xlators/mount/fuse/src/fuse-resolve.c
@@ -33,27 +33,11 @@ fuse_resolve_loc_touchup (fuse_state_t *state)
{
fuse_resolve_t *resolve = NULL;
loc_t *loc = NULL;
- char *path = NULL;
- int ret = 0;
resolve = state->resolve_now;
loc = state->loc_now;
- if (!loc->path) {
- if (loc->parent && resolve->bname) {
- ret = inode_path (loc->parent, resolve->bname, &path);
- uuid_copy (loc->pargfid, loc->parent->gfid);
- loc->name = resolve->bname;
- } else if (loc->inode) {
- ret = inode_path (loc->inode, NULL, &path);
- uuid_copy (loc->gfid, loc->inode->gfid);
- }
- if (ret)
- gf_log (THIS->name, GF_LOG_TRACE,
- "return value inode_path %d", ret);
- loc->path = path;
- }
-
+ loc_touchup (loc, resolve->bname);
return 0;
}
diff --git a/xlators/protocol/server/src/server-resolve.c b/xlators/protocol/server/src/server-resolve.c
index 3b787c61734..9528259970a 100644
--- a/xlators/protocol/server/src/server-resolve.c
+++ b/xlators/protocol/server/src/server-resolve.c
@@ -42,19 +42,7 @@ resolve_loc_touchup (call_frame_t *frame)
resolve = state->resolve_now;
loc = state->loc_now;
- if (!loc->path) {
- if (loc->parent && resolve->bname) {
- ret = inode_path (loc->parent, resolve->bname, &path);
- loc->name = resolve->bname;
- } else if (loc->inode) {
- ret = inode_path (loc->inode, NULL, &path);
- }
- if (ret)
- gf_log (frame->this->name, GF_LOG_TRACE,
- "return value inode_path %d", ret);
- loc->path = path;
- }
-
+ loc_touchup (loc, resolve->bname);
return 0;
}