Skip to content

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

Closed
@ChrisDenton

Description

@ChrisDenton

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ACP-acceptedAPI Change Proposal is accepted (seconded with no objections)T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard libraries

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions