From 1c39c5b648b8aa5d7961d10135fca68eb8069be4 Mon Sep 17 00:00:00 2001 From: Charles Manning Date: Fri, 22 May 2015 09:54:08 +1200 Subject: [PATCH] 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 --- direct/yaffsfs.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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; -- 2.30.2