feat: Add relpathat

This commit is contained in:
Ibuki Omatsu
2026-05-27 14:02:55 +00:00
committed by Jacob Lorentzon
parent f14358d4d8
commit 5cc70f148f
2 changed files with 12 additions and 3 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
[package]
name = "libredox"
authors = ["4lDO2 <4lDO2@protonmail.com>"]
version = "0.1.16"
version = "0.1.17"
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.7", optional = true }
redox_syscall = { version = "0.8", optional = true }
ioslice = { version = "0.6", optional = true }
plain = { version = "0.2", optional = true }
+10 -1
View File
@@ -115,7 +115,7 @@ pub mod flag {
O_NONBLOCK, O_PATH, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY,
};
pub use libc::{MSG_DONTROUTE, MSG_OOB, MSG_PEEK, MSG_DONTWAIT, MSG_EOR, };
pub use libc::{MSG_DONTROUTE, MSG_DONTWAIT, MSG_EOR, MSG_OOB, MSG_PEEK};
pub use libc::{CLOCK_MONOTONIC, CLOCK_REALTIME};
@@ -257,6 +257,7 @@ extern "C" {
fn redox_unlinkat_v0(fd: usize, buf: *const u8, path_len: usize, flags: u32) -> RawResult;
*/
fn redox_fpath_v1(fd: usize, dst_base: *mut u8, dst_len: usize) -> RawResult;
fn redox_relpathat_v0(dirfd: usize, fd: usize, dst_base: *mut u8, dst_len: usize) -> RawResult;
fn redox_close_v1(fd: usize) -> RawResult;
// NOTE: While the Redox kernel currently doesn't distinguish between threads and processes,
@@ -412,6 +413,10 @@ impl Fd {
call::fpath(self.raw(), path)
}
#[inline]
pub fn relpathat(&self, fd: usize, path: &mut [u8]) -> Result<usize> {
call::relpathat(self.raw(), fd, path)
}
#[inline]
pub fn close(self) -> Result<()> {
call::close(self.into_raw())
}
@@ -564,6 +569,10 @@ pub mod call {
Error::demux(unsafe { redox_fpath_v1(raw_fd, buf.as_mut_ptr(), buf.len()) })
}
#[inline]
pub fn relpathat(raw_fd: usize, fd: usize, buf: &mut [u8]) -> Result<usize> {
Error::demux(unsafe { redox_relpathat_v0(raw_fd, fd, buf.as_mut_ptr(), buf.len()) })
}
#[inline]
pub fn close(raw_fd: usize) -> Result<()> {
Error::demux(unsafe { redox_close_v1(raw_fd) })?;
Ok(())