| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Impressive fix... relying on very undocumented stuff if you ask me... unless "named surrogates" and "data.dwReserved0 & 0x20000000" is documented somewhere. Steve Lee (@SteveL-MSFT)?
|
Sorry, something went wrong.
|
Stéphane BARIZIEN (@sba923) correct, next version is 7.0-preview.1. As noted in the comments in the change, the use of dwReserved0 & 0x20000000 is documented via the macro published in the Windows SDK header. I agree that it would have been better as an API (or even better just another FileAttribute), but that's what we have to work with right now. |
Sorry, something went wrong.
|
Steve Lee (@SteveL-MSFT) Thanks for the confirmation about 7.0. I had missed the comment with the reference to the IsReparseTagNameSurrogate macro, sorry for that. Reparse point tags are documented here, this documents the N (Name surrogate) bit with value 0x20000000, and links to another documentation for the macro. The documentation for WIN32_FIND_DATAA documents that symlinks use a reparse point tag of IO_REPARSE_TAG_SYMLINK (0xA000000C) that has the N bit set. To satisfy my curiosity, I will check what reparse point tag (with the N bit not set) is used by OneDrive (and request that it be added to the documentation). |
Sorry, something went wrong.
| { | ||
| #if !UNIX | ||
| var data = new WIN32_FIND_DATA(); | ||
| using (SafeFileHandle handle = FindFirstFileEx(filePath, FINDEX_INFO_LEVELS.FindExInfoBasic, ref data, FINDEX_SEARCH_OPS.FindExSearchNameMatch, IntPtr.Zero, 0)) |
There was a problem hiding this comment.
Perhaps we could use method with fewer parameters
https://github.com/dotnet/corefx/blob/87089ef4559605f8a34ca8959a0ef9c71aa1e02e/src/System.IO.FileSystem/src/System/IO/FileSystem.Windows.cs#L241
I do very wonder that CoreFX uses IsNameSurrogateReparsePoint() method only for recurse directory remove but not for recurse directory read.
Sorry, something went wrong.
There was a problem hiding this comment.
CoreFx uses FindFirstFileEx() as well, they just name their wrapper FindFirstFile()
Sorry, something went wrong.
There was a problem hiding this comment.
On the second point, I agree it might be an oversight that they don't have symmetric behavior.
Sorry, something went wrong.
|
I've collected my findings about the reparse tags used by OneDrive in this spreadsheet. https://docs.microsoft.com/en-us/windows/desktop/w8cookbook/placeholder-files is definitely outdated, as Windows 10 OneDrive doesn't use IO_REPARSE_TAG_FILE_PLACEHOLDER anymore. Instead, it uses a number of tags from IO_REPARSE_TAG_CLOUD_1 to IO_REPARSE_TAG_CLOUD_F (on my system I found only 3 values being used), with a IO_REPARSE_TAG_CLOUD_MASK that apparently can be used to compute (tag & IO_REPARSE_TAG_CLOUD_MASK) >> 12 and get some value between 1 and 15 that the OneDrive sync client probably uses as information about the item... I'm not sure where to post the request to document all this. Steve Lee (@SteveL-MSFT): can you help? |
Sorry, something went wrong.
|
For now I've opened MicrosoftDocs/feedback#1484 and MicrosoftDocs/feedback#1483 |
Sorry, something went wrong.
| IntPtr hTemplateFile); | ||
|
|
||
| [DllImport(PinvokeDllNames.FindFirstFileDllName, EntryPoint = "FindFirstFileExW", SetLastError = true, CharSet = CharSet.Unicode)] | ||
| private static extern SafeFileHandle FindFirstFileEx(string lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, ref WIN32_FIND_DATA lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, IntPtr lpSearchFilter, int dwAdditionalFlags); |
There was a problem hiding this comment.
This returns a SafeFileHandle, which eventually calls CloseHandle.
According to the FindFirstFileExW documentation, the handle should be closed with FindClose, not CloseHandle.
Sorry, something went wrong.
There was a problem hiding this comment.
Nice catch! Will submit a new PR to address.
Sorry, something went wrong.
There was a problem hiding this comment.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
The current logic of Get-ChildItem -Recurse for the FileSystemProvider is that if it's a symlink, we don't recurse into it unless -FollowSymLink is specified. However, OneDrive reparse points aren't symlinks (in that they don't link to the local filesystem). There is another flag (on Windows) to indicate if the reparse point is a named surrogate which means it IS a symlink. So the fix is to check for this flag and if it's not a named surrogate (aka symlink), it is ok to recurse into it.
Manually verified with OneDrive.
PR Context
Fix #9461
PR Checklist