Skip to content

Commit

Permalink
Disable use of linkat on Android as well.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sunfishcode committed Oct 24, 2020
1 parent d0178b4 commit 6249cda
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions library/std/src/sys/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6249cda

Please sign in to comment.