Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2872,7 +2872,7 @@ pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> io::Result<u64> {
///
/// This function currently corresponds to the `CreateHardLink` function on Windows.
/// On most Unix systems, it corresponds to the `linkat` function with no flags.
/// On Android, VxWorks, and Redox, it instead corresponds to the `link` function.
/// On VxWorks and Redox, it instead corresponds to the `link` function.
/// On MacOS, it uses the `linkat` function if it is available, but on very old
/// systems where `linkat` is not available, `link` is selected at runtime instead.
/// Note that, this [may change in the future][changes].
Expand Down
3 changes: 0 additions & 3 deletions library/std/src/sys/fs/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2057,9 +2057,6 @@ pub fn link(original: &CStr, link: &CStr) -> io::Result<()> {
target_os = "vxworks",
target_os = "redox",
target_os = "espidf",
// Android has `linkat` on newer versions, but we happen to know
// `link` always has the correct behavior, so it's here as well.
target_os = "android",
// Other misc platforms
target_os = "horizon",
target_os = "vita",
Expand Down
5 changes: 1 addition & 4 deletions src/tools/miri/tests/pass/shims/fs.rs

@the8472 the8472 Jul 22, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those miri tests executed anywhere on an android system/emulator?
All the hard_link tests in the std testsuite are guarded with this:

#[cfg_attr(target_os = "android", ignore = "Android SELinux rules prevent creating hardlinks")]

This was introduced in #102757
So we have nominal hardlink support on android but it's not available to regular apps. OS components might be able to use it, but we're not testing that at the moment.

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, those tests are only run on Linux natively, and inside Miri on various targets.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So Miri is simulating the android target and the restrictions don't apply, ok.

Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ fn main() {
if cfg!(not(windows)) {
test_directory();
test_canonicalize();
#[cfg(not(target_os = "solaris"))]
#[cfg(not(target_os = "solaris"))] // does not have flock
test_flock();
#[cfg(not(target_os = "android"))]
test_hard_link();

test_readv_writev();
Expand Down Expand Up @@ -559,8 +558,6 @@ fn test_preadv_pwritev() {
assert_eq!(written_bytes.as_slice(), &write_buffer[0..bytes_written]);
}

// std uses `libc::link` on Android which we do not support.
#[cfg(not(target_os = "android"))]
fn test_hard_link() {
let source = utils::prepare_with_content("miri_test_fs_hard_link_source.txt", b"hello");
let link = utils::prepare("miri_test_fs_hard_link_link.txt");
Expand Down
Loading