Implement readlinkat

Like readlink except capability based. Most of this patch is refactoring
fstatat into a reusable, openat-like private function.
This commit is contained in:
Josh Megnauth
2025-09-12 02:52:37 -04:00
parent 56460260b1
commit c555503a35
11 changed files with 254 additions and 46 deletions
+12
View File
@@ -585,6 +585,18 @@ impl Pal for Sys {
})
}
fn readlinkat(dirfd: c_int, pathname: CStr, out: &mut [u8]) -> Result<usize> {
e_raw(unsafe {
syscall!(
READLINKAT,
dirfd,
pathname.as_ptr(),
out.as_mut_ptr(),
out.len()
)
})
}
fn rename(old: CStr, new: CStr) -> Result<()> {
e_raw(unsafe { syscall!(RENAMEAT, AT_FDCWD, old.as_ptr(), AT_FDCWD, new.as_ptr()) })
.map(|_| ())