From 08601a84881b975db1feef1047eab8bc63b08168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 7 Mar 2012 01:53:18 +0100 Subject: [PATCH] Added support for reporting invalid B+trees. * Fixed the inode progress not being overwritten by the final stats. * Minor cleanup. --- src/add-ons/disk_systems/bfs/BFSAddOn.cpp | 24 ++++++++++++----------- src/tools/bfs_shell/command_checkfs.cpp | 10 +++++----- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/add-ons/disk_systems/bfs/BFSAddOn.cpp b/src/add-ons/disk_systems/bfs/BFSAddOn.cpp index 898da64d92..6dab456c8c 100644 --- a/src/add-ons/disk_systems/bfs/BFSAddOn.cpp +++ b/src/add-ons/disk_systems/bfs/BFSAddOn.cpp @@ -1,6 +1,6 @@ /* * 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. */ @@ -233,11 +233,11 @@ BFSPartitionHandle::Repair(bool checkOnly) struct check_control result; memset(&result, 0, sizeof(result)); result.magic = BFS_IOCTL_CHECK_MAGIC; - result.flags = !checkOnly ? BFS_FIX_BITMAP_ERRORS : 0; + result.flags = 0; if (!checkOnly) { //printf("will fix any severe errors!\n"); - result.flags |= BFS_REMOVE_WRONG_TYPES | BFS_REMOVE_INVALID - | BFS_FIX_NAME_MISMATCHES; + result.flags |= BFS_FIX_BITMAP_ERRORS | BFS_REMOVE_WRONG_TYPES + | BFS_REMOVE_INVALID | BFS_FIX_NAME_MISMATCHES | BFS_FIX_BPLUSTREES; } // start checking @@ -256,18 +256,20 @@ BFSPartitionHandle::Repair(bool checkOnly) if (result.errors) { 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"); - if (result.errors & BFS_BLOCKS_ALREADY_SET) + if ((result.errors & BFS_BLOCKS_ALREADY_SET) != 0) 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)"); - if (result.errors & BFS_COULD_NOT_OPEN) + if ((result.errors & BFS_COULD_NOT_OPEN) != 0) printf(", could not be opened"); - if (result.errors & BFS_WRONG_TYPE) + if ((result.errors & BFS_WRONG_TYPE) != 0) printf(", has wrong type"); - if (result.errors & BFS_NAMES_DONT_MATCH) + if ((result.errors & BFS_NAMES_DONT_MATCH) != 0) printf(", names don't match"); + if ((result.errors & BFS_INVALID_BPLUSTREE) != 0) + printf(", invalid b+tree"); putchar('\n'); } if ((result.mode & (S_INDEX_DIR | 0777)) == S_INDEX_DIR) @@ -290,7 +292,7 @@ BFSPartitionHandle::Repair(bool checkOnly) 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 " blocks could be freed\n\n", counter, result.stats.missing, result.stats.already_set, result.stats.freed); diff --git a/src/tools/bfs_shell/command_checkfs.cpp b/src/tools/bfs_shell/command_checkfs.cpp index 8922d8b7da..a987f42c0e 100644 --- a/src/tools/bfs_shell/command_checkfs.cpp +++ b/src/tools/bfs_shell/command_checkfs.cpp @@ -37,7 +37,7 @@ command_checkfs(int argc, const char* const* argv) result.flags = 0; if (!checkOnly) { 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 @@ -70,8 +70,8 @@ command_checkfs(int argc, const char* const* argv) fssh_dprintf(", has wrong type"); if ((result.errors & BFS_NAMES_DONT_MATCH) != 0) fssh_dprintf(", names don't match"); -// if ((result.errors & BFS_INVALID_BPLUSTREE) != 0) -// fssh_dprintf(", invalid b+tree"); + if ((result.errors & BFS_INVALID_BPLUSTREE) != 0) + fssh_dprintf(", invalid b+tree"); fssh_dprintf("\n"); } 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); - fssh_dprintf("\t%" B_PRIu64 " nodes checked,\n\t%" B_PRIu64 " blocks not " - "allocated,\n\t%" B_PRIu64 " blocks already set,\n\t%" B_PRIu64 + fssh_dprintf(" %" B_PRIu64 " nodes checked,\n\t%" B_PRIu64 " blocks " + "not allocated,\n\t%" B_PRIu64 " blocks already set,\n\t%" B_PRIu64 " blocks could be freed\n\n", counter, result.stats.missing, result.stats.already_set, result.stats.freed); fssh_dprintf("\tfiles\t\t%" B_PRIu64 "\n\tdirectories\t%" B_PRIu64 "\n"