Make readOneBlock return -EBADMSG when decode fails

instead of throwing an exception, as with writeOneBlock
This commit is contained in:
benrubson 2017-03-16 15:48:19 +01:00
parent 63d11e6989
commit 36f3505af0
3 changed files with 6 additions and 2 deletions

View File

@ -147,6 +147,10 @@ ssize_t BlockFileIO::read(const IORequest &req) const {
}
ssize_t readSize = cacheReadOneBlock(blockReq);
if (readSize < 0) {
result = readSize;
break;
}
if (readSize <= partialOffset) break; // didn't get enough bytes
int cpySize = min((size_t)(readSize - partialOffset), size);

View File

@ -337,7 +337,7 @@ ssize_t CipherFileIO::readOneBlock(const IORequest &req) const {
if (!ok) {
VLOG(1) << "decodeBlock failed for block " << blockNum << ", size "
<< readSize;
readSize = -1;
readSize = -EBADMSG;
}
} else {
VLOG(1) << "readSize zero for offset " << req.offset;

View File

@ -190,7 +190,7 @@ ssize_t MACFileIO::readOneBlock(const IORequest &req) const {
RLOG(WARNING) << "MAC comparison failure in block " << blockNum;
if (!warnOnly) {
MemoryPool::release(mb);
throw Error(_("MAC comparison failure, refusing to read"));
return -EBADMSG;
}
}
}