This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit f57fbb786ac4f49baf4f848199e1aaaf8ffcdc6b Author: guohao15 <[email protected]> AuthorDate: Thu Nov 12 13:08:43 2026 +0800 fs/vfs: return EISDIR from unlink() of a directory nx_unlink() removes an empty pseudo file system directory as if it were a file. POSIX does not allow unlink() of a directory (EPERM, and Linux returns EISDIR); remove() in libc already falls back to rmdir() on either error. Return -EISDIR for a pseudo directory. Signed-off-by: guohao15 <[email protected]> Signed-off-by: jingfei <[email protected]> --- fs/vfs/fs_unlink.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/vfs/fs_unlink.c b/fs/vfs/fs_unlink.c index 648caacf5c9..fc336269c7c 100644 --- a/fs/vfs/fs_unlink.c +++ b/fs/vfs/fs_unlink.c @@ -156,17 +156,17 @@ int nx_unlink(FAR const char *pathname) } } #endif - else if ( + else if (INODE_IS_PSEUDODIR(inode)) + { + ret = -EISDIR; + goto errout_with_inode; + } #ifdef CONFIG_FS_LINKS - INODE_IS_SOFTLINK(inode) || INODE_IS_HARDLINK(inode) || -#endif - INODE_IS_PSEUDODIR(inode)) + else if (INODE_IS_SOFTLINK(inode) || INODE_IS_HARDLINK(inode)) { - /* If this is a "dangling" pseudo-file node - * (i.e., it has no operations) or a soft link, - * then rm should remove the node. - */ + /* A link has no operations: removing the node removes it */ } +#endif else { ret = -ENXIO;
