Major rework of the Virtual File System layer covering path resolution, I/O modes, device abstractions, symlinks, and boot mount infrastructure. #58

Merged
admin merged 4 commits from feature/vfs_improvements into develop 2026-03-08 20:16:46 +00:00
Member

Path Resolution

Introduced GetObjectFromPathEx which tracks unconsumed path segments after hitting a DRIVE node, returning a volume-relative path alongside the VFS object. All callers (GetDirectoryListing, PathValid, ResolveFilePath) now use this instead of the old makeRelative/getAbsolutePath approach. Symlink traversal is handled inline with a configurable depth guard (MAX_SYMLINK_DEPTH = 8) and cycle detection.

Device Nodes

Added /dev/null and /dev/zero as built-in VFS device nodes with a RegisterDevice API. Device nodes support read, write, and size callbacks via a TVFSDeviceOps record. Open/Read/Write/Close all dispatch through device ops when the underlying object is otDEVICE.

Stream I/O

Merged the old TOpenMode and TWriteMode into a single TOpenMode enum (omRead, omWrite, omCreate, omReadWrite, omStream). Stream mode auto-advances the file offset on each read/write, enabling sequential I/O without manual offset tracking. Both sync and async paths support stream mode.

Symlinks

Added CreateSymlink for creating VFS symlink objects (otSYMLINK). Path resolution follows symlinks transparently with remaining path segments appended after resolution. Chained symlinks resolve up to the max depth. The file picker now includes otSYMLINK in its directory collection so symlinked directories like /sys appear and are navigable.

Declarative Boot Mounts (mount.asr)

Replaced the old asr.mnt binary blob with a human-readable mount.asr file parsed at boot. Each line is mnt {device}/path /vfs_path where {device} expands to the boot volume's mount point. Currently used to symlink /sys. The boot drive itself is now directly mounted at /boot via mountVolume in auto_mount_volumes.

Test Cleanup

VFS unit tests expanded from 77 to 104 covering symlink traversal, chained symlinks, cycle detection, symlink-to-root, device node I/O, stream mode, and watch/notify. STORTEST expanded to 34 tests with symlink traversal coverage. Both test suites now clean up after themselves via RemoveVirtualTree, and a listing leak in cmd_stortest was fixed.

Misc

Consolidated scattered type/const/var sections into single blocks. Removed unused /cfg virtual directory. Added FreeVFSObjTree and RemoveVirtualTree for proper teardown of virtual directory trees.

## Path Resolution Introduced `GetObjectFromPathEx` which tracks unconsumed path segments after hitting a DRIVE node, returning a volume-relative path alongside the VFS object. All callers (`GetDirectoryListing`, `PathValid`, `ResolveFilePath`) now use this instead of the old `makeRelative`/`getAbsolutePath` approach. Symlink traversal is handled inline with a configurable depth guard (`MAX_SYMLINK_DEPTH = 8`) and cycle detection. ## Device Nodes Added `/dev/null` and `/dev/zero` as built-in VFS device nodes with a `RegisterDevice` API. Device nodes support read, write, and size callbacks via a `TVFSDeviceOps` record. Open/Read/Write/Close all dispatch through device ops when the underlying object is `otDEVICE`. ## Stream I/O Merged the old `TOpenMode` and `TWriteMode` into a single `TOpenMode` enum (`omRead`, `omWrite`, `omCreate`, `omReadWrite`, `omStream`). Stream mode auto-advances the file offset on each read/write, enabling sequential I/O without manual offset tracking. Both sync and async paths support stream mode. ## Symlinks Added `CreateSymlink` for creating VFS symlink objects (`otSYMLINK`). Path resolution follows symlinks transparently with remaining path segments appended after resolution. Chained symlinks resolve up to the max depth. The file picker now includes `otSYMLINK` in its directory collection so symlinked directories like `/sys` appear and are navigable. ## Declarative Boot Mounts (mount.asr) Replaced the old `asr.mnt` binary blob with a human-readable `mount.asr` file parsed at boot. Each line is `mnt {device}/path /vfs_path` where `{device}` expands to the boot volume's mount point. Currently used to symlink `/sys`. The boot drive itself is now directly mounted at `/boot` via `mountVolume` in `auto_mount_volumes`. ## Test Cleanup VFS unit tests expanded from 77 to 104 covering symlink traversal, chained symlinks, cycle detection, symlink-to-root, device node I/O, stream mode, and watch/notify. STORTEST expanded to 34 tests with symlink traversal coverage. Both test suites now clean up after themselves via `RemoveVirtualTree`, and a listing leak in `cmd_stortest` was fixed. ## Misc Consolidated scattered `type`/`const`/`var` sections into single blocks. Removed unused `/cfg` virtual directory. Added `FreeVFSObjTree` and `RemoveVirtualTree` for proper teardown of virtual directory trees.
Aaron added 4 commits 2026-03-08 19:03:21 +00:00
- 5-phase VFS architecture overhaul (path resolution, dir cache, watch/notify,
  symlinks, async API)
