bfs_tools/bfsinfo: Cleanup output, use human sizes
* Correct some warnings on 64-bit
This commit is contained in:
@@ -3,6 +3,7 @@ SubDir HAIKU_TOP src bin bfs_tools ;
|
|||||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||||
|
|
||||||
SubDirHdrs $(HAIKU_TOP) src bin bfs_tools lib ;
|
SubDirHdrs $(HAIKU_TOP) src bin bfs_tools lib ;
|
||||||
|
UsePrivateHeaders [ FDirName shared ] ;
|
||||||
|
|
||||||
StdBinCommands
|
StdBinCommands
|
||||||
bfsinfo.cpp
|
bfsinfo.cpp
|
||||||
@@ -10,7 +11,7 @@ StdBinCommands
|
|||||||
bfswhich.cpp
|
bfswhich.cpp
|
||||||
recover.cpp
|
recover.cpp
|
||||||
|
|
||||||
: libbfs_tools.a be [ TargetLibstdc++ ] : $(haiku-utils_rsrc)
|
: libbfs_tools.a be shared [ TargetLibstdc++ ] : $(haiku-utils_rsrc)
|
||||||
;
|
;
|
||||||
|
|
||||||
SubInclude HAIKU_TOP src bin bfs_tools lib ;
|
SubInclude HAIKU_TOP src bin bfs_tools lib ;
|
||||||
|
|||||||
@@ -12,12 +12,17 @@
|
|||||||
#include "Inode.h"
|
#include "Inode.h"
|
||||||
#include "dump.h"
|
#include "dump.h"
|
||||||
|
|
||||||
|
#include <StringForSize.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace BPrivate;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
dump_bplustree(Disk &disk, BPositionIO *file, off_t size, bool hexDump)
|
dump_bplustree(Disk &disk, BPositionIO *file, off_t size, bool hexDump)
|
||||||
{
|
{
|
||||||
@@ -172,7 +177,7 @@ list_bplustree(Disk& disk, Directory* directory, off_t size)
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("--\n%lld items.\n", count);
|
printf("--\n%" B_PRId64 " items.\n", count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -187,7 +192,7 @@ count_bplustree(Disk& disk, Directory* directory, off_t size)
|
|||||||
while (directory->GetNextEntry(name, &run) == B_OK)
|
while (directory->GetNextEntry(name, &run) == B_OK)
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
printf("%lld items.\n", count);
|
printf("%" B_PRId64 " items.\n", count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -210,8 +215,6 @@ parseBlockRun(Disk &disk, char *first, char *last)
|
|||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
puts("Copyright (c) 2001-2010 pinc Software.");
|
|
||||||
|
|
||||||
if (argc < 2 || !strcmp(argv[1], "--help")) {
|
if (argc < 2 || !strcmp(argv[1], "--help")) {
|
||||||
char *filename = strrchr(argv[0],'/');
|
char *filename = strrchr(argv[0],'/');
|
||||||
fprintf(stderr,"usage: %s [-srib] <device> [allocation_group start]\n"
|
fprintf(stderr,"usage: %s [-srib] <device> [allocation_group start]\n"
|
||||||
@@ -288,32 +291,36 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
if (!dumpSuperBlock && !dumpRootNode && !dumpInode && !dumpBTree
|
if (!dumpSuperBlock && !dumpRootNode && !dumpInode && !dumpBTree
|
||||||
&& !dumpHex && !listBTree && !countBTree) {
|
&& !dumpHex && !listBTree && !countBTree) {
|
||||||
|
char buffer[16];
|
||||||
printf(" Name:\t\t\t\"%s\"\n", disk.SuperBlock()->name);
|
printf(" Name:\t\t\t\"%s\"\n", disk.SuperBlock()->name);
|
||||||
printf(" (disk is %s)\n\n",
|
printf(" SuperBlock:\t\t%s\n\n",
|
||||||
disk.ValidateSuperBlock() == B_OK ? "valid" : "invalid!!");
|
disk.ValidateSuperBlock() == B_OK ? "valid" : "invalid!");
|
||||||
printf(" Block Size:\t\t%" B_PRIu32 " bytes\n", disk.BlockSize());
|
printf(" Block Size:%*" B_PRIu32 " bytes\n", 23, disk.BlockSize());
|
||||||
printf(" Number of Blocks:\t%12" B_PRIdOFF "\t%10g MB\n",
|
string_for_size(disk.NumBlocks() * disk.BlockSize(), buffer,
|
||||||
disk.NumBlocks(), disk.NumBlocks() * disk.BlockSize()
|
sizeof(buffer));
|
||||||
/ (1024.0*1024));
|
printf(" Number of Blocks:%*" B_PRIdOFF "\t%*s\n", 17, disk.NumBlocks(),
|
||||||
|
16, buffer);
|
||||||
if (disk.BlockBitmap() != NULL) {
|
if (disk.BlockBitmap() != NULL) {
|
||||||
printf(" Used Blocks:\t\t%12" B_PRIdOFF "\t%10g MB\n",
|
string_for_size(disk.BlockBitmap()->UsedBlocks() * disk.BlockSize(),
|
||||||
disk.BlockBitmap()->UsedBlocks(),
|
buffer, sizeof(buffer));
|
||||||
disk.BlockBitmap()->UsedBlocks() * disk.BlockSize()
|
printf(" Used Blocks:%*" B_PRIdOFF "\t%*s\n", 22,
|
||||||
/ (1024.0*1024));
|
disk.BlockBitmap()->UsedBlocks(), 16, buffer);
|
||||||
printf(" Free Blocks:\t\t%12" B_PRIdOFF "\t%10g MB\n",
|
|
||||||
disk.BlockBitmap()->FreeBlocks(),
|
string_for_size(disk.BlockBitmap()->FreeBlocks() * disk.BlockSize(),
|
||||||
disk.BlockBitmap()->FreeBlocks() * disk.BlockSize()
|
buffer, sizeof(buffer));
|
||||||
/ (1024.0*1024));
|
printf(" Free Blocks:%*" B_PRIdOFF "\t%*s\n", 22,
|
||||||
|
disk.BlockBitmap()->FreeBlocks(), 16, buffer);
|
||||||
}
|
}
|
||||||
int32 size
|
int32 size
|
||||||
= (disk.AllocationGroups() * disk.SuperBlock()->blocks_per_ag);
|
= (disk.AllocationGroups() * disk.SuperBlock()->blocks_per_ag);
|
||||||
printf(" Bitmap Size:\t\t%" B_PRIu32 " bytes (%" B_PRId32 " blocks, %"
|
string_for_size(disk.BlockSize() * size, buffer, sizeof(buffer));
|
||||||
B_PRId32 " per allocation group)\n", disk.BlockSize() * size, size,
|
printf(" Bitmap Blocks:%*" B_PRId32 "\t%*s\n", 20, size, 16, buffer);
|
||||||
|
printf(" Allocation Group Size:%*" B_PRId32 " blocks\n", 12,
|
||||||
disk.SuperBlock()->blocks_per_ag);
|
disk.SuperBlock()->blocks_per_ag);
|
||||||
printf(" Allocation Groups:\t%" B_PRIu32 "\n\n",
|
printf(" Allocation Groups:%*" B_PRIu32 "\n\n", 16,
|
||||||
disk.AllocationGroups());
|
disk.AllocationGroups());
|
||||||
dump_block_run(" Log:\t\t\t", disk.Log());
|
dump_block_run(" Log:\t\t\t", disk.Log());
|
||||||
printf(" (was %s)\n\n", disk.SuperBlock()->flags == SUPER_BLOCK_CLEAN
|
printf("\t\t\t%s\n\n", disk.SuperBlock()->flags == SUPER_BLOCK_CLEAN
|
||||||
? "cleanly unmounted" : "not unmounted cleanly!");
|
? "cleanly unmounted" : "not unmounted cleanly!");
|
||||||
dump_block_run(" Root Directory:\t", disk.Root());
|
dump_block_run(" Root Directory:\t", disk.Root());
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
|
|||||||
Reference in New Issue
Block a user