below at the `if (create_link || S_ISDIR( st2.st_mode ))` line)
We can probably eliminate the check and just handle the EISDIR/EEXISTS error from link()/rename() themselves. Would make sense for your goal too, which is perf optimization.
The last stat (for the executable bit) is probably not called very frequently anyway, so I think it's fine to skip the cache there too.
`unlink_closed_fd` appears to think it can mismatch. I mean it makes sense (since in Linux we can remove open fds), didn't know we even guard against it though. Should it be a concern here?
`unlink_closed_fd` is calling `stat( fd->unix_name, ... )`, not `fstat( fd->unix_fd, ... )`. Note there is a difference.
Unix names can be basically moved around and renamed, but fd's dev/ino will stay the same.