Xiang Xiao
b33d967548
fs/tmpfs: Iterate the entry reversely in readdir
to avoid readdir return the wrong entry in the following code:
void rmdir_recursive(FAR const char *path)
{
FAR DIR *dir = opendir(path);
while (1)
{
char fullpath[MAX_PATH];
FAR dirent *ent = readdir(dir);
if (ent == NULL)
{
break;
}
sprintf(fullpath, "%s/%s", path, ent->d_name);
if (DIRENT_ISDIRECTORY(ent->d_type))
{
rmdir_recursive(fullpath);
}
else
{
unlink(fullpath);
}
}
}
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ide60fe8db6aada88ad3d8e45367f11599a6f33b1