Skip to content

Retarget decb and os9 to libdiskimage - #99

Merged
DrPitre merged 10 commits into
nitros9project:mainfrom
tlindner:retarget-decb-os9
Nov 2, 2026
Merged

DrPitre merged 10 commits into
nitros9project:mainfrom
tlindner:retarget-decb-os9

Conversation

@tlindner

@tlindner tlindner commented Nov 1, 2026

Copy link
Copy Markdown
Member

994a505: decb and os9 now run on libdiskimage, so they work on DMK, JVC, SDF and VDK images.
726818f: decb dir lists filenames with ? sizes when the FAT is missing, then fails with the FAT’s error.
2c4f63c: Detects possible filesystems on an image, and copy refuses to overwrite a host disk image.
ef72d24: Adds dgndos dsave and dsave -x=path, and moves the shared code into libtoolshed as TSDSave.
ed52202: os9 format and decb dskini take -f to pick an image format, and hdbconv is fixed.
690821d: Removes libdiskimage’s unused stream API.
b85f8da: Adds diskinfo -s, which reports possible filesystems as an exit-status bitmask.
71fb44c: Test failures now stick in tinytest, and non-raw images are tested across formats.
37e3150: Adds tests against a real Disk BASIC disk made under MAME.
cfa26b7: Zero-fills raw-image gaps, so output matches ToolShed 2.6.1 again.

tlindner and others added 10 commits November 1, 2026 12:24
libdecb, librbf and libcoco's image detection no longer read images with
stdio, so decb and os9 now work on DMK, JVC, SDF and VDK images as well as
raw ones.

Sectors are addressed by cylinder, side and sector rather than through the
stream, so a missing sector fails with EOS_SECT by itself and does not move
the sectors after it. The FAT and the OS-9 bitmap only fail what needs them,
and are written back only if they changed. A bad CRC gives the data as
recorded with a warning. Write protected images fail writes with EOS_WP.

A drive number or offset in a pathlist, and decb dskini -h with more than
one drive, now require a raw image.

diskinfo gets -p and -u to set and clear the write protect flag, and reports
when an image is protected. libdiskimage rechecks a raw file's size so a
second open cannot overwrite sectors the first one added.

Also fix TSCopyFile: copying a raw path stopped at a size misread from LSN0
and took its permissions and date from there, failures to find the end of
the source were not reported, and -l wrote nothing when both ends used the
same line endings.

Add git ignore for CLAUDE.md and the os9 mame.dmk test fixture.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The names come from the directory, so only the size column needs the FAT.
List every file with ? for its size, then fail with the FAT's error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add _coco_detect_filesystems, which reports which of OS-9, Disk BASIC and
Dragon DOS an image could hold, since a disk can hold several. Disk BASIC has
no marker, so the new _decb_identify validates the FAT and directory on track
17. A track 17 of only $FF is an unused track, so it does not count. diskinfo
prints what is found, and os9, decb and dgndos dir end their listing by naming
any other filesystems.

Move dgndos copy's check for host files that look like disk images into
libcoco, and use it in os9, decb and cecb copy too. Forgetting a comma no
longer replaces a whole disk, even with -r; the copy fails and says why.

dsave returned system()'s wait status, whose low byte is 0, so it exited 0
when a copy failed. It now exits with the copy's status, and a failure in a
subdirectory is no longer ignored.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
dsave runs copy commands by name, so it used whichever binary the shell found
first. -x=path on os9, decb and dgndos dsave names the one to use.

Move do_dsave out of os9/os9dsave.c, which decb compiled in directly, into
libtoolshed as TSDSave. dgndos dsave uses it, and fails with an explanation at
a subdirectory, as Dragon DOS has no directories.

Fix what the move turned up: the option buffer overflowed with -r -l -t, paths
too long for the command could overflow or be cut off, and decb dsave's double
quotes let the shell expand a $ in a filename.

_dragondos_open ignored FAM_DIR, so a file could be opened as a directory. It
now returns EOS_FNA.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
os9 format and decb dskini now take -f<name> for raw, jvc, vdk, dmk or sdf, and
otherwise go by the disk's extension and then raw, as dgndos dskinit does. The
naming code moves into libdiskimage so all three share it. _os9_format_image
and _decb_dskini_format are new; _os9_format and _decb_dskini are unchanged.

Non-raw os9 format images are new files only and always hold the whole disk.
decb dskini initializes an existing disk of the same format again, and leaves
one of another format alone. Many HDB-DOS drives still need a raw image.

hdbconv read a DMK as plain bytes and could replace an image. It now takes only
a raw source, won't replace a target that looks like an image, doesn't write
garbage after a failed read, and reports errors in its exit status.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Nothing but its own tests used the stream functions. libdecb, librbf and
libdragondos address sectors directly, so that a missing sector fails by itself
rather than moving the ones after it.

Remove libdiskimagestream.c, the _diskimage_stream_ functions, and the
stream_size and stream_offset fields. Delete the tests of streams alone, and
check what the other tests only checked through a stream by reading sectors.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With -s, diskinfo prints nothing and exits with the possible filesystems of one
file: 1 for OS-9, 2 for Disk BASIC and 4 for Dragon DOS, added together, or 0
for a disk image with none. fsck's exit status is a bitmask in the same way.

Anything that isn't an answer exits 64, including several files or another
option, so that a status of 1 can't be mistaken for a usage error. Without -s,
diskinfo is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
tinytest overwrote its failed flag on every assertion, so a failure in a helper
was cleared by the next assertion that passed. Failures now stick, and the first
is the one reported. The test Makefile also ignored header changes, and now
rebuilds a test when a header it includes changes.

That showed os9 format -bs512 was never tested: 18 sectors of 512 bytes don't
fit on a track, and it rightly fails. The test now uses 9, and checks the refusal.

Add imagedamage.h to damage DMK, SDF and JVC images, replacing helpers copied
between tests, and test across formats: missing sectors and bad CRCs including
on side 1, write protection, raw paths, decb raw writes and seeking, the commands
themselves, os9 gen, bad LSN0 values, and detection staying quiet on a bad CRC.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add "rsdos mame.dmk", made by Disk Extended Color BASIC 1.1 under MAME. Its
machine code files come from a pattern that tests can recompute, and what the
tests expect of its directory and free space is what DIR and FREE(0) reported.

The disk has every file type, sizes at the edges as the ROM records them, a chain
across track 17, a chain with a gap, a second directory sector, and a killed entry
with a file after it. The tests read all of it, list its tokenized program as
BASIC's own ASCII copy and tokenize that back to the same bytes, and change copies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
raw_extend() filled the sectors skipped by a distant write with $FF. Before
the move to libdiskimage these writes used fseek and fwrite, which left them
zero, so a quick format followed by os9 gen no longer matched ToolShed 2.6.1.

Fill the gaps with zero and remove DI_RAW_FILL, which nothing else used. The
rest of a new partial sector in librbf is still $FF, as it was in 2.6.1.

Test quick formatted images extended by distant writes, including gen writing
the kernel track before OS9Boot, and that fully formatted images are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@tlindner

tlindner commented Nov 1, 2026

Copy link
Copy Markdown
Member Author

I should also mentions NitrOS9 disk testing. All recipe disk images byte matched from this PR to tag v2.6.1.

@DrPitre
DrPitre merged commit 90a0831 into nitros9project:main Nov 2, 2026
6 checks passed
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.

2 participants