From 6ebe15a0392c1a632c032d4be18a3b1ff06a3a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 3 Feb 2004 02:17:59 +0000 Subject: [PATCH] Added support for properly initializing a file system without issueing any cache warnings. Now prints out actual useful information with the -v option. Removed DEBUG from the build, so that it's now silent and can be used as a replacement of the original. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6482 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/file_systems/bfs/mkbfs/Jamfile | 3 +- .../kernel/file_systems/bfs/mkbfs/mkbfs.cpp | 53 ++++++++++++++++++- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/src/tests/add-ons/kernel/file_systems/bfs/mkbfs/Jamfile b/src/tests/add-ons/kernel/file_systems/bfs/mkbfs/Jamfile index a186042e83..f02623172e 100644 --- a/src/tests/add-ons/kernel/file_systems/bfs/mkbfs/Jamfile +++ b/src/tests/add-ons/kernel/file_systems/bfs/mkbfs/Jamfile @@ -13,7 +13,8 @@ UsePrivateHeaders [ FDirName kernel util ] ; malloc_debug_flags = -fcheck-memory-usage ; } - local defines = [ FDefines USER DEBUG + local defines = [ FDefines USER + UNSAFE_GET_VNODE #BFS_BIG_ENDIAN_ONLY $(malloc_debug_defines) ] ; SubDirCcFlags $(defines) -fno-exceptions -fno-rtti $(malloc_debug_flags) ; diff --git a/src/tests/add-ons/kernel/file_systems/bfs/mkbfs/mkbfs.cpp b/src/tests/add-ons/kernel/file_systems/bfs/mkbfs/mkbfs.cpp index 55d9798b84..280e00277e 100644 --- a/src/tests/add-ons/kernel/file_systems/bfs/mkbfs/mkbfs.cpp +++ b/src/tests/add-ons/kernel/file_systems/bfs/mkbfs/mkbfs.cpp @@ -15,6 +15,33 @@ #include +// Note: these structures have been stolen from fs_shell/kernel.c. +// They shouldn't be used anywhere else + +extern vnode_ops fs_entry; +struct vnode; + +struct vnlist { + vnode *head; + vnode *tail; + int num; +}; + +struct nspace { + nspace_id nsid; + my_dev_t dev; + my_ino_t ino; + fsystem *fs; + vnlist vnodes; + void *data; + vnode * root; + vnode * mount; + nspace * prev; + nspace * next; + char shutdown; +}; + + void usage(char *programName) { @@ -95,15 +122,37 @@ main(int argc, char **argv) init_block_cache(4096, 0); init_vnode_layer(); - Volume volume(1); + if (install_file_system(&fs_entry, "bfs", 1, -1) == NULL) { + printf("can't install my file system\n"); + exit(0); + } + + struct nspace *mount = (nspace *)malloc(sizeof(nspace)); + if (add_nspace(mount, NULL, "bfs", -1, -1) < B_OK) { + fprintf(stderr, "%s: add mount structure failed\n", programName); + return -1; + } + + Volume volume(mount->nsid); status_t status = volume.Initialize(deviceName, volumeName, blockSize, flags); if (status < B_OK) { fprintf(stderr, "%s: Initializing volume failed: %s\n", programName, strerror(status)); return -1; } + remove_nspace(mount); + if (verbose) { - // ToDo: dump disk info + disk_super_block super = volume.SuperBlock(); + + printf("%s: Disk was initialized successfully.\n", programName); + printf("\tname: \"%s\"\n", super.name); + printf("\tnum blocks: %Ld\n", super.NumBlocks()); + printf("\tused blocks: %Ld\n", super.UsedBlocks()); + printf("\tblock size: %lu bytes\n", super.BlockSize()); + printf("\tnum allocation groups: %ld\n", super.AllocationGroups()); + printf("\tallocation group size: %ld blocks\n", 1L << super.AllocationGroupShift()); + printf("\tlog size: %u blocks\n", super.log_blocks.Length()); } shutdown_block_cache();