On Mon Mar 10 23:32:18 2025 +0000, Jinoh Kang wrote:
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.
Yeah, my issue was inaccurate. The ISDIR check only happens if create_link is false, but the first fstat happens only when it's true, so they can't both happen, which is fine.
I changed these to better fit your suggestions and split into 2 patches. But I have no problem dropping them from this MR, if needed. The important part is to fix the hardlink issue anyway.