Re: git: d549de769055 - main - libc: Remove readdir_r(3) [This broke building rust 1.88]

From: Dag-Erling_Smørgrav <des_at_FreeBSD.org>
Date: Fri, 12 Sep 2025 10:59:26 UTC
Bob Bishop <rb@gid.co.uk> writes:
> And while I’m here, POSIX.1 defines for readdir_r (and readdir):
>
> [EOVERFLOW]
>    One of the values in the structure to be returned cannot be represented correctly.
>
> …which I think would cover the case of indeterminate NAME_MAX/PATH_MAX for readdir_r.

No, because readdir_r() has no way of knowing the size of the buffer
that was passed to it.

Moreover, our readdir_r() is a wrapper around our readdir(), so if the
reason you're using readdir_r() is that you consider readdir() unsafe,
congratulations, you played yourself.

The only argument in favor of readdir_r() was thread safety because some
readdir() implementations used to return a pointer to a static buffer,
but was never the case for FreeBSD.  Our readdir() is thread-safe as
long as you don't have multiple threads operating on the same DIR.

DES
-- 
Dag-Erling Smørgrav - des@FreeBSD.org