From: Stefan Sperling Subject: Re: ugly hack for repositories on NFS To: "Todd C. Miller" Cc: gameoftrees@openbsd.org Date: Tue, 21 Jul 2020 15:55:25 +0200 On Tue, Jul 21, 2020 at 07:48:29AM -0600, Todd C. Miller wrote: > As you've discovered, not all file systems support the d_type > optimization. The situation is even worse on other systems. I > wouldn't call this a hack--it's simply what you have to do when the > file system doesn't support d_type. There really isn't another > option. > > I don't think this approach is any racier than relying on d_type. > There will always be TOCTOU races unless you open the file first > and use fstat(). That's true whether you get the info from readdir(2) > or lstat(2). > > What you have there looks fine to me, though I would remove the > comment about it being racey. > > - todd > Fair enough. I'll go ahead with this change then and tweak the comments as you suggest. Thank you for the insight :)