mirror of
https://github.com/mii443/izoli.git
synced 2025-08-22 16:05:40 +00:00
add box enter
This commit is contained in:
@ -12,3 +12,4 @@ name = "izoli"
|
||||
path = "src/bin/izoli.rs"
|
||||
|
||||
[dependencies]
|
||||
nix = { version = "0.29.0", features = ["sched"] }
|
||||
|
@ -1 +1,25 @@
|
||||
use nix::{
|
||||
libc::SIGCHLD,
|
||||
sched::{self, CloneCb, CloneFlags},
|
||||
unistd::Pid,
|
||||
};
|
||||
|
||||
const STACK_SIZE: usize = 8192;
|
||||
|
||||
pub struct IzoliBox {}
|
||||
|
||||
impl IzoliBox {
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
|
||||
pub fn enter(&self, callback: CloneCb<'_>) -> Result<Pid, nix::errno::Errno> {
|
||||
let mut stack = [0u8; STACK_SIZE];
|
||||
let flags = CloneFlags::CLONE_NEWNS
|
||||
| CloneFlags::CLONE_NEWUTS
|
||||
| CloneFlags::CLONE_NEWIPC
|
||||
| CloneFlags::CLONE_NEWPID;
|
||||
|
||||
unsafe { sched::clone(callback, &mut stack, flags, Some(SIGCHLD)) }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user