Module FileSystemProvider

Module FileSystemProvider 

Source
Expand description

ยงFileSystemProvider (Environment)

RESPONSIBILITIES:

  • Implements FileSystemReader and FileSystemWriter for MountainEnvironment
  • 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::IsPathAllowedForAccess first
  • 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 CommonError for 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_metadata in addition to metadata
  • TODO: Consider caching file metadata for frequently accessed files

VS CODE REFERENCE:

  • vs/workbench/services/files/electron-browser/diskFileSystemProvider.ts - secure FS access
  • vs/platform/files/common/files.ts - file system interfaces
  • vs/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:

Modulesยง

read_operations ๐Ÿ”’
FileSystemProvider - Read Operations
write_operations ๐Ÿ”’
FileSystemProvider - Write Operations