-
Notifications
You must be signed in to change notification settings - Fork 428
Expand file tree
/
Copy pathmessage.rs
More file actions
62 lines (56 loc) · 2.14 KB
/
message.rs
File metadata and controls
62 lines (56 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use core::fmt;
use std::collections::HashMap;
use oci_spec::runtime::LinuxIdMapping;
use serde::{Deserialize, Serialize};
use crate::network::cidr::CidrAddress;
/// Used as a wrapper for messages to be sent between child and parent processes
#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum Message {
IntermediateReady(i32),
InitReady,
WriteMapping,
MappingWritten,
SeccompNotify,
SeccompNotifyDone,
SetupNetworkDeviceReady,
MoveNetworkDevice(HashMap<String, Vec<CidrAddress>>),
MountFdPlease(MountMsg),
MountFdReply,
ExecFailed(String),
OtherError(String),
MountFdError(String),
HookRequest,
HookDone,
}
impl fmt::Display for Message {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Message::IntermediateReady(pid) => write!(f, "IntermediateReady({})", pid),
Message::InitReady => write!(f, "InitReady"),
Message::WriteMapping => write!(f, "WriteMapping"),
Message::MappingWritten => write!(f, "MappingWritten"),
Message::SetupNetworkDeviceReady => write!(f, "SetupNetworkDeviceReady"),
Message::MoveNetworkDevice(addr) => write!(f, "MoveNetworkDevice({:?})", addr),
Message::SeccompNotify => write!(f, "SeccompNotify"),
Message::SeccompNotifyDone => write!(f, "SeccompNotifyDone"),
Message::HookRequest => write!(f, "HookRequest"),
Message::HookDone => write!(f, "HookDone"),
Message::MountFdPlease(_) => write!(f, "MountFdPlease"),
Message::MountFdReply => write!(f, "MountFdReply"),
Message::MountFdError(err) => write!(f, "MountFdError({})", err),
Message::ExecFailed(s) => write!(f, "ExecFailed({})", s),
Message::OtherError(s) => write!(f, "OtherError({})", s),
}
}
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct MountMsg {
pub source: String,
pub idmap: Option<MountIdMap>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct MountIdMap {
pub uid_mappings: Vec<LinuxIdMapping>,
pub gid_mappings: Vec<LinuxIdMapping>,
pub recursive: bool,
}