diff --git a/src/call.rs b/src/call.rs index 53ec5a530b..63567c4592 100644 --- a/src/call.rs +++ b/src/call.rs @@ -216,6 +216,30 @@ pub fn openat>(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>( + fd: usize, + path: T, + flags: usize, + fcntl_flags: usize, + uid: u32, + gid: u32, +) -> Result { + 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 { #[cfg(target_pointer_width = "32")] @@ -240,6 +264,29 @@ pub fn unlinkat>(fd: usize, path: T, flags: usize) -> Result>( + fd: usize, + path: T, + flags: usize, + uid: u32, + gid: u32, +) -> Result { + 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 { unsafe { syscall3(SYS_READ, fd, buf.as_mut_ptr() as usize, buf.len()) }