support `fstat64` on linux
Author: JefffreyCreated Aug 27, 2026Updated Sep 4, 2026
LabelsC-enhancementA-shims
main usecase is to support reopen in tempfile:
#[cfg(test)]
mod tests {
#[test]
fn test123() {
let a = tempfile::NamedTempFile::new().unwrap();
a.reopen().unwrap();
}
}tempfile = "3.27.0"cargo 1.100.0-nightly (e8cb624d5 2026-08-22)
currently:
test123 (main)$ MIRIFLAGS="-Zmiri-disable-isolation" cargo +nightly miri test --target x86_64-unknown-linux-gnu
Finished `test` profile [unoptimized + debuginfo] target(s) in 0.01s
Running unittests src/main.rs (/Users/jeffrey/.cargo_target_cache/miri/x86_64-unknown-linux-gnu/debug/build/test123/c6bc3d26cee920f1/out/test123-c6bc3d26cee920f1)
running 1 test
test tests::test123 ... error: unsupported operation: can't call foreign function `fstat64` on OS `linux`
--> /Users/jeffrey/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-1.1.4/src/backend/libc/fs/syscalls.rs:1569:13
|
1569 | ret(c::fstat(borrowed_fd(fd), stat.as_mut_ptr().cast()))?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unsupported operation occurred here
|
= help: this means the program tried to do something Miri does not support; it does not indicate a bug in the program
= note: this is on thread `tests::test123`
= note: stack backtrace:
0: rustix::backend::fs::syscalls::fstat
at /Users/jeffrey/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-1.1.4/src/backend/libc/fs/syscalls.rs:1569:13: 1569:64
1: rustix::fs::fd::fstat::<&std::fs::File>
at /Users/jeffrey/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-1.1.4/src/fs/fd.rs:157:5: 157:45
2: tempfile::file::imp::platform::reopen
at /Users/jeffrey/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tempfile-3.27.0/src/file/imp/unix.rs:83:20: 83:43
3: tempfile::NamedTempFile::reopen
at /Users/jeffrey/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tempfile-3.27.0/src/file/mod.rs:952:9: 952:63
4: tests::test123
at src/main.rs:10:9: 10:19
5: tests::test123::{closure#0}
at src/main.rs:8:17: 8:17
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: aborting due to 1 previous error
error: test failed, to rerun pass `--bin test123`
Caused by:
process didn't exit successfully: `/Users/jeffrey/.rustup/toolchains/nightly-aarch64-apple-darwin/bin/cargo-miri runner /Users/jeffrey/.cargo_target_cache/miri/x86_64-unknown-linux-gnu/debug/build/test123/c6bc3d26cee920f1/out/test123-c6bc3d26cee920f1` (exit status: 1)
note: test exited abnormally; to see the full output pass --no-capture to the harness.related PR/issue:
Source: rust-lang/miri