[issue12084] os.stat() on windows doesn't consider relative symlink

Brian Curtin report at bugs.python.org
Sat May 28 03:07:51 CEST 2011


Brian Curtin <brian at python.org> added the comment:

It turns out DeviceIoControl/FSCTL_GET_REPARSE_POINT (in win32_read_link) will only work for us as long as the symlink was created with a full path. Starting at the top level of a source checkout, if I create `os.symlink("README", "README.lnk")` and then do `os.stat("..\\README.lnk")` from up a directory (or any other directory), DeviceIoControl can only find out that the symlink was created with "README", so the reparse tag it knows about is "README", which doesn't really help us in figuring out where that file is actually located. Everything is fine if I create the symlink with full paths.

I'm in the middle of refactoring this to work with GetFinalPathNameByHandle. I had thought about a quick-and-dirty solution of modifying os.symlink to convert all paths into fully qualified paths in order to give DeviceIoControl the info it needs for os.stat...but that doesn't help for any previously created links, or for any links created by Microsoft tools such as the "mklink" command line tool (it doesn't set the reparse tag with a fully qualified path either).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12084>
_______________________________________


More information about the Python-bugs-list mailing list