Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions library/std/src/sys/fs/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2077,12 +2077,25 @@ pub fn symlink(original: &CStr, link: &CStr) -> io::Result<()> {

pub fn link(original: &CStr, link: &CStr) -> io::Result<()> {
cfg_select! {
any(target_os = "vxworks", target_os = "redox", target_os = "android", target_os = "espidf", target_os = "horizon", target_os = "vita", target_env = "nto70") => {
// VxWorks, Redox and ESP-IDF lack `linkat`, so use `link` instead. POSIX leaves
// it implementation-defined whether `link` follows symlinks, so rely on the
// `symlink_hard_link` test in library/std/src/fs/tests.rs to check the behavior.
// Android has `linkat` on newer versions, but we happen to know `link`
// always has the correct behavior, so it's here as well.
any(
// VxWorks, Redox and ESP-IDF lack `linkat`, so use `link` instead.
// POSIX leaves it implementation-defined whether `link` follows
// symlinks, so rely on the `symlink_hard_link` test in
// library/std/src/fs/tests.rs to check the behavior.
target_os = "vxworks",
target_os = "redox",
target_os = "espidf",
// Android has `linkat` on newer versions, but we happen to know
// `link` always has the correct behavior, so it's here as well.
target_os = "android",
// wasi-sdk-29-and-prior have a buggy `linkat` so use `link` instead
// until wasi-sdk is updated (see WebAssembly/wasi-libc#690)
target_os = "wasi",
// Other misc platforms
target_os = "horizon",
target_os = "vita",
target_env = "nto70",
) => {
Comment on lines -2080 to +2098
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a note for this I took the liberty to reformat the line to be less long and arrange the comments to apply to the platform-in-question too.

cvt(unsafe { libc::link(original.as_ptr(), link.as_ptr()) })?;
}
_ => {
Expand Down
Loading