Add mkns API.

This commit is contained in:
4lDO2
2024-03-18 17:08:14 +01:00
parent 0cd9eec99e
commit fa1739a954
2 changed files with 16 additions and 0 deletions
+2
View File
@@ -14,8 +14,10 @@ exclude = ["target"]
default = ["call", "std", "redox_syscall"]
call = []
std = []
mkns = ["ioslice"]
[dependencies]
bitflags = "2"
libc = "0.2"
redox_syscall = { version = "0.5", optional = true }
ioslice = { version = "0.6", optional = true }
+14
View File
@@ -185,6 +185,7 @@ pub mod data {
pub use libc::stat as Stat;
pub use libc::statvfs as StatVfs;
pub use libc::timespec as TimeSpec;
pub use libc::iovec as IoVec;
// TODO: Remove
pub fn timespec_from_mut_bytes(bytes: &mut [u8]) -> &mut TimeSpec {
@@ -217,6 +218,7 @@ pub mod data {
type RawResult = usize;
#[cfg(feature = "call")]
#[allow(dead_code)]
extern "C" {
// NOTE: Although there are version suffixes, there'd have to be strong reasons for adding new
// version.
@@ -245,6 +247,7 @@ extern "C" {
fn redox_get_egid_v1() -> RawResult;
fn redox_get_rgid_v1() -> RawResult;
fn redox_setrens_v1(rns: usize, ens: usize) -> RawResult;
fn redox_mkns_v1(names: *const data::IoVec, num_names: usize, _flags: u32) -> RawResult;
fn redox_kill_v1(pid: usize, signal: u32) -> RawResult;
fn redox_waitpid_v1(pid: usize, status: *mut i32, options: u32) -> RawResult;
@@ -551,4 +554,15 @@ pub mod call {
))
}
}
#[inline]
#[cfg(feature = "mkns")]
pub fn mkns(names: &[ioslice::IoSlice]) -> Result<usize> {
// no-op
let iovecs = ioslice::IoSlice::cast_to_raw_iovecs(names);
unsafe {
Error::demux(redox_mkns_v1(iovecs.as_ptr(), iovecs.len(), 0))
}
}
}