From b14aae168fac28054cc841cbf777d2d3d68f3e45 Mon Sep 17 00:00:00 2001 From: Ibuki Omatsu Date: Tue, 9 Sep 2025 13:35:19 +0000 Subject: [PATCH] Add getens and expose it to libredox --- redox-rt/src/sys.rs | 4 ++++ src/platform/redox/libredox.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/redox-rt/src/sys.rs b/redox-rt/src/sys.rs index 14662331d7..07b06f745d 100644 --- a/redox-rt/src/sys.rs +++ b/redox-rt/src/sys.rs @@ -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 { sgid, } } +pub fn getens() -> Result { + 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 { if buf.len() < size_of::() { return Err(Error::new(EINVAL)); diff --git a/src/platform/redox/libredox.rs b/src/platform/redox/libredox.rs index f74c14fab0..2ae5ca843f 100644 --- a/src/platform/redox/libredox.rs +++ b/src/platform/redox/libredox.rs @@ -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,