rustix/process/
fcntl_getlk.rs

1use super::Flock;
2use crate::fd::AsFd;
3use crate::{backend, io};
4
5/// `fcntl(fd, F_GETLK)`—Get the first lock that blocks the lock description
6/// pointed to by the argument `lock`. If no such lock is found, then `None` is
7/// returned.
8///
9/// If `lock.typ` is set to `FlockType::Unlocked`, the returned value/error is
10/// not explicitly defined, as per POSIX, and will depend on the underlying
11/// platform implementation.
12///
13/// # References
14///  - [POSIX]
15///  - [Linux]
16///
17/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/fcntl.html
18/// [Linux]: https://man7.org/linux/man-pages/man2/fcntl.2.html
19#[inline]
20#[doc(alias = "F_GETLK")]
21pub fn fcntl_getlk<Fd: AsFd>(fd: Fd, lock: &Flock) -> io::Result<Option<Flock>> {
22    backend::process::syscalls::fcntl_getlk(fd.as_fd(), lock)
23}