Skip to content

Commit 6249cda

Browse files
committed
Disable use of linkat on Android as well.
According to [the bionic status page], `linkat` has only been available since API level 21. Since Android is based on Linux and Linux's `link` doesn't follow symlinks, just use `link` on Android. [the bionic status page]: https://android.googlesource.com/platform/bionic/+/master/docs/status.md
1 parent d0178b4 commit 6249cda

File tree

1 file changed

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

1 file changed

+5
-5
lines changed

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -1068,11 +1068,11 @@ pub fn link(src: &Path, dst: &Path) -> io::Result<()> {
10681068
let src = cstr(src)?;
10691069
let dst = cstr(dst)?;
10701070
cfg_if::cfg_if! {
1071-
if #[cfg(any(target_os = "vxworks", target_os = "redox"))] {
1072-
// VxWorks and Redox lack `linkat`, so use `link` instead. POSIX
1073-
// leaves it implementation-defined whether `link` follows symlinks,
1074-
// so rely on the `symlink_hard_link` test in
1075-
// library/std/src/fs/tests.rs to check the behavior.
1071+
if #[cfg(any(target_os = "vxworks", target_os = "redox", target_os = "android"))] {
1072+
// VxWorks, Redox, and old versions of Android lack `linkat`, so use
1073+
// `link` instead. POSIX leaves it implementation-defined whether
1074+
// `link` follows symlinks, so rely on the `symlink_hard_link` test
1075+
// in library/std/src/fs/tests.rs to check the behavior.
10761076
cvt(unsafe { libc::link(src.as_ptr(), dst.as_ptr()) })?;
10771077
} else {
10781078
// Use `linkat` with `AT_FDCWD` instead of `link` as `linkat` gives

0 commit comments

Comments
 (0)