Why when moving the file to which the recording is going to the same media, this operation is successful. However, if you try to transfer such a file to another material medium, the new file is empty. Why is this happening?
1 answer
Within a single file system, only the directory entry pointing to the inode containing the file is transferred. And after the file is opened for recording, in fact, all the work goes on with the inode and continues smoothly regardless of how many directory pointers to it exist (maybe even 0 — the file is deleted). And when transferring to another file system, you also need to transfer data, and depending on how exactly the file was opened and recorded, data for reading and transfer may not be available yet. In addition, when transferring to another FS, even if some data were available and were transferred, the new data will not get there anyway, since the directory entry on the original filesystem is deleted, but the recording continues into the deleted file.
mvhas not yet dropped (write()) his buffer to the file. Otherwise, some data would be copied. But the rest of the recording will disappear, since the writer will continue to write to the file that has already been deleted (which actually disappears when the last writer (if there were several of them at the time ofmv) closes the file) - avp