From: "Todd C. Miller" Subject: Re: ugly hack for repositories on NFS To: Stefan Sperling Cc: gameoftrees@openbsd.org Date: Tue, 21 Jul 2020 07:48:29 -0600 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