Skip to content

Commit 566c541

Browse files
committed
add support for the tempfile crate
1 parent a64c1fd commit 566c541

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

src/shims/unix/fs.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
585585
);
586586
};
587587

588-
if mode != 0o666 {
589-
throw_unsup_format!("non-default mode 0o{:o} is not supported", mode);
588+
// currently we only support that the owner must always have
589+
// read-write permissions and that none of the owner, group
590+
// and other may have execute permissions.
591+
let owner_has_read_write_permissions = mode & 0o600 == 0o600;
592+
let has_any_execute_permissions = mode & 0o111 != 0;
593+
if !owner_has_read_write_permissions || has_any_execute_permissions {
594+
throw_unsup_format!("mode 0o{:o} is not supported", mode);
590595
}
591596

592597
mirror |= o_creat;

test_dependencies/Cargo.lock

+42
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test_dependencies/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ tokio = { version = "1.0", features = ["full"] }
1313
libc = "0.2"
1414
page_size = "0.5"
1515
num_cpus = "1.10.1"
16+
tempfile = "3"
1617

1718
getrandom_1 = { package = "getrandom", version = "0.1" }
1819
getrandom = { version = "0.2" }

tests/pass-dep/shims/libc-fs.rs

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ fn main() {
2020
test_file_open_unix_extra_third_arg();
2121
#[cfg(target_os = "linux")]
2222
test_o_tmpfile_flag();
23+
test_tempfile();
2324
}
2425

2526
fn tmp() -> PathBuf {
@@ -165,3 +166,9 @@ fn test_o_tmpfile_flag() {
165166
.raw_os_error(),
166167
);
167168
}
169+
170+
/// Test that the [`tempfile`] crate is compatible with miri.
171+
fn test_tempfile() {
172+
let dir_path = tmp();
173+
tempfile::tempfile_in(dir_path).unwrap();
174+
}

0 commit comments

Comments
 (0)