On 27Jul2020 22:19, Grant Edwards <grant.b.edwa...@gmail.com> wrote: >On 2020-07-27, Termoregolato <waste@is.invalid> wrote: >> Il 26/07/20 22:47, dn ha scritto: >>> Thus, compare the results of the two calls to detect a difference. >> >> I will try also another way, If I don't err symlinks and original >> directory have the same inode number (I talk about Linux, where I'm >> using the application). > >You err. Symlinks are distinct i-nodes which are not the same i-node >as the destination. A symlink is basically a file containing a string >that is read and then used a path to another file.
We need to be careful with terminology (just for clarity). Each "source" symlink has its own inode. But if you os.stat() the symlink it follows the symlink and you get the inode for the "target" directory - two symlinks which point at the same directory will return the same inode and thus (st_dev,st_ino) in that stat result. That can be used for comparison, and you don't need to readlink or anything like that - let the OS do it all for you during the os.stat() call. >If you create a "hard" link (ln without the '-s') then you end up a single >i-node that has entries in multiple directories. Aye. >[old-Unix-guy story: Way back when, SunOS used to allow you (if root) >to create a hard link to a directory. It's not something you did a >second time.] It's a well defined operation. There are some policy choices an OS can make about some of the side effects (how does pwd work? how you got there? or some underlying "real" path - this spills over into "what does ".." mean?), etc. But having made those choices, the idea is just fine. As a counter example, many rsync based backup systems have the following underlying approach: - make a new directory tree with every file hardlinked from the previous backup tree - rsync into the new tree, because rsync unlinks and replaces changed files By contrast, MacOS Time Machine utilitises hardlinking directories on HFS volumes: instead of making a new directory tree full of hardlinks you just hardlink the top directory itself if nothing inside it has been changed. Cheers, Cameron Simpson <c...@cskk.id.au> -- https://mail.python.org/mailman/listinfo/python-list