From 6c2e3e6a651e0f507e812114ada00cc5f505b4f2 Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Wed, 3 Oct 2012 00:26:01 -0700 Subject: glfs-resolve: fix resolution of "/" Change-Id: I78d63b39dde14a9a32ea197cf0dedeb5695b35c9 BUG: 839950 Signed-off-by: Anand Avati Reviewed-on: http://review.gluster.org/4021 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi --- api/src/glfs-resolve.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'api') diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c index 181d1788875..f7754d2019b 100644 --- a/api/src/glfs-resolve.c +++ b/api/src/glfs-resolve.c @@ -109,6 +109,28 @@ out: } +void +glfs_resolve_base (struct glfs *fs, xlator_t *subvol, inode_t *inode, + struct iatt *iatt) +{ + loc_t loc = {0, }; + int ret = -1; + char *path = NULL; + + loc.inode = inode_ref (inode); + uuid_copy (loc.gfid, inode->gfid); + + ret = inode_path (loc.inode, NULL, &path); + loc.path = path; + if (ret < 0) + goto out; + + ret = syncop_lookup (subvol, &loc, NULL, iatt, NULL, NULL); +out: + loc_wipe (&loc); +} + + inode_t * glfs_resolve_component (struct glfs *fs, xlator_t *subvol, inode_t *parent, const char *component, struct iatt *iatt) @@ -208,14 +230,17 @@ glfs_resolve_at (struct glfs *fs, xlator_t *subvol, inode_t *at, } parent = NULL; - if (at && path[0] != '/') + if (at && path[0] != '/') { /* A relative resolution of a path which starts with '/' is equal to an absolute path resolution. */ inode = inode_ref (at); - else + } else { inode = inode_ref (subvol->itable->root); + glfs_resolve_base (fs, subvol, inode, &ciatt); + } + for (component = strtok_r (path, "/", &saveptr); component; component = next_component) { -- cgit