I don't know, the rationale seems quite reasonable to me. I don't know the technical aspects of rename, but I assume that the file is copied and then the one that was copied is removed, making it so that a copy of this file is guaranteed to exist in full somewhere on the filesystem. If this is indeed the method used, how would you go about moving a file to the same path? You'd have to hold the entire file contents in memory, delete the original file, then create the "new" file and place the in-memory contents back in. (Or you could use a temp file rather than memory). This would leave somewhat of an undesirable race condition in which a file we are renaming doesn't exist on the filesystem at all.
This doesn't answer the "why is there no error" question, but I don't see why there should be.
In reply to Re^2: [OT] rename(2) -- renaming file to itself produces no error.
by Coruscate
in thread [OT] rename(2) -- renaming file to itself produces no error.
by dmitri
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |