Expand description
ยงFileSystemProvider (Environment)
RESPONSIBILITIES:
- Implements
FileSystemReaderandFileSystemWriterforMountainEnvironment - Provides secure, validated filesystem access with workspace trust enforcement
- Handles file operations: read, write, stat, delete, rename, copy, directory traversal
- Detects and handles symbolic links properly
- Enforces path validation to prevent directory traversal attacks
SECURITY MODEL:
- Sandboxed filesystem access limited to registered workspace folders
- All operations call
Utility::IsPathAllowedForAccessfirst - Requires workspace trust to be enabled for any file access
- Path normalization prevents
../attacks - Symbolic link detection avoids following untrusted links outside workspaces
ERROR HANDLING:
- Uses
CommonErrorfor all operations - File operation errors are mapped via
CommonError::FromStandardIOError - Validates paths are within workspace boundaries (IsPathAllowedForAccess)
- Rejects directory reads when file expected (ReadFile)
PERFORMANCE:
- Uses async tokio::fs for non-blocking I/O operations
- Symbolic link detection uses
symlink_metadatain addition tometadata - TODO: Consider caching file metadata for frequently accessed files
VS CODE REFERENCE:
vs/workbench/services/files/electron-browser/diskFileSystemProvider.ts- secure FS accessvs/platform/files/common/files.ts- file system interfacesvs/base/common/network.ts- URI and path handling
TODO:
- Implement filesystem change watching (notify, inotify, FSEvents)
- Add path normalization to prevent directory traversal
- Implement proper symbolic link resolution with security checks
- Add support for file permissions and ownership metadata
- Implement atomic file writes using temp file + rename pattern
- Add filesystem usage statistics (disk space, file counts)
- Implement file attribute querying (hidden, readonly, executable)
- Add support for extended file attributes on Unix/macOS
- Consider adding filesystem cache for metadata
- Implement trash operation using platform trash API (not delete)
- Add support for file system encoding detection
- Implement case sensitivity handling based on filesystem type
MODULE STRUCTURE:
read_operations.rs-FileSystemReaderimplementationwrite_operations.rs-FileSystemWriterimplementation
Modulesยง
- read_
operations ๐ - FileSystemProvider - Read Operations
- write_
operations ๐ - FileSystemProvider - Write Operations