Skip to content

No flock support on Illumos in std even though it is available on Illumos #146312

@RalfJung

Description

@RalfJung

Rust supports flock on a number of OSes, but Illumos is not on the list:

#[cfg(any(
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
target_os = "cygwin",
target_vendor = "apple",
))]
pub fn try_lock(&self) -> Result<(), TryLockError> {
let result = cvt(unsafe { libc::flock(self.as_raw_fd(), libc::LOCK_EX | libc::LOCK_NB) });
if let Err(err) = result {
if err.kind() == io::ErrorKind::WouldBlock {
Err(TryLockError::WouldBlock)
} else {
Err(TryLockError::Error(err))
}
} else {
Ok(())
}
}

This is despite the fact that Illumos does seem to support flock:

https://github.com/illumos/illumos-gate/blob/80040569a359c61120972d882d97428e80dcab90/usr/src/man/man3c/flock.3c

flock support for Illumos was present before #132977. That PR talks only about Solaris in its title but actually removed flock support for a wide range of Unixes -- supposedly because they don't support it, which was claimed without giving any sources and which was apparently incorrect at least for Illumos, Fuchsia, and OpenBSD.

Judging from libc, solaris is the only cfg(unix) OS that should be excluded here:

https://github.com/rust-lang/libc/blob/abf01706808828e82f4132113ecfeee4fe6c0d46/src/unix/mod.rs#L1636-L1642

Cc @cberned @tgross35 @jclulow @pfmooney

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.E-help-wantedCall for participation: Help is requested to fix this issue.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.I-prioritizeIssue: Indicates that prioritization has been requested for this issue.O-illumosthe other shiny OST-libsRelevant to the library team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions