mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-26 13:49:21 +00:00
Issue 278: fix ModeSense(6) and ModeSense(10) (#280)
* Change ModeSense(6) and ModeSense(10) to return proper length of data * Fix size of block descripter returned from ModeSense(10)
This commit is contained in:
parent
7e456b76bf
commit
b3b740e3cc
@ -784,6 +784,13 @@ int Disk::ModeSense6(const DWORD *cdb, BYTE *buf)
|
||||
SetStatusCode(STATUS_INVALIDCDB);
|
||||
return 0;
|
||||
}
|
||||
//check if size of data is more than size requested.
|
||||
if (size > length) {
|
||||
SetStatusCode(STATUS_INVALIDCDB);
|
||||
return 0;
|
||||
}
|
||||
//Set length returned to actual size of data
|
||||
length = size;
|
||||
|
||||
return length;
|
||||
}
|
||||
@ -838,20 +845,20 @@ int Disk::ModeSense10(const DWORD *cdb, BYTE *buf)
|
||||
// Check LLBAA for short or long block descriptor
|
||||
if ((cdb[1] & 0x10) == 0 || disk_blocks <= 0xFFFFFFFF) {
|
||||
// Mode parameter header, block descriptor length
|
||||
buf[3] = 0x08;
|
||||
buf[7] = 0x08;
|
||||
|
||||
// Short LBA mode parameter block descriptor (number of blocks and block length)
|
||||
|
||||
buf[4] = disk_blocks >> 24;
|
||||
buf[5] = disk_blocks >> 16;
|
||||
buf[6] = disk_blocks >> 8;
|
||||
buf[7] = disk_blocks;
|
||||
buf[8] = disk_blocks >> 24;
|
||||
buf[9] = disk_blocks >> 16;
|
||||
buf[10] = disk_blocks >> 8;
|
||||
buf[11] = disk_blocks;
|
||||
|
||||
buf[9] = disk_size >> 16;
|
||||
buf[10] = disk_size >> 8;
|
||||
buf[11] = disk_size;
|
||||
buf[13] = disk_size >> 16;
|
||||
buf[14] = disk_size >> 8;
|
||||
buf[15] = disk_size;
|
||||
|
||||
size = 12;
|
||||
size = 16;
|
||||
}
|
||||
else {
|
||||
// Mode parameter header, LONGLBA
|
||||
@ -862,21 +869,21 @@ int Disk::ModeSense10(const DWORD *cdb, BYTE *buf)
|
||||
|
||||
// Long LBA mode parameter block descriptor (number of blocks and block length)
|
||||
|
||||
buf[4] = disk_blocks >> 56;
|
||||
buf[5] = disk_blocks >> 48;
|
||||
buf[6] = disk_blocks >> 40;
|
||||
buf[7] = disk_blocks >> 32;
|
||||
buf[8] = disk_blocks >> 24;
|
||||
buf[9] = disk_blocks >> 16;
|
||||
buf[10] = disk_blocks >> 8;
|
||||
buf[11] = disk_blocks;
|
||||
buf[8] = disk_blocks >> 56;
|
||||
buf[9] = disk_blocks >> 48;
|
||||
buf[10] = disk_blocks >> 40;
|
||||
buf[11] = disk_blocks >> 32;
|
||||
buf[12] = disk_blocks >> 24;
|
||||
buf[13] = disk_blocks >> 16;
|
||||
buf[14] = disk_blocks >> 8;
|
||||
buf[15] = disk_blocks;
|
||||
|
||||
buf[16] = disk_size >> 24;
|
||||
buf[17] = disk_size >> 16;
|
||||
buf[18] = disk_size >> 8;
|
||||
buf[19] = disk_size;
|
||||
buf[20] = disk_size >> 24;
|
||||
buf[21] = disk_size >> 16;
|
||||
buf[22] = disk_size >> 8;
|
||||
buf[23] = disk_size;
|
||||
|
||||
size = 20;
|
||||
size = 24;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -945,6 +952,13 @@ int Disk::ModeSense10(const DWORD *cdb, BYTE *buf)
|
||||
SetStatusCode(STATUS_INVALIDCDB);
|
||||
return 0;
|
||||
}
|
||||
//check if size of data is more than size requested.
|
||||
if (size > length) {
|
||||
SetStatusCode(STATUS_INVALIDCDB);
|
||||
return 0;
|
||||
}
|
||||
//Set length returned to actual size of data
|
||||
length = size;
|
||||
|
||||
return length;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user