diff options
author | Raghavendra Talur <rtalur@redhat.com> | 2014-09-18 11:47:23 +0530 |
---|---|---|
committer | Raghavendra Bhat <raghavendra@redhat.com> | 2015-01-08 01:40:12 -0800 |
commit | b55c8920b50fff18937b2ab213e2b168f534a84e (patch) | |
tree | 11f75d3288ef86c73eb57afd4e4dcb1f11f3f00d /api | |
parent | 590466375d0240abbe4a83a3ba98af44d2eac56d (diff) |
gfapi: Change lookup logic for "/.." and "/." .
Backport of http://review.gluster.org/#/c/8455
We should handle /.. and /. in unique way,
otherwise we may end up setting glusterfs xattrs
on parent of the brick dir.
Change-Id: Id317cd625436734f496852b8513f3e9dc1c4fa4e
BUG: 1179658
Signed-off-by: Raghavendra Talur <rtalur@redhat.com>
Reviewed-on: http://review.gluster.org/9403
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: soumya k <skoduri@redhat.com>
Reviewed-by: Poornima G <pgurusid@redhat.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'api')
-rw-r--r-- | api/src/glfs-resolve.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c index 7a3a0bc13c7..e3f14f9a364 100644 --- a/api/src/glfs-resolve.c +++ b/api/src/glfs-resolve.c @@ -241,17 +241,27 @@ glfs_resolve_component (struct glfs *fs, xlator_t *subvol, inode_t *parent, loc.parent = inode_ref (parent); uuid_copy (loc.pargfid, parent->gfid); - - if (strcmp (component, ".") == 0) { - loc.inode = inode_ref (parent); - } else if (strcmp (component, "..") == 0) { - if (__is_root_gfid (parent->gfid)) - /* ".." on root points to itself */ + /* /.. and /. should point back to / + we lookup using inode and gfid of root + Fill loc.name so that we make use md-cache. + md-cache is not valid for nameless lookups. + */ + if (__is_root_gfid (parent->gfid)) { + if ((strcmp (component, ".") == 0) || + (strcmp (component, "..") == 0)) { loc.inode = inode_ref (parent); - else + loc.name = "."; + } + } else { + if (strcmp (component, ".") == 0) + loc.inode = inode_ref (parent); + else if (strcmp (component, "..") == 0) loc.inode = inode_parent (parent, 0, 0); - } else - loc.inode = inode_grep (parent->table, parent, component); + else + loc.inode = inode_grep (parent->table, parent, + component); + } + if (loc.inode) { uuid_copy (loc.gfid, loc.inode->gfid); |