"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "encfs/BlockFileIO.cpp" between
encfs-1.9.4.tar.gz and encfs-1.9.5.tar.gz

About: EncFS is an encrypted virtual filesystem for Linux using the FUSE kernel module.

BlockFileIO.cpp  (encfs-1.9.4):BlockFileIO.cpp  (encfs-1.9.5)
skipping to change at line 101 skipping to change at line 101
_cache.dataLen = result; // the amount we really have _cache.dataLen = result; // the amount we really have
if ((size_t)result > req.dataLen) { if ((size_t)result > req.dataLen) {
result = req.dataLen; // only as much as requested result = req.dataLen; // only as much as requested
} }
memcpy(req.data, _cache.data, result); memcpy(req.data, _cache.data, result);
} }
return result; return result;
} }
ssize_t BlockFileIO::cacheWriteOneBlock(const IORequest &req) { ssize_t BlockFileIO::cacheWriteOneBlock(const IORequest &req) {
// cache results of write (before pass-thru, because it may be modified // Let's point request buffer to our own buffer, as it may be modified by
// in-place) // encryption : originating process may not like to have its buffer modified
memcpy(_cache.data, req.data, req.dataLen); memcpy(_cache.data, req.data, req.dataLen);
_cache.offset = req.offset; IORequest tmp;
_cache.dataLen = req.dataLen; tmp.offset = req.offset;
ssize_t res = writeOneBlock(req); tmp.data = _cache.data;
tmp.dataLen = req.dataLen;
ssize_t res = writeOneBlock(tmp);
if (res < 0) { if (res < 0) {
clearCache(_cache, _blockSize); clearCache(_cache, _blockSize);
} }
else {
// And now we can cache the write buffer from the request
memcpy(_cache.data, req.data, req.dataLen);
_cache.offset = req.offset;
_cache.dataLen = req.dataLen;
}
return res; return res;
} }
/** /**
* Serve a read request of arbitrary size at an arbitrary offset. * Serve a read request of arbitrary size at an arbitrary offset.
* Stitches together multiple blocks to serve large requests, drops * Stitches together multiple blocks to serve large requests, drops
* data from the front of the first block if the request is not aligned. * data from the front of the first block if the request is not aligned.
* Always requests aligned data of the size of one block or less from the * Always requests aligned data of the size of one block or less from the
* lower layer. * lower layer.
* Returns the number of bytes read, or -errno in case of failure. * Returns the number of bytes read, or -errno in case of failure.
skipping to change at line 181 skipping to change at line 189
if (blockReq.data != out) { if (blockReq.data != out) {
memcpy(out, blockReq.data + partialOffset, cpySize); memcpy(out, blockReq.data + partialOffset, cpySize);
} }
result += cpySize; result += cpySize;
size -= cpySize; size -= cpySize;
out += cpySize; out += cpySize;
++blockNum; ++blockNum;
partialOffset = 0; partialOffset = 0;
if (readSize < _blockSize) { if ((size_t)readSize < _blockSize) {
break; break;
} }
} }
if (mb.data != nullptr) { if (mb.data != nullptr) {
MemoryPool::release(mb); MemoryPool::release(mb);
} }
return result; return result;
} }
 End of changes. 4 change blocks. 
6 lines changed or deleted 14 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)