Skip to content

Commit 769e900

Browse files
committed
Auto merge of rust-lang#3781 - RalfJung:flock, r=RalfJung
flock: a bit of cleanup Follow-up to rust-lang/miri#3759
2 parents 50d51fb + 5af27e4 commit 769e900

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/tools/miri/src/shims/unix/fd.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ use rustc_target::abi::Size;
1212
use crate::shims::unix::*;
1313
use crate::*;
1414

15+
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
16+
pub(crate) enum FlockOp {
17+
SharedLock { nonblocking: bool },
18+
ExclusiveLock { nonblocking: bool },
19+
Unlock,
20+
}
21+
1522
/// Represents an open file descriptor.
1623
pub trait FileDescription: std::fmt::Debug + Any {
1724
fn name(&self) -> &'static str;
@@ -567,10 +574,3 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
567574
Ok(Scalar::from_target_isize(this.try_unwrap_io_result(result)?, this))
568575
}
569576
}
570-
571-
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
572-
pub(crate) enum FlockOp {
573-
SharedLock { nonblocking: bool },
574-
ExclusiveLock { nonblocking: bool },
575-
Unlock,
576-
}

src/tools/miri/src/shims/unix/fs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ impl FileDescription for FileHandle {
198198
let code: u32 = err.raw_os_error().unwrap().try_into().unwrap();
199199
if matches!(code, ERROR_IO_PENDING | ERROR_LOCK_VIOLATION) {
200200
if lock_nb {
201-
// Replace error with a custom WouldBlock error, which later will be
202-
// mapped in the `helpers` module
201+
// The io error mapping does not know about these error codes,
202+
// so we translate it to `WouldBlock` manually.
203203
let desc = format!("LockFileEx wouldblock error: {err}");
204204
err = io::Error::new(io::ErrorKind::WouldBlock, desc);
205205
} else {

src/tools/miri/tests/pass-dep/libc/libc-fs-flock.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Flock tests are separate since they don't in general work on a Windows host.
21
//@ignore-target-windows: File handling is not implemented yet
32
//@compile-flags: -Zmiri-disable-isolation
43

0 commit comments

Comments
 (0)