summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/xlator.c
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src/xlator.c')
-rw-r--r--libglusterfs/src/xlator.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index 49af7d2e0e6..cc4726e0ea5 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -860,9 +860,51 @@ loc_is_root (loc_t *loc)
} else if (loc && loc->inode && __is_root_gfid (loc->inode->gfid)) {
return _gf_true;
}
+
return _gf_false;
}
+int32_t
+loc_build_child (loc_t *child, loc_t *parent, char *name)
+{
+ int32_t ret = -1;
+
+ GF_VALIDATE_OR_GOTO ("xlator", child, out);
+ GF_VALIDATE_OR_GOTO ("xlator", parent, out);
+ GF_VALIDATE_OR_GOTO ("xlator", name, out);
+
+ loc_gfid (parent, child->pargfid);
+
+ if (strcmp (parent->path, "/") == 0)
+ ret = gf_asprintf ((char **)&child->path, "/%s", name);
+ else
+ ret = gf_asprintf ((char **)&child->path, "%s/%s", parent->path,
+ name);
+
+ if (ret < 0 || !child->path) {
+ ret = -1;
+ goto out;
+ }
+
+ child->name = strrchr (child->path, '/') + 1;
+
+ child->parent = inode_ref (parent->inode);
+ child->inode = inode_new (parent->inode->table);
+
+ if (!child->inode) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = 0;
+
+out:
+ if ((ret < 0) && child)
+ loc_wipe (child);
+
+ return ret;
+}
+
int
xlator_destroy (xlator_t *xl)
{