Added support for reporting invalid B+trees.

* Fixed the inode progress not being overwritten by the final stats.
* Minor cleanup.
This commit is contained in:
Axel Dörfler 2012-03-07 01:53:18 +01:00
parent 49a2067a17
commit 08601a8488
2 changed files with 18 additions and 16 deletions

View File

@ -1,6 +1,6 @@
/* /*
* Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2008-2010, Axel Dörfler, axeld@pinc-software.de. * Copyright 2008-2012, Axel Dörfler, axeld@pinc-software.de.
* *
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@ -233,11 +233,11 @@ BFSPartitionHandle::Repair(bool checkOnly)
struct check_control result; struct check_control result;
memset(&result, 0, sizeof(result)); memset(&result, 0, sizeof(result));
result.magic = BFS_IOCTL_CHECK_MAGIC; result.magic = BFS_IOCTL_CHECK_MAGIC;
result.flags = !checkOnly ? BFS_FIX_BITMAP_ERRORS : 0; result.flags = 0;
if (!checkOnly) { if (!checkOnly) {
//printf("will fix any severe errors!\n"); //printf("will fix any severe errors!\n");
result.flags |= BFS_REMOVE_WRONG_TYPES | BFS_REMOVE_INVALID result.flags |= BFS_FIX_BITMAP_ERRORS | BFS_REMOVE_WRONG_TYPES
| BFS_FIX_NAME_MISMATCHES; | BFS_REMOVE_INVALID | BFS_FIX_NAME_MISMATCHES | BFS_FIX_BPLUSTREES;
} }
// start checking // start checking
@ -256,18 +256,20 @@ BFSPartitionHandle::Repair(bool checkOnly)
if (result.errors) { if (result.errors) {
printf("%s (inode = %lld)", result.name, result.inode); printf("%s (inode = %lld)", result.name, result.inode);
if (result.errors & BFS_MISSING_BLOCKS) if ((result.errors & BFS_MISSING_BLOCKS) != 0)
printf(", some blocks weren't allocated"); printf(", some blocks weren't allocated");
if (result.errors & BFS_BLOCKS_ALREADY_SET) if ((result.errors & BFS_BLOCKS_ALREADY_SET) != 0)
printf(", has blocks already set"); printf(", has blocks already set");
if (result.errors & BFS_INVALID_BLOCK_RUN) if ((result.errors & BFS_INVALID_BLOCK_RUN) != 0)
printf(", has invalid block run(s)"); printf(", has invalid block run(s)");
if (result.errors & BFS_COULD_NOT_OPEN) if ((result.errors & BFS_COULD_NOT_OPEN) != 0)
printf(", could not be opened"); printf(", could not be opened");
if (result.errors & BFS_WRONG_TYPE) if ((result.errors & BFS_WRONG_TYPE) != 0)
printf(", has wrong type"); printf(", has wrong type");
if (result.errors & BFS_NAMES_DONT_MATCH) if ((result.errors & BFS_NAMES_DONT_MATCH) != 0)
printf(", names don't match"); printf(", names don't match");
if ((result.errors & BFS_INVALID_BPLUSTREE) != 0)
printf(", invalid b+tree");
putchar('\n'); putchar('\n');
} }
if ((result.mode & (S_INDEX_DIR | 0777)) == S_INDEX_DIR) if ((result.mode & (S_INDEX_DIR | 0777)) == S_INDEX_DIR)
@ -290,7 +292,7 @@ BFSPartitionHandle::Repair(bool checkOnly)
close(fd); close(fd);
printf("\t%" B_PRIu64 " nodes checked,\n\t%" B_PRIu64 " blocks not " printf(" %" B_PRIu64 " nodes checked,\n\t%" B_PRIu64 " blocks not "
"allocated,\n\t%" B_PRIu64 " blocks already set,\n\t%" B_PRIu64 "allocated,\n\t%" B_PRIu64 " blocks already set,\n\t%" B_PRIu64
" blocks could be freed\n\n", counter, result.stats.missing, " blocks could be freed\n\n", counter, result.stats.missing,
result.stats.already_set, result.stats.freed); result.stats.already_set, result.stats.freed);

View File

@ -37,7 +37,7 @@ command_checkfs(int argc, const char* const* argv)
result.flags = 0; result.flags = 0;
if (!checkOnly) { if (!checkOnly) {
result.flags |= BFS_FIX_BITMAP_ERRORS | BFS_REMOVE_WRONG_TYPES result.flags |= BFS_FIX_BITMAP_ERRORS | BFS_REMOVE_WRONG_TYPES
| BFS_REMOVE_INVALID | BFS_FIX_NAME_MISMATCHES /*| BFS_FIX_BPLUSTREES*/; | BFS_REMOVE_INVALID | BFS_FIX_NAME_MISMATCHES | BFS_FIX_BPLUSTREES;
} }
// start checking // start checking
@ -70,8 +70,8 @@ command_checkfs(int argc, const char* const* argv)
fssh_dprintf(", has wrong type"); fssh_dprintf(", has wrong type");
if ((result.errors & BFS_NAMES_DONT_MATCH) != 0) if ((result.errors & BFS_NAMES_DONT_MATCH) != 0)
fssh_dprintf(", names don't match"); fssh_dprintf(", names don't match");
// if ((result.errors & BFS_INVALID_BPLUSTREE) != 0) if ((result.errors & BFS_INVALID_BPLUSTREE) != 0)
// fssh_dprintf(", invalid b+tree"); fssh_dprintf(", invalid b+tree");
fssh_dprintf("\n"); fssh_dprintf("\n");
} }
if ((result.mode & (S_INDEX_DIR | 0777)) == S_INDEX_DIR) if ((result.mode & (S_INDEX_DIR | 0777)) == S_INDEX_DIR)
@ -95,8 +95,8 @@ command_checkfs(int argc, const char* const* argv)
_kern_close(rootDir); _kern_close(rootDir);
fssh_dprintf("\t%" B_PRIu64 " nodes checked,\n\t%" B_PRIu64 " blocks not " fssh_dprintf(" %" B_PRIu64 " nodes checked,\n\t%" B_PRIu64 " blocks "
"allocated,\n\t%" B_PRIu64 " blocks already set,\n\t%" B_PRIu64 "not allocated,\n\t%" B_PRIu64 " blocks already set,\n\t%" B_PRIu64
" blocks could be freed\n\n", counter, result.stats.missing, " blocks could be freed\n\n", counter, result.stats.missing,
result.stats.already_set, result.stats.freed); result.stats.already_set, result.stats.freed);
fssh_dprintf("\tfiles\t\t%" B_PRIu64 "\n\tdirectories\t%" B_PRIu64 "\n" fssh_dprintf("\tfiles\t\t%" B_PRIu64 "\n\tdirectories\t%" B_PRIu64 "\n"