summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libglusterfs/src/inode.c44
-rw-r--r--libglusterfs/src/inode.h3
2 files changed, 47 insertions, 0 deletions
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c
index 08bedf8fa3e..7a50fe22861 100644
--- a/libglusterfs/src/inode.c
+++ b/libglusterfs/src/inode.c
@@ -660,6 +660,50 @@ inode_grep (inode_table_t *table, inode_t *parent, const char *name)
return inode;
}
+
+inode_t *
+inode_resolve (inode_table_t *table, char *path)
+{
+ char *tmp = NULL, *bname = NULL, *str = NULL, *saveptr = NULL;
+ inode_t *inode = NULL, *parent = NULL;
+
+ if ((path == NULL) || (table == NULL)) {
+ goto out;
+ }
+
+ parent = inode_ref (table->root);
+ str = tmp = gf_strdup (path);
+
+ while (1) {
+ bname = strtok_r (str, "/", &saveptr);
+ if (bname == NULL) {
+ break;
+ }
+
+ if (inode != NULL) {
+ inode_unref (inode);
+ }
+
+ inode = inode_grep (table, parent, bname);
+ if (inode == NULL) {
+ break;
+ }
+
+ if (parent != NULL) {
+ inode_unref (parent);
+ }
+
+ parent = inode_ref (inode);
+ str = NULL;
+ }
+
+ inode_unref (parent);
+ GF_FREE (tmp);
+out:
+ return inode;
+}
+
+
int
inode_grep_for_gfid (inode_table_t *table, inode_t *parent, const char *name,
uuid_t gfid, ia_type_t *type)
diff --git a/libglusterfs/src/inode.h b/libglusterfs/src/inode.h
index 5dced800616..f6401c5b9b1 100644
--- a/libglusterfs/src/inode.h
+++ b/libglusterfs/src/inode.h
@@ -180,6 +180,9 @@ int
inode_ctx_del2 (inode_t *inode, xlator_t *xlator, uint64_t *value1,
uint64_t *value2);
+inode_t *
+inode_resolve (inode_table_t *table, char *path);
+
#define __inode_ctx_set(i,x,v_p) __inode_ctx_set2(i,x,v_p,0)
#define inode_ctx_set(i,x,v_p) inode_ctx_set2(i,x,v_p,0)