-
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
[release/6.0-rc1] Add internal junction support to link APIs #58285
Merged
danmoseley
merged 19 commits into
release/6.0-rc1
from
backport/pr-57996-to-release/6.0-rc1
Aug 28, 2021
Merged
[release/6.0-rc1] Add internal junction support to link APIs #58285
danmoseley
merged 19 commits into
release/6.0-rc1
from
backport/pr-57996-to-release/6.0-rc1
Aug 28, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… refactored/removed in the future. Detect if SUBST is available in Windows machine, to bring back Nano.
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsBackport of #57996 to release/6.0-rc1 /cc @carlossanlop Customer ImpactTestingRisk
|
carlossanlop
added
the
Servicing-consider
Issue for next servicing release review
label
Aug 27, 2021
jozkee
approved these changes
Aug 28, 2021
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #57996 to release/6.0-rc1
/cc @carlossanlop @jozkee
Customer Impact
We added new APIs to
FileSystemInfo
,File
andDirectory
in 6.0 for link manipulation:CreateSymbolicLink(string pathToTarget)
- For creation of a symbolic link of the specified filesystem type.ResolveLinkTarget(bool returnFinalTarget)
- If the specified filesystem item represents a link, the target is returned (immediate or final target).LinkTarget
- If the specified filesystem item represents a link, gets the path of the immediate target path.Initially we wanted these APIs to exclusively work with symbolic links in 6.0, then we would add support for all the other types of links in 7.0 (reparse points like junctions or app exec links).
After some discussions, and after looking at the PowerShell code (which already handles symlinks, junctions and app exec links), we decided that the
ResolveLinkTarget()
andLinkTarget
APIs should be able to also resolve those other types of links. This would allow the PowerShell team to fully migrate their existing link-handling code to our new APIs (here's their code - they currently perform all the P/Invokes themselves).This PR adds only junction support for those APIs. The app exec link support will be backported in a separate PR, which is still being reviewed for main.
By adding junction support, we also fix a bug that a customer reported recently in the new APIs: when a symbolic link lives inside a virtual drive (a directory mounted on a drive letter), the symbolic link path was not getting resolved properly. This is because a virtual drive is just a junction under the covers, and we were unable to detect it and resolve its target properly.
The
CreateSymbolicLink()
method will remain unaffected.Testing
Added unit tests that create junctions both in normal directories and in virtual drives. They verify if the targets are resolved, whether they are direct (link->target) or indirect (in a chain of links).
Risk
Low. These are all new APIs, and the changes only affect new code. The symbolic link logic, which was introduced in a previous Preview, is unaffected. The new logic only kicks in when the filesystem item is a junction (which are links that only work for directories).
The main benefit of this change is to address customer feedback in the new APIs. We shipped link support in preview 7, but we only added support and validated symlinks; those are a subset of reparse points in NTFS, we received feedback in that time frame asking for Junction support, another kind of reparse point, which is what this PR does.
Helping PowerShell with their existing scenarios is an additional, secondary benefit.