littlefs:fix rmdir can remove a file
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
parent
6bdc737f5c
commit
9b52e4e311
1 changed files with 11 additions and 1 deletions
|
|
@ -1258,7 +1258,17 @@ static int littlefs_mkdir(FAR struct inode *mountpt, FAR const char *relpath,
|
|||
|
||||
static int littlefs_rmdir(FAR struct inode *mountpt, FAR const char *relpath)
|
||||
{
|
||||
return littlefs_unlink(mountpt, relpath);
|
||||
struct stat buf;
|
||||
|
||||
littlefs_stat(mountpt, relpath, &buf);
|
||||
if (S_ISDIR(buf.st_mode))
|
||||
{
|
||||
return littlefs_unlink(mountpt, relpath);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -ENOTDIR;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue