Repository navigation
fs/tmpfs: Return ENOTEMPTY from rmdir of a non-empty directory. - #21450
Merged
Merged
Conversation
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 <marco.casaroli@gmail.com>
|
xiaoxiang781216
approved these changes
Nov 4, 2026
acassis
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rmdir()of a tmpfs directory that is not empty fails withEBUSY. POSIX specifiesENOTEMPTYorEEXIST.tmpfs_rmdir()now returns-ENOTEMPTYfor a directory with entries. An empty directory that is open still givesEBUSY.Impact
ENOTEMPTY, notEBUSY. This is a change of an error code that flat-build programs can see.remove()gives the same error.ENOTEMPTY. The rename path of tmpfs already returnsENOTEMPTYfirst and thenEBUSY, in the same order.EBUSYfromrmdir().examples/mountexpectsENOTEMPTY. The caller infs_rename.cdoes not test the error code.rmdir().Testing
Test program
rmdirbusy.c, 6 checks on a new tmpfs mount:rmdir(), the directory has a directoryEBUSYENOTEMPTYremove(), the directory has a directoryEBUSYENOTEMPTYrmdir(), the directory has a fileEBUSYENOTEMPTYrmdir(), the directory has a file and is openEBUSYENOTEMPTYrmdir(), the directory is empty and openEBUSYEBUSYrmdir(), the directory is empty and closedThe results are the same on qemu-armv8a:knsh (kernel, arm64, QEMU with HVF) and qemu-armv8a:nsh (flat, arm64, HVF): master 2 PASS, 4 FAIL; this PR 6 PASS.
ostest exits with status 0 on master and with this PR: qemu-armv8a:knsh, qemu-armv8a:nsh, and the flat qemu-armv8a:nsh build with the test. All have
CONFIG_FS_TMPFS.No test in CI checks this error code: the cmocka test
rmdir02asks forENOTEMPTYin its table, but it checks only thatrmdir()fails.Builds with
EXTRAFLAGS="-Wno-cpp -Werror", each OK: qemu-armv8a:knsh and qemu-armv8a:nsh (withCONFIG_FS_TMPFS), sim:nsh (macOS host; the only warnings come from the host linker,-ld_classic).The tests ran on master 39a1f27; the branch is rebased on 3d57048 (no change in the touched files).
tools/checkpatch.sh -c -u -m -gpasses.