-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
File.stat
: Support detection of Kind.sym_link
on Windows
#18326
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this sort of like AT_SYMLINK_NOFOLLOW
on unices? Should we introduce that flag as an argument across all OSes?
This is in Note, though, that the inability to specify not to follow symlinks when calling |
File.stat
: Support detection of Kind.sym_link
on Windows
Requires an extra NtQueryInformationFile call when FILE_ATTRIBUTE_REPARSE_POINT is set to determine if it's actually a symlink or some other kind of reparse point (https://learn.microsoft.com/en-us/windows/win32/fileio/reparse-point-tags). This is something that `File.Metadata.kind` was already doing, so the same technique is used in `stat`. Also, replace the std.os.windows.DeviceIoControl call in `metadata` with NtQueryInformationFile (NtQueryInformationFile is what gets called during kernel32.GetFileInformationByHandleEx with FileAttributeTagInfo, verified using NtTrace).
b26ade2
to
11a398a
Compare
Looks like the added test uncovered a EDIT: Lines 1336 to 1337 in f36ac22
https://linux.die.net/man/2/open
Seems likely that Linux will fail, too. EDIT#2: Seems like
EDIT#3: Lines 1410 to 1413 in f36ac22
Lines 1369 to 1370 in f36ac22
EDIT#4: If the intention of |
@squeek502 Thanks for the PR. Just a few question:
|
If there's an example of how to go about getting a
Likely just an oversight, the context for the |
60b9523
to
0a6a9d9
Compare
…ow behavior The `no_follow` behavior happened to allow opening a file descriptor of a symlink itself on Windows, but that behavior may change in the future. Instead, we implement the opening of the symlink as a file descriptor manually (and per-platform) in the test case.
0a6a9d9
to
f5d0664
Compare
Requires an extra NtQueryInformationFile call when FILE_ATTRIBUTE_REPARSE_POINT is set to determine if it's actually a symlink or some other kind of reparse point (https://learn.microsoft.com/en-us/windows/win32/fileio/reparse-point-tags). This is something that
File.Metadata.kind
was already doing, so the same technique is used instat
.Also, replace the std.os.windows.DeviceIoControl call in
metadata
with NtQueryInformationFile (NtQueryInformationFile is what gets called during kernel32.GetFileInformationByHandleEx with FileAttributeTagInfo, verified using NtTrace).Addresses the last bit of #18290 that #18323 doesn't.