From f01d2bff749e23dcf1568adeeb2e0a02df9c1322 Mon Sep 17 00:00:00 2001 From: Pointerbender Date: Thu, 8 Dec 2022 19:41:42 +0100 Subject: [PATCH] check `O_TMPFILE` flag on linux only --- src/shims/unix/fs.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/shims/unix/fs.rs b/src/shims/unix/fs.rs index afcb506c14..7d60273232 100644 --- a/src/shims/unix/fs.rs +++ b/src/shims/unix/fs.rs @@ -605,12 +605,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { // (Technically we do not support *not* setting this flag, but we ignore that.) mirror |= o_cloexec; } - let o_tmpfile = this.eval_libc_i32("O_TMPFILE")?; - if flag & o_tmpfile != 0 { - // if the flag contains `O_TMPFILE` then we return a graceful error - let eopnotsupp = this.eval_libc("EOPNOTSUPP")?; - this.set_last_error(eopnotsupp)?; - return Ok(-1); + if cfg!(target_os = "linux") { + let o_tmpfile = this.eval_libc_i32("O_TMPFILE")?; + if flag & o_tmpfile != 0 { + // if the flag contains `O_TMPFILE` then we return a graceful error + let eopnotsupp = this.eval_libc("EOPNOTSUPP")?; + this.set_last_error(eopnotsupp)?; + return Ok(-1); + } } // If `flag` is not equal to `mirror`, there is an unsupported option enabled in `flag`, // then we throw an error.