Skip to main content

MountManager

Trait MountManager 

Source
pub trait MountManager: Send + Sync {
    // Required methods
    fn acquire_mount(&self, image_path: &str) -> Result<MountHandle, MountError>;
    fn release_mount(&self, handle: &MountHandle) -> Result<(), MountError>;
    fn force_unmount(&self, image_path: &str) -> Result<(), MountError>;
    fn reconstruct_state(
        &self,
        active_allocations: &[String],
    ) -> Result<(), MountError>;
}
Expand description

Trait for refcounted mount management.

Both pact (as init) and lattice (standalone mode) implement this.

§Invariants

  • WI2: refcount exactly equals active allocations using the mount. Refcount going negative is a bug — implementations must assert.
  • WI3: lazy unmount with configurable hold time. Emergency --force overrides the hold timer.
  • WI6: on agent restart, reconstruct_state rebuilds refcounts from the kernel mount table + active allocations.

Required Methods§

Source

fn acquire_mount(&self, image_path: &str) -> Result<MountHandle, MountError>

Acquire a reference to a uenv mount.

If this is the first reference, the SquashFS image is mounted. Otherwise, the refcount is incremented and a bind-mount is prepared for the allocation’s mount namespace.

Source

fn release_mount(&self, handle: &MountHandle) -> Result<(), MountError>

Release a reference to a mount.

Decrements the refcount. When refcount reaches zero, starts the cache hold timer. The mount is not unmounted until the timer expires (or emergency force-unmount).

Source

fn force_unmount(&self, image_path: &str) -> Result<(), MountError>

Force-unmount regardless of refcount or hold timer.

Only allowed during emergency mode (RI3). Cancels any running hold timer and unmounts immediately.

Source

fn reconstruct_state( &self, active_allocations: &[String], ) -> Result<(), MountError>

Reconstruct refcounts from kernel mount table and active allocations.

Called on agent restart (WI6). Scans /proc/mounts and correlates with the provided list of active allocation IDs (from journal state). Mounts without matching allocations get refcount=0 and start hold timers.

Implementors§