procfs_core/process/
namespaces.rs

1use std::collections::HashMap;
2use std::ffi::OsString;
3use std::path::PathBuf;
4
5#[cfg(feature = "serde1")]
6use serde::{Deserialize, Serialize};
7
8/// Information about a namespace
9#[derive(Debug, Clone, Eq)]
10#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
11pub struct Namespace {
12    /// Namespace type
13    pub ns_type: OsString,
14    /// Handle to the namespace
15    pub path: PathBuf,
16    /// Namespace identifier (inode number)
17    pub identifier: u64,
18    /// Device id of the namespace
19    pub device_id: u64,
20}
21
22impl PartialEq for Namespace {
23    fn eq(&self, other: &Self) -> bool {
24        // see https://lore.kernel.org/lkml/87poky5ca9.fsf@xmission.com/
25        self.identifier == other.identifier && self.device_id == other.device_id
26    }
27}
28
29/// All namespaces of a process.
30#[derive(Debug, Clone, PartialEq, Eq)]
31#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
32pub struct Namespaces(pub HashMap<OsString, Namespace>);