Auto merge of #3781 - RalfJung:flock, r=RalfJung
flock: a bit of cleanup Follow-up to https://github.com/rust-lang/miri/pull/3759
This commit is contained in:
commit
769e900d23
@ -12,6 +12,13 @@
|
||||
use crate::shims::unix::*;
|
||||
use crate::*;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
||||
pub(crate) enum FlockOp {
|
||||
SharedLock { nonblocking: bool },
|
||||
ExclusiveLock { nonblocking: bool },
|
||||
Unlock,
|
||||
}
|
||||
|
||||
/// Represents an open file descriptor.
|
||||
pub trait FileDescription: std::fmt::Debug + Any {
|
||||
fn name(&self) -> &'static str;
|
||||
@ -567,10 +574,3 @@ fn write(
|
||||
Ok(Scalar::from_target_isize(this.try_unwrap_io_result(result)?, this))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
||||
pub(crate) enum FlockOp {
|
||||
SharedLock { nonblocking: bool },
|
||||
ExclusiveLock { nonblocking: bool },
|
||||
Unlock,
|
||||
}
|
||||
|
@ -198,8 +198,8 @@ fn flock<'tcx>(
|
||||
let code: u32 = err.raw_os_error().unwrap().try_into().unwrap();
|
||||
if matches!(code, ERROR_IO_PENDING | ERROR_LOCK_VIOLATION) {
|
||||
if lock_nb {
|
||||
// Replace error with a custom WouldBlock error, which later will be
|
||||
// mapped in the `helpers` module
|
||||
// The io error mapping does not know about these error codes,
|
||||
// so we translate it to `WouldBlock` manually.
|
||||
let desc = format!("LockFileEx wouldblock error: {err}");
|
||||
err = io::Error::new(io::ErrorKind::WouldBlock, desc);
|
||||
} else {
|
||||
|
@ -1,4 +1,3 @@
|
||||
// Flock tests are separate since they don't in general work on a Windows host.
|
||||
//@ignore-target-windows: File handling is not implemented yet
|
||||
//@compile-flags: -Zmiri-disable-isolation
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user