strange interaction between open and cwd

Nobody nobody at nowhere.com
Tue May 4 19:44:14 EDT 2010


On Tue, 04 May 2010 14:36:06 +0100, Baz Walter wrote:

> this will work so long as the file is in a part of the filesystem that can
> be traversed from the current directory to the root. what i'm not sure
> about is whether it's possible to cross filesystem boundaries using this
> kind of technique.

At least on Linux, the kernel "fixes" the links at mount points, i.e.
within the root directory of a mounted filesystem, ".." refers to
the directory containing the mount point on the parent filesystem, while
the mount point refers to the root directory of the mounted filesystem.

This also appears to work correctly for bind mounts (mounting an arbitrary
directory to another directory, which results in a directory hierarchy
appearing at multiple locations within the filesystem), i.e. ".." refers
to the appropriate directory for each "instance".

OTOH, the algorithm can fail if a directory is moved (whether by rename()
or remounting) between the stat("..") and the listdir().




More information about the Python-list mailing list