When fts_children() is called, sp->fts_child is set. On the
next fts_read() call, fts_safe_changedir() was incorrectly
passed p->fts_dirfd (pointing to the parent directory) instead
of -1. This caused fts to fchdir to the parent instead of the
child directory, silently skipping the contents of 3rd-level
subdirectories. This was observed as a failure in
nmtree_test:mtree_create which calls fts_children() internally.
Add regression test accpath_correct_after_descent that calls
fts_children() on each directory entry and verifies files at
depth 3 are still visited correctly. The test fails with the
unfixed libc and passes with the fix.
Reported by: Herbert J. Skuhra <[email protected]>
Sponsored by: Google LLC (GSoC 2026)
Reviewed by: asomers
Fixes: 4bd01d6ae0 ("fts: refactor to use fd-relative")
Pull Request: https://github.com/freebsd/freebsd-src/pull/2354