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

[release/6.0-rc1] Add internal junction support to link APIs #58285

Merged
merged 19 commits into from
Aug 28, 2021

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Aug 27, 2021

Backport of #57996 to release/6.0-rc1

/cc @carlossanlop @jozkee

Customer Impact

We added new APIs to FileSystemInfo, File and Directory 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() and LinkTarget 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.

@ghost
Copy link

ghost commented Aug 27, 2021

Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.

Issue Details

Backport of #57996 to release/6.0-rc1

/cc @carlossanlop

Customer Impact

Testing

Risk

Author: github-actions[bot]
Assignees: -
Labels:

area-System.IO

Milestone: -

@jozkee jozkee requested a review from danmoseley August 27, 2021 18:55
@carlossanlop carlossanlop added the Servicing-consider Issue for next servicing release review label Aug 27, 2021
@danmoseley danmoseley merged commit 9edb089 into release/6.0-rc1 Aug 28, 2021
@danmoseley danmoseley deleted the backport/pr-57996-to-release/6.0-rc1 branch August 28, 2021 02:04
@ghost ghost locked as resolved and limited conversation to collaborators Sep 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.IO Servicing-consider Issue for next servicing release review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants