bonefish + mmlr + axeld:

* Fixed a bug that could easily corrupt your disks (yeah, one of those
  again): bfs_get_file_map() truncated the last vec incorrectly and
  would potentially return a too large file size -- which was later
  happily overwritten with file data, but could have belonged to
  anything but that file (like inodes, B+trees, etc.).
* Renamed previous round_up() function to key_align().
* Added round_up() template function, and used it where appropriate.
* The latter actually fixed two bugs where the and mask was computed in
  32 bit where it should have been in 64 bit.
* Inode::FindBlockRun() should have checked the max indirect size
  instead of the direct size - this didn't cause any problems, though.
* White space cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26531 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-07-20 23:59:32 +00:00
parent a0a18e64f0
commit 9083840f34
6 changed files with 37 additions and 30 deletions
@@ -1036,7 +1036,7 @@ BPlusTree::_SplitNode(bplustree_node *node, off_t nodeOffset,
}
out++;
if (round_up(sizeof(bplustree_node) + bytesBefore + bytesAfter + bytes)
if (key_align(sizeof(bplustree_node) + bytesBefore + bytesAfter + bytes)
+ out * (sizeof(uint16) + sizeof(off_t)) >= size) {
// we have found the number of keys in the new node!
break;
@@ -1303,7 +1303,7 @@ BPlusTree::Insert(Transaction &transaction, const uint8 *key, uint16 keyLength,
return B_IO_ERROR;
// is the node big enough to hold the pair?
if (int32(round_up(sizeof(bplustree_node)
if (int32(key_align(sizeof(bplustree_node)
+ writableNode->AllKeyLength() + keyLength)
+ (writableNode->NumKeys() + 1) * (sizeof(uint16)
+ sizeof(off_t))) < fNodeSize) {