Skip to main content

Crate monty_fs

Crate monty_fs 

Source
Available on crate features code and embedded-python only.
Expand description

Filesystem mounting system for sandboxed execution.

Provides MountTable, which maps virtual paths to real host directories with configurable access modes. When sandbox code calls filesystem methods like Path.read_text(), the mount table intercepts the operation, resolves the virtual path, and executes it according to the mount mode.

This crate is HOST-side code: it performs real std::fs I/O and is linked only by host/parent crates (monty-pool, the CLI, bindings). The monty interpreter crate deliberately does not depend on it — sandboxed code can only request filesystem operations by suspending with an OsFunctionCall, which a host holding a MountTable services via MountTable::handle_os_call.

§Security

The monty runtime MUST NEVER read, write, or obtain any information about any file or directory outside the specific directory that is mounted.

Enforced by path_security::resolve_path via path canonicalization, boundary checks, and symlink escape detection. Each mount has an aggregate memory budget, defaulting to DEFAULT_MEMORY_USAGE_LIMIT, for retained overlay data and results.

§Mount Modes

Structs§

Mount
A single mount point mapping a virtual path to a host directory.
MountTable
A collection of mount points mapping virtual paths to host directories.
OverlayState
In-memory overlay state for super::MountMode::OverlayMemory.

Enums§

MountCallOutcome
Outcome of MountTable::handle_os_call.
MountError
Errors from mount configuration or filesystem operations.
MountMode
Access policy for a mount point.

Constants§

DEFAULT_MEMORY_USAGE_LIMIT
Default aggregate memory budget for one mount: 100 MB in decimal bytes.