use crate::imp;
use crate::io::{self, OwnedFd};
use imp::fd::{AsFd, RawFd};
use imp::fs::{FdFlags, OFlags};
#[inline]
#[doc(alias = "F_GETFD")]
pub fn fcntl_getfd<Fd: AsFd>(fd: Fd) -> io::Result<FdFlags> {
imp::fs::syscalls::fcntl_getfd(fd.as_fd())
}
#[inline]
#[doc(alias = "F_SETFD")]
pub fn fcntl_setfd<Fd: AsFd>(fd: Fd, flags: FdFlags) -> io::Result<()> {
imp::fs::syscalls::fcntl_setfd(fd.as_fd(), flags)
}
#[inline]
#[doc(alias = "F_GETFL")]
pub fn fcntl_getfl<Fd: AsFd>(fd: Fd) -> io::Result<OFlags> {
imp::fs::syscalls::fcntl_getfl(fd.as_fd())
}
#[inline]
#[doc(alias = "F_SETFL")]
pub fn fcntl_setfl<Fd: AsFd>(fd: Fd, flags: OFlags) -> io::Result<()> {
imp::fs::syscalls::fcntl_setfl(fd.as_fd(), flags)
}
#[cfg(any(
target_os = "android",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
))]
#[inline]
#[doc(alias = "F_GET_SEALS")]
pub fn fcntl_get_seals<Fd: AsFd>(fd: Fd) -> io::Result<SealFlags> {
imp::fs::syscalls::fcntl_get_seals(fd.as_fd())
}
#[cfg(any(
target_os = "android",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
))]
pub use imp::fs::SealFlags;
#[cfg(any(
target_os = "android",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
))]
#[inline]
#[doc(alias = "F_ADD_SEALS")]
pub fn fcntl_add_seals<Fd: AsFd>(fd: Fd, seals: SealFlags) -> io::Result<()> {
imp::fs::syscalls::fcntl_add_seals(fd.as_fd(), seals)
}
#[cfg(not(target_os = "wasi"))]
#[inline]
#[doc(alias = "F_DUPFD_CLOEXEC")]
pub fn fcntl_dupfd_cloexec<Fd: AsFd>(fd: Fd, min: RawFd) -> io::Result<OwnedFd> {
imp::fs::syscalls::fcntl_dupfd_cloexec(fd.as_fd(), min)
}