Skip to content

Make MDF/MDS maintenance parity-safe and file-level - #305

Merged
Hawkynt merged 14 commits into
mainfrom
feat/mdf-mds-maintenance
Sep 11, 2026
Merged

Hawkynt merged 14 commits into
mainfrom
feat/mdf-mds-maintenance

Conversation

@Hawkynt

@Hawkynt Hawkynt commented Sep 11, 2026

Copy link
Copy Markdown
Owner

What changed

  • replace MDF's synthetic sector-NNNNNN.bin descriptor edits with transactional root-level ISO 9660 file add/replace/remove
  • add a fixed-capacity cooked-sector stream over 2048/2336/2352 MDF geometry so companion MDS track sizes stay valid
  • regenerate ECMA-130 Mode 1 / Mode 2 Form 1 EDC and P/Q ECC whenever raw-sector payload bytes change
  • add physical layout mapping, unused-space wipe, purge, and transactional defrag
  • keep shrink and geometry relayout unsupported because changing the MDF track length/geometry without rewriting the companion MDS would invalidate the pair
  • add known-vector/regression/round-trip coverage for parity, transactional no-space failure, R/W, wipe, purge, defrag, and layout coverage

Design

The archive API gives a format one stream, while Alcohol images are a paired MDF data stream plus MDS descriptor. Existing paired images are therefore treated as fixed-capacity: ISO metadata and payload may change inside the current track, but the physical MDF sector count may not. Edits are staged to a scratch file and committed only after the result can be parsed.

Raw-sector framing is not treated as disposable padding. Mode 1 EDC is recomputed over bytes 0..2063; Mode 2 Form 1 over subheader+data; ECMA-130 GF(2^8) P parity is generated before Q because Q covers P. The physical layout map conservatively reserves whole raw sectors when their ISO payload is otherwise free; the wipe path uses the finer cooked logical view and rewrites parity after zeroing payload bytes.

References / licensing

  • ECMA-119 for ISO 9660 filesystem layout
  • ECMA-130 for 2352-byte CD-ROM Mode 1 framing, EDC and ECC
  • ECMA-168 for Mode 2 Form 1 sector organization
  • Aaru Alcohol120 structures/enums (LGPL-2.1-or-later) and libMirage/CDEmu as behavioral/reference material

No third-party implementation code or lookup tables were copied. EDC/ECC tables are derived at runtime from the specification polynomials/field definition.

Validation

Local execution is unavailable in this session, so validation is being driven by repository tests plus GitHub Actions. The PR includes a fixed ECMA-130 Mode-1 known-vector SHA-256 and MDF round-trip/regression tests; CI results will be checked and failures caused by this change fixed here.

@Hawkynt
Hawkynt force-pushed the feat/mdf-mds-maintenance branch 3 times, most recently from ef1bf0b to 7e3cee7 Compare September 11, 2026 19:19
Hawkynt and others added 14 commits September 11, 2026 22:09
# MDF defrag refused its own rebuild, and a scaffolding workflow shipped with it

MdfCookedStream.SetLength refused every length change, but ISO defragmentation
legitimately shrinks the logical volume inside a track whose physical size is
fixed by the MDS descriptors. A shrink costs nothing physically and is now
accepted; only growth past the track is refused.

The branch also carried .github/workflows/mdf-docs-temp.yml, which applied its
README row by string substitution on every pull request and pushed the result
back. The row it writes is already in the branch, so the workflow could only
fail from here on, and it is removed along with the matching test deferral it
was meant to drop.

Add_WithoutPhysicalHeadroom assumed a full track refuses any add, but
AddOrReplace releases reclaimable slack before it checks capacity. The test now
asks for more than the whole track, which no trimming can satisfy.
@Hawkynt
Hawkynt force-pushed the feat/mdf-mds-maintenance branch from 7e3cee7 to 0f7e04e Compare September 11, 2026 20:12
@Hawkynt
Hawkynt merged commit eaebb9e into main Sep 11, 2026
5 checks passed
@Hawkynt
Hawkynt deleted the feat/mdf-mds-maintenance branch September 11, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant