fix(storage/spiffs): fix readdir setting errno on directory end (IDFGH-16698) #17789
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
spiffs_res_to_errno maps
SPIFFS_ERR_END_OF_OBJECTto EIO which breaks the common contract where errno should be 0 if readdir iterated through all the entries in a directory.The fix is explicitly checking for
SPIFFS_ERR_END_OF_OBJECTand in that case set errno to 0.Related
The issue was discovered because a c++ std::filesystem::directory_iterator on a spiffs vfs path threw an std::filesystem::filesystem_error with the following message
filesystem error: directory iterator cannot advance: I/O errorTesting
std::filesystem::directory_iterator on a spiffs vfs path now actually works without throwing exceptions
Checklist
Before submitting a Pull Request, please ensure the following: