From: Charles Manning Date: Thu, 21 May 2015 21:54:08 +0000 (+1200) Subject: yaffs: Add handling for . and .. at end of path X-Git-Tag: aleph1-release~28 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=1c39c5b648b8aa5d7961d10135fca68eb8069be4 yaffs: Add handling for . and .. at end of path yaffs_opendir("/nand/x/./") or yaffs_opendir("/nand/x/../") were not working, but yaffs_opendir("/nand/x/.") and yaffs_opendir("/nand/x/..") were. Make them all work. Signed-off-by: Charles Manning --- diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index cdde7ab..7afde71 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -747,7 +747,20 @@ static struct yaffs_obj *yaffsfs_FindObject(struct yaffs_obj *relDir, if (dirOut) *dirOut = dir; - if (dir && *name) + /* At this stage we have looked up directory part and have the name part + * in name if there is one. + * + * eg /nand/x/ will give us a name of "" + * /nand/x will give us a name of "x" + * + * Since the name part might be "." or ".." which need to be fixed. + */ + if (dir && (yaffs_strcmp(name, _Y("..")) == 0)) { + dir = dir->parent; + obj = dir; + } else if (dir && (yaffs_strcmp(name, _Y(".")) == 0)) + obj = dir; + else if (dir && *name) obj = yaffs_find_by_name(dir, name); else obj = dir;