- Add character/block device node layer with /dev/null and /dev/zero built-ins
- RegisterDevice() API for custom device nodes with read/write/size callbacks
- Merge TOpenMode + TWriteMode into single TOpenMode enum
  (omRead, omWrite, omCreate, omReadWrite, omStream)
- Add stream write support: WriteFile/WriteFileAsync now accept omStream handles
  with auto-advancing offset for both device and volume FDs
- Add PPWriteOffsetHook type and writeOffsetCallback field to TFilesystem
- Add PPReadOffsetHook-based streaming reads for FAT32 and ISO9660
- Update all callers (notepad, edit, inio, wasm runner, filepicker, filedispatch,
  vterminal, stdio) to new 2-param OpenFile API
- 77 unit tests (0 failures) covering path ops, dir cache, symlinks, watch,
  device nodes, and stream read/write
- Add doc/vfs.md — comprehensive public VFS API documentation
- Add mount.asr parser in auto_mount_volumes: reads MOUNT.ASR from boot
  volume root, parses 'mnt {device}<src> <target>' lines, expands {device}
  to the boot volume's /disk/volN path, creates symlinks for each entry
- Remove old asr.mnt persistent mount logic from auto_mount_volumes
- Remove persistent mount write ([p] flag) from MOUNT shell command
- Remove hardcoded /boot mount for boot volumes (now driven by mount.asr)
- Add iso/mount.asr with default /boot and /sys symlinks
- Update doc/vfs.md with mount.asr documentation
vfs: symlink support in file picker, test cleanup, boot mount fix
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
c8c7c2983d
- File picker (app.filepicker.pas): add otSYMLINK to directory case in
  fp_collect_cb so symlinks like /sys appear as navigable directories
- VFS: add RemoveVirtualTree() to recursively free vdir/symlink trees
- VFS UnitTest: clean up /utest_vfs tree after all tests
- STORTEST: clean up /st_test tree after tests, fix listing leak in
  cmd_stortest (GetDirectoryListingFrom result was never freed)
- Boot mount: auto-mount boot drive at /boot via mountVolume() instead
  of symlink; remove /boot and /cfg from init() vdirs
- mount.asr: remove boot line (now only 'mnt {device}/sys /sys')
Aaron requested review from admin 2026-03-08 19:03:30 +00:00
Aaron requested review from t3hn3rd 2026-03-08 19:03:31 +00:00
Aaron added the Improvement label 2026-03-08 19:03:41 +00:00
Aaron added this to the 2.0.0 milestone 2026-03-08 19:03:45 +00:00
Aaron self-assigned this 2026-03-08 19:03:51 +00:00
admin approved these changes 2026-03-08 20:05:03 +00:00
admin left a comment
Owner

Approved 👍

Approved 👍
admin scheduled this pull request to auto merge when all checks succeed 2026-03-08 20:05:20 +00:00
admin merged commit 7157a57513 into develop 2026-03-08 20:16:46 +00:00
Sign in to join this conversation.