Files
libretroadmin 7c6f368f9a DEV9: read and write VHD and CHD hard-disk images
Arcade games ship their HDD as a CHD (or, from other tools, a VHD), and
the DEV9 drive only knew raw images. pcsx2/DEV9/ATA/HddImage.c (C89)
puts a small image layer under the ATA I/O thread:

- VHD: fixed and dynamic images, read and write. Footer and dynamic
  header checksums are checked; a write to an unallocated block places
  the new block where the footer was, moves the footer after it and
  then writes the BAT entry. Differencing images are refused.
- CHD: read through libretro-common's rchd (every codec it has, a
  one-hunk cache); parent CHDs are refused. The CHD is never written:
  writes go to <image>.overlay, a sparse file of 4 KiB blocks with a
  bitmap, keyed to the CHD's SHA-1 so an overlay of another image is
  refused rather than applied.

The libretro core uses DEV9hdd.chd, then DEV9hdd.vhd, from
system/pcsx2/ when one is there, and DEV9hdd.raw as before otherwise;
the drive's size comes from the image.

Tests: tests/hddimage checks both formats and the overlay with images
it writes itself, and when qemu-img and chdman are installed (CI now
installs qemu-utils and mame-tools) cross-checks against their images
both ways. tests/ata runs its I/O-thread suite on a raw image, a
dynamic VHD and a CHD with its overlay.
2026-11-08 18:28:56 +01:00
..