Browse Source

fix SPIFFS_readdir setting errno to SPIFFS_VIS_END

When iteration finishes, spiffs_obj_lu_find_entry_visitor returns
SPIFFS_VIS_END. Previously, SPIFFS_readdir function used to set
errno to this internal error value when readdir reached the end.
Handle this case and add a check into the regression test.
pull/288/head
Ivan Grokhotkov 2 years ago
parent
commit
1239341b0d
No known key found for this signature in database GPG Key ID: 1E050E141B280628
  1. 2
      src/spiffs_hydrogen.c
  2. 1
      src/test/test_hydrogen.c

2
src/spiffs_hydrogen.c

@ -1121,6 +1121,8 @@ struct spiffs_dirent *SPIFFS_readdir(spiffs_DIR *d, struct spiffs_dirent *e) {
d->entry = entry + 1;
e->obj_id &= ~SPIFFS_OBJ_ID_IX_FLAG;
ret = e;
} else if (res == SPIFFS_VIS_END) {
// end of iteration
} else {
d->fs->err_code = res;
}

1
src/test/test_hydrogen.c

@ -439,6 +439,7 @@ TEST(list_dir)
#endif
}
}
TEST_CHECK_EQ(SPIFFS_errno(FS), SPIFFS_OK);
SPIFFS_closedir(&d);
TEST_CHECK(found == file_cnt);

Loading…
Cancel
Save