On 9/3/20, Greg Ewing <greg.ew...@canterbury.ac.nz> wrote: > On 2/09/20 6:55 am, Eryk Sun wrote: >> According to POSIX (st_dev, st_ino), it's the same directory, yet the >> ".." entry evaluates depending on the path parsing context: >> >> >>> os.lstat('test1/spam/..').st_ino == os.lstat('test1').st_ino >> True >> >>> os.lstat('test2/spam/..').st_ino == os.lstat('test2').st_ino >> True > > What happens if you go one level deeper? I.e. is > os.lstat('test1/spam/eggs/../..').st_ino == os.lstat('test1').st_ino > and > os.lstat('test2/spam/eggs/../..').st_ino == os.lstat('test2').st_ino > ?
Those two examples return true. Going a level deeper to 'spam/eggs' doesn't change the behavior of the graft at "test2/spam". An interesting case is bind mounting a directory on one of its child directories. For example, if "spam" is mounted on "spam/mount_spam": >>> s = os.lstat('spam/mount_spam/mount_spam/..') >>> s.st_ino == os.lstat('spam').st_ino True The namespace graft only occurs at "spam/mount_spam". So "spam/mount_spam/mount_spam" is the original filesystem directory, for which the ".." entry references "spam". It's also consistent with "spam/mount_spam" being bound to "spam". -- https://mail.python.org/mailman/listinfo/python-list