* The "bfs" KDL command can now also convert block offsets to block_runs and
vice versa. * Some cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25248 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -226,19 +226,23 @@ dump_bplustree_node(const bplustree_node *node, const bplustree_header *header,
|
|||||||
buffer[length] = '\0';
|
buffer[length] = '\0';
|
||||||
|
|
||||||
off_t* value = node->Values() + i;
|
off_t* value = node->Values() + i;
|
||||||
if ((addr_t)value < (addr_t)node || (addr_t)value > (addr_t)node + header->node_size)
|
if ((addr_t)value < (addr_t)node
|
||||||
|
|| (addr_t)value > (addr_t)node + header->node_size)
|
||||||
Print(" %2d. Invalid Offset!!\n", (int)i);
|
Print(" %2d. Invalid Offset!!\n", (int)i);
|
||||||
else {
|
else {
|
||||||
Print(" %2d. ", (int)i);
|
Print(" %2d. ", (int)i);
|
||||||
if (header->data_type == BPLUSTREE_STRING_TYPE)
|
if (header->data_type == BPLUSTREE_STRING_TYPE)
|
||||||
Print("\"%s\"", buffer);
|
Print("\"%s\"", buffer);
|
||||||
else if (header->data_type == BPLUSTREE_INT32_TYPE)
|
else if (header->data_type == BPLUSTREE_INT32_TYPE) {
|
||||||
Print("int32 = %d (0x%x)", (int)*(int32 *)&buffer, (int)*(int32 *)&buffer);
|
Print("int32 = %d (0x%x)", (int)*(int32 *)&buffer,
|
||||||
else if (header->data_type == BPLUSTREE_UINT32_TYPE)
|
(int)*(int32 *)&buffer);
|
||||||
Print("uint32 = %u (0x%x)", (unsigned)*(uint32 *)&buffer, (unsigned)*(uint32 *)&buffer);
|
} else if (header->data_type == BPLUSTREE_UINT32_TYPE) {
|
||||||
else if (header->data_type == BPLUSTREE_INT64_TYPE)
|
Print("uint32 = %u (0x%x)", (unsigned)*(uint32 *)&buffer,
|
||||||
Print("int64 = %Ld (0x%Lx)", *(int64 *)&buffer, *(int64 *)&buffer);
|
(unsigned)*(uint32 *)&buffer);
|
||||||
else
|
} else if (header->data_type == BPLUSTREE_INT64_TYPE) {
|
||||||
|
Print("int64 = %Ld (0x%Lx)", *(int64 *)&buffer,
|
||||||
|
*(int64 *)&buffer);
|
||||||
|
} else
|
||||||
Print("???");
|
Print("???");
|
||||||
|
|
||||||
off_t offset = *value & 0x3fffffffffffffffLL;
|
off_t offset = *value & 0x3fffffffffffffffLL;
|
||||||
@@ -247,9 +251,11 @@ dump_bplustree_node(const bplustree_node *node, const bplustree_header *header,
|
|||||||
block_run run = volume->ToBlockRun(offset);
|
block_run run = volume->ToBlockRun(offset);
|
||||||
Print(" (%d, %d)", (int)run.allocation_group, run.start);
|
Print(" (%d, %d)", (int)run.allocation_group, run.start);
|
||||||
}
|
}
|
||||||
if (bplustree_node::LinkType(*value) == BPLUSTREE_DUPLICATE_FRAGMENT)
|
if (bplustree_node::LinkType(*value)
|
||||||
|
== BPLUSTREE_DUPLICATE_FRAGMENT)
|
||||||
Print(" (duplicate fragment %Ld)\n", *value & 0x3ff);
|
Print(" (duplicate fragment %Ld)\n", *value & 0x3ff);
|
||||||
else if (bplustree_node::LinkType(*value) == BPLUSTREE_DUPLICATE_NODE)
|
else if (bplustree_node::LinkType(*value)
|
||||||
|
== BPLUSTREE_DUPLICATE_NODE)
|
||||||
Print(" (duplicate node)\n");
|
Print(" (duplicate node)\n");
|
||||||
else
|
else
|
||||||
Print("\n");
|
Print("\n");
|
||||||
@@ -272,7 +278,9 @@ dump_inode(int argc, char **argv)
|
|||||||
block = true;
|
block = true;
|
||||||
|
|
||||||
if (argc != 2 + (block ? 1 : 0) || !strcmp(argv[1], "--help")) {
|
if (argc != 2 + (block ? 1 : 0) || !strcmp(argv[1], "--help")) {
|
||||||
kprintf("usage: bfsinode [-b] <ptr-to-inode>\n");
|
kprintf("usage: bfsinode [-b] <ptr-to-inode>\n"
|
||||||
|
" -b the address is regarded as pointer to a block instead of one "
|
||||||
|
"to an inode.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,13 +299,41 @@ dump_inode(int argc, char **argv)
|
|||||||
static int
|
static int
|
||||||
dump_volume(int argc, char** argv)
|
dump_volume(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (argc != 2 || !strcmp(argv[1], "--help")) {
|
if (argc < 2 || !strcmp(argv[1], "--help")) {
|
||||||
kprintf("usage: bfs <ptr-to-volume>\n");
|
kprintf("usage: bfs <ptr-to-volume> [<block-run>]\n"
|
||||||
|
"Dumps a BFS volume - <block-run> is given, it is converted to a "
|
||||||
|
"block offset instead (and vice versa).\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Volume* volume = (Volume*)parse_expression(argv[1]);
|
Volume* volume = (Volume*)parse_expression(argv[1]);
|
||||||
|
|
||||||
|
if (argc > 2) {
|
||||||
|
// convert block_runs/offsets
|
||||||
|
for (int i = 2; i < argc; i++) {
|
||||||
|
char* arg = argv[i];
|
||||||
|
if (strchr(arg, '.') != NULL) {
|
||||||
|
// block_run to offset
|
||||||
|
block_run run;
|
||||||
|
run.allocation_group = HOST_ENDIAN_TO_BFS_INT32(
|
||||||
|
strtoul(arg, &arg, 0));
|
||||||
|
run.start = HOST_ENDIAN_TO_BFS_INT16(strtoul(arg, NULL, 0));
|
||||||
|
run.length = 0;
|
||||||
|
|
||||||
|
kprintf("%ld.%u -> block %Ld\n", run.AllocationGroup(),
|
||||||
|
run.Start(), volume->ToBlock(run));
|
||||||
|
} else {
|
||||||
|
// offset to block_run
|
||||||
|
off_t offset = parse_expression(arg);
|
||||||
|
block_run run = volume->ToBlockRun(offset);
|
||||||
|
|
||||||
|
kprintf("block %Ld -> %ld.%u\n", offset, run.AllocationGroup(),
|
||||||
|
run.Start());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
kprintf("block cache: %p\n", volume->BlockCache());
|
kprintf("block cache: %p\n", volume->BlockCache());
|
||||||
kprintf("root node: %p\n", volume->RootNode());
|
kprintf("root node: %p\n", volume->RootNode());
|
||||||
kprintf("indices node: %p\n", volume->IndicesNode());
|
kprintf("indices node: %p\n", volume->IndicesNode());
|
||||||
@@ -380,4 +416,3 @@ add_debugger_commands()
|
|||||||
|
|
||||||
|
|
||||||
#endif // BFS_DEBUGGER_COMMANDS
|
#endif // BFS_DEBUGGER_COMMANDS
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user