Storage system overhaul: VFS, FAT32, ISO9660, AHCI/IDE refactor, GUI apps & boot drive mounting #49

Merged
admin merged 11 commits from feature/storage-system into develop 2026-03-07 19:53:17 +00:00
Member

Overview

Complete rewrite and expansion of the storage subsystem. Introduces a unified
VFS, proper filesystem drivers, volume and storage management, a suite of new
GUI and CLI applications, and boot drive auto-mounting.

Storage Architecture

  • Replaced storagemanagement.pas with storagemanager.pas, unified physical
    device registry with BIOS drive byte correlation for boot device detection
  • New storagetypes.pas, shared type definitions across the storage stack
  • New volumemanager.pas, volume discovery, registration, and lifecycle
  • New iorequest.pas / iobuffer.pas, async I/O request plumbing
  • New fdtable.pas, per-process file descriptor table
  • New filesystemmanager.pas, filesystem driver registry

Filesystem Drivers

  • New fat32.pas, full FAT32 read/write driver (replaces stub)
  • New iso9660.pas, read-only ISO9660 driver for CD-ROM boot media
  • New flatfs.pas, custom flat filesystem driver
  • Retained asfs.pas with minor fixes

Partition Support

  • New gpt.pas, GUID Partition Table parser
  • New MBR.pas, Master Boot Record parser

Driver Refactors

  • AHCI split into AHCI/AHCI.pas + AHCI/AHCITypes.pas (296 to 1074 lines)
  • IDE split into IDE/IDE.pas + IDE/ata.pas + IDE/atapi.pas + IDE/idetypes.pas
  • Removed legacy ATA_ISR.pas

VFS

  • Major rewrite of vfs.pas (+1900 lines net)
  • Path resolution, directory listing, mounting, symlinks, working directory support
  • Auto-mount volumes at /disk/volN; boot volume auto-mounted at /boot

Boot Drive Detection

  • Multiboot boot_device byte decoded in kernel.pas and passed to storagemanager
  • isBootDevice flagged on the correct physical device and propagated through volumes
  • /boot VFS directory created and populated automatically on startup

Bug Fixes

  • FAT32 triple fault on deleted directories getDirEntries now skips $E5
    (deleted) entries; previously stale cluster pointers caused a triple fault when
    navigating into recently deleted directories

New Programs

  • diskutil.pas, GUI disk utility (device/volume inspector, format, partitions)
  • notepad.pas, GUI text editor with open/save/selection/word-wrap
  • filepicker.pas, reusable inline file picker component
  • diskcmd.pas, disk inspection CLI commands
  • partcmd.pas, partition management CLI commands
  • volcmd.pas, volume management CLI commands

Process Management Integration

  • diskutil and notepad call processmanager.create() on launch and
    processmanager.kill() on close
  • Both apps appear in PS and respond to KILL / TERMINATE
  • Windows associated with their owning process via windows.setWindowOwner()

Stats

53 files changed, 17176 insertions(+), 2997 deletions(-)

## Overview Complete rewrite and expansion of the storage subsystem. Introduces a unified VFS, proper filesystem drivers, volume and storage management, a suite of new GUI and CLI applications, and boot drive auto-mounting. ## Storage Architecture - Replaced `storagemanagement.pas` with `storagemanager.pas`, unified physical device registry with BIOS drive byte correlation for boot device detection - New `storagetypes.pas`, shared type definitions across the storage stack - New `volumemanager.pas`, volume discovery, registration, and lifecycle - New `iorequest.pas` / `iobuffer.pas`, async I/O request plumbing - New `fdtable.pas`, per-process file descriptor table - New `filesystemmanager.pas`, filesystem driver registry ## Filesystem Drivers - New `fat32.pas`, full FAT32 read/write driver (replaces stub) - New `iso9660.pas`, read-only ISO9660 driver for CD-ROM boot media - New `flatfs.pas`, custom flat filesystem driver - Retained `asfs.pas` with minor fixes ## Partition Support - New `gpt.pas`, GUID Partition Table parser - New `MBR.pas`, Master Boot Record parser ## Driver Refactors - AHCI split into `AHCI/AHCI.pas` + `AHCI/AHCITypes.pas` (296 to 1074 lines) - IDE split into `IDE/IDE.pas` + `IDE/ata.pas` + `IDE/atapi.pas` + `IDE/idetypes.pas` - Removed legacy `ATA_ISR.pas` ## VFS - Major rewrite of `vfs.pas` (+1900 lines net) - Path resolution, directory listing, mounting, symlinks, working directory support - Auto-mount volumes at `/disk/volN`; boot volume auto-mounted at `/boot` ## Boot Drive Detection - Multiboot `boot_device` byte decoded in `kernel.pas` and passed to `storagemanager` - `isBootDevice` flagged on the correct physical device and propagated through volumes - `/boot` VFS directory created and populated automatically on startup ## Bug Fixes - **FAT32 triple fault on deleted directories** `getDirEntries` now skips `$E5` (deleted) entries; previously stale cluster pointers caused a triple fault when navigating into recently deleted directories ## New Programs - `diskutil.pas`, GUI disk utility (device/volume inspector, format, partitions) - `notepad.pas`, GUI text editor with open/save/selection/word-wrap - `filepicker.pas`, reusable inline file picker component - `diskcmd.pas`, disk inspection CLI commands - `partcmd.pas`, partition management CLI commands - `volcmd.pas`, volume management CLI commands ## Process Management Integration - `diskutil` and `notepad` call `processmanager.create()` on launch and `processmanager.kill()` on close - Both apps appear in `PS` and respond to `KILL` / `TERMINATE` - Windows associated with their owning process via `windows.setWindowOwner()` ## Stats 53 files changed, 17176 insertions(+), 2997 deletions(-)
Aaron added 7 commits 2026-03-07 19:30:06 +00:00
VFS fixes:
- GetDirectoryListing(otVDIRECTORY) now returns a heap-allocated snapshot
  instead of a raw live-tree pointer; FreeDirectoryListing no longer
  corrupts the VFS tree (fixes page fault on repeated navigation)
- volumeGetDirectories: guard LL_Size > 0 before loop to prevent uint32
  underflow (0-1 = 0xFFFFFFFF) causing 4B kalloc iterations -> OOM
- Free entry^.fileName and dirList in all branches (memory leak fix)

iso9660:
- equalsIgnoreCase: guard la=0 before loop (same uint32 underflow bug)
- readDirectoryEntries/resolvePath: add 65536/256-iter safety caps

storagemanager:
- Strip debug syslog calls that were allocating 6+ strings per I/O
  (hundreds of I/Os x 6 allocs exhausted the heap)

Process manager:
- Per-process FDTable and Cwd initialised on create, freed on reap
- proc_await: use pointer-indirection spin per lesson #6 (FPC caches
  non-volatile reads; raw while flag=0 returns immediately)
- graphicsrefresh: move LVGL handler from timer ISR (IF=0) to a
  dedicated process so LVGL callbacks can call blocking I/O

New units:
- fdtable.pas: per-process file descriptor table (fd_alloc/get/close)
- iorequest.pas: heap allocation helpers for TIORequest
- gpt.pas: GPT header/entry read + CRC validation
- filepicker.pas: reusable OS-level open/save file picker dialog
- notepad.pas: GUI text editor with selection, indent, save-as

Shell commands (diskcmd, partcmd, volcmd, diskutil):
- Route output to stdout_buf instead of syslog (lesson #4)
- diskutil: async add/remove/format partition; cache-based device display

Add Apache 2.0 license headers to storagemanager.pas, iso9660.pas,
fat32.pas, storagetest.pas

Lessons learnt: #9 VFS listing must return snapshot (not live pointer)
- Decode multiboot boot_device byte in storagemanager to identify boot device
- Add isBootDevice to TStorage_Device; propagate isBootDrive to volumes
- Create /boot VFS directory at init; mount boot volume there in auto_mount_volumes
- Fix getDirEntries skipping \-marked (deleted) FAT32 entries to prevent
  triple fault when navigating into a deleted directory via file picker
feat: add processmanager.create to diskutil and notepad
continuous-integration/drone/push Build is passing
3d9c4cb49a
- diskutil: add proc_pid global, diskutil_entry idle proc, create process
  on launch with setWindowOwner, kill on close, zero proc_pid in init
- notepad: add pid field to TNotepadState, notepad_entry idle proc, create
  process on launch with setWindowOwner, kill pid in doCloseWindow
- both apps now appear in PS and are manageable via KILL/TERMINATE
Removed bad files
continuous-integration/drone/push Build is passing
f0531ff861
removed another bad file
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
f8182b24b3
Aaron added 1 commit 2026-03-07 19:33:47 +00:00
chore: remove lessons_learnt.md from tracking
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2f837ace6e
Aaron added 1 commit 2026-03-07 19:34:04 +00:00
chore: ignore lessons_learnt.md
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
1fc00e3e7c
Aaron added 1 commit 2026-03-07 19:37:37 +00:00
update header
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
d3581eea2e
Aaron added 1 commit 2026-03-07 19:40:28 +00:00
Fix file headers
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
acb4a15e41
admin approved these changes 2026-03-07 19:45:22 +00:00
admin left a comment
Owner

All good, big change, big for the project.

All good, big change, big for the project.
admin scheduled this pull request to auto merge when all checks succeed 2026-03-07 19:45:34 +00:00
admin merged commit f78eaa3811 into develop 2026-03-07 19:53:17 +00:00
Sign in to join this conversation.