The status of readdir_r in Rust

From: Alan Somers <asomers_at_freebsd.org>
Date: Mon, 22 Sep 2025 20:59:52 UTC
On 13-September we had a long conversation about readdir_r, about whether
modern applications should be using it (they shouldn't), and about whether
we should remove it entirely for FreeBSD 16 (no, at least not yet).  The
big problem was that lang/rust still used readdir_r in its standard
library, so we definitely need to preserve that function for now.

Since then I've submitted a PR to remove the readdir_r calls from the
standard library [^1].  I also updated libc to specifically bind to the
pre-FreeBSD 15 ELF symbol for readdir_r [^2], which ensures that
applications will continue to build even after we remove that function.
Finally, Github code search found several crates that are still using
readdir_r, but only one of them is a crate that I personally care about:
Nix.  So I did the same thing there that I did to the standard library [^3].

At this point, I think it should be safe to remove readdir_r from FreeBSD
16 in about six months, at least as far as Rust is concerned.

[^1]: https://github.com/rust-lang/rust/pull/146549
[^2]: https://github.com/rust-lang/libc/pull/4694
[^3]: https://github.com/nix-rust/nix/pull/2674