atahd: Make sure disk is not too big.

This commit is contained in:
joevt 2024-01-01 04:41:23 -08:00 committed by dingusdev
parent eaddcab0ba
commit 96dc02b249

View File

@ -63,11 +63,15 @@ int AtaHardDisk::device_postinit() {
void AtaHardDisk::insert_image(std::string filename) {
if (!this->hdd_img.open(filename)) {
ABORT_F("%s: could not open image file", this->name.c_str());
ABORT_F("%s: could not open image file \"%s\"", this->name.c_str(), filename.c_str());
}
this->img_size = this->hdd_img.size();
this->total_sectors = this->hdd_img.size() / ATA_HD_SEC_SIZE;
uint64_t sectors = this->hdd_img.size() / ATA_HD_SEC_SIZE;
this->total_sectors = (uint32_t)sectors;
if (sectors != this->total_sectors) {
ABORT_F("%s: image file \"%s\" is too big", this->name.c_str(), filename.c_str());
}
this->calc_chs_params();
}