@ @ requires \valid(disk_car); @ requires \valid_read(fat_header); @ requires \valid(partition); @ requires \separated(disk_car, fat_header, partition); @*/
| 133 | @ requires \separated(disk_car, fat_header, partition); |
| 134 | @*/ |
| 135 | static void set_FAT_info(disk_t *disk_car, const struct fat_boot_sector *fat_header, partition_t *partition) |
| 136 | { |
| 137 | uint64_t start_fat1; |
| 138 | uint64_t start_data; |
| 139 | uint64_t part_size; |
| 140 | unsigned long int no_of_cluster; |
| 141 | unsigned long int fat_length; |
| 142 | const char *buffer=(const char*)fat_header; |
| 143 | partition->fsname[0]='\0'; |
| 144 | partition->blocksize=fat_sector_size(fat_header)* fat_header->sectors_per_cluster; |
| 145 | fat_length=le16(fat_header->fat_length)>0?le16(fat_header->fat_length):le32(fat_header->fat32_length); |
| 146 | part_size=(fat_sectors(fat_header)>0?fat_sectors(fat_header):le32(fat_header->total_sect)); |
| 147 | start_fat1=le16(fat_header->reserved); |
| 148 | start_data=start_fat1+fat_header->fats*fat_length+(get_dir_entries(fat_header)*32+fat_sector_size(fat_header)-1)/fat_sector_size(fat_header); |
| 149 | no_of_cluster=(part_size-start_data)/fat_header->sectors_per_cluster; |
| 150 | if(no_of_cluster<4085) |
| 151 | { |
| 152 | partition->upart_type=UP_FAT12; |
| 153 | snprintf(partition->info, sizeof(partition->info), "FAT12, blocksize=%u", partition->blocksize); |
| 154 | if(buffer[38]==0x29) /* BS_BootSig */ |
| 155 | { |
| 156 | set_part_name_chomp(partition, buffer+FAT1X_PART_NAME, 11); |
| 157 | if(check_VFAT_volume_name(partition->fsname, 11)) |
| 158 | partition->fsname[0]='\0'; |
| 159 | } |
| 160 | } |
| 161 | else if(no_of_cluster<65525) |
| 162 | { |
| 163 | partition->upart_type=UP_FAT16; |
| 164 | snprintf(partition->info, sizeof(partition->info), "FAT16, blocksize=%u", partition->blocksize); |
| 165 | if(buffer[38]==0x29) /* BS_BootSig */ |
| 166 | { |
| 167 | set_part_name_chomp(partition, buffer+FAT1X_PART_NAME, 11); |
| 168 | if(check_VFAT_volume_name(partition->fsname, 11)) |
| 169 | partition->fsname[0]='\0'; |
| 170 | } |
| 171 | } |
| 172 | else |
| 173 | { |
| 174 | partition->upart_type=UP_FAT32; |
| 175 | if(partition->sb_offset==0) |
| 176 | snprintf(partition->info, sizeof(partition->info), "FAT32, blocksize=%u", partition->blocksize); |
| 177 | else |
| 178 | snprintf(partition->info, sizeof(partition->info), "FAT32 found using backup sector, blocksize=%u", partition->blocksize); |
| 179 | fat32_set_part_name(disk_car,partition,fat_header); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | /*@ |
| 184 | @ requires \valid_read(fh1); |
no test coverage detected