This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 5ea5bec216b fs/tmpfs: Return ENOTEMPTY from rmdir of a non-empty 
directory.
5ea5bec216b is described below

commit 5ea5bec216b07cdef49b7bd798fb049cabd9cc8b
Author: Marco Casaroli <[email protected]>
AuthorDate: Wed Nov 4 10:47:48 2026 +0100

    fs/tmpfs: Return ENOTEMPTY from rmdir of a non-empty directory.
    
    tmpfs_rmdir() returned EBUSY for a directory with entries.  POSIX
    specifies ENOTEMPTY or EEXIST.  FAT, SmartFS, littlefs and the rename
    path of tmpfs return ENOTEMPTY.
    
    An empty directory that is open still gives EBUSY.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 fs/tmpfs/fs_tmpfs.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/fs/tmpfs/fs_tmpfs.c b/fs/tmpfs/fs_tmpfs.c
index b762a214257..1fa042e6010 100644
--- a/fs/tmpfs/fs_tmpfs.c
+++ b/fs/tmpfs/fs_tmpfs.c
@@ -2896,12 +2896,20 @@ static int tmpfs_rmdir(FAR struct inode *mountpt, FAR 
const char *relpath)
     }
 
   /* Is the directory empty?  We cannot remove directories that still
-   * contain references to file system objects.  No can we remove the
-   * directory if there are outstanding references on it (other than
-   * our reference).
+   * contain references to file system objects.
    */
 
-  if (tdo->tdo_nentries > 0 || tdo->tdo_refs > 1)
+  if (tdo->tdo_nentries > 0)
+    {
+      ret = -ENOTEMPTY;
+      goto errout_with_objects;
+    }
+
+  /* Nor can we remove the directory if there are outstanding references on
+   * it (other than our reference).
+   */
+
+  if (tdo->tdo_refs > 1)
     {
       ret = -EBUSY;
       goto errout_with_objects;

Reply via email to