Date: Fri, 12 Sep 2025 12:59:26 +0200 From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@FreeBSD.org> To: Bob Bishop <rb@gid.co.uk> Cc: Olivier Certner <olce@FreeBSD.org>, FreeBSD Current <freebsd-current@FreeBSD.org>, Alan Somers <asomers@FreeBSD.org>, Toomas Soome <tsoome@me.com> Subject: Re: git: d549de769055 - main - libc: Remove readdir_r(3) [This broke building rust 1.88] Message-ID: <86qzwcgcmp.fsf@ltc.des.dev> In-Reply-To: <0F481EDD-24F4-4F2C-BCBB-9B016DD313F3@gid.co.uk> (Bob Bishop's message of "Fri, 12 Sep 2025 11:19:54 %2B0100") References: <C79DD894-11FD-4919-B3EE-147978D36AF8@me.com> <CAOtMX2gS54kMJMsudth5AzCSWzELgP5o8%2B8gQ5ac2P3mcSVG%2BA@mail.gmail.com> <4148862.BRNeRiNLvY@ravel> <0F481EDD-24F4-4F2C-BCBB-9B016DD313F3@gid.co.uk>
index | next in thread | previous in thread | raw e-mail
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.orghome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86qzwcgcmp.fsf>
