From bb8470625e8aeafb5b0162c9b476749cbca439af Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 5 May 2024 14:23:02 +0200 Subject: [PATCH] Properly fill in stat struct in dirnext implementation --- source/romfs_dev.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/source/romfs_dev.cpp b/source/romfs_dev.cpp index 3ff2cd4..1df62b9 100644 --- a/source/romfs_dev.cpp +++ b/source/romfs_dev.cpp @@ -885,9 +885,7 @@ int romfs_dirnext(struct _reent *r, DIR_ITER *dirState, char *filename, struct s if (iter->state == 0) { /* '.' entry */ - memset(filestat, 0, sizeof(*filestat)); - filestat->st_ino = dir_inode(iter->mount, iter->dir); - filestat->st_mode = romFS_dir_mode; + fillDir(filestat, iter->mount, iter->dir); strcpy(filename, "."); iter->state = 1; @@ -902,9 +900,7 @@ int romfs_dirnext(struct _reent *r, DIR_ITER *dirState, char *filename, struct s return -1; } - memset(filestat, 0, sizeof(*filestat)); - filestat->st_ino = dir_inode(iter->mount, dir); - filestat->st_mode = romFS_dir_mode; + fillDir(filestat, iter->mount, dir); strcpy(filename, ".."); iter->state = 2; @@ -922,9 +918,7 @@ int romfs_dirnext(struct _reent *r, DIR_ITER *dirState, char *filename, struct s iter->childDir = dir->sibling; - memset(filestat, 0, sizeof(*filestat)); - filestat->st_ino = dir_inode(iter->mount, dir); - filestat->st_mode = romFS_dir_mode; + fillDir(filestat, iter->mount, dir); memset(filename, 0, NAME_MAX); @@ -948,9 +942,7 @@ int romfs_dirnext(struct _reent *r, DIR_ITER *dirState, char *filename, struct s iter->childFile = file->sibling; - memset(filestat, 0, sizeof(*filestat)); - filestat->st_ino = file_inode(iter->mount, file); - filestat->st_mode = romFS_file_mode; + fillFile(filestat, iter->mount, file); memset(filename, 0, NAME_MAX);