#4674: readdir skips entries after unlink ------------------------------+-------------------- Reporter: Alexandre Oliva | Owner: (none) Type: defect | Status: new Priority: normal | Milestone: Component: admin | Version: 6 Severity: normal | Keywords: Blocked By: | Blocking: ------------------------------+-------------------- Removing directory entries returned by readdir causes entries to be skipped in subsequent readdir calls. AFAICT this behavior is not POSIX- conforming, and it breaks several of libstdc++-v3's std::filesystem tests.
More specifically, consider a directory containing entries A, B and C. The first readdir call after opening the directory returns the entry for A, and advances the offset to B. The second readdir call is supposed to return B, and it does, unless (here's the problem) A is removed before the second call, in which case it returns C, and B is skipped entirely. It's as if the directory offset was an index into active entries, so that the removal decremented the indices for subsequent entries, leaving the offset for the current dir entry pointing past the entry that should be returned next. This affects at least the root, in-memory filesystem. I haven't tested with on-disk filesystems. I've proposed a few possibilities of workarounds to libstdc++, so that remove_all would get the job done even under this implementation choice/limitation, but the recommendation I got from Sebastian Huber was to file this report instead, so here it is. https://gcc.gnu.org/pipermail/gcc-patches/2022-June/597525.html (the proposed workarounds are earlier posts in the same thread) -- Ticket URL: <http://devel.rtems.org/ticket/4674> RTEMS Project <http://www.rtems.org/> RTEMS Project
_______________________________________________ bugs mailing list bugs@rtems.org http://lists.rtems.org/mailman/listinfo/bugs