Philipp Stephani wrote: > there's no way to special-case > casing changes while keeping atomicity intact. So I'd rather have Emacs > react conservatively and skip the casing check entirely. Yes, that makes sense, at least for macOS. > Note that the manpage says: > > RENAME_EXCL On file systems that support it (see getattrlist(2) > VOL_CAP_INT_RENAME_EXCL), it will cause EEXIST to be returned if the > destination already exists. > > I interpret this such that if the filesystem doesn't support RENAME_EXCL > the rename will succeed even if the destination exists. I interpret it to mean that if the filesystem doesn't support RENAME_EXCL, the rename will fail with errno == EINVAL or ENOSYS. At least, that's how it works under GNU/Linux. If it behaved the way you suggest, there'd be no good way to emulate RENAME_EXCL on filesystems lacking it, which would surely not be Apple's intent. Please check this, though. I installed the patch on 'master' to help you do that. Now that renameat_noreplace works on DOS_NT, would it make sense to apply the attached further patch as well? If we can get renameat_noreplace to work on Cygwin the we could simplify the fileio.c code even further. > Since we probably won't be able to solve all issues across operating > systems and filesystems, probably we should have at least a warning in the > documentation that rename-file attempts to be race-free and atomic, but > only on a best-effort basis. True. I'd like to get the directory issue fixed before worrying about this, though. (That way I don't have to document the security holes in the current implementation. :-) I'll follow up separately about that.