Skip to content

Commit

Permalink
Remove conditional compilation of spec fields
Browse files Browse the repository at this point in the history
The spec objects are not platform-dependent. There are fields that are
not applicable for certain runtime environments, but they should still
be available to programs that are not runtimes. Runtime implementations
are free to ignore fields they can't process.

Signed-off-by: Markus Rudy <mr@edgeless.systems>
  • Loading branch information
burgerdev committed Oct 24, 2024
1 parent dab248b commit d379e0b
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions src/runtime/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ pub struct Process {

#[serde(default, skip_serializing_if = "Option::is_none")]
#[getset(get = "pub", set = "pub")]
#[cfg(any(target_os = "linux", target_os = "solaris"))]
/// Rlimits specifies rlimit options to apply to the process.
rlimits: Option<Vec<PosixRlimit>>,

Expand Down Expand Up @@ -150,7 +149,6 @@ impl Default for Process {
capabilities: Some(Default::default()),
// Sets the default maximum of 1024 files the process can open
// This is the same as the linux kernel default
#[cfg(any(target_os = "linux", target_os = "solaris"))]
rlimits: vec![PosixRlimit {
typ: PosixRlimitType::RlimitNofile,
hard: 1024,
Expand Down Expand Up @@ -191,7 +189,6 @@ pub struct Box {
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize, StrumDisplay, EnumString)]
#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[cfg(any(target_os = "linux", target_os = "solaris"))]
/// Available rlimit types (see <https://man7.org/linux/man-pages/man2/getrlimit.2.html>)
pub enum PosixRlimitType {
/// Limit in seconds of the amount of CPU time that the process can consume.
Expand All @@ -212,53 +209,43 @@ pub enum PosixRlimitType {

/// Limit on the process's resident set (the number of virtual pages
/// resident in RAM).
#[cfg(target_os = "linux")]
RlimitRss,

/// Limit on number of threads for the real uid calling processes.
#[cfg(target_os = "linux")]
RlimitNproc,

/// One greator than the maximum number of file descritors that one process
/// may open.
RlimitNofile,

/// Maximum number of bytes of memory that may be locked into RAM.
#[cfg(target_os = "linux")]
RlimitMemlock,

/// Maximum size of the process's virtual memory(address space) in bytes.
RlimitAs,

/// Limit on the number of locks and leases for the process.
#[cfg(target_os = "linux")]
RlimitLocks,

/// Limit on number of signals that may be queued for the process.
#[cfg(target_os = "linux")]
RlimitSigpending,

/// Limit on the number of bytes that can be allocated for POSIX message
/// queue.
#[cfg(target_os = "linux")]
RlimitMsgqueue,

/// Specifies a ceiling to which the process's nice value can be raised.
#[cfg(target_os = "linux")]
RlimitNice,

/// Specifies a ceiling on the real-time priority.
#[cfg(target_os = "linux")]
RlimitRtprio,

/// This is a limit (in microseconds) on the amount of CPU time that a
/// process scheduled under a real-time scheduling policy may consume
/// without making a blocking system call.
#[cfg(target_os = "linux")]
RlimitRttime,
}

#[cfg(any(target_os = "linux", target_os = "solaris"))]
impl Default for PosixRlimitType {
fn default() -> Self {
Self::RlimitCpu
Expand All @@ -275,7 +262,6 @@ impl Default for PosixRlimitType {
build_fn(error = "OciSpecError")
)]
#[getset(get_copy = "pub", set = "pub")]
#[cfg(any(target_os = "linux", target_os = "solaris"))]
/// RLimit types and restrictions.
pub struct PosixRlimit {
#[serde(rename = "type")]
Expand Down

0 comments on commit d379e0b

Please sign in to comment.