#1152980 fsck.cpm: an SFCB's first slot's date stamps are read crosswise

Package:
cpmtools
Source:
cpmtools
Description:
Tools to access CP/M file systems
Submitter:
Jefferson Hunt
Date:
2026-11-03 23:31:02 UTC
Severity:
normal
#1152980#5
Date:
2026-11-03 23:29:10 UTC
From:
To:
Hello,

fsck.cpm 2.23 reads the date stamps of the first file entry in each four-entry group (an SFCB's first slot) with the low bytes of the two day counts swapped. So an entry there that was created on one day and updated on a later day gets a false warning:

  Warning: Modification date earlier than creation date (extent=7/4)

And an entry whose stamps really are in the wrong order gets no warning at all. The second and third slots, and the directory label, are read correctly.

The cause, in fsck.cpm.c (lines 313-314 in 2.23):

  created=(dir->name[4]+(dir->name[1]<<8))*(0x60*0x60)+dir->name[2]*0x60+dir->name[3];
  modified=(dir->name[0]+(dir->name[5]<<8))*(0x60*0x60)+dir->name[6]*0x60+dir->name[7];

The first slot's creation stamp is bytes 1-4 of the SFCB (name[0..3]), and its update stamp is bytes 5-8 (name[4..7]), each one a two-byte day count with the low byte first, then the hour and the minute. The day’s low byte is taken from the other stamp: name[4] where name[0] belongs, and name[0] where name[4] belongs. The second and third slots' lines, just below, read their bytes in order.

The fix: