use alloc::sync::Arc;
use core::sync::atomic::{AtomicU64, Ordering};
use crate::sync::IrqMutex;
pub static ROOT_MNT_NS: ax_lazyinit::LazyLock<Arc<IrqMutex<MntNamespace>>> =
ax_lazyinit::LazyLock::new(|| Arc::new(IrqMutex::new(MntNamespace::new_root())));
static MNT_NS_ID: AtomicU64 = AtomicU64::new(1);
pub struct MntNamespace {
id: u64,
}
impl MntNamespace {
pub fn new_root() -> Self {
Self {
id: MNT_NS_ID.fetch_add(1, Ordering::Relaxed),
}
}
pub fn clone_ns(&self) -> Self {
Self {
id: MNT_NS_ID.fetch_add(1, Ordering::Relaxed),
}
}
pub fn id(&self) -> u64 {
self.id
}
}