Does mv on a FAT filesystem actually rename or does it copy and delete?
On Sat, 2018-02-03 at 16:46 +0100, Ralf Mardorf wrote:
> > Thanks for the answers so far but to re-emphasise why I asked the
> > question:-
> > I know that mv of a file in a directory on a Linux type filesystem
> > will just write the new name of a file in the directory without
> > moving the data/contents of the file.
> > However in different circumstances (e.g. across filesystems) it
> > *can't* do this and has to copy/delete. I was just asking if
> > anyone knows if 'mv file1 file2' on a VFAT (i.e. not native Linux)
> > filesystem does the 'easy' thing (copy/delete) or not.
> As already pointed out, you still could run "strace" ;).
That doesn't answer the question.
Obviously the mv(1) command is always going to run the same system
call, regardless of the underlying filesystem. It's not going to try
to look up the type of the filesystem and behave differently : it's
going to rely on the published kernel interface to move a file, e.g.
invoke the rename(2) system call.
However, that doesn't mean that the actual behavior of that system call
is the same on a VFAT filesystem: a typical filesystem will allow the
directory entry for the file to be changed without actually copying
bytes around on the hardware.
The question is not what system call is invoked, but rather does the
implementation of the filesystem in the kernel allow for the rename
operation to simply change the directory to implement the move, or does
it require the actual contents of the file to be copied to a different
location on the underlying media?
 mv _will_ check whether the source and destination are on the same
partition or not, since rename(2) is not supported across different