From 21282c0a7bf2783c8845335fe4834b043689ef0d Mon Sep 17 00:00:00 2001 From: Raghavendra Talur Date: Thu, 18 Sep 2014 11:47:23 +0530 Subject: gfapi: Change lookup logic for "/.." and "/." . We should handle /.. and /. in unique way, otherwise we may end up setting glusterfs xattrs on parent of the brick dir. Change-Id: I206bb1751622bd912bc678fd52f4eddfd9b907c8 BUG: 1128648 Signed-off-by: Raghavendra Talur Reviewed-on: http://review.gluster.org/8455 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- api/src/glfs-resolve.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'api/src/glfs-resolve.c') 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); -- cgit