Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
9 changes: 7 additions & 2 deletions src/shims/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
);
};

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

mirror |= o_creat;
Expand Down
42 changes: 42 additions & 0 deletions test_dependencies/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test_dependencies/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ tokio = { version = "1.0", features = ["full"] }
libc = "0.2"
page_size = "0.5"
num_cpus = "1.10.1"
tempfile = "3"

getrandom_1 = { package = "getrandom", version = "0.1" }
getrandom = { version = "0.2" }
Expand Down
34 changes: 34 additions & 0 deletions tests/pass-dep/tempfile.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//@ignore-target-windows: no libc on Windows
//@compile-flags: -Zmiri-disable-isolation

//! Test that the [`tempfile`] crate is compatible with miri.
fn main() {
test_tempfile();
test_tempfile_in();
}

fn tmp() -> PathBuf {
std::env::var("MIRI_TEMP")
.map(|tmp| {
// MIRI_TEMP is set outside of our emulated
// program, so it may have path separators that don't
// correspond to our target platform. We normalize them here
// before constructing a `PathBuf`

#[cfg(windows)]
return PathBuf::from(tmp.replace("/", "\\"));

#[cfg(not(windows))]
return PathBuf::from(tmp.replace("\\", "/"));
})
.unwrap_or_else(|_| std::env::temp_dir())
}

fn test_tempfile() {
tempfile::tempfile().unwrap();
}

fn test_tempfile_in() {
let dir_path = tmp();
tempfile::tempfile_in(dir_path).unwrap();
}