diff options
author | Raghavendra G <raghavendra@gluster.com> | 2012-03-27 15:05:15 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-04-24 00:06:39 -0700 |
commit | 5d3108d182877795eab118a448d1e21f021d7d9c (patch) | |
tree | 5b92ff6fd409ac15d88ba3089e1a7b976b2f9776 /libglusterfs/src/inode.c | |
parent | 7313b22f10fafe7773a15d8306496d1d56ef5f81 (diff) |
libglusterfs/inode.c: add inode_resolve
inode_resolve takes an itable and path as arguments and returns either
NULL or the inode corresponding to the path
Change-Id: Id42d62cce6b04dbfec7d606120b09a1e54ab484e
BUG: 802905
Signed-off-by: Raghavendra G <raghavendra@gluster.com>
Reviewed-on: http://review.gluster.com/3021
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Bhat <raghavendrabhat@gluster.com>
Reviewed-by: Mohammed Junaid <junaid@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'libglusterfs/src/inode.c')
-rw-r--r-- | libglusterfs/src/inode.c | 44 |
1 files changed, 44 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) |