Eryk Sun <eryk...@gmail.com> added the comment:

> Unless your point is that we should _always_ traverse junctions? In 
> which case we have a traverse 'upgrade' scenario (calls to lstat() 
> become calls to stat() when we find out it's a junction).

If we've opened the reparse point to test IO_REPARSE_TAG_SYMLINK, and that's 
not the case, then we need to reopen with reparsing enabled. This is exactly 
what Windows API functions do in order to implement particular behavior for 
just symlinks or just mountpoints. 

For example, if we've opened an HSM reparse point, we must reopen to let the 
file-system filter driver implement its semantics to replace the reparse point 
with the real file from auxiliary storage and complete the request. That is the 
stat() result I want when I say stat(filename, follow_symlinks=False) or 
lstat(filename), because this file is not a symlink. It's implicitly just the 
file to end users -- despite whatever backend tricks are being played in the 
kernel to implement other behavior such as HSM. Conflating this with a symlink 
is not right. Lies catch up with us. We can't copy it as link via os.symlink 
and os.readlink, and it doesn't get treated like a symlink in API functions.  

If you want to add an "open reparse point" parameter, that would make sense. 
It's of some use to get the tag and implement particular behavior for types of 
reparse points, and particularly for name surrogates, which includes mount 
points (junctions).

As to mount points, yes, I do think we should always traverse them. Please see 
my extended comment and the follow-up example on GitHub.

> Again, not sure why we'd want to hide the ability to manipulate the 
> junction itself from Python users, except to emulate POSIX. And I'd 
> imagine anyone using lstat() is doing it deliberately to manipulate 
> the link and would prefer we didn't force them to add Windows-
> specific code that's even more complex.

A mount point is not a link. ismount() and islink() can never both be true. 
Also, a POSIX symlink can never be a directory, which is why we make stat() 
pretend directory symlinks aren't directories. If the user wants a link, they 
can use a symlink that's created by os.symlink, mklink, new-item -type 
SymbolicLink, etc.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37834>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to