-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Preview 7 Improper LinkTarget returned for a Directory Junction on Windows #57575
Comments
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsMain IssueWhen a directory is a junction (as opposed to being a regular directory or a symlink) on Windows, as of Preview 7,
Strangely, I suspect the issue comes that you have an incorrect check for a reparse tag kind in your code: runtime/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Windows.cs Line 506 in eeee548
Should instead be: if (rdb.ReparseTag != Interop.Kernel32.IOReparseOptions.IO_REPARSE_TAG_SYMLINK) Since you say you support symlinks only ATM. Smaller issueOn Windows, there is an inconsistency of final targets returned depending on which APIs are used, and whether or not virtual drives created with subst command are used in the path (both the link and the target residing on such virtual drives): The So, given a structure like this:
Calling While calling Even though, logically, and for consistency results should be the same.
|
@carlossanlop @jozkee PTAL |
Thanks for your report, @fitdev The "main issue" should get moved to 7.0. As you correctly stated, we only support symlinks at the moment. I'm moving the "smaller issue" into a separate issue, and we can then determine if it should be fixed for 6.0 or 7.0. |
@carlossanlop Thanks for looking into this. However this issue was not about supporting Junctions. It was about a bug in Preview 7 and your current code that basically returns a target (i.e. non-null string) even if the directory is a Junction. Instead it should return null then, and certainly NOT the totally erroneous path as it does currently. I mean if DotNet 6 does not support Junctions, then it should not support them at all, i.e. LinkTarget and ResolveLinkTarget should all return |
Good point, @fitdev. I'll mark it for 6.0 and return null for junctions. |
@fitdev I had a conversation with @jozkee and there's no need to return |
If it would work correctly, I suppose. But currently it does not work correctly, see my original issue comment:
Better to just return null until Junctions are properly supported instead of an improper path like this. |
Noted. With the bug fix, the |
@carlossanlop I noticed you merged your changes into main yesterday. However, I see that you still use the old check to determine reparse tag kind: runtime/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Windows.cs Lines 559 to 560 in cc0c121
Shouldn't these be: ((data.dwReserved0 != Interop.Kernel32.IOReparseOptions.IO_REPARSE_TAG_SYMLINK) &&
(data.dwReserved0 != Interop.Kernel32.IOReparseOptions.IO_REPARSE_TAG_MOUNT_POINT))) I mean otherwise, supposing reparse tag was say |
The fix for that will be in .NET 6-RC2 release. |
When a directory is a junction (as opposed to being a regular directory or a symlink) on Windows, as of Preview 7,
DirectoryInfo.LinkTarget
returns a non-null value, which is wrong. Considering a structure like this:DirectoryInfo.LinkTarget
forC:\Test\JunctionToRealFolder
returns\Test\RealFolder
(instead ofC:\Test\RealFolder
)DirectoryInfo.LinkTarget
forC:\Test\SymlinkToRealFolder
returnsC:\Test\RealFolder
(which is correct)Strangely,
DirectoryInfo.ResolveLinkTarget(returnFinalTarget: true)
returns the correct target in all cases (Junction and Symlink).I suspect the issue comes that you have an incorrect check for a reparse tag kind in your code:
runtime/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Windows.cs
Line 506 in eeee548
Should instead be:
Since you say you support symlinks only ATM.
The text was updated successfully, but these errors were encountered: