--- nono/vm/scsidev.cpp 2026/04/29 17:04:59 1.1.1.11 +++ nono/vm/scsidev.cpp 2026/04/29 17:05:03 1.1.1.12 @@ -619,7 +619,7 @@ SCSIDisk::SCSIDisk(SCSIHostDevice *h, in // lib/object.h 参照。 SetName(string_format("SCSI%s%d", devtypename, id)); ClearAlias(); - AddAlias(GetName()); + AddAlias(string_format("SCSI%d", id)); AddAlias(string_format("%s%d", devtypename, id)); switch (devtype) { @@ -770,13 +770,11 @@ SCSIDisk::LoadDisk(const std::string& pa // 新しいイメージをオープン(する準備) pathname = pathname_; - try { - image.reset(DiskImage::Create(pathname)); - } catch (...) { + if (image.CreateHandler(pathname) == false) { goto done; } - if (image->GetInfo(&size, &w_ok) < 0) { + if (image.GetInfo(&size, &w_ok) == false) { goto done; } @@ -847,7 +845,7 @@ SCSIDisk::LoadDisk(const std::string& pa // ここでオープン read_only = (GetWriteMode() != RW::Writeable); - if (image->Open(read_only) == false) { + if (image.Open(read_only, write_ignore) == false) { goto done; } @@ -916,7 +914,7 @@ void SCSIDisk::Clear() { medium_loaded = false; - image.reset(); + image.Close(); pathname.clear(); write_mode = RW::Writeable; } @@ -1127,7 +1125,7 @@ SCSIDisk::Read(std::vector& buf, if (__predict_false((bool)image == false)) { return false; } - return image->Read(buf.data(), start, buf.size()); + return image.Read(buf.data(), start, buf.size()); } bool @@ -1137,15 +1135,11 @@ SCSIDisk::Write(const std::vector return false; } - if (GetWriteMode() == RW::Writeable) { - return image->Write(buf.data(), start, buf.size()); - } else if (GetWriteMode() == RW::WriteIgnore) { - // 書き込み無視 - return true; - } else { + if (GetWriteMode() >= RW::WriteProtect) { // 書き込み不可 return false; } + return image.Write(buf.data(), start, buf.size()); } off_t @@ -1154,7 +1148,7 @@ SCSIDisk::GetSize() const if (__predict_false((bool)image == false)) { return 0; } - return image->GetSize(); + return image.GetSize(); } // 指定の場所を自由に読み出す @@ -1165,11 +1159,7 @@ SCSIDisk::Peek(void *buf, uint64 start, if (__predict_false((bool)image == false)) { return false; } - - if (start + len > GetSize()) { - return false; - } - return image->Read(buf, start, len); + return image.Read(buf, start, len); } // メディアの取り出し可否(取り出し禁止)を設定する