summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorRaghavendra Talur <rtalur@redhat.com>2014-09-18 11:47:23 +0530
committerVijay Bellur <vbellur@redhat.com>2014-11-13 23:34:44 -0800
commit21282c0a7bf2783c8845335fe4834b043689ef0d (patch)
treed1afb94c33a980c89f26312b857d9bd95cb0f6ca /api
parentaa0ba671f3e64858b9c93571383f2a0452eddf26 (diff)
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 <rtalur@redhat.com> Reviewed-on: http://review.gluster.org/8455 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'api')
-rw-r--r--api/src/glfs-resolve.c28
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);