My head is really getting bent out of shape now; I cannot see what I am missing.
With a newly formatted disk, no files added, this is what I see from the various parameter blocks:
Code: Select all
NeoDOS32 v0.0411
VIB sector $00000800
FSI sector $00000801
Sectors in partition $000EA000
Sectors per cluster $08
Free cluster count $0001D310
Next free cluster $00000002
FAT 1 sector $00000820
FAT 2 sector $00000BC8
Sectors per fat $000003A8
Start of clusters $00000F70
Root dir cluster $00000002
Which is exactly right; the root directory lives at cluster 2 and so that's what's stored as the next free cluster. With everything empty, the start of the FAT table looks like this (in all these next images, ignore the addresses at the start of the line; that's the address of the transient buffer):
Code: Select all
7E00 F8 FF FF 0F FF FF FF 0F F8 FF FF 0F 00 00 00 00 ................
7E10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Showing that (fake) clusters 0 and 1 are occupied by the formatting, and cluster 2 holds the root directory. That lives at $F70.
Cluster 2 at this point is empty, as required by the format rules; cluster 3 may contain previous data but is irrelevant as nothing in the FAT points to it.
Now I make a change. On the linux box, I copy a previously made directory into root (for simplicity: if a directory is created and renamed, it leaves a deleted file entry hanging around and it's not clear what it does with the old cluster. Also, a directory named in capitals and with fewer than eight characters does not create a long file name entry.) That gives me, as viewed from my code:
Code: Select all
Free cluster count $0001D30F
Next free cluster $00000003
- that is, the free cluster count has decremented and the next free cluster has incremented (as always, the 'next free cluster' always seems to mean 'last allocated cluster', so as it just allocated cluster 3...).
Now the start of the FAT looks like:
Code: Select all
7E00 F8 FF FF 0F FF FF FF 0F F8 FF FF 0F FF FF FF 0F ................
7E10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
showing that cluster three is allocated.
Cluster two - the root directory - now includes a reference to the new directory:
Code: Select all
Cluster 2
7E00 46 4F 4C 44 45 52 20 20 20 20 20 10 00 2D 12 49 FOLDER ..-.I
7E10 71 5C 71 5C 00 00 0C 49 71 5C 03 00 00 00 00 00 q\q\...Iq\......
and the freshly allocated cluster 3 now has the dot and dotdot entries:
Code: Select all
Cluster 3
7E00 2E 20 20 20 20 20 20 20 20 20 20 10 00 2D 12 49 . ..-.I
7E10 71 5C 71 5C 00 00 12 49 71 5C 03 00 00 00 00 00 q\q\...Iq\......
7E20 2E 2E 20 20 20 20 20 20 20 20 20 10 00 2D 12 49 .. ..-.I
7E30 71 5C 71 5C 00 00 12 49 71 5C 00 00 00 00 00 00 q\q\...Iq\......
Which is all well and good... but now, I start again with a newly formatted disk and attempt to create a directory in root. The initial state is as above; I won't repeat it. Cluster three contains the relics of the previous directory 'FOLDER', with the creating/access date of $5c71.
After creating the directory name in root, I get:
Code: Select all
7E00 44 49 52 45 43 54 30 30 20 20 20 10 00 00 D0 21 DIRECT00 ....!
7E10 21 5C 21 5C 00 00 D0 21 21 5C 03 00 00 00 00 00 !\!\...!!\......
(different name so I can see it changed, and a creation date of 5c21 (Jan 1 2026))
I then create the new directory structure (dot and dotdot entries) and write it to cluster three.
At this point nothing crashes...
When I look again at the sectors, I now see that the free cluster count and next free clusters are the same as when Linux moved the file,
Code: Select all
7E00 F8 FF FF 0F FF FF FF 0F F8 FF FF 0F FF FF FF 0F ................
7E10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
The FAT entries are correct (cluster three is now in use)
Code: Select all
Cluster 2
7E00 44 49 52 45 43 54 30 30 20 20 20 10 00 00 D0 21 DIRECT00 ....!
7E10 21 5C 21 5C 00 00 D0 21 21 5C 03 00 00 00 00 00 !\!\...!!\......
Cluster 2 has the directory entry in root (datestamped 5C21)
And cluster 3 contains the dot and dotdot entries for the new folder (different time/date stamps than the linux version, as expected)
Code: Select all
Cluster 3
7E00 2E 20 20 20 20 20 20 20 20 20 20 10 00 00 D7 21 . ....!
7E10 21 5C 21 5C 00 00 D7 21 21 5C 03 00 00 00 00 00 !\!\...!!\......
7E20 2E 2E 20 20 20 20 20 20 20 20 20 10 00 00 D7 21 .. ....!
7E30 21 5C 21 5C 00 00 D7 21 21 5C 00 00 00 00 00 00 !\!\...!!\......
So everything looks spot on. And yet, when I try and open the new file in linux...
Code: Select all
barnacle@barnacle-Latitude-9430:~$ cd /media/barnacle/AB17-FFB6/
barnacle@barnacle-Latitude-9430:/media/barnacle/AB17-FFB6$ dir
DIRECT00
barnacle@barnacle-Latitude-9430:/media/barnacle/AB17-FFB6$ cd DIRECT00/
barnacle@barnacle-Latitude-9430:/media/barnacle/AB17-FFB6/DIRECT00$ dir
dir: reading directory '.': Input/output error
$é╖!;£┐╒.\037½_ \002¿\025¡─\005æó.C\bê iⁿó\t╚≥4δ.∙Φσ [╔~}û┐÷╞.5f\022
3oKT╧$\024Ç.2P\001 \n°dp╩k{f.¿·\037 ò!╕_┤ôδ⌐.k∩\n
A_E{Ö·╖\006.{╦\004 íëî°µ¿a8.;║2 ß∙a█■ì]ì.@εî
barnacle@barnacle-Latitude-9430:/media/barnacle/AB17-FFB6/DIRECT00$
weird stuff happens. It looks as if it's reading some random part of the disk as if it were the directory cluster/sector, and I have exactly no idea why...
I can see the directory in /root. I can cd to that directory (and the tab extensions work to select it). But it ought to be reading directory '.' and it ain't. I'm assuming that the input/output error is something generic possibly relating to a pointer outside the partition; I am told that linux does check that. But it's still hinting that the contents of the directory are bent out of shape.
Ungood. Double plus ungood.
Neil
p.s. just checked: FAT1 and FAT2 are identical.