Changeset d241aae in mainline for uspace/app/ext2info/ext2info.c
- Timestamp:
- 2011-02-15T19:24:38Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ce13577
- Parents:
- 1d6f507
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/ext2info/ext2info.c
r1d6f507 rd241aae 53 53 54 54 static void syntax_print(void); 55 static void print_superblock(ext2_superblock_t *sb); 55 static void print_superblock(ext2_superblock_t *); 56 static void print_block_groups(ext2_filesystem_t *); 57 static void print_block_group(ext2_block_group_t *); 56 58 57 59 int main(int argc, char **argv) … … 62 64 devmap_handle_t handle; 63 65 ext2_filesystem_t filesystem; 66 bool strict_check; 64 67 65 68 if (argc < 2) { … … 68 71 return 1; 69 72 } 73 74 strict_check = false; 75 if (str_cmp(*argv, "--strict-check") == 0) { 76 --argc; ++argv; 77 strict_check = true; 78 } 70 79 71 80 --argc; ++argv; … … 94 103 if (rc != EOK) { 95 104 printf(NAME ": Filesystem did not pass sanity check.\n"); 96 return 3; 105 if (strict_check) { 106 return 3; 107 } 97 108 } 98 109 99 110 print_superblock(filesystem.superblock); 111 print_block_groups(&filesystem); 100 112 101 113 ext2_filesystem_fini(&filesystem); … … 200 212 } 201 213 214 void print_block_groups(ext2_filesystem_t *filesystem) { 215 uint32_t block_group_count; 216 uint32_t i; 217 ext2_block_group_ref_t *block_group_ref; 218 int rc; 219 220 printf("Block groups:\n"); 221 222 block_group_count = ext2_superblock_get_block_group_count( 223 filesystem->superblock); 224 225 for (i = 0; i < block_group_count; i++) { 226 printf(" Block group %u\n", i); 227 rc = ext2_filesystem_get_block_group_ref(filesystem, i, &block_group_ref); 228 if (rc != EOK) { 229 printf(" Failed reading block group\n"); 230 continue; 231 } 232 233 print_block_group(block_group_ref->block_group); 234 235 rc = ext2_filesystem_put_block_group_ref(block_group_ref); 236 if (rc != EOK) { 237 printf(" Failed freeing block group\n"); 238 } 239 } 240 241 } 242 243 void print_block_group(ext2_block_group_t *bg) { 244 uint32_t block_bitmap_block; 245 uint32_t inode_bitmap_block; 246 uint32_t inode_table_first_block; 247 uint16_t free_block_count; 248 uint16_t free_inode_count; 249 uint16_t directory_inode_count; 250 251 block_bitmap_block = ext2_block_group_get_block_bitmap_block(bg); 252 inode_bitmap_block = ext2_block_group_get_inode_bitmap_block(bg); 253 inode_table_first_block = ext2_block_group_get_inode_table_first_block(bg); 254 free_block_count = ext2_block_group_get_free_block_count(bg); 255 free_inode_count = ext2_block_group_get_free_inode_count(bg); 256 directory_inode_count = ext2_block_group_get_directory_inode_count(bg); 257 258 printf(" Block bitmap block: %u\n", block_bitmap_block); 259 printf(" Inode bitmap block: %u\n", inode_bitmap_block); 260 printf(" Inode table's first block: %u\n", inode_table_first_block); 261 printf(" Free blocks: %u\n", free_block_count); 262 printf(" Free inodes: %u\n", free_inode_count); 263 printf(" Directory inodes: %u\n", directory_inode_count); 264 } 265 202 266 /** 203 267 * @}
Note:
See TracChangeset
for help on using the changeset viewer.