| 554 | */ |
| 555 | |
| 556 | int test_FAT(disk_t *disk_car, const struct fat_boot_sector *fat_header, const partition_t *partition, const int verbose, const int dump_ind) |
| 557 | { |
| 558 | uint64_t start_fat1; |
| 559 | uint64_t start_fat2; |
| 560 | uint64_t start_rootdir; |
| 561 | uint64_t start_data; |
| 562 | uint64_t part_size; |
| 563 | uint64_t end_data; |
| 564 | unsigned long int no_of_cluster; |
| 565 | unsigned long int fat_length; |
| 566 | unsigned long int fat_length_calc; |
| 567 | const char *buffer=(const char*)fat_header; |
| 568 | if(!(le16(fat_header->marker)==0xAA55 |
| 569 | && (fat_header->ignored[0]==0xeb || fat_header->ignored[0]==0xe9) |
| 570 | && (fat_header->fats==1 || fat_header->fats==2))) |
| 571 | return 1; /* Obviously not a FAT */ |
| 572 | #ifndef DISABLED_FOR_FRAMAC |
| 573 | if(verbose>1 || dump_ind!=0) |
| 574 | { |
| 575 | log_trace("test_FAT\n"); |
| 576 | log_partition(disk_car, partition); |
| 577 | } |
| 578 | #endif |
| 579 | if(dump_ind!=0) |
| 580 | dump_log(fat_header, DEFAULT_SECTOR_SIZE); |
| 581 | if(!((fat_header->ignored[0]==0xeb && fat_header->ignored[2]==0x90)||fat_header->ignored[0]==0xe9)) |
| 582 | { |
| 583 | #ifndef DISABLED_FOR_FRAMAC |
| 584 | screen_buffer_add(msg_CHKFAT_BAD_JUMP); |
| 585 | log_error(msg_CHKFAT_BAD_JUMP); |
| 586 | #endif |
| 587 | return 1; |
| 588 | } |
| 589 | switch(fat_header->sectors_per_cluster) |
| 590 | { |
| 591 | case 1: |
| 592 | case 2: |
| 593 | case 4: |
| 594 | case 8: |
| 595 | case 16: |
| 596 | case 32: |
| 597 | case 64: |
| 598 | case 128: |
| 599 | break; |
| 600 | default: |
| 601 | #ifndef DISABLED_FOR_FRAMAC |
| 602 | screen_buffer_add(msg_CHKFAT_SECT_CLUSTER); |
| 603 | log_error(msg_CHKFAT_SECT_CLUSTER); |
| 604 | #endif |
| 605 | return 1; |
| 606 | } |
| 607 | switch(fat_header->fats) |
| 608 | { |
| 609 | case 1: |
| 610 | #ifndef DISABLED_FOR_FRAMAC |
| 611 | screen_buffer_add("check_FAT: Unusual, only one FAT\n"); |
| 612 | log_warning("check_FAT: Unusual, only one FAT\n"); |
| 613 | #endif |
no test coverage detected