--- nono/host/diskimage_raw.cpp 2026/04/29 17:05:00 1.1.1.2 +++ nono/host/diskimage_raw.cpp 2026/04/29 17:05:22 1.1.1.4 @@ -30,6 +30,21 @@ DiskImageRaw::~DiskImageRaw() bool DiskImageRaw::GetInfo(off_t *sizep, bool *w_ok) { + // ファイルのパーミッション + int r = access(pathname.c_str(), W_OK); + if (r == 0) { + *w_ok = true; + } else if (errno == EACCES) { + *w_ok = false; + } else { + if (errno == ENOENT) { + warn("%s", pathname.c_str()); + } else { + warn("%s: access failed", pathname.c_str()); + } + return false; + } + // ファイルサイズは未取得なら取得 if (filesize == (off_t)-1) { struct stat st; @@ -42,17 +57,6 @@ DiskImageRaw::GetInfo(off_t *sizep, bool } *sizep = filesize; - // ファイルのパーミッション - int r = access(pathname.c_str(), W_OK); - if (r == 0) { - *w_ok = true; - } else if (errno == EACCES) { - *w_ok = false; - } else { - warn("%s: access failed", pathname.c_str()); - return false; - } - return true; } @@ -110,7 +114,7 @@ DiskImageRaw::Read(void *buf, off_t offs if (__predict_false(fd < 0)) { return false; } - if (__predict_false(offset + size >= GetSize())) { + if (__predict_false(offset + size > GetSize())) { return false; } @@ -130,7 +134,7 @@ DiskImageRaw::Write(const void *buf, off if (__predict_false(fd < 0)) { return false; } - if (__predict_false(offset + size >= GetSize())) { + if (__predict_false(offset + size > GetSize())) { return false; }