From 0899f212c0ac4026110ea0ab7a32886631f09738 Mon Sep 17 00:00:00 2001 From: Ibuki Omatsu Date: Wed, 1 Jul 2026 14:01:37 +0000 Subject: [PATCH] feat: Add fcntl --- Cargo.toml | 4 ++-- src/lib.rs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8a52c4cfdb..9a7bc84e6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "libredox" authors = ["4lDO2 <4lDO2@protonmail.com>"] -version = "0.1.17" +version = "0.1.18" edition = "2021" license = "MIT" description = "Redox stable ABI" @@ -21,6 +21,6 @@ mkns = ["ioslice"] [dependencies] bitflags = { version = "2", optional = true } libc = { version = "0.2", optional = true } -redox_syscall = { version = "0.8", optional = true } +redox_syscall = { version = "0.9", optional = true } ioslice = { version = "0.6", optional = true } plain = { version = "0.2", optional = true } diff --git a/src/lib.rs b/src/lib.rs index d95697ae97..cce27f25f9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -321,6 +321,8 @@ extern "C" { name_len: usize, cap_fd: usize, ) -> RawResult; + + fn redox_fcntl_v0(fd: usize, cmd: usize, arg: usize) -> RawResult; } #[cfg(feature = "call")] @@ -451,6 +453,11 @@ impl Fd { ) -> Result { call::call_rw(self.raw(), payload, flags, metadata) } + + #[inline] + pub fn fcntl(&self, cmd: usize, arg: usize) -> Result { + call::fcntl(self.raw(), cmd, arg) + } } #[cfg(feature = "call")] impl Drop for Fd { @@ -793,6 +800,11 @@ pub mod call { }) .map(|_| ()) } + + #[inline] + pub fn fcntl(fd: usize, cmd: usize, arg: usize) -> Result { + Error::demux(unsafe { redox_fcntl_v0(fd, cmd, arg) }) + } } #[cfg(feature = "protocol")] @@ -1086,4 +1098,8 @@ pub mod protocol { }) } } + + // CLOEXEC flags + pub const O_CLOEXEC: usize = 0x0100_0000; + pub const F_DUPFD_CLOEXEC: usize = 1030; }