From 3c1eac5bb047bdbaae31d3a0dcf92c6f91ee9353 Mon Sep 17 00:00:00 2001 From: KYzhang_X Date: Sun, 31 Jul 2022 22:44:59 +0800 Subject: [PATCH] vfs: fix readdir bug --- components/fs/fatfs/wrapper/tos_fatfs_vfs.c | 2 +- components/fs/vfs/tos_vfs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/fs/fatfs/wrapper/tos_fatfs_vfs.c b/components/fs/fatfs/wrapper/tos_fatfs_vfs.c index eaa59950..d021e921 100644 --- a/components/fs/fatfs/wrapper/tos_fatfs_vfs.c +++ b/components/fs/fatfs/wrapper/tos_fatfs_vfs.c @@ -220,7 +220,7 @@ static int fatfs_readdir(vfs_dir_t *dir, vfs_dirent_t *dirent) dp = (DIR *)dir->private; res = tos_f_readdir(dp, &info); - if (res != FR_OK) { + if (res != FR_OK || info.fname[0] == 0) { return -1; } diff --git a/components/fs/vfs/tos_vfs.c b/components/fs/vfs/tos_vfs.c index 01352c25..b3e070df 100644 --- a/components/fs/vfs/tos_vfs.c +++ b/components/fs/vfs/tos_vfs.c @@ -430,7 +430,7 @@ __API__ vfs_dirent_t *tos_vfs_readdir(VFS_DIR *dirp) vfs_dir_t *dir = K_NULL; vfs_inode_t *inode = K_NULL; - if (!dir) { + if (!dirp) { return K_NULL; }