Changeset a8e1aae in mainline for uspace/app/ext2info
- Timestamp:
- 2011-02-24T21:03:42Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9ffbdf1
- Parents:
- 102d400
- File:
-
- 1 edited
-
uspace/app/ext2info/ext2info.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/ext2info/ext2info.c
r102d400 ra8e1aae 56 56 static void print_block_groups(ext2_filesystem_t *); 57 57 static void print_block_group(ext2_block_group_t *); 58 static void print_inode_by_number(ext2_filesystem_t *, uint32_t, bool, uint32_t); 58 static void print_inode_by_number(ext2_filesystem_t *, uint32_t, bool, uint32_t, 59 bool); 60 static void print_data(unsigned char *, size_t); 59 61 static void print_inode(ext2_filesystem_t *, ext2_inode_t *); 60 62 static void print_inode_data(ext2_filesystem_t *, ext2_inode_t *, uint32_t); 63 static void print_directory_contents(ext2_filesystem_t *, ext2_inode_ref_t *); 61 64 62 65 #define ARG_SUPERBLOCK 1 … … 65 68 #define ARG_STRICT_CHECK 8 66 69 #define ARG_INODE_DATA 16 70 #define ARG_INODE_LIST 32 67 71 #define ARG_COMMON (ARG_SUPERBLOCK | ARG_BLOCK_GROUPS) 68 72 #define ARG_ALL (ARG_COMMON | ARG_INODE) … … 141 145 --argc; ++argv; 142 146 } 147 148 if (str_cmp(*argv, "--list") == 0) { 149 --argc; ++argv; 150 arg_flags |= ARG_INODE_LIST; 151 } 143 152 } 144 153 … … 186 195 if (arg_flags & ARG_INODE) { 187 196 print_inode_by_number(&filesystem, inode, arg_flags & ARG_INODE_DATA, 188 inode_data );197 inode_data, arg_flags & ARG_INODE_LIST); 189 198 } 190 199 … … 198 207 { 199 208 printf("syntax: ext2info [--strict-check] [--superblock] [--block-groups] " 200 "[--inode <i-number> [--inode-data <block-number>] ] <device_name>\n");209 "[--inode <i-number> [--inode-data <block-number>] [--list]] <device_name>\n"); 201 210 } 202 211 … … 346 355 347 356 void print_inode_by_number(ext2_filesystem_t *fs, uint32_t inode, 348 bool print_data, uint32_t data )357 bool print_data, uint32_t data, bool list) 349 358 { 350 359 int rc; … … 362 371 if (print_data) { 363 372 print_inode_data(fs, inode_ref->inode, data); 373 } 374 375 if (list && ext2_inode_is_type(fs->superblock, inode_ref->inode, 376 EXT2_INODE_MODE_DIRECTORY)) { 377 print_directory_contents(fs, inode_ref); 364 378 } 365 379 … … 444 458 } 445 459 460 void print_data(unsigned char *data, size_t size) 461 { 462 unsigned char c; 463 size_t i; 464 465 for (i = 0; i < size; i++) { 466 c = data[i]; 467 if (c >= 32 && c < 127) { 468 putchar(c); 469 } 470 else { 471 putchar('.'); 472 } 473 } 474 } 475 446 476 void print_inode_data(ext2_filesystem_t *fs, ext2_inode_t *inode, uint32_t data) 447 477 { … … 449 479 uint32_t data_block_index; 450 480 block_t *block; 451 size_t i;452 unsigned char c;453 481 454 482 rc = ext2_filesystem_get_inode_data_block_index(fs, inode, data, … … 471 499 } 472 500 473 for (i = 0; i < block->size; i++) { 474 c = ((unsigned char *)block->data)[i]; 475 if (c >= 32 && c < 127) { 476 putchar(c); 477 } 478 else { 479 putchar('.'); 480 } 481 } 482 501 print_data(block->data, block->size); 483 502 printf("\n"); 484 503 … … 486 505 if (rc != EOK) { 487 506 printf("Failed putting filesystem block\n"); 507 } 508 509 } 510 511 void print_directory_contents(ext2_filesystem_t *fs, 512 ext2_inode_ref_t *inode_ref) 513 { 514 int rc; 515 ext2_directory_iterator_t it; 516 size_t name_size; 517 518 printf(" Directory contents:\n"); 519 520 rc = ext2_directory_iterator_init(&it, fs, inode_ref); 521 if (rc != EOK) { 522 printf("Failed initializing directory iterator\n"); 523 return; 524 } 525 526 while (it.current != NULL) { 527 name_size = ext2_directory_entry_ll_get_name_length(fs->superblock, 528 it.current); 529 printf(" "); 530 print_data(&it.current->name, name_size); 531 printf(" --> %u\n", it.current->inode); 532 533 rc = ext2_directory_iterator_next(&it); 534 if (rc != EOK) { 535 printf("Failed reading directory contents\n"); 536 goto cleanup; 537 } 538 } 539 540 cleanup: 541 rc = ext2_directory_iterator_fini(&it); 542 if (rc != EOK) { 543 printf("Failed cleaning-up directory iterator\n"); 488 544 } 489 545
Note:
See TracChangeset
for help on using the changeset viewer.
