incubator-nuttx/fs/tmpfs
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
2021-01-21 15:07:01 -03:00
..
Kconfig Fix typos in comments and documentation (#750) 2020-04-08 06:45:35 -06:00
Make.defs Change all 'Nuttx' to 'NuttX' 2020-10-20 01:45:06 -07:00
fs_tmpfs.c fs/tmpfs: Iterate the entry reversely in readdir 2021-01-21 15:07:01 -03:00
fs_tmpfs.h fix nxstyle warning 2020-07-10 21:30:02 +01:00