Skip to content

flock: a bit of cleanup #3781

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

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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