Skip to content

Commit ca52a2c

Browse files
authored
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. try-job: dist-various-2
2 parents 369fa55 + a5fe19d commit ca52a2c

File tree

1 file changed

+2
-19
lines changed
  • std/src/sys/pal/unix

1 file changed

+2
-19
lines changed

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

+2-19
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,12 @@ 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};
2929

30-
#[cfg(any(
31-
target_os = "solaris",
32-
all(target_os = "linux", target_env = "gnu"),
33-
target_vendor = "apple",
34-
))]
30+
#[cfg(any(all(target_os = "linux", target_env = "gnu"), target_vendor = "apple"))]
3531
use libc::c_char;
3632
#[cfg(any(
3733
all(target_os = "linux", not(target_env = "musl")),
@@ -1753,19 +1749,6 @@ pub fn link(original: &Path, link: &Path) -> io::Result<()> {
17531749
// Android has `linkat` on newer versions, but we happen to know `link`
17541750
// always has the correct behavior, so it's here as well.
17551751
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-
};
17691752
} else {
17701753
// Where we can, use `linkat` instead of `link`; see the comment above
17711754
// this one for details on why.

0 commit comments

Comments
 (0)