Skip to content

Commit a603b07

Browse files
committed
disable long filename fallback under miri
1 parent 2b0bee2 commit a603b07

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

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

+7-4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ use libc::c_char;
4343
use libc::dirfd;
4444
#[cfg(any(target_os = "linux", target_os = "emscripten"))]
4545
use libc::fstatat64;
46+
#[cfg(all(miri, any(target_os = "linux")))]
47+
use libc::open64;
4648
#[cfg(any(
4749
target_os = "android",
4850
target_os = "solaris",
@@ -89,7 +91,7 @@ use libc::{
8991
use libc::{dirent64, fstat64, ftruncate64, lseek64, lstat64, off64_t, stat64};
9092

9193
// FIXME: port this to other unices that support *at syscalls
92-
#[cfg(any(target_os = "linux", target_os = "android"))]
94+
#[cfg(all(not(miri), any(target_os = "linux", target_os = "android")))]
9395
mod dir_fd;
9496

9597
pub use crate::sys_common::fs::try_exists;
@@ -1085,7 +1087,7 @@ impl File {
10851087
pub fn open(path: &Path, opts: &OpenOptions) -> io::Result<File> {
10861088
let result = run_path_with_cstr(path, |path| File::open_c(None, &path, opts));
10871089

1088-
#[cfg(any(target_os = "linux", target_os = "android"))]
1090+
#[cfg(all(not(miri), any(target_os = "linux", target_os = "android")))]
10891091
let result = {
10901092
use crate::io::ErrorKind;
10911093
match result {
@@ -1100,7 +1102,7 @@ impl File {
11001102
result
11011103
}
11021104

1103-
#[cfg(not(any(target_os = "linux", target_os = "android")))]
1105+
#[cfg(any(miri, not(any(target_os = "linux", target_os = "android"))))]
11041106
pub fn open_c(
11051107
dirfd: Option<BorrowedFd<'_>>,
11061108
path: &CStr,
@@ -1779,7 +1781,8 @@ pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {
17791781

17801782
macro long_filename_fallback($path:expr, $result:expr, $fallback:expr) {{
17811783
cfg_if::cfg_if! {
1782-
if #[cfg(any(target_os = "linux", target_os = "android"))] {
1784+
// miri doesn't support the *at syscalls
1785+
if #[cfg(all(not(miri), any(target_os = "linux", target_os = "android")))] {
17831786
dir_fd::long_filename_fallback($result, $path, $fallback)
17841787
} else {
17851788
$result

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ cfg_if::cfg_if! {
420420
}
421421
}
422422

423-
#[cfg(not(any(target_os = "linux", target_os = "android")))]
423+
#[cfg(any(miri, not(any(target_os = "linux", target_os = "android"))))]
424424
mod unsupported {
425425
use crate::io;
426426

0 commit comments

Comments
 (0)