-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add graceful shim for the custom O_TMPFILE
file opening flag plus test case
#2718
Conversation
Thank you for the speedy review @RalfJung! I just pushed all the requested changes :) |
LGTM if CI passes, but please squash the commits. |
9bd4f6b
to
acb51b5
Compare
Thanks! The CI passed just now and the commits are squashed, too 👍 |
@bors r+ |
☀️ Test successful - checks-actions |
@@ -605,6 +605,15 @@ 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; | |||
} | |||
if this.tcx.sess.target.os == "linux" { | |||
let o_tmpfile = this.eval_libc_i32("O_TMPFILE")?; | |||
if flag & o_tmpfile != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you noted, O_TMPFILE = 0x410000
, which is more than one bit. This is for historical reasons, since the open() syscall ignores unrecognized flags: https://lwn.net/Articles/588444/
So the right check should be flag & o_tmpfile == o_tmpfile
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! Since this PR is already merged, I will address your feedback within my other related PR #2720
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it looks like #2720 might be a bit more tricky, it'd be good to have a separate PR for this.
update Miri Noteworthy PRs: - rust-lang/miri#2357 - rust-lang/miri#2646 - rust-lang/miri#2718 - rust-lang/miri#2721 - rust-lang/miri#2725
update Miri Noteworthy PRs: - rust-lang#2357 - rust-lang#2646 - rust-lang#2718 - rust-lang#2721 - rust-lang#2725
update Miri Noteworthy PRs: - rust-lang/miri#2357 - rust-lang/miri#2646 - rust-lang/miri#2718 - rust-lang/miri#2721 - rust-lang/miri#2725
I'm trying if I can get the
tempfile
crate to work nicely with miri. Right now miri errors out due to an unsupported flagO_TMPFILE
(=0x410000
) passed toOpenOptions::custom_flags
. Interestingly,tempfile
has a fallback in case the underlying file system does not support theO_TMPFILE
flag, in which caseopen
/open64
is expected to return the error codeEOPNOTSUPP
(=95
). This PR adds support for this scenario and also includes a test case (relevant zulip discussion).