fat32: fix pre-alloc cluster leak; add write-handle ref-count

- Remove FAT_WRITE_PREALLOC_BYTES (redundant at typical cluster sizes)
- Simplify fatPreallocClusterCount to always return MAX_CLUSTERS
- FAT32CloseFile: truncate pre-allocated tail clusters back to ByteSize
  on close, freeing FAT chain entries beyond the file's real size
- Add TFATWriteRef + WriteRefs[32] in TFATVolumeCtx and Registered flag
  on TFATOpenFile to track concurrent write handles per dir entry
- fatRegisterWriteHandle / fatUnregisterWriteHandle: CLI-guarded slot scan
  keyed by (DirLoc.SectorLBA, DirLoc.EntryIdx)
- Register on first FAT chain extension in FAT32EnsureCapacityForWrite
- Truncation in FAT32CloseFile skipped unless this is the last writer
  (prevents RunMap corruption in concurrent-open scenarios)
- Add forward decl for fatFreeClusterChain to fix ordering issue
- app.iotest: update default path to /disk/vol2/IOTEST.BIN
This commit is contained in:
Aaron committed 2026-03-18 21:05:36 +00:00
1 parent 663bfbb0e4
commit 096db148d0
6 files changed
+818 -27

No files matched your search

+1 -1
View File
@@ -34,7 +34,7 @@ const
TICK_HZ = 1024; { timer ISR frequency }
IO_WAIT_TIMEOUT_TICKS = 10 * TICK_HZ;
DELETE_TIMEOUT_TICKS = 5 * TICK_HZ;
DEFAULT_PATH : pchar = '/disk/vol0/IOTEST.BIN';
DEFAULT_PATH : pchar = '/disk/vol2/IOTEST.BIN';
type
TIOTSyncWaitCtx = record