-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Can FS/src/vfs_api.cpp VFSImpl::rmdir use actual rmdir instead of or in addition to unlink? #4138
Comments
Why does unlink fail? Can you directly unlink a directory outside of the FS methods? What is the return code from the rmdir? |
@lbernstone |
I assume @me-no-dev used unlink there due to an issue with rmdir in one of the other libraries.... Maybe that could be revisited at some point. |
No problem, I have a workaround. |
Yes, leave it open until it is fixed. Did you try putting the define into your code so the source doesn't need to be changed? |
Hi, with define only cannot be fixed. vfs_littlefs_unlink is originally made for files only. |
@lbernstone Off topic, what is the story of fatfs - do you have by chance any "mkfatfs" - like tool build for win that actually works and images from it mount to esp32 or esp8266? Couldn't find anything "ready for use" ... |
Any guidance how to build on Win32 or ready binary? |
Nope. I have tried to revisit it and the code is so ancient it doesn't compile properly any more. Maybe if you go back to IDF 2.x. It would be nice to make it a standalone, but my makefile skills are not good enough. Take this convo over to gitter if you want to chat. |
Ok, back to the topic if esp-core devs want to review. Summary: arduino-esp FS vfs_api.cpp - both methods use unlink()
IDF esp_littlefs (a candidate for official LittleFS IDF component) has separate functions for removing files and folders:
arduino-esp wrapper LITTLEFS based on esp_littlefs.c, the rmdir fails because vfs_api.cpp calls vfs_littlefs_unlink |
Just weighing in (author of esp-idf littlefs port), I believe it's improper than the current vfs implementation calls
So I could allow unlink to operate on directories, but I don't think its proper. The |
@me-no-dev Is there a particular reason you used unlink instead of rmdir in FS? |
@BrianPugh thanks for explaining your valid points! |
Ok. I think this was added in to deal with SPIFFS causing issues with rmdir. I'll see if there is some way to fix this. |
@lbernstone, did you check if your lbernstone@e151d5b resolves what is discussed here? |
If you use "/spiffs" for the default mountpoint on littlefs, your code will not be accepted. This is just a label applied when you call begin, so it is not going to catch spiffs if someone decides to be "smart". Those people will get a nice stack fault for their efforts. I have made additional changes, look at the actual PR to see what will be committed. |
Ok, if I understand properly, on your last idea, if mounting point is named "/spiffs" for any reason, then you just kick and say "no rmdir" :) for you. And if real SPIFFS has other mounting point name ... then rmdir will fail. The assumption is that SPIFFS has only files, so rmdir will not be attempted - did I get it or I am off? Anyway, thank you for your efforts. |
Yes, rmdir is meaningless (it should be a noop) in spiffs. Files can have "/" in the name, but when you remove the file with the slash, the "directory" goes with it. |
@lorol doesn't your littlefs mount to |
I am a bit confused what _mounpoint of the vfs_api.cpp means, Please help to confirm. If _mounpoint means (takes value from) basePath below, the then no, the default is Anyway, with my limited knowledge, I believe the fix at vfs_api.cpp can be done differently than proposed solution by @lbernstone |
@lorol, the fix is changing unlink to rmdir. That is done. The spiffs change was made to keep it from causing additional issues. Read the topic title. |
@lbernstone . For me is OK, Hope to be for others as well. |
Hi @BrianPugh and @lbernstone I think, LittleFS gets like example: [E][vfs_api.cpp:65] open(): /littlefs/config/wifiSettings.json does not exist |
I didn't really look too hard, but does the folder |
There are no directories in SPIFFS. So, if you open "/test/file" that is the name of the file, and it does not matter if "/test/" exists. Full filesystems should return an error if the path does not exist. |
You are right to suspect. /littlefs/config was not exiting on my first test. Again because the code I used was made for SPIFFS and these files (paths) can be created later when needed. I had to pre-make the folder. But even after folder exists up to /littlefs/config still throwing the errors :) because these files don't actually exist |
Yes exactly what is happening. Unfortunately a code made for SPIFFS never returns error there. I already got questions from people testing littlefs on esp32 ... why now this error shows ... on my working code for SPIFFS. Guess no right answer on that :) HM ... so what opendir() is returning on SPIFFS? always true? |
Hardware:
Board: ESP32 Dev Module
Core Installation/update date: b92c58d 2020-05-31
IDE name: Arduino IDE
Flash Frequency: 40Mhz
PSRAM enabled: no
Upload Speed: 115200
Computer OS: Windows 10
Description:
The sketch tests LittleFS, based on https://github.com/joltwallet/esp_littlefs
Proposed as: #4096 until the LittleFS gets implemented as official IDF-ESP component or otherwise.
Everything works except FS.rmdir(path) - which always fails
As found by @joltwallet, the implemented in esp_littlefs.c rmdir is not called, rather unlink is called from vfs_api.cpp
https://github.com/espressif/arduino-esp32/blob/master/libraries/FS/src/vfs_api.cpp#L203
Sketch:
https://github.com/lorol/LITTLEFS/blob/master/examples/LittleFS_test/LittleFS_test.ino
Debug Messages:
Serial Output:
The text was updated successfully, but these errors were encountered: