--- nono/host/diskimage.cpp 2026/04/29 17:05:00 1.1.1.2 +++ nono/host/diskimage.cpp 2026/04/29 17:05:43 1.1.1.7 @@ -38,21 +38,18 @@ DiskImage::CreateHandler(const std::stri // 今の所 Raw しかない try { driver.reset(new DiskImageRaw(pathname)); - return true; - } catch (...) { - } - - return false; + } catch (...) { } + return (bool)driver; } -// このディスクイメージのサイズと書き込み可能かどうかを返す。 +// このディスクイメージが書き込み可能かどうかを返す。 // Open() 前でも動作する。 -bool -DiskImage::GetInfo(off_t *sizep, bool *w_ok) +int +DiskImage::IsWriteable() const { assert((bool)driver); - return driver->GetInfo(sizep, w_ok); + return driver->IsWriteable(); } // オープン @@ -91,7 +88,7 @@ DiskImage::Open(bool read_only, bool cow assert(cowname.empty() == false); cowname = gMainApp.GetVMDir() + "/." + cowname + ".cow"; - cowfd = open(cowname.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0644); + cowfd = open(cowname.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0600); if (cowfd < 0) { return false; } @@ -132,7 +129,7 @@ DiskImage::Read(void *buf, off_t offset, { assert((bool)driver); - if (__predict_false(offset + size >= GetSize())) { + if (__predict_false(offset + size > GetSize())) { return false; } @@ -178,7 +175,7 @@ DiskImage::Write(const void *buf, off_t { assert((bool)driver); - if (__predict_false(offset + size >= GetSize())) { + if (__predict_false(offset + size > GetSize())) { return false; }