|
|
@ -22,7 +22,6 @@ mod network;
|
|
|
|
static WORKSPACE: &str = "/home/rocker";
|
|
|
|
static WORKSPACE: &str = "/home/rocker";
|
|
|
|
static USER_NAME: &str = "rocker";
|
|
|
|
static USER_NAME: &str = "rocker";
|
|
|
|
static INFO_FILE: &str = "info.toml";
|
|
|
|
static INFO_FILE: &str = "info.toml";
|
|
|
|
static LOCK_FILE: &str = ".lock";
|
|
|
|
|
|
|
|
static mut STACK: [u8; 1024*1024*1] = [0; 1024*1024*1];
|
|
|
|
static mut STACK: [u8; 1024*1024*1] = [0; 1024*1024*1];
|
|
|
|
static CLONE_FLAG: i32 = 0b1101100000000100000000000000000; // CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWPID | CLONE_NEWIPC | CLONE_NEWNET;
|
|
|
|
static CLONE_FLAG: i32 = 0b1101100000000100000000000000000; // CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWPID | CLONE_NEWIPC | CLONE_NEWNET;
|
|
|
|
|
|
|
|
|
|
|
@ -120,16 +119,6 @@ fn extend_image(image_name: &String) -> Result<PathBuf> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn init_container_lock<P: AsRef<Path>>(container_work_path:P) -> Result<i32> {
|
|
|
|
|
|
|
|
use nix::sys::stat::Mode;
|
|
|
|
|
|
|
|
use nix::fcntl::{OFlag, open};
|
|
|
|
|
|
|
|
let lock_path = container_work_path.as_ref().join(LOCK_FILE);
|
|
|
|
|
|
|
|
let lock_path_str = lock_path.as_os_str();
|
|
|
|
|
|
|
|
let oflag = OFlag::O_RDWR | OFlag::O_CREAT;
|
|
|
|
|
|
|
|
let mode = Mode::empty();
|
|
|
|
|
|
|
|
println!("{lock_path_str:?}");
|
|
|
|
|
|
|
|
Ok(open(lock_path_str, oflag, mode)?)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn init_container_overlay<P: AsRef<Path>>(volume_path: P, upper_path: P, merged_path: P) -> Result<()> {
|
|
|
|
fn init_container_overlay<P: AsRef<Path>>(volume_path: P, upper_path: P, merged_path: P) -> Result<()> {
|
|
|
|
let lower_dir = volume_path.as_ref().to_string_lossy().to_string();
|
|
|
|
let lower_dir = volume_path.as_ref().to_string_lossy().to_string();
|
|
|
@ -424,7 +413,6 @@ fn run_container(_container_id: &String, cmd: &String, args: &RockerArgs, volume
|
|
|
|
create_dir(&container_merged_path, true)?;
|
|
|
|
create_dir(&container_merged_path, true)?;
|
|
|
|
|
|
|
|
|
|
|
|
let _cb = || {
|
|
|
|
let _cb = || {
|
|
|
|
init_container_lock(&container_work_path).unwrap();
|
|
|
|
|
|
|
|
init_container_overlay(volume_path, &container_upper_path, &container_merged_path).unwrap();
|
|
|
|
init_container_overlay(volume_path, &container_upper_path, &container_merged_path).unwrap();
|
|
|
|
if let Some(custom_volume) = &args.volume {
|
|
|
|
if let Some(custom_volume) = &args.volume {
|
|
|
|
init_container_custom_volume(&container_merged_path, custom_volume).unwrap();
|
|
|
|
init_container_custom_volume(&container_merged_path, custom_volume).unwrap();
|
|
|
@ -514,7 +502,6 @@ fn save_container_info(args: &RockerArgs, container_id: &String, pid: i32) -> Re
|
|
|
|
fn get_container_info(container_id: &str) -> Result<ContainerInfo> {
|
|
|
|
fn get_container_info(container_id: &str) -> Result<ContainerInfo> {
|
|
|
|
let container_work_path = Path::new(WORKSPACE).join("containers").join(container_id);
|
|
|
|
let container_work_path = Path::new(WORKSPACE).join("containers").join(container_id);
|
|
|
|
let container_info_path = container_work_path.join(INFO_FILE);
|
|
|
|
let container_info_path = container_work_path.join(INFO_FILE);
|
|
|
|
let lock_path = container_work_path.join(LOCK_FILE);
|
|
|
|
|
|
|
|
let info_str = fs::read_to_string(container_info_path)?;
|
|
|
|
let info_str = fs::read_to_string(container_info_path)?;
|
|
|
|
let mut container_info: ContainerInfo = toml::from_str(&info_str)?;
|
|
|
|
let mut container_info: ContainerInfo = toml::from_str(&info_str)?;
|
|
|
|
|
|
|
|
|
|
|
|