Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-37834: Normalise handling of reparse points on Windows #15231

Merged
merged 3 commits into from Aug 21, 2019

Conversation

@zooba
Copy link
Member

commented Aug 12, 2019

@zooba zooba changed the title bpo-37834: Enable os.readlink and os.path.is_link to recognize app execution aliases bpo-37834: Only treat symlink and junction reparse points as links Aug 13, 2019

Python/fileutils.c Outdated Show resolved Hide resolved
if (PyModule_AddObject(m, "IO_REPARSE_TAG_MOUNT_POINT",
PyLong_FromUnsignedLong(IO_REPARSE_TAG_MOUNT_POINT))) return NULL;
if (PyModule_AddObject(m, "IO_REPARSE_TAG_APPEXECLINK",
PyLong_FromUnsignedLong(IO_REPARSE_TAG_APPEXECLINK))) return NULL;

This comment has been minimized.

Copy link
@eryksun

eryksun Aug 20, 2019

Contributor

IO_REPARSE_TAG_UNHANDLED (0x80000020), going by its name, is always an unhandled tag. IO_REPARSE_TAG_LX_SYMLINK (0xA000001D) should be an unhandled link tag, since it's used for symlinks between an NT file system and a WSL file system (e.g. "/mnt/c/etc" -> "/etc").

I looked over Microsoft's tags for a handled tag that's not a link, but nothing stands out. I thought that OneDrive used them (i.e. IO_REPARSE_TAG_CLOUD*), but that doesn't appear to be the case anymore. I also thought the new Projected File System support would use them (i.e. IO_REPARSE_TAG_PROJFS). I built the RegFS sample to try to confirm this, and I was surprised to find that none of the virtual directories and files (keys and values) was a reparse point.

However, both OneDrive and ProjFS do make extensive use of the following new file attributes:

FILE_ATTRIBUTE_PINNED  0x00080000
FILE_ATTRIBUTE_UNPINNED  0x00100000
FILE_ATTRIBUTE_RECALL_ON_OPEN  0x00040000
FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS  0x00400000
bpo-37834: Clarify reparse point handling on Windows.
* ntpath.realpath() and nt.stat() will traverse all supported reparse points (previously was mixed)
* nt.lstat() will let the OS traverse reparse points that are not name surrogates (previously would not traverse any reparse point)
* nt.[l]stat() will only set S_IFLNK for symlinks (previous behaviour)
* nt.readlink() will read destinations for symlinks and junction points only

bpo-1311: os.path.exists('nul') now returns True on Windows
* nt.stat('nul').st_mode is now S_IFCHR (previously was an error)

@zooba zooba force-pushed the zooba:bpo-37834 branch from 57cc198 to 514d5d7 Aug 21, 2019

@zooba zooba changed the title bpo-37834: Only treat symlink and junction reparse points as links bpo-37834: Normalise handling of reparse points on Windows Aug 21, 2019

@zooba zooba merged commit df2d4a6 into python:master Aug 21, 2019

5 checks passed

Azure Pipelines PR #20190821.43 succeeded
Details
bedevere/issue-number Issue number 37834 found
Details
bedevere/news News entry found in Misc/NEWS.d
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@zooba zooba deleted the zooba:bpo-37834 branch Aug 21, 2019

@miss-islington

This comment has been minimized.

Copy link

commented Aug 21, 2019

Thanks @zooba for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒🤖

@miss-islington

This comment has been minimized.

Copy link

commented Aug 21, 2019

Sorry, @zooba, I could not cleanly backport this to 3.8 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker df2d4a6f3d5da2839c4fc11d31511c8e028daf2c 3.8

@bedevere-bot

This comment has been minimized.

Copy link

commented Aug 21, 2019

GH-15370 is a backport of this pull request to the 3.8 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.