move reject with isolation for fcntl under F_FULLFSYNC
This commit is contained in:
parent
8a3688926c
commit
0e2e617825
7 changed files with 26 additions and 17 deletions
|
|
@ -628,13 +628,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
|||
let fd = this.read_scalar(&args[0])?.to_i32()?;
|
||||
let cmd = this.read_scalar(&args[1])?.to_i32()?;
|
||||
|
||||
// Reject if isolation is enabled.
|
||||
if let IsolatedOp::Reject(reject_with) = this.machine.isolated_op {
|
||||
this.reject_in_isolation("`fcntl`", reject_with)?;
|
||||
this.set_last_error_from_io_error(ErrorKind::PermissionDenied)?;
|
||||
return Ok(-1);
|
||||
}
|
||||
|
||||
// We only support getting the flags for a descriptor.
|
||||
if cmd == this.eval_libc_i32("F_GETFD") {
|
||||
// Currently this is the only flag that `F_GETFD` returns. It is OK to just return the
|
||||
|
|
@ -677,6 +670,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
|||
None => this.handle_not_found(),
|
||||
}
|
||||
} else if this.tcx.sess.target.os == "macos" && cmd == this.eval_libc_i32("F_FULLFSYNC") {
|
||||
// Reject if isolation is enabled.
|
||||
if let IsolatedOp::Reject(reject_with) = this.machine.isolated_op {
|
||||
this.reject_in_isolation("`fcntl`", reject_with)?;
|
||||
this.set_last_error_from_io_error(ErrorKind::PermissionDenied)?;
|
||||
return Ok(-1);
|
||||
}
|
||||
|
||||
if let Some(file_descriptor) = this.machine.file_handler.handles.get(&fd) {
|
||||
// FIXME: Support fullfsync for all FDs
|
||||
let FileHandle { file, writable } =
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
//@only-target-apple: F_FULLFSYNC only on apple systems
|
||||
//@compile-flags: -Zmiri-isolation-error=warn-nobacktrace
|
||||
|
||||
use std::io::Error;
|
||||
|
||||
fn main() {
|
||||
// test `fcntl(F_FULLFSYNC)`
|
||||
unsafe {
|
||||
assert_eq!(libc::fcntl(1, libc::F_FULLFSYNC, 0), -1);
|
||||
assert_eq!(Error::last_os_error().raw_os_error(), Some(libc::EPERM));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
warning: `fcntl` was made to return an error due to isolation
|
||||
|
||||
|
|
@ -7,10 +7,9 @@ use std::fs;
|
|||
use std::io::{Error, ErrorKind};
|
||||
|
||||
fn main() {
|
||||
// test `fcntl`
|
||||
// test `fcntl(F_DUPFD): should work even with isolation.`
|
||||
unsafe {
|
||||
assert_eq!(libc::fcntl(1, libc::F_DUPFD, 0), -1);
|
||||
assert_eq!(Error::last_os_error().raw_os_error(), Some(libc::EPERM));
|
||||
assert!(libc::fcntl(1, libc::F_DUPFD, 0) >= 0);
|
||||
}
|
||||
|
||||
// test `readlink`
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
warning: `fcntl` was made to return an error due to isolation
|
||||
|
||||
warning: `readlink` was made to return an error due to isolation
|
||||
|
||||
warning: `$STAT` was made to return an error due to isolation
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
//@compile-flags: -Zmiri-disable-isolation -Zmiri-permissive-provenance -Zmiri-backtrace=full
|
||||
//@compile-flags: -Zmiri-permissive-provenance -Zmiri-backtrace=full
|
||||
//@only-target-x86_64-unknown-linux: support for tokio only on linux and x86
|
||||
|
||||
use tokio::time::{sleep, Duration, Instant};
|
||||
|
|
@ -7,8 +7,6 @@ use tokio::time::{sleep, Duration, Instant};
|
|||
async fn main() {
|
||||
let start = Instant::now();
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
// It takes 96 millisecond to sleep for 1 millisecond
|
||||
// It takes 1025 millisecond to sleep for 1 second
|
||||
let time_elapsed = &start.elapsed().as_millis();
|
||||
assert!(time_elapsed > &1000, "{}", time_elapsed);
|
||||
assert!((1000..1100).contains(time_elapsed), "{}", time_elapsed);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// Need to disable preemption to stay on the supported MVP codepath in mio.
|
||||
//@compile-flags: -Zmiri-disable-isolation -Zmiri-permissive-provenance
|
||||
//@compile-flags: -Zmiri-permissive-provenance
|
||||
//@only-target-x86_64-unknown-linux: support for tokio exists only on linux and x86
|
||||
|
||||
#[tokio::main]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue