Handle getSize errors in BlockFileIO::write

getSize can return -1 if the file was deleted.
Just return an error to the user instead of
crashing in a segmentation fault.
This commit is contained in:
Jakob Unterwurzacher 2015-11-08 21:10:27 +01:00
parent deba6064ac
commit ed058fabcd
2 changed files with 5 additions and 1 deletions

View File

@ -178,6 +178,8 @@ bool BlockFileIO::write(const IORequest &req) {
rAssert(_blockSize != 0);
off_t fileSize = getSize();
if (fileSize < 0)
return false;
// where write request begins
off_t blockNum = req.offset / _blockSize;

View File

@ -178,8 +178,10 @@ off_t RawFileIO::getSize() const {
const_cast<RawFileIO *>(this)->fileSize = stbuf.st_size;
const_cast<RawFileIO *>(this)->knownSize = true;
return fileSize;
} else
} else {
rError("getSize on %s failed: %s", name.c_str(), strerror(errno));
return -1;
}
} else {
return fileSize;
}