-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Seek mode "SeekEnd" attempts to read outside of file #11
Comments
Of course this can be easiely worked around using |
esp8266/Arduino#7323 |
Thank you :) 👍 For the PR you linked, this part from line 376 of LittleFS.h is interesting: int32_t offset = static_cast<int32_t>(pos);
if (mode == SeekEnd) {
offset = -offset; // TODO - this seems like its plain wrong vs. POSIX
} That seems to explain what the 8266 guys have done differently - that comment indicates that they were also in doubt how to implement it properly. |
Yes, I see same thing.
This change of esp_littlefs.c seems to fix it, I just checked on your example |
i'll implement it soon, just double checking thats absolutely what we want to do. Looking at upstream littlefs code, it seems like we do want to make the offset negative, just double checking that everything is "expected behavior" |
Sure, no rush :) |
a lot of online documentation for
so it seems like the current behavior is expected and the 8266 implementation is wrong? And the comment on their code indicates that they know it |
Hm .. |
No ... Opps ... not same but similar, just stuck to 8 ?! So maybe the esp8266 should not be followed ... E (2007) SPIFFS: mount failed, -10025 |
I agree that a define sounds like the most sensible solution 👍 Interesting find @lorol !! I wouldn't have expected SPIFFS on ESP32 to behave the same, in that case I would suggest keeping the current behavior as the default as ESP32 users upgrading from SPIFFS should rather expect 100% identical behavior than ESP8266 LittleFS users. |
@lorol maybe this macro should be in your layer rather than mine, since mine "doesn't know" about arduino |
@BrianPugh is it allowed pos to point beyond the file end? |
It does not. In the event that you attempt to index past the size of the file, it will return |
So the example above should not go to pos 9, 10 ... but it does? |
actually I was wrong, that |
In this case it is correct to return true and see position after the end. |
I think, we should leave as it is. We cannot and shouldn't always run after SPIFFS and/or esp8266. |
according to arduino documentation, if you seek beyond the size of the file it:
|
Just searched the SPIFFS ... way :) I wanted to keep everything directly from your implementation. For things like this maybe code writing is required ... |
I tested with FFat on esp32. Same results as LITTLEFS. |
First off all, thank you so much @lorol for making the best embedded FS easily usable on ESP32! It's highly appreciated :)
I've ran into a problem with the
seek()
function, specifically inSeekEnd
mode. It doesn't set the position correctly and attempting to read just causes 255 to be read. On closer inspection it seems like SeekEnd takes the file end and adds the offset to it (instead of subtracting), thus setting the position outsite the file. I would have tried setting a negative offset, but the seek() function only takes an unsigned integer.Should it matter, this is with
CONFIG_LITTLEFS_FOR_IDF_3_2
defined to enable support for the current ESP32 core release 1.0.4.MCVE
Output
For reference, the correct output from the ESP8266 version of LittleFS
The text was updated successfully, but these errors were encountered: