scsicdrom, scsihd: Check lun.

READ_CAPACITY_10, READ_6, and READ_10 now checks LUN that is included in CDB and returns a CHECK_CONDITION if it doesn't match.
This commit is contained in:
joevt 2024-03-10 03:37:37 -07:00 committed by dingusdev
parent 6bb5227ee1
commit c999c51d77
2 changed files with 12 additions and 0 deletions

View File

@ -178,6 +178,9 @@ bool ScsiCdrom::get_more_data() {
void ScsiCdrom::read(uint32_t lba, uint16_t nblocks, uint8_t cmd_len)
{
if (!check_lun())
return;
if (cmd_len == 6 && nblocks == 0)
nblocks = 256;
@ -381,6 +384,9 @@ void ScsiCdrom::read_capacity_10()
return;
}
if (!check_lun())
return;
int last_lba = (int)this->size_blocks - 1;
WRITE_DWORD_BE_A(&this->data_buf[0], last_lba);

View File

@ -323,6 +323,9 @@ void ScsiHardDisk::read_capacity_10() {
return;
}
if (!check_lun())
return;
uint32_t last_lba = this->total_blocks - 1;
uint32_t blk_len = this->sector_size;
@ -346,6 +349,9 @@ void ScsiHardDisk::format() {
}
void ScsiHardDisk::read(uint32_t lba, uint16_t transfer_len, uint8_t cmd_len) {
if (!check_lun())
return;
uint32_t transfer_size = transfer_len;
std::memset(this->data_buf, 0, sizeof(this->data_buf));