0.3.0: restore legacy openat_with_filter / unlinkat_with_filter wrappers

This commit is contained in:
2026-07-06 20:58:49 +03:00
parent 2c06be31a7
commit 7e9cffd20a
+47
View File
@@ -216,6 +216,30 @@ pub fn openat<T: AsRef<str>>(fd: usize, path: T, flags: usize, fcntl_flags: usiz
}
}
/// Open a file at a specific path with uid/gid filtering.
/// Red Bear: legacy wrapper preserved for bootstrap namespace capability checks.
pub fn openat_with_filter<T: AsRef<str>>(
fd: usize,
path: T,
flags: usize,
fcntl_flags: usize,
uid: u32,
gid: u32,
) -> Result<usize> {
let path = path.as_ref();
unsafe {
syscall6(
SYS_OPENAT_WITH_FILTER,
fd,
path.as_ptr() as usize,
path.len(),
flags | fcntl_flags,
uid as usize,
gid as usize,
)
}
}
/// Send a file descriptor to another process via a socket
pub fn sendfd(receiver_socket: usize, fd: usize, flags: usize, arg: u64) -> Result<usize> {
#[cfg(target_pointer_width = "32")]
@@ -240,6 +264,29 @@ pub fn unlinkat<T: AsRef<str>>(fd: usize, path: T, flags: usize) -> Result<usize
let path = path.as_ref();
unsafe { syscall4(SYS_UNLINKAT, fd, path.as_ptr() as usize, path.len(), flags) }
}
/// Remove a file at a specific path with uid/gid filtering.
/// Red Bear: legacy wrapper preserved for bootstrap namespace capability checks.
pub fn unlinkat_with_filter<T: AsRef<str>>(
fd: usize,
path: T,
flags: usize,
uid: u32,
gid: u32,
) -> Result<usize> {
let path = path.as_ref();
unsafe {
syscall6(
SYS_UNLINKAT_WITH_FILTER,
fd,
path.as_ptr() as usize,
path.len(),
flags,
uid as usize,
gid as usize,
)
}
}
/// Read from a file descriptor into a buffer
pub fn read(fd: usize, buf: &mut [u8]) -> Result<usize> {
unsafe { syscall3(SYS_READ, fd, buf.as_mut_ptr() as usize, buf.len()) }