Browse Source

fixed dfs_normalize_path.
ls failure because cd ../xx on the /.

xieyangrun 2 years ago
parent
commit
51efec1a06
1 changed files with 9 additions and 4 deletions
  1. 9 4
      components/dfs/src/dfs.c

+ 9 - 4
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--;