Skip to main content

kernel_explainer/
namespaces.rs

1// Namespace type string → short description.
2
3/// Returns a plain-English description of a Linux namespace type (e.g. "pid" → "Process ID isolation").
4pub fn namespace_description(ns_type: &str) -> String {
5    match ns_type {
6        "pid" => "Process ID isolation: processes see only PIDs in this namespace".to_string(),
7        "net" => "Network: separate network stack, interfaces, and ports".to_string(),
8        "ipc" => "IPC: isolated System V IPC and POSIX message queues".to_string(),
9        "mnt" => "Mount: separate mount hierarchy and filesystem view".to_string(),
10        "uts" => "UTS: isolated hostname and NIS domain".to_string(),
11        "user" => {
12            "User: separate UID/GID mapping (e.g. root in namespace ≠ root on host)".to_string()
13        }
14        "cgroup" => "Cgroup: separate cgroup hierarchy for resource limits".to_string(),
15        "time" => "Time: separate system clock (e.g. for containers)".to_string(),
16        _ => format!("Namespace type: {}", ns_type),
17    }
18}