static int log_fat_info(const struct fat_boot_sector*fh1, const upart_type_t upart_type, const unsigned int sector_size) { log_info("sector_size %u\n", fat_sector_size(fh1)); log_info("cluster_size %u\n", fh1->sectors_per_cluster); log_info("reserved %u\n", le16(fh1->reserved)); log_info("fats %u\n", fh1->fats); log_info("dir_entries %u\n", get_dir_entries(fh1)); log_info("sectors %u\n", fat_sectors(fh1)); log_info("media %02X\n", fh1->media); log_info("fat_length %u\n", le16(fh1->fat_length)); log_info("secs_track %u\n", le16(fh1->secs_track)); log_info("heads %u\n", le16(fh1->heads)); log_info("hidden %u\n", (unsigned int)le32(fh1->hidden)); log_info("total_sect %u\n", (unsigned int)le32(fh1->total_sect)); if(upart_type==UP_FAT32) { log_info("fat32_length %u\n", (unsigned int)le32(fh1->fat32_length)); log_info("flags %04X\n", le16(fh1->flags)); log_info("version %u.%u\n", fh1->version[0], fh1->version[1]); log_info("root_cluster %u\n", (unsigned int)le32(fh1->root_cluster)); log_info("info_sector %u\n", le16(fh1->info_sector)); log_info("backup_boot %u\n", le16(fh1->backup_boot)); if(fat32_get_free_count((const unsigned char*)fh1,sector_size)==0xFFFFFFFF) log_info("free_count uninitialised\n"); else log_info("free_count %lu\n",fat32_get_free_count((const unsigned char*)fh1,sector_size)); if(fat32_get_next_free((const unsigned char*)fh1,sector_size)==0xFFFFFFFF) log_info("next_free uninitialised\n"); else log_info("next_free %lu\n",fat32_get_next_free((const unsigned char*)fh1,sector_size)); } return 0; }
int log_fat2_info(const struct fat_boot_sector*fh1, const struct fat_boot_sector*fh2, const upart_type_t upart_type, const unsigned int sector_size) { switch(upart_type) { case UP_FAT12: log_info("\nFAT12\n"); break; case UP_FAT16: log_info("\nFAT16\n"); break; case UP_FAT32: log_info("\nFAT32\n"); break; default: return 1; } log_info("sector_size %u %u\n", fat_sector_size(fh1),fat_sector_size(fh2)); log_info("cluster_size %u %u\n", fh1->sectors_per_cluster,fh2->sectors_per_cluster); log_info("reserved %u %u\n", le16(fh1->reserved),le16(fh2->reserved)); log_info("fats %u %u\n", fh1->fats,fh2->fats); log_info("dir_entries %u %u\n", get_dir_entries(fh1),get_dir_entries(fh2)); log_info("sectors %u %u\n", fat_sectors(fh1),fat_sectors(fh2)); log_info("media %02X %02X\n", fh1->media,fh2->media); log_info("fat_length %u %u\n", le16(fh1->fat_length),le16(fh2->fat_length)); log_info("secs_track %u %u\n", le16(fh1->secs_track),le16(fh2->secs_track)); log_info("heads %u %u\n", le16(fh1->heads),le16(fh2->heads)); log_info("hidden %u %u\n", (unsigned int)le32(fh1->hidden),(unsigned int)le32(fh2->hidden)); log_info("total_sect %u %u\n", (unsigned int)le32(fh1->total_sect),(unsigned int)le32(fh2->total_sect)); if(upart_type==UP_FAT32) { log_info("fat32_length %u %u\n", (unsigned int)le32(fh1->fat32_length),(unsigned int)le32(fh2->fat32_length)); log_info("flags %04X %04X\n", le16(fh1->flags),le16(fh2->flags)); log_info("version %u.%u %u.%u\n", fh1->version[0], fh1->version[1],fh2->version[0], fh2->version[1]); log_info("root_cluster %u %u\n", (unsigned int)le32(fh1->root_cluster),(unsigned int)le32(fh2->root_cluster)); log_info("info_sector %u %u\n", le16(fh1->info_sector),le16(fh2->info_sector)); log_info("backup_boot %u %u\n", le16(fh1->backup_boot),le16(fh2->backup_boot)); log_info("free_count "); if(fat32_get_free_count((const unsigned char*)fh1,sector_size)==0xFFFFFFFF) log_info("uninitialised "); else log_info("%lu ",fat32_get_free_count((const unsigned char*)fh1,sector_size)); if(fat32_get_free_count((const unsigned char*)fh2,sector_size)==0xFFFFFFFF) log_info("uninitialised"); else log_info("%lu",fat32_get_free_count((const unsigned char*)fh2,sector_size)); log_info("\nnext_free "); if(fat32_get_next_free((const unsigned char*)fh1,sector_size)==0xFFFFFFFF) log_info("uninitialised "); else log_info("%lu ",fat32_get_next_free((const unsigned char*)fh1,sector_size)); if(fat32_get_next_free((const unsigned char*)fh2,sector_size)==0xFFFFFFFF) log_info("uninitialised\n"); else log_info("%lu\n",fat32_get_next_free((const unsigned char*)fh2,sector_size)); } return 0; }
int dump_2fat_info_ncurses(const struct fat_boot_sector*fh1, const struct fat_boot_sector*fh2, const upart_type_t upart_type, const unsigned int sector_size) { switch(upart_type) { case UP_FAT12: wprintw(stdscr,"FAT : 12\n"); break; case UP_FAT16: wprintw(stdscr,"FAT : 16\n"); break; case UP_FAT32: wprintw(stdscr,"FAT : 32\n"); break; default: wprintw(stdscr,"Not a FAT\n"); return 1; } wprintw(stdscr,"cluster_size %u %u\n", fh1->sectors_per_cluster, fh2->sectors_per_cluster); wprintw(stdscr,"reserved %u %u\n", le16(fh1->reserved),le16(fh2->reserved)); if(fat_sectors(fh1)!=0 || fat_sectors(fh2)!=0) wprintw(stdscr,"sectors %u %u\n", fat_sectors(fh1), fat_sectors(fh2)); if(le32(fh1->total_sect)!=0 || le32(fh2->total_sect)!=0) wprintw(stdscr,"total_sect %u %u\n", (unsigned int)le32(fh1->total_sect), (unsigned int)le32(fh2->total_sect)); if(upart_type==UP_FAT32) { wprintw(stdscr,"fat32_length %u %u\n", (unsigned int)le32(fh1->fat32_length), (unsigned int)le32(fh2->fat32_length)); wprintw(stdscr,"root_cluster %u %u\n", (unsigned int)le32(fh1->root_cluster), (unsigned int)le32(fh2->root_cluster)); wprintw(stdscr,"free_count "); if(fat32_get_free_count((const unsigned char*)fh1,sector_size)==0xFFFFFFFF) wprintw(stdscr,"uninitialised "); else wprintw(stdscr,"%lu ",fat32_get_free_count((const unsigned char*)fh1,sector_size)); if(fat32_get_free_count((const unsigned char*)fh2,sector_size)==0xFFFFFFFF) wprintw(stdscr,"uninitialised\n"); else wprintw(stdscr,"%lu\n",fat32_get_free_count((const unsigned char*)fh2,sector_size)); wprintw(stdscr,"next_free "); if(fat32_get_next_free((const unsigned char*)fh1,sector_size)==0xFFFFFFFF) wprintw(stdscr,"uninitialised "); else wprintw(stdscr,"%lu ",fat32_get_next_free((const unsigned char*)fh1,sector_size)); if(fat32_get_next_free((const unsigned char*)fh2,sector_size)==0xFFFFFFFF) wprintw(stdscr,"uninitialised\n"); else wprintw(stdscr,"%lu\n",fat32_get_next_free((const unsigned char*)fh2,sector_size)); } else { wprintw(stdscr,"fat_length %u %u\n", le16(fh1->fat_length), le16(fh2->fat_length)); wprintw(stdscr,"dir_entries %u %u\n", get_dir_entries(fh1), get_dir_entries(fh2)); } return 0; }
int dump_fat_info_ncurses(const struct fat_boot_sector*fh1, const upart_type_t upart_type, const unsigned int sector_size) { switch(upart_type) { case UP_FAT12: wprintw(stdscr,"FAT : 12\n"); break; case UP_FAT16: wprintw(stdscr,"FAT : 16\n"); break; case UP_FAT32: wprintw(stdscr,"FAT : 32\n"); break; default: wprintw(stdscr,"Not a FAT\n"); return 0; } wprintw(stdscr,"cluster_size %u\n", fh1->sectors_per_cluster); wprintw(stdscr,"reserved %u\n", le16(fh1->reserved)); if(fat_sectors(fh1)!=0) wprintw(stdscr,"sectors %u\n", fat_sectors(fh1)); if(le32(fh1->total_sect)!=0) wprintw(stdscr,"total_sect %u\n", (unsigned int)le32(fh1->total_sect)); if(upart_type==UP_FAT32) { wprintw(stdscr,"fat32_length %u\n", (unsigned int)le32(fh1->fat32_length)); wprintw(stdscr,"root_cluster %u\n", (unsigned int)le32(fh1->root_cluster)); wprintw(stdscr,"flags %04X\n", le16(fh1->flags)); wprintw(stdscr,"version %u.%u\n", fh1->version[0], fh1->version[1]); wprintw(stdscr,"root_cluster %u\n", (unsigned int)le32(fh1->root_cluster)); wprintw(stdscr,"info_sector %u\n", le16(fh1->info_sector)); wprintw(stdscr,"backup_boot %u\n", le16(fh1->backup_boot)); if(fat32_get_free_count((const unsigned char*)fh1,sector_size)==0xFFFFFFFF) wprintw(stdscr,"free_count uninitialised\n"); else wprintw(stdscr,"free_count %lu\n",fat32_get_free_count((const unsigned char*)fh1,sector_size)); if(fat32_get_next_free((const unsigned char*)fh1,sector_size)==0xFFFFFFFF) wprintw(stdscr,"next_free uninitialised\n"); else wprintw(stdscr,"next_free %lu\n",fat32_get_next_free((const unsigned char*)fh1,sector_size)); } else { wprintw(stdscr,"fat_length %u\n", le16(fh1->fat_length)); wprintw(stdscr,"dir_entries %u\n", get_dir_entries(fh1)); } return 0; }