diff --git a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp index 360472818f..540cfae2b3 100644 --- a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp +++ b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2010, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2001-2012, Axel Dörfler, axeld@pinc-software.de. * This file may be used under the terms of the MIT License. */ @@ -1420,8 +1420,7 @@ BlockAllocator::CheckNextNode(check_control* control) return B_OK; } - // get iterator for the next directory - + // Check directory BPlusTree* tree = inode->Tree(); if (tree == NULL) { FATAL(("check: could not open b+tree from inode at %" B_PRIdOFF @@ -1432,6 +1431,7 @@ BlockAllocator::CheckNextNode(check_control* control) fCheckCookie->parent = inode; fCheckCookie->parent_mode = inode->Mode(); + // get iterator for the next directory fCheckCookie->iterator = new(std::nothrow) TreeIterator(tree); if (fCheckCookie->iterator == NULL) RETURN_ERROR(B_NO_MEMORY); @@ -1917,6 +1917,18 @@ BlockAllocator::CheckInode(Inode* inode) } } + if (inode->IsContainer()) { + bool errorsFound = false; + status_t status = inode->Tree()->Validate( + (fCheckCookie->control.flags & BFS_FIX_BPLUSTREES) != 0, + errorsFound); + if (errorsFound) + fCheckCookie->control.errors |= BFS_INVALID_BPLUSTREE; + + if (status != B_OK) + return status; + } + return B_OK; } diff --git a/src/add-ons/kernel/file_systems/bfs/bfs_control.h b/src/add-ons/kernel/file_systems/bfs/bfs_control.h index f71b85e90f..2054456a01 100644 --- a/src/add-ons/kernel/file_systems/bfs/bfs_control.h +++ b/src/add-ons/kernel/file_systems/bfs/bfs_control.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2010, Axel Dörfler, axeld@pinc-software.de + * Copyright 2001-2012, Axel Dörfler, axeld@pinc-software.de * This file may be used under the terms of the MIT License. */ #ifndef BFS_CONTROL_H @@ -78,6 +78,7 @@ struct check_control { * Also requires the B_FIX_BITMAP_ERRORS to be set. */ #define BFS_FIX_NAME_MISMATCHES 8 +#define BFS_FIX_BPLUSTREES 16 /* values for the errors field */ #define BFS_MISSING_BLOCKS 1 @@ -86,6 +87,7 @@ struct check_control { #define BFS_COULD_NOT_OPEN 8 #define BFS_WRONG_TYPE 16 #define BFS_NAMES_DONT_MATCH 32 +#define BFS_INVALID_BPLUSTREE 64 /* check control magic value */ #define BFS_IOCTL_CHECK_MAGIC 'BChk'