Add getens and expose it to libredox

This commit is contained in:
Ibuki Omatsu
2025-09-09 13:35:19 +00:00
committed by Jeremy Soller
parent 7e0c6a91e0
commit b14aae168f
2 changed files with 8 additions and 0 deletions
+4
View File
@@ -12,6 +12,7 @@ use syscall::{
use crate::{
arch::manually_enter_trampoline,
protocol::{ProcCall, ProcKillTarget, RtSigInfo, ThreadCall, WaitFlags},
read_proc_meta,
signal::tmp_disable_signals,
DynamicProcInfo, RtTcb, Tcb, DYNAMIC_PROC_INFO,
};
@@ -305,6 +306,9 @@ pub fn posix_getresugid() -> Resugid<u32> {
sgid,
}
}
pub fn getens() -> Result<usize> {
read_proc_meta(crate::current_proc_fd()).map(|meta| meta.ens as usize)
}
pub fn get_proc_credentials(cap_fd: usize, target_pid: usize, buf: &mut [u8]) -> Result<usize> {
if buf.len() < size_of::<crate::protocol::ProcMeta>() {
return Err(Error::new(EINVAL));
+4
View File
@@ -243,6 +243,10 @@ pub unsafe extern "C" fn redox_get_rgid_v1() -> RawResult {
redox_rt::sys::posix_getresugid().rgid as _
}
#[no_mangle]
pub unsafe extern "C" fn redox_get_ens_v0() -> RawResult {
Error::mux(redox_rt::sys::getens())
}
#[no_mangle]
pub unsafe extern "C" fn redox_get_proc_credentials_v1(
cap_fd: usize,
target_pid: usize,