Jinoh Kang (@iamahuman) commented about server/fd.c:
} if (rename( fd->unix_name, name ))
{
if (errno != ENOTDIR) { file_set_error(); goto failed; }
/* rename() cannot replace files with directories */
if (unlink( name ) || rename( fd->unix_name, name ))
Not sure if this is correct per se.
For example, ENOTDIR could be caused by `fd->unix_name` being moved out of a directory and then said directory being replaced with a non-directory, before the rename/link took place.
Could be fixed by re-introducing a stat call on `fd->unix_name` (but this time only on failure path) though. (I wouldn't mind splitting this to a separate patchset either as you said.)