Symlinks already present
Chris Angelico
rosuav at gmail.com
Tue Sep 1 16:27:24 EDT 2020
On Wed, Sep 2, 2020 at 4:55 AM Eryk Sun <eryksun at gmail.com> wrote:
>
> On 9/1/20, Chris Angelico <rosuav at gmail.com> wrote:
> >
> > Also, even if all that could be solved, I don't like the idea that
> > reading the same directory from two different sources leads to
> > different results. Is it really the same directory if reading it in
> > different ways gives different results?
>
> What's your take on the following example in Linux?
>
> "test2/spam" is a bind mount for "test1/spam", and note that `mount
> --bind` in Linux is a namespace operation, i.e. it's not a new device:
>
> >>> os.lstat('test1/spam').st_dev == os.lstat('test2/spam').st_dev
> True
> >>> os.lstat('test1/spam').st_ino == os.lstat('test2/spam').st_ino
> True
>
> 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
When you add ".." to the end of a path, it is very frequently handled
textually. Can you do this exercise by actually opening the
directories and then using openat or statat?
ChrisA
More information about the Python-list
mailing list