You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/10/19 05:12:51 UTC
[incubator-nuttx] branch master updated: littlefs:fix rmdir can
remove a file
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 9b52e4e littlefs:fix rmdir can remove a file
9b52e4e is described below
commit 9b52e4e311f381a08ed99f7b697e71fb6afc0c8f
Author: anjiahao <an...@xiaomi.com>
AuthorDate: Thu Sep 23 14:08:49 2021 +0800
littlefs:fix rmdir can remove a file
Signed-off-by: anjiahao <an...@xiaomi.com>
---
fs/littlefs/lfs_vfs.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/fs/littlefs/lfs_vfs.c b/fs/littlefs/lfs_vfs.c
index 66b666c..75d3d335 100644
--- a/fs/littlefs/lfs_vfs.c
+++ b/fs/littlefs/lfs_vfs.c
@@ -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;
+ }
}
/****************************************************************************