I’ve heard for a while that for the mv tool in Linux, moving a file is the same as renaming a file. Here is the comment that piqued my interest recently:
“On one file system renaming and moving is exactly the same thing; "moving" is just renaming the directory-entry's full path (i. e. the part stating its parent directories) instead of just the directory-entry's base name (the part after the last slash). It is done via the system call rename(2); tools like mv test whether using this is possible and only if it is not fall back to copy-and-delete.”
I want to know, how does renaming a file move the file? I thought that a file is moved by removing the entry in the old parent directory, and creating an entry in the new parent directory. I don’t see how this is related to renaming a file.
/a/b/c
to/a/b/x
and moving a file from/a/b/c
to/a/x/c
? You could maybe add some optimizations, but those are basically the same thing