I am not sure how it works across different FS.
The rename operation itself doesn’t operate across different file systems; there is no difference between writing to a file from say a text editor and writing to a file using
cp with a source file on another file system.
On Linux, the
rename system call is transparent to other links to the file, which include other hard links and open file descriptions (and descriptors). The manpage explicitly states
Open file descriptors for oldpath are also unaffected.
(I’m qualifying with “on Linux” only because I couldn’t find a reference in POSIX; I think this is common across POSIX-style operating systems.)
So when you’re copying a file across file systems,
cp opens the source for reading, the target for writing, and starts copying. Rename operations don’t affect the file descriptors it’s using; you can rename the source and/or the target without affecting
Another way to think of this is that the file’s name in its containing directory is part of its directory entry, which points at its inode; open file descriptions are other pointers to the inode, as are other hard links. Changing the file name doesn’t affect any other existing pointers.
The caveats to watch out for are that tools such as
mv don’t limit themselves to what the
rename system call can do; if you
mv files across file systems, the
rename will fail (or
mv will figure out that the operation is across file systems and won’t even attempt it), and
mv will then resort to manually copying the file contents and deleting the original. This won’t give good results if the file being renamed is being changed simultaneously.