Executing 'mv A B': Will the 'inode' be changed?

无人久伴 提交于 2019-12-23 12:20:03

问题


If we execute a command:

mv A B

then what will happen to the fields in the inode of file A? Will it change?

I don't think that it should change just by changing the name of the file, but I'm not sure.


回答1:


It depends at least partially on what A and B are. If you're moving between file systems, the inode will almost certainly be different.

Simply renaming the file on the same system is more likely to keep the same inode simply because the inode belongs to the data rather than the directory entry and efficiency would lead to that design. However, it depends on the file system and is in no way mandated by standards.

For example, there may be a versioning file system with the inode concept that gives you a new inode because it wants to track the name change.




回答2:


It depends.

There is a nice example on this site which shows that the inode may stay the same. But I would not rely on this behaviour, I doubt that it is specified in any standard.



来源:https://stackoverflow.com/questions/10702767/executing-mv-a-b-will-the-inode-be-changed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!