diff --git a/Cargo.toml b/Cargo.toml index 7fee67def4..aff99a02b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "libredox" authors = ["4lDO2 <4lDO2@protonmail.com>"] -version = "0.1.11" +version = "0.1.12" edition = "2021" license = "MIT" description = "Redox stable ABI" @@ -19,5 +19,5 @@ mkns = ["ioslice"] [dependencies] bitflags = "2" libc = "0.2" -redox_syscall = { version = "0.6.0", optional = true } +redox_syscall = { version = "0.7", optional = true } ioslice = { version = "0.6", optional = true } diff --git a/src/lib.rs b/src/lib.rs index 3d6a82049b..025c1e2a13 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -259,7 +259,7 @@ extern "C" { fn redox_get_rgid_v1() -> RawResult; fn redox_get_ens_v0() -> RawResult; - + fn redox_get_ns_v0() -> RawResult; // This function is used to get the credentials, pid, euid, egid etc. of the process with the target pid. fn redox_get_proc_credentials_v1(cap_fd: usize, target_pid: usize, buf: &mut [u8]) -> RawResult; @@ -299,8 +299,16 @@ extern "C" { metadata: *const u64, metadata_len: usize, ) -> RawResult; - fn redox_get_socket_token_v0(fd: usize, payload: *mut u8, payload_len: usize) -> RawResult; + + fn redox_setns_v0(fd: usize) -> RawResult; + + fn redox_register_scheme_to_ns_v0( + ns_fd: usize, + name_base: *const u8, + name_len: usize, + cap_fd: usize, + ) -> RawResult; } #[cfg(feature = "call")] @@ -308,6 +316,9 @@ pub struct Fd(usize); #[cfg(feature = "call")] impl Fd { + pub fn new(raw: usize) -> Self { + Self(raw) + } #[inline] pub fn open(path: &str, flags: i32, mode: u16) -> Result { Ok(Self(call::open(path, flags, mode)?)) @@ -711,4 +722,22 @@ pub mod call { pub fn get_socket_token(fd: usize, buf: &mut [u8]) -> Result { Error::demux(unsafe { redox_get_socket_token_v0(fd, buf.as_mut_ptr(), buf.len()) }) } + + #[inline] + pub fn setns(fd: usize) -> Result { + Error::demux(unsafe { redox_setns_v0(fd) }) + } + #[inline] + pub fn getns() -> Result { + Error::demux(unsafe { redox_get_ns_v0() }) + } + + #[inline] + pub fn register_scheme_to_ns(ns_fd: usize, name: impl AsRef, cap_fd: usize) -> Result<()> { + let name = name.as_ref(); + Error::demux(unsafe { + redox_register_scheme_to_ns_v0(ns_fd, name.as_ptr(), name.len(), cap_fd) + }) + .map(|_| ()) + } }