twizzler_abi/syscall/
security.rsuse num_enum::{FromPrimitive, IntoPrimitive};
use super::{convert_codes_to_result, Syscall};
use crate::{arch::syscall::raw_syscall, object::ObjID};
#[derive(
Debug,
Copy,
Clone,
PartialEq,
PartialOrd,
Ord,
Eq,
Hash,
IntoPrimitive,
FromPrimitive,
thiserror::Error,
)]
#[repr(u64)]
pub enum SctxAttachError {
#[num_enum(default)]
#[error("unknown error")]
Unknown = 0,
#[error("invalid argument")]
InvalidArgument = 1,
#[error("object not found")]
ObjectNotFound = 2,
#[error("permission denied")]
PermissionDenied = 3,
#[error("already attached")]
AlreadyAttached = 4,
}
impl core::error::Error for SctxAttachError {}
pub fn sys_sctx_attach(id: ObjID) -> Result<(), SctxAttachError> {
let args = [id.split().0, id.split().1, 0, 0, 0];
let (code, val) = unsafe { raw_syscall(Syscall::SctxAttach, &args) };
convert_codes_to_result(
code,
val,
|c, _| c == 1,
|_, _| (),
|_, v| SctxAttachError::from(v),
)
}