Changeset 1ff896e in mainline
- Timestamp:
- 2011-03-23T23:07:32Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 694ca93f
- Parents:
- 54e90cc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/ext2info/ext2info.c
r54e90cc r1ff896e 58 58 static void print_block_group(ext2_block_group_t *); 59 59 static void print_inode_by_number(ext2_filesystem_t *, uint32_t, bool, uint32_t, 60 bool );60 bool, bool); 61 61 static void print_data(unsigned char *, size_t); 62 static void print_inode(ext2_filesystem_t *, ext2_inode_t * );62 static void print_inode(ext2_filesystem_t *, ext2_inode_t *, bool); 63 63 static void print_inode_data(ext2_filesystem_t *, ext2_inode_t *, uint32_t); 64 64 static void print_directory_contents(ext2_filesystem_t *, ext2_inode_ref_t *); … … 67 67 #define ARG_BLOCK_GROUPS 2 68 68 #define ARG_INODE 4 69 #define ARG_ STRICT_CHECK 869 #define ARG_NO_CHECK 8 70 70 #define ARG_INODE_DATA 16 71 71 #define ARG_INODE_LIST 32 72 #define ARG_COMMON (ARG_SUPERBLOCK | ARG_BLOCK_GROUPS) 73 #define ARG_ALL (ARG_COMMON | ARG_INODE) 72 #define ARG_INODE_BLOCKS 64 73 #define ARG_COMMON (ARG_SUPERBLOCK) 74 #define ARG_ALL 127 74 75 75 76 … … 97 98 --argc; ++argv; 98 99 99 if (argc > 0 && str_cmp(*argv, "-- strict-check") == 0) {100 if (argc > 0 && str_cmp(*argv, "--no-check") == 0) { 100 101 --argc; ++argv; 101 arg_flags |= ARG_ STRICT_CHECK;102 arg_flags |= ARG_NO_CHECK; 102 103 } 103 104 … … 129 130 --argc; ++argv; 130 131 131 if (argc > 0 && str_cmp(*argv, "--inode-data") == 0) { 132 if (argc > 0 && str_cmp(*argv, "--blocks") == 0) { 133 --argc; ++argv; 134 arg_flags |= ARG_INODE_BLOCKS; 135 } 136 137 if (argc > 0 && str_cmp(*argv, "--data") == 0) { 132 138 --argc; ++argv; 133 139 if (argc == 0) { 134 printf(NAME ": Argument expected for -- inode-data\n");140 printf(NAME ": Argument expected for --data\n"); 135 141 return 2; 136 142 } … … 138 144 inode_data = strtol(*argv, &endptr, 10); 139 145 if (*endptr != '\0') { 140 printf(NAME ": Error, invalid argument for -- inode-data.\n");146 printf(NAME ": Error, invalid argument for --data.\n"); 141 147 syntax_print(); 142 148 return 1; … … 187 193 if (rc != EOK) { 188 194 printf(NAME ": Filesystem did not pass sanity check.\n"); 189 if ( arg_flags & ARG_STRICT_CHECK) {195 if (!(arg_flags & ARG_NO_CHECK)) { 190 196 return 3; 191 197 } … … 202 208 if (arg_flags & ARG_INODE) { 203 209 print_inode_by_number(&filesystem, inode, arg_flags & ARG_INODE_DATA, 204 inode_data, arg_flags & ARG_INODE_LIST); 210 inode_data, arg_flags & ARG_INODE_LIST, 211 arg_flags & ARG_INODE_BLOCKS); 205 212 } 206 213 … … 213 220 static void syntax_print(void) 214 221 { 215 printf("syntax: ext2info [--strict-check] [--superblock] [--block-groups] " 216 "[--inode <i-number> [--inode-data <block-number>] [--list]] <device_name>\n"); 222 printf("syntax: ext2info [--no-check] [--superblock] [--block-groups] " 223 "[--inode <i-number> [--blocks] [--data <block-number>] [--list]] " 224 "<device_name>\n"); 217 225 } 218 226 … … 362 370 363 371 void print_inode_by_number(ext2_filesystem_t *fs, uint32_t inode, 364 bool print_data, uint32_t data, bool list )372 bool print_data, uint32_t data, bool list, bool blocks) 365 373 { 366 374 int rc; … … 375 383 } 376 384 377 print_inode(fs, inode_ref->inode );385 print_inode(fs, inode_ref->inode, blocks); 378 386 if (print_data) { 379 387 print_inode_data(fs, inode_ref->inode, data); … … 391 399 } 392 400 393 void print_inode(ext2_filesystem_t *fs, ext2_inode_t *inode )401 void print_inode(ext2_filesystem_t *fs, ext2_inode_t *inode, bool blocks) 394 402 { 395 403 uint32_t mode; … … 462 470 printf(" Flags: %u\n", flags); 463 471 printf(" Total allocated blocks: %u\n", total_blocks); 464 printf(" Block list: "); 465 466 range_start = 0; 467 range_current = 0; 468 range_last = 0; 469 470 printed_range = false; 471 472 for (i = 0; i <= file_blocks; i++) { 473 if (i < file_blocks) { 474 rc = ext2_filesystem_get_inode_data_block_index(fs, inode, i, &range_current); 475 if (rc != EOK) { 476 printf("Error reading data block indexes\n"); 477 return; 478 } 479 } 480 if (range_last == 0) { 481 range_expected = 0; 482 } 483 else { 484 range_expected = range_last + 1; 485 } 486 if (range_current != range_expected) { 487 if (i > 0) { 488 if (printed_range) { 489 printf(", "); 472 473 if (blocks) { 474 printf(" Block list: "); 475 476 range_start = 0; 477 range_current = 0; 478 range_last = 0; 479 480 printed_range = false; 481 482 for (i = 0; i <= file_blocks; i++) { 483 if (i < file_blocks) { 484 rc = ext2_filesystem_get_inode_data_block_index(fs, inode, i, &range_current); 485 if (rc != EOK) { 486 printf("Error reading data block indexes\n"); 487 return; 490 488 } 491 if (range_start == 0 && range_last == 0) { 492 if (range_start_file == range_last_file) { 493 printf("%u N/A", range_start_file); 489 } 490 if (range_last == 0) { 491 range_expected = 0; 492 } 493 else { 494 range_expected = range_last + 1; 495 } 496 if (range_current != range_expected) { 497 if (i > 0) { 498 if (printed_range) { 499 printf(", "); 500 } 501 if (range_start == 0 && range_last == 0) { 502 if (range_start_file == range_last_file) { 503 printf("%u N/A", range_start_file); 504 } 505 else { 506 printf("[%u, %u] N/A", range_start_file, 507 range_last_file); 508 } 494 509 } 495 510 else { 496 printf("[%u, %u] N/A", range_start_file, 497 range_last_file); 511 if (range_start_file == range_last_file) { 512 printf("%u -> %u", range_start_file, range_start); 513 } 514 else { 515 printf("[%u, %u] -> [%u, %u]", range_start_file, 516 range_last_file, range_start, range_last); 517 } 498 518 } 519 printed_range = true; 499 520 } 500 else { 501 if (range_start_file == range_last_file) { 502 printf("%u -> %u", range_start_file, range_start); 503 } 504 else { 505 printf("[%u, %u] -> [%u, %u]", range_start_file, 506 range_last_file, range_start, range_last); 507 } 508 } 509 printed_range = true; 510 } 511 range_start = range_current; 512 range_start_file = i; 513 } 514 range_last = range_current; 515 range_last_file = i; 516 } 517 printf("\n"); 521 range_start = range_current; 522 range_start_file = i; 523 } 524 range_last = range_current; 525 range_last_file = i; 526 } 527 printf("\n"); 528 } 518 529 } 519 530
Note:
See TracChangeset
for help on using the changeset viewer.