View Single Post
Old 27 February 2018, 12:59   #109
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,347
There might be a couple of issues in scsi_get_geometry().
Code:
struct SCSIBlockDescriptor *bd = (struct SCSIBlockDescriptor*)(ph + 1);
ULONG blocks = bd->scbd_NumberOfBlocks & 0x00ffffff;
if (blocks != 0x00ffffff)
	geom->dg_TotalSectors = blocks;
geom->dg_SectorSize = bd->scbd_BlockLength & 0x00ffffff;
The number of blocks field can contain zero: "A value of zero indicates that all of the remaining logical blocks of the logical unit shall have the medium characteristics specified."
So instead of if (blocks != 0x00ffffff) perhaps do if ((blocks != 0x00ffffff) && (blocks != 0))

Also it looks like there's an off-by-one bug with READ CAPACITY:
Code:
struct SCSICapacity *scc = (struct SCSICapacity*)buffer;
geom->dg_TotalSectors = scc->scc_Block;
geom->dg_SectorSize = scc->scc_BlockLength ? scc->scc_BlockLength : 512;
Instead of geom->dg_TotalSectors = scc->scc_Block; do something like
Code:
if (scc->scc_Block != 0xFFFFFFFF)
	geom->dg_TotalSectors = scc->scc_Block + 1;
else
	geom->dg_TotalSectors = 0xFFFFFFFF;
mark_k is offline  
 
Page generated in 0.07718 seconds with 10 queries