Thread View: linux.debian.bugs.dist
1 messages
1 total messages
Started by Jefferson Hunt
Tue, 03 Nov 2026 23:40
Bug#1152980: fsck.cpm: an SFCB's first slot's date stamps are read crosswise
Author: Jefferson Hunt
Date: Tue, 03 Nov 2026 23:40
Date: Tue, 03 Nov 2026 23:40
157 lines
10168 bytes
10168 bytes
--Apple-Mail=_E2FF1CE8-802F-4B46-A268-F76F98134EC7
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=utf-8
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=3D7/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=3D(dir->name[4]+(dir->name[1]<<8))*(0x60*0x60)+dir->name[2]*0x60+d=
ir->name[3];
=
modified=3D(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=E2=80=
=99s 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=3D(dir->name[4]+(dir->name[1]<<8))*(0x60*0x60)+dir->name[2]*0x60+d=
ir->name[3];
- =
modified=3D(dir->name[0]+(dir->name[5]<<8))*(0x60*0x60)+dir->name[6]*0x60+=
dir->name[7];
+ =
created=3D(dir->name[0]+(dir->name[1]<<8))*(0x60*0x60)+dir->name[2]*0x60+d=
ir->name[3];
+ =
modified=3D(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=3D%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=
--Apple-Mail=_E2FF1CE8-802F-4B46-A268-F76F98134EC7
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=utf-8
<html aria-label=3D"message body"><head><meta http-equiv=3D"content-type" =
content=3D"text/html; charset=3Dutf-8"></head><body =
style=3D"overflow-wrap: break-word; -webkit-nbsp-mode: space; =
line-break: after-white-space;"><div>Package: =
cpmtools</div><div>Version: =
2.23-4</div><div><br></div><div>Hello,</div><div><br></div><div>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:</div><div><br></div><div><font =
face=3D"Menlo"> Warning: Modification date earlier than creation =
date (extent=3D7/4)</font></div><div><br></div><div>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.</div><div><br></div><div>The cause, in fsck.cpm.c (lines =
313-314 in 2.23):</div><div><br></div><div><font face=3D"Menlo"> =
created=3D(dir->name[4]+(dir->name[1]<<8))*(0x60*0x60)+dir->=
;name[2]*0x60+dir->name[3];</font></div><div><font =
face=3D"Menlo"> =
modified=3D(dir->name[0]+(dir->name[5]<<8))*(0x60*0x60)+dir-&g=
t;name[6]*0x60+dir->name[7];</font></div><div><br></div><div>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=E2=80=
=99s 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.</div><div><br></div><div>The fix:</div><div><font =
face=3D"Menlo"><br></font></div><div><div><div><font face=3D"Menlo"> =
--- a/fsck.cpm.c</font></div><div><font =
face=3D"Menlo"> +++ =
b/fsck.cpm.c</font></div><div><font face=3D"Menlo"> =
@@ -310,8 +310,8 @@</font></div><div><font face=3D"Menlo"> =
=
bcdCheck(dir->name[3],60,sb->cnotatime ? "creation date" : "access =
date","minute",extent,extent2);</font></div><div><font =
face=3D"Menlo"> =
bcdCheck(dir->name[6],24,"modification =
date","hour",extent,extent2);</font></div><div><font face=3D"Menlo"> =
=
bcdCheck(dir->name[7],60,"modification =
date","minute",extent,extent2);</font></div><div><font =
face=3D"Menlo"> - =
created=3D(dir->name[4]+(dir->name[1]<<8))*(0x60*0x60)+d=
ir->name[2]*0x60+dir->name[3];</font></div><div><font =
face=3D"Menlo"> - =
modified=3D(dir->name[0]+(dir->name[5]<<8))*(0x60*0x60)+=
dir->name[6]*0x60+dir->name[7];</font></div><div><font =
face=3D"Menlo"> + =
created=3D(dir->name[0]+(dir->name[1]<<8))*(0x60*0x60)+d=
ir->name[2]*0x60+dir->name[3];</font></div><div><font =
face=3D"Menlo"> + =
modified=3D(dir->name[4]+(dir->name[5]<<8))*(0x60*0x60)+=
dir->name[6]*0x60+dir->name[7];</font></div><div><font =
face=3D"Menlo"> if =
(sb->cnotatime && modified<created)</font></div><div><font =
face=3D"Menlo"> =
{</font></div><div><font face=3D"Menlo"> =
printf("Warning: Modification date earlier =
than creation date =
(extent=3D%d/%d)\n",extent,extent2);</font></div></div><div><br></div></di=
v><div><div>What it prints, and what it should =
print:</div><div><br></div><div><font face=3D"Menlo"> =
updated later: warns of entry 4 (the first =
slot) should be clean</font></div><div><font =
face=3D"Menlo"> updated backwards: warns of entry 5 =
(the second slot) only should warn of 4 and =
5</font></div><div><br></div><div>With the patch, it does what it =
should.</div><div><br></div><div>Thank you for cpmtools: we use it to =
check that our CP/M 3 file system reads and writes the same disks Linux =
does.</div><div><br></div><div>Jefferson Hunt</div></div></body></html>=
--Apple-Mail=_E2FF1CE8-802F-4B46-A268-F76F98134EC7--
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads