Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • 1
    What's the difference between moving a file from /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 Commented Mar 19, 2021 at 4:08
  • Sorry, I don’t fully understand your point. I’m thinking that moving a file to a new location would be different compared to renaming a file in place, because rather than modifying the existing parent directory entry you need to add an entry in the new parent directory. Commented Mar 19, 2021 at 4:52
  • When you create a new directory entry in the same filesystem for the file, the file has a new name. You can see this action as "moving" from one directory to the other, although you don't really move the file (i.e. the inode), you only give it a new name. It's like changing the names of a web site from www.example.com to www.example.org - the web site gets a new name, or you could say that the site "moved" to www.example.org, although it is still at the same server. Commented Mar 19, 2021 at 5:28
  • Thanks, that makes the idea more clear. I know that the file’s inode is not modified when moving to a new location, but I suppose the process of making a new entry in the parent directory can be considered “renaming,” even when the new file name is the same as the original one. The main concern I have is that modifying the existing entry is not sufficient to move the file. The original directory entry needs to be deleted and a new directory entry needs to be created elsewhere, so that feels like a different process compared to renaming. Commented Mar 19, 2021 at 5:59
  • There's an optimisation you've made in that process: you're implicitly assuming that you could just change whatever part of the directory entry holds the name. After all, both "moving" and "renaming" could be done fine via adding an entry and then deleting the old entry (both operations need to possible for moving). Now the question is: what constraints do you need to impose to ensure that this optimization can be done? Is it necessary that all filesystems follow those constraints? What if I have a hash/map implementation in which the name is the key and not an attribute of directory entry? Commented Mar 19, 2021 at 7:41