Package: cpmtools
Version: 2.23-4
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:
--- a/fsck.cpm.c
+++ b/fsck.cpm.c
@@ -310,8 +310,8 @@
bcdCheck(dir->name[3],60,sb->cnotatime ? "creation date" :
"access date","minute",extent,extent2);
bcdCheck(dir->name[6],24,"modification
date","hour",extent,extent2);
bcdCheck(dir->name[7],60,"modification
date","minute",extent,extent2);
-
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];
+
created=(dir->name[0]+(dir->name[1]<<8))*(0x60*0x60)+dir->name[2]*0x60+dir->name[3];
+
modified=(dir->name[4]+(dir->name[5]<<8))*(0x60*0x60)+dir->name[6]*0x60+dir->name[7];
if (sb->cnotatime && modified<created)
{
printf("Warning: Modification date earlier than creation date
(extent=%d/%d)\n",extent,extent2);
What it prints, and what it should print:
updated later: warns of entry 4 (the first slot) should be clean
updated backwards: warns of entry 5 (the second slot) only should warn of
4 and 5
With the patch, it does what it should.
Thank you for cpmtools: we use it to check that our CP/M 3 file system reads
and writes the same disks Linux does.
Jefferson Hunt