From 51efec1a0601bbcae93a0e6af8ba1ccca619b4ef Mon Sep 17 00:00:00 2001 From: xieyangrun Date: Tue, 8 Nov 2022 19:58:43 +0800 Subject: [PATCH] fixed dfs_normalize_path. ls failure because cd ../xx on the /. --- components/dfs/src/dfs.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/components/dfs/src/dfs.c b/components/dfs/src/dfs.c index bfe9942f47..71ebc0b197 100644 --- a/components/dfs/src/dfs.c +++ b/components/dfs/src/dfs.c @@ -655,11 +655,16 @@ char *dfs_normalize_path(const char *directory, const char *filename) continue; up_one: - dst--; - if (dst < dst0) + /* keep the topmost root directory */ + if (dst - dst0 != 1 || dst[-1] != '/') { - rt_free(fullpath); - return NULL; + dst--; + + if (dst < dst0) + { + rt_free(fullpath); + return NULL; + } } while (dst0 < dst && dst[-1] != '/') dst--; -- Gitee