more block checking

git-svn-id: https://profuse.googlecode.com/svn/branches/v2@259 aa027e90-d47c-11dd-86d7-074df07e0730
This commit is contained in:
ksherlock 2010-05-22 16:11:41 +00:00
parent 4a98605123
commit ef4f906d70
2 changed files with 17 additions and 4 deletions

View File

@ -64,6 +64,12 @@ void MappedBlockCache::release(unsigned block, int flags)
void MappedBlockCache::write(unsigned block, const void *vp) void MappedBlockCache::write(unsigned block, const void *vp)
{ {
#undef __METHOD__
#define __METHOD__ "MappedBlockCache::write"
if (block >= blocks())
throw Exception(__METHOD__ ": Invalid block.");
_dirty = true; _dirty = true;
std::memcpy(_data + block * 512, vp, 512); std::memcpy(_data + block * 512, vp, 512);
} }
@ -71,6 +77,13 @@ void MappedBlockCache::write(unsigned block, const void *vp)
void MappedBlockCache::zeroBlock(unsigned block) void MappedBlockCache::zeroBlock(unsigned block)
{ {
#undef __METHOD__
#define __METHOD__ "MappedBlockCache::zeroBlock"
if (block >= blocks())
throw Exception(__METHOD__ ": Invalid block.");
_dirty = true; _dirty = true;
std::memset(_data + block * 512, 0, 512); std::memset(_data + block * 512, 0, 512);
} }

View File

@ -22,11 +22,11 @@ class MappedBlockCache : public BlockCache {
virtual void markDirty(unsigned block); virtual void markDirty(unsigned block);
private: private:
void sync(unsigned block); void sync(unsigned block);
uint8_t *_data; uint8_t *_data;
bool _dirty; bool _dirty;
}; };
} // namespace } // namespace