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

ACP: std::os::windows::fs::junction_point #203

Closed
ChrisDenton opened this issue Apr 5, 2023 · 0 comments
Closed

ACP: std::os::windows::fs::junction_point #203

ChrisDenton opened this issue Apr 5, 2023 · 0 comments
Labels
ACP-accepted API Change Proposal is accepted (seconded with no objections) api-change-proposal A proposal to add or alter unstable APIs in the standard libraries T-libs-api

Comments

@ChrisDenton
Copy link
Member

ChrisDenton commented Apr 5, 2023

Proposal

Problem statement

On Windows creating symlinks is (be default) a privileged operation. However, many types of applications may want to create links. Junction points can be used by less privileged users to create directory links.

Motivation, use-cases

For example, bootstrap uses junction points as an alternative to symlinks on Windows: https://github.com/rust-lang/rust/blob/90a9f69c80812c8694959c1f2d5c336e3300d1e2/src/bootstrap/util.rs#L134-L135

Solution sketches

// std::os::windows::fs

/// Create a junction point.
///
/// The `link` path will be a directory junction pointing to the original path.
/// If `link` is a relative path then it will be made absolute prior to creating the junction point.
/// The `original` path must be a directory or a link to a directory, otherwise the junction point will be broken.
///
/// If either path is not a local file path then this will fail.
fn junction_point<P: AsRef<Path>, Q: AsRef<Path>>(
    original: P,
    link: Q
) -> Result<()>;

Links and related work

  • Windows only std::os::windows::fssymlink_dir function for creating directory symlinks (which is likely to fail for most users due to lack of privileges).
  • The standard library already has a function for creating junction points but it's only used in tests. See symlink_junction

What happens now?

This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals in its weekly meeting. You should receive feedback within a week or two.

@ChrisDenton ChrisDenton added api-change-proposal A proposal to add or alter unstable APIs in the standard libraries T-libs-api labels Apr 5, 2023
@m-ou-se m-ou-se closed this as completed Feb 27, 2024
@Amanieu Amanieu added the ACP-accepted API Change Proposal is accepted (seconded with no objections) label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ACP-accepted API Change Proposal is accepted (seconded with no objections) api-change-proposal A proposal to add or alter unstable APIs in the standard libraries T-libs-api
Projects
None yet
Development

No branches or pull requests

3 participants