Skip to content

Commit

Permalink
Auto merge of #3781 - RalfJung:flock, r=RalfJung
Browse files Browse the repository at this point in the history
flock: a bit of cleanup

Follow-up to #3759
  • Loading branch information
bors committed Aug 1, 2024
2 parents eee8eb6 + 9b64225 commit cc70cad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/shims/unix/fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ use rustc_target::abi::Size;
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;
Expand Down Expand Up @@ -567,10 +574,3 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
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,
}
4 changes: 2 additions & 2 deletions src/shims/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ impl FileDescription for FileHandle {
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 {
Expand Down
1 change: 0 additions & 1 deletion tests/pass-dep/libc/libc-fs-flock.rs
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit cc70cad

Please sign in to comment.