Skip to content

Commit

Permalink
Document that Err(io::Errno::INVAL) is returned when FlockType is…
Browse files Browse the repository at this point in the history
… unlocked in `fcntl_getlk`
  • Loading branch information
metent committed Feb 8, 2025
1 parent e0c2932 commit 99d1061
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/backend/libc/process/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,8 @@ pub(crate) fn getgroups(buf: &mut [Gid]) -> io::Result<usize> {
)))]
#[inline]
pub(crate) fn fcntl_getlk(fd: BorrowedFd<'_>, lock: &Flock) -> io::Result<Option<Flock>> {
// In order to guarantee consistent behavior across all POSIX platforms, return `EINVAL` when
// `flock.l_type` is `F_UNLCK`
if lock.typ == crate::process::FlockType::Unlocked {
return Err(io::Errno::INVAL);
}
Expand Down
5 changes: 4 additions & 1 deletion src/process/fcntl_getlk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use super::Flock;
use crate::fd::AsFd;
use crate::{backend, io};

/// `fcntl(fd, F_GETLK)`—Get the first lock that blocks the lock description pointed to by the argument `lock`. If no such lock is found, then `None` is returned
/// `fcntl(fd, F_GETLK)`—Get the first lock that blocks the lock description pointed to by the
/// argument `lock`. If no such lock is found, then `None` is returned
///
/// If `lock.typ` is `FlockType::Unlocked`, then `Err(io::Errno::INVAL)` is returned
///
/// # References
/// - [POSIX]
Expand Down

0 comments on commit 99d1061

Please sign in to comment.