Jinoh Kang (@iamahuman) commented about server/fd.c:
{ if (!fstat( fd->unix_fd, &st2 ) && st.st_ino == st2.st_ino && st.st_dev == st2.st_dev) {
if (create_link && !replace) set_error( STATUS_OBJECT_NAME_COLLISION );
if (!create_link)
{
/* if it's not the "same" file (by path), it means it's a hardlink, so we need to remove the source */
if (!is_same_file_by_path( fd->unix_name, name ) && unlink( fd->unix_name ))
This probably suffers from the same casefold problem that !246 has run into. On a casefold filesystem, the `fd->unix_name` is the realpath, but `name` uses whatever casing is provided by the application. This is treated as a "hardlink," resulting in erroneous removal.
(untested)