littlefs: Get and return the current error status before RMDIR execution type
In some cases, deleting a folder will return unexpected results. For example, ENOENT should be returned when deleting a non-existent folder, but the result will return ENOTDIR.
@@ -1324,8 +1324,14 @@ static int littlefs_mkdir(FAR struct inode *mountpt, FAR const char *relpath,
static int littlefs_rmdir(FAR struct inode *mountpt, FAR const char *relpath)
{
struct stat buf;
+ int ret;
+
+ ret = littlefs_stat(mountpt, relpath, &buf);
+ if (ret < 0)
+ {
+ return ret;
+ }
- littlefs_stat(mountpt, relpath, &buf);
if (S_ISDIR(buf.st_mode))
{
return littlefs_unlink(mountpt, relpath);
