fix self-referencing sector

This commit is contained in:
Denis Molony 2016-07-17 07:33:31 +10:00
parent b1c9e1aadc
commit c9eb6f0036

View File

@ -27,7 +27,7 @@ class CatalogEntry extends AbstractCatalogEntry
{ {
System.out.printf ("Attempt to assign TS sector to occupied sector " System.out.printf ("Attempt to assign TS sector to occupied sector "
+ ": %s from %s%n", da, name); + ": %s from %s%n", da, name);
break; // break;
} }
tsSectors.add (da); tsSectors.add (da);
byte[] sectorBuffer = disk.readSector (da); byte[] sectorBuffer = disk.readSector (da);
@ -42,6 +42,7 @@ class CatalogEntry extends AbstractCatalogEntry
break; break;
} }
DiskAddress thisDA = da;
for (int i = startPtr, max = disk.getBlockSize (); i < max; i += 2) for (int i = startPtr, max = disk.getBlockSize (); i < max; i += 2)
{ {
da = getValidAddress (sectorBuffer, i); da = getValidAddress (sectorBuffer, i);
@ -76,11 +77,17 @@ class CatalogEntry extends AbstractCatalogEntry
da = getValidAddress (sectorBuffer, 1); da = getValidAddress (sectorBuffer, 1);
if (da == null) if (da == null)
{ {
System.out.print ("Next T/S list in sector " + da); System.out.print ("Next T/S list in sector " + thisDA);
System.out.printf (" is invalid : %02X, %02X%n", sectorBuffer[1], System.out.printf (" is invalid : %02X, %02X%n", sectorBuffer[1],
sectorBuffer[2]); sectorBuffer[2]);
break; break;
} }
if (thisDA.compareTo (da) == 0)
{
System.out.printf ("Next T/S list in sector %s points to itself%n", thisDA);
break;
}
} }
} }