Unverified Commit 882b12c4 authored by lbernstone's avatar lbernstone Committed by GitHub

rmdir causes issues in SPIFFS. Fixes #4138, albeit not very cleanly (#4154)

SPIFFS causes crashes if you attempt to rmdir. Since there are no true directories in spiffs, this ought to be a noop. It looks like @me-no-dev worked around this by using unlink instead of rmdir, which works in fatfs and doesn't panic spiffs. This behavior is not universal. In order to get littlefs working, it would be good to get this back to conformity. Rather than digging deep into the upstream spiffs, I just check the mountpoint and noop if it is "/spiffs". So, if the user has changed the mountpoint, this will not work, but I think it's a pretty good tradeoff.
parent 93d850f7
...@@ -184,6 +184,11 @@ bool VFSImpl::rmdir(const char *path) ...@@ -184,6 +184,11 @@ bool VFSImpl::rmdir(const char *path)
return false; return false;
} }
if (strcmp(_mountpoint, "/spiffs") == 0) {
log_e("rmdir is unnecessary in SPIFFS");
return false;
}
VFSFileImpl f(this, path, "r"); VFSFileImpl f(this, path, "r");
if(!f || !f.isDirectory()) { if(!f || !f.isDirectory()) {
if(f) { if(f) {
...@@ -200,7 +205,7 @@ bool VFSImpl::rmdir(const char *path) ...@@ -200,7 +205,7 @@ bool VFSImpl::rmdir(const char *path)
return false; return false;
} }
sprintf(temp,"%s%s", _mountpoint, path); sprintf(temp,"%s%s", _mountpoint, path);
auto rc = unlink(temp); auto rc = ::rmdir(temp);
free(temp); free(temp);
return rc == 0; return rc == 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment