Skip to content

No flock support 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

No one assigned

    Labels

    C-bugCategory: This is a bug.O-illumosthe other shiny OST-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions