about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDan Gohman <dev@sunfishcode.online>2020-10-23 15:39:02 -0700
committerDan Gohman <dev@sunfishcode.online>2020-10-24 09:43:31 -0700
commit6249cda78f0cd32b60fb11702b7ffef3e3bab0b2 (patch)
treea9bf73ee38de46bdc3692dfe256133b35d008946
parentd0178b4f99c70d2443f9b76421429d0d23dadc45 (diff)
downloadrust-6249cda78f0cd32b60fb11702b7ffef3e3bab0b2.tar.gz
rust-6249cda78f0cd32b60fb11702b7ffef3e3bab0b2.zip
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
-rw-r--r--library/std/src/sys/unix/fs.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs
index bf4c9419287..ec721fccaa6 100644
--- a/library/std/src/sys/unix/fs.rs
+++ b/library/std/src/sys/unix/fs.rs
@@ -1068,11 +1068,11 @@ pub fn link(src: &Path, dst: &Path) -> io::Result<()> {
     let src = cstr(src)?;
     let dst = cstr(dst)?;
     cfg_if::cfg_if! {
-        if #[cfg(any(target_os = "vxworks", target_os = "redox"))] {
-            // VxWorks and Redox 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.
+        if #[cfg(any(target_os = "vxworks", target_os = "redox", target_os = "android"))] {
+            // VxWorks, Redox, and old versions of Android 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.
             cvt(unsafe { libc::link(src.as_ptr(), dst.as_ptr()) })?;
         } else {
             // Use `linkat` with `AT_FDCWD` instead of `link` as `linkat` gives