Came across this bug today. Both Atrax and I have confirmed that in some cases, you can write beyond the currently allocated sectors, corrupting other drives in the process.
When ROS looks for free sectors to write to a file, it does so based on the bitmap in sector 0. When it scans the bitmap, it compares the scanned (current) allocation unit number with the total sectors of the disk. With a 3200 sector disk, the total sectors must be divided by 2, to ensure each allocation unit represents two sectors. In the current code the division never takes place, so ROS thinks there are up to 6400 sectors to scan.
The offending routine is listed below. I'll fix this as time permits.
* FIND FIRST FREE SECTOR OUT: R1= Sector number (ZERO if none)
FNDSEC LI R6,>5838 Point to the start of the BITMAP
MOV @OFSET,R7 Page # of the first page
CB @MASK+1,@LINK+1 8 bit or 16 bit BUS
JNE FNDSED Jump if 16 bit
SWPB R7 8 bit, so swap it
FNDSED LDCR R7,0 Write the page # to the card
CLR R1 Start searching at sector 0
JMP NXWRD Jump and get the first WORD
NXCHK DEC R2 Finished with this WORD
JNE NXSEC Nope, so shift some more
NXWRD MOV *R6+,R0 Get another WORD of the BITMAP
SWPB R0 Put it in the right order
LI R2,16 16 sectors per WORD
NXSEC SRL R0,1 Shift 1 sector out
JNC FDSEC If no carry, then it's free
INC R1 Not free, so check next sector
C R1,@FORSEC Are we at the end of the drive (BUG! Must /2 IFF disk total allocation is greater than 1600 sectors, i.e., 2 AUs/sector)
JLT NXCHK Nope, so check next sector
CLR R1 Yep, so send >0000 back
***2-19-2012tt FDSEC RT RETURN TO THE CALLING PROGRAM
* Test for >1600 and return proper sector#
FDSEC C @FORSEC,@D1600 2-19, disk size>1600?
JLE FDRT11 no
SLA R1,1 yes, adjust x2