Skip to content

Commit

Permalink
Changed littlefs to remove . and .. entries in readdir
Browse files Browse the repository at this point in the history
  • Loading branch information
totalspectrum committed Aug 18, 2023
1 parent 0d59a83 commit 1c95d92
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Version 6.3.1
- Added getcrc() builtin for Spin2
- Changed littlefs to not return . and .. entries in path search (so it matches host fs and FATFS)
- Fixed compilation error for object arrays in bytecode
- Fixed some quirks in the space/tab warning code

Expand Down
8 changes: 7 additions & 1 deletion include/filesys/littlefs/lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2106,6 +2106,12 @@ int lfs_dir_read(lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info) {
(void*)lfs, (void*)dir, (void*)info);
memset(info, 0, sizeof(*info));

#ifdef __FLEXC__
// leave out . and .. entries
if (dir->pos == 0 || dir->pos == 1) {
dir->pos = 2;
}
#else
// special offset for '.' and '..'
if (dir->pos == 0) {
info->type = LFS_TYPE_DIR;
Expand All @@ -2120,7 +2126,7 @@ int lfs_dir_read(lfs_t *lfs, lfs_dir_t *dir, struct lfs_info *info) {
LFS_TRACE("lfs_dir_read -> %d", true);
return true;
}

#endif
while (true) {
if (dir->id == dir->m.count) {
if (!dir->m.split) {
Expand Down

0 comments on commit 1c95d92

Please sign in to comment.