Skip to content

Commit d4304e4

Browse files
Rollup merge of rust-lang#126351 - devnexen:to_sol11_upd, r=ChrisDenton
std::unix::fs::link using direct linkat call for Solaris. Since we support solaris 11 as minimum, we can get rid of the runtime overhead.
2 parents 38f1c6a + 075f068 commit d4304e4

File tree

1 file changed

+1
-14
lines changed
  • library/std/src/sys/pal/unix

1 file changed

+1
-14
lines changed

library/std/src/sys/pal/unix/fs.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
2222

2323
#[cfg(any(all(target_os = "linux", target_env = "gnu"), target_vendor = "apple"))]
2424
use crate::sys::weak::syscall;
25-
#[cfg(any(target_os = "android", target_os = "macos", target_os = "solaris"))]
25+
#[cfg(target_os = "android")]
2626
use crate::sys::weak::weak;
2727

2828
use libc::{c_int, mode_t};
@@ -1753,19 +1753,6 @@ pub fn link(original: &Path, link: &Path) -> io::Result<()> {
17531753
// Android has `linkat` on newer versions, but we happen to know `link`
17541754
// always has the correct behavior, so it's here as well.
17551755
cvt(unsafe { libc::link(original.as_ptr(), link.as_ptr()) })?;
1756-
} else if #[cfg(any(target_os = "macos", target_os = "solaris"))] {
1757-
// MacOS (<=10.9) and Solaris 10 lack support for linkat while newer
1758-
// versions have it. We want to use linkat if it is available, so we use weak!
1759-
// to check. `linkat` is preferable to `link` because it gives us a flag to
1760-
// specify how symlinks should be handled. We pass 0 as the flags argument,
1761-
// meaning it shouldn't follow symlinks.
1762-
weak!(fn linkat(c_int, *const c_char, c_int, *const c_char, c_int) -> c_int);
1763-
1764-
if let Some(f) = linkat.get() {
1765-
cvt(unsafe { f(libc::AT_FDCWD, original.as_ptr(), libc::AT_FDCWD, link.as_ptr(), 0) })?;
1766-
} else {
1767-
cvt(unsafe { libc::link(original.as_ptr(), link.as_ptr()) })?;
1768-
};
17691756
} else {
17701757
// Where we can, use `linkat` instead of `link`; see the comment above
17711758
// this one for details on why.

0 commit comments

Comments
 (0)