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.
This commit is contained in:
crafcat7 2022-12-03 00:30:25 +08:00 committed by Xiang Xiao
parent cb0418676f
commit 8b95b7ca5b

View file

@ -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);