Page MenuHomeFreeBSD

rm(1): remove whiteouts when forcibly removing directories
ClosedPublic

Authored by jah on Nov 8 2025, 4:45 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jan 7, 8:16 PM
Unknown Object (File)
Tue, Jan 6, 12:42 AM
Unknown Object (File)
Fri, Jan 2, 4:12 AM
Unknown Object (File)
Mon, Dec 29, 7:16 PM
Unknown Object (File)
Mon, Dec 29, 11:59 AM
Unknown Object (File)
Dec 2 2025, 7:57 PM
Unknown Object (File)
Nov 23 2025, 7:17 PM
Unknown Object (File)
Nov 23 2025, 4:27 PM
Subscribers

Details

Summary

Commit 2ed053cde5 changed UFS' VOP_RMDIR() behavior to no longer
ignore whiteouts when determining whether a directory is empty,
unless explicitly requested by the caller. However, this also
necessitates a change to rm(1) to avoid breaking the expected
behavior when forcibly removing directory hierarchies via rm -fr.
I neglected to make this follow-on change despite discussing it
in the review for the breaking commit (D45987).

Finally address the breakage by making rm -fr imply FTS_WHITEOUT
when rm(1) reads directory contents via fts_read(3). While here,
also fix a logic error which produces a spurious 'No error' warning
message on stdout for each deleted whiteout.

Reported by: csjp
MFC after: 3 days

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jah requested review of this revision.Nov 8 2025, 4:45 AM

Do we have automated tests for rm(1) somewhere that I'll need to change?

jah edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Nov 8 2025, 10:23 AM
In D53640#1224643, @jah wrote:

Do we have automated tests for rm(1) somewhere that I'll need to change?

Nothing compelling that I know of, but we have some (tiny) script in bin/rm/tests.