| 988 | } |
| 989 | |
| 990 | int recover_FAT(disk_t *disk_car, const struct fat_boot_sector*fat_header, partition_t *partition, const int verbose, const int dump_ind, const int backup) |
| 991 | { |
| 992 | int efi=0; |
| 993 | if(test_FAT(disk_car, fat_header, partition, verbose, dump_ind)) |
| 994 | return 1; |
| 995 | partition->part_size=(uint64_t)(fat_sectors(fat_header)>0?fat_sectors(fat_header):le32(fat_header->total_sect)) * |
| 996 | fat_sector_size(fat_header); |
| 997 | /* test_FAT has set partition->upart_type */ |
| 998 | partition->sborg_offset=0; |
| 999 | partition->sb_size=512; |
| 1000 | partition->sb_offset=0; |
| 1001 | set_FAT_info(disk_car, fat_header, partition); |
| 1002 | switch(partition->upart_type) |
| 1003 | { |
| 1004 | case UP_FAT12: |
| 1005 | #ifndef DISABLED_FOR_FRAMAC |
| 1006 | if(verbose||dump_ind) |
| 1007 | { |
| 1008 | log_info("\nFAT12 at %u/%u/%u\n", |
| 1009 | offset2cylinder(disk_car,partition->part_offset), |
| 1010 | offset2head(disk_car,partition->part_offset), |
| 1011 | offset2sector(disk_car,partition->part_offset)); |
| 1012 | } |
| 1013 | #endif |
| 1014 | partition->part_type_i386=P_12FAT; |
| 1015 | partition->part_type_gpt=GPT_ENT_TYPE_MS_BASIC_DATA; |
| 1016 | break; |
| 1017 | case UP_FAT16: |
| 1018 | #ifndef DISABLED_FOR_FRAMAC |
| 1019 | if(verbose||dump_ind) |
| 1020 | { |
| 1021 | log_info("\nFAT16 at %u/%u/%u\n", |
| 1022 | offset2cylinder(disk_car,partition->part_offset), |
| 1023 | offset2head(disk_car,partition->part_offset), |
| 1024 | offset2sector(disk_car,partition->part_offset)); |
| 1025 | } |
| 1026 | #endif |
| 1027 | if(fat_sectors(fat_header)!=0) |
| 1028 | partition->part_type_i386=P_16FAT; |
| 1029 | else if(offset2cylinder(disk_car,partition->part_offset+partition->part_size-1)<=1024) |
| 1030 | partition->part_type_i386=P_16FATBD; |
| 1031 | else |
| 1032 | partition->part_type_i386=P_16FATBD_LBA; |
| 1033 | partition->part_type_gpt=GPT_ENT_TYPE_MS_BASIC_DATA; |
| 1034 | break; |
| 1035 | case UP_FAT32: |
| 1036 | #ifndef DISABLED_FOR_FRAMAC |
| 1037 | if(verbose||dump_ind) |
| 1038 | { |
| 1039 | log_info("\nFAT32 at %u/%u/%u\n", |
| 1040 | offset2cylinder(disk_car,partition->part_offset), |
| 1041 | offset2head(disk_car,partition->part_offset), |
| 1042 | offset2sector(disk_car,partition->part_offset)); |
| 1043 | } |
| 1044 | #endif |
| 1045 | if(offset2cylinder(disk_car,partition->part_offset+partition->part_size-1)<=1024) |
| 1046 | partition->part_type_i386=P_32FAT; |
| 1047 | else |
no test coverage detected