Skip to content

Commit 8f51d7f

Browse files
committed
fix(flock): check if they are marked unsupported in libstd
Before this Cargo invokes syscalls and check whether it gets ENOTSUP to determine flock is unsupported. However, now the "unsupported platforms" are pre-defined by libstd [1]. Cargo should perhaps return unsupported if a platform is marked unsupported by libstd. Without this, some people on Termux may be affected I guess? [1]: https://github.com/rust-lang/rust/blob/e9b6085088fd671ecfbe4cbebe1d26796d8bfa30/library/std/src/sys/fs/unix.rs#L1395-L1410
1 parent 9eb3240 commit 8f51d7f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/cargo/util/flock.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,13 +435,15 @@ fn error_unsupported(err: &std::io::Error) -> bool {
435435
#[allow(unreachable_patterns)]
436436
Some(libc::ENOTSUP | libc::EOPNOTSUPP) => true,
437437
Some(libc::ENOSYS) => true,
438-
_ => false,
438+
_ => err.kind() == std::io::ErrorKind::Unsupported,
439439
}
440440
}
441441

442442
#[cfg(windows)]
443443
fn error_unsupported(err: &std::io::Error) -> bool {
444444
use windows_sys::Win32::Foundation::ERROR_INVALID_FUNCTION;
445-
err.raw_os_error()
446-
.map_or(false, |x| x == ERROR_INVALID_FUNCTION as i32)
445+
match err.raw_os_error() {
446+
Some(code) if code == ERROR_INVALID_FUNCTION as i32 => true,
447+
_ => err.kind() == std::io::ErrorKind::Unsupported,
448+
}
447449
}

0 commit comments

Comments
 (0)