Skip to content

Commit f0aa3c6

Browse files
committed
Check the presence of linkat() on Solaris (not available in version 10, available in version 11)
1 parent 7e21b41 commit f0aa3c6

File tree

1 file changed

+6
-5
lines changed
  • library/std/src/sys/unix

1 file changed

+6
-5
lines changed

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

+6-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
3333
target_os = "watchos",
3434
))]
3535
use crate::sys::weak::syscall;
36-
#[cfg(any(target_os = "android", target_os = "macos"))]
36+
#[cfg(any(target_os = "android", target_os = "macos", target_os = "solaris"))]
3737
use crate::sys::weak::weak;
3838

3939
use libc::{c_int, mode_t};
@@ -42,6 +42,7 @@ use libc::{c_int, mode_t};
4242
target_os = "macos",
4343
target_os = "ios",
4444
target_os = "watchos",
45+
target_os = "solaris",
4546
all(target_os = "linux", target_env = "gnu")
4647
))]
4748
use libc::c_char;
@@ -1423,15 +1424,15 @@ pub fn link(original: &Path, link: &Path) -> io::Result<()> {
14231424
run_path_with_cstr(original, |original| {
14241425
run_path_with_cstr(link, |link| {
14251426
cfg_if::cfg_if! {
1426-
if #[cfg(any(target_os = "vxworks", target_os = "redox", target_os = "android", target_os = "espidf", target_os = "horizon", target_os = "solaris"))] {
1427-
// VxWorks, Redox, ESP-IDF and Solaris lack `linkat`, so use `link` instead. POSIX leaves
1427+
if #[cfg(any(target_os = "vxworks", target_os = "redox", target_os = "android", target_os = "espidf", target_os = "horizon"))] {
1428+
// VxWorks, Redox and ESP-IDF lack `linkat`, so use `link` instead. POSIX leaves
14281429
// it implementation-defined whether `link` follows symlinks, so rely on the
14291430
// `symlink_hard_link` test in library/std/src/fs/tests.rs to check the behavior.
14301431
// Android has `linkat` on newer versions, but we happen to know `link`
14311432
// always has the correct behavior, so it's here as well.
14321433
cvt(unsafe { libc::link(original.as_ptr(), link.as_ptr()) })?;
1433-
} else if #[cfg(target_os = "macos")] {
1434-
// On MacOS, older versions (<=10.9) lack support for linkat while newer
1434+
} else if #[cfg(any(target_os = "macos", target_os = "solaris"))] {
1435+
// MacOS (<=10.9) and Solaris 10 lack support for linkat while newer
14351436
// versions have it. We want to use linkat if it is available, so we use weak!
14361437
// to check. `linkat` is preferable to `link` because it gives us a flag to
14371438
// specify how symlinks should be handled. We pass 0 as the flags argument,

0 commit comments

Comments
 (0)