On 05/05/10 00:44, Nobody wrote:
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().

i think the algorithm also can't guarantee the intended result when crossing filesystem boundaries. IIUC, a stat() call on the root directory of a mounted filesystem will give the same inode number as its parent. so if several filesystems are mounted in the same parent directory, there is no way to tell which of them is the "right" one.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to