Skip to content

Commit d2e283b

Browse files
committed
Auto merge of #1394 - RalfJung:fs-mode, r=RalfJung
fs shim: check that mode is default
2 parents 13f1b5f + 45ef975 commit d2e283b

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/shims/fs.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -246,18 +246,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
246246

247247
let flag = this.read_scalar(flag_op)?.to_i32()?;
248248

249-
// Check mode (size depends on platform).
250-
// FIXME: should we do something with the mode?
251-
match this.tcx.sess.target.target.target_os.as_str() {
252-
"macos" => {
253-
// FIXME: I think `mode` should be `u16` on macOS, but see
254-
// <https://github.com/rust-lang/rust/issues/71915>.
255-
// For now, just don't check on macos.
256-
}
257-
_ => {
258-
this.read_scalar(mode_op)?.to_u32()?;
259-
}
260-
};
249+
// Get the mode. On macOS, the argument type `mode_t` is actually `u16`, but
250+
// C integer promotion rules mean that on the ABI level, it gets passed as `u32`
251+
// (see https://github.com/rust-lang/rust/issues/71915).
252+
let mode = this.read_scalar(mode_op)?.to_u32()?;
253+
if mode != 0o666 {
254+
throw_unsup_format!("non-default mode 0o{:o} is not supported", mode);
255+
}
261256

262257
let mut options = OpenOptions::new();
263258

0 commit comments

Comments
 (0)