From 069670179c22b3c3afd075f284c80c6851221324 Mon Sep 17 00:00:00 2001 From: zhuangwei Date: Mon, 17 Jun 2024 17:15:05 +0800 Subject: [PATCH] [fix][romfs]dfs_romfs_lookup error when it needs to be a directory but it's actually a file --- components/dfs/dfs_v1/filesystems/romfs/dfs_romfs.c | 12 ++++++++++-- components/dfs/dfs_v2/filesystems/romfs/dfs_romfs.c | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/components/dfs/dfs_v1/filesystems/romfs/dfs_romfs.c b/components/dfs/dfs_v1/filesystems/romfs/dfs_romfs.c index b84c0498eb..e3dc79a6b6 100644 --- a/components/dfs/dfs_v1/filesystems/romfs/dfs_romfs.c +++ b/components/dfs/dfs_v1/filesystems/romfs/dfs_romfs.c @@ -132,8 +132,16 @@ struct romfs_dirent *dfs_romfs_lookup(struct romfs_dirent *root_dirent, const ch } else { - /* return file dirent */ - return &dirent[index]; + if(rt_strcmp(dirent[index].name, subpath) == 0) + { + /* return file dirent */ + return &dirent[index]; + } + else + { + /* It needs to be a directory but it's actually a file */ + return NULL; + } } } } diff --git a/components/dfs/dfs_v2/filesystems/romfs/dfs_romfs.c b/components/dfs/dfs_v2/filesystems/romfs/dfs_romfs.c index 7cb30b348b..0071803cfa 100644 --- a/components/dfs/dfs_v2/filesystems/romfs/dfs_romfs.c +++ b/components/dfs/dfs_v2/filesystems/romfs/dfs_romfs.c @@ -153,8 +153,16 @@ struct romfs_dirent *__dfs_romfs_lookup(struct romfs_dirent *root_dirent, const } else { - /* return file dirent */ - return &dirent[index]; + if(rt_strcmp(dirent[index].name, subpath) == 0) + { + /* return file dirent */ + return &dirent[index]; + } + else + { + /* It needs to be a directory but it's actually a file */ + return NULL; + } } } } -- Gitee