๐ Little FS โ
The little_fs crate is the concrete LittleFS backend that implements Xila's file-system contracts.
Role โ
- Implements
file_system::FileSystemOperationsand related traits on top oflittlefs2-sys. - Provides mount/format bootstrap paths used before VFS initialization.
Boundaries โ
- In scope: backend adaptation, attribute translation, file/directory context operations.
- Out of scope: global mount namespace and path policy (owned by VFS).
Internal structure โ
file_system.rs:FileSystemtype, mount/format lifecycle, trait implementations.callbacks.rs+configuration.rs: glue fromDirectBlockDeviceto LittleFS C callbacks/config.file.rs/directory.rs: context-specific file and directory operations.attributes.rs/flags.rs: mapping between Xila and LittleFS representations.error.rs: LittleFS result-to-file_system::Errorconversion.
Runtime interaction โ
- Backend is created via
FileSystem::new(...),new_format(...), orget_or_format(...). - It mounts using
littlefs::lfs_mountand seeds root internal attributes if missing. - VFS calls trait methods; crate routes calls through a mounted mutex wrapper.
- On drop, it unmounts and releases leaked configuration context.
Dependency model โ
- Core dependencies: File system, Task, Users, Time, Synchronization,
littlefs2-sys.
Failure semantics โ
- Mount/format/operation failures are translated to
file_system::Error. get_or_formatretries by formatting when initial mount fails.- Context type mismatch in operation dispatch returns
InvalidParameter.
Extension points โ
- Additional mount policies can wrap existing constructors.
- New attribute/flag translations can be added without changing trait-level contracts.
Contract vs implementation โ
- Contract: fully conforms to
file_systemtrait interfaces expected by VFS. - Current implementation: based on LittleFS C runtime (
lfs_*) withMutexMountWrapper<CriticalSectionRawMutex, lfs_t>.
Limitations and trade-offs โ
- Behavior inherits LittleFS semantics and target storage constraints.
- Relies on callback/config correctness; misconfigured block geometry can fail at runtime.