_size_t mbr_part(_size_t id) { _mbr_t mbr; _size_t i, n = 0; if ((disk_read(id, &mbr, sizeof(_mbr_t), 0x1be) != -1) && (mbr.sign == 0xaa55)) { debug("Disk %d: Boot signature", id); for (i = 0; i < 4; i++) { if (mbr.part[i].part_type == TYPE_EXT) { debug("Disk %d: DOS Partition %d, Extended", id, i); n += mbr_part(disk_mmap(id, mbr.part[i].first_sector_lba, mbr.part[i].sector_num)); n++; } else if (mbr.part[i].part_type == TYPE_GPT) { n += gpt_part(id); } else if (mbr.part[i].part_type != TYPE_EMPTY) { debug("Disk %d: DOS Partition %d, Id %02X", id, i, mbr.part[i].part_type); disk_mmap(id, mbr.part[i].first_sector_lba, mbr.part[i].sector_num); n++; } } } return n; }
static void gpt_list_table(int xtra UNUSED_PARAM) { int i; char numstr6[6]; smart_ulltoa5(total_number_of_sectors * sector_size, numstr6, " KMGTPEZY")[0] = '\0'; printf("Disk %s: %llu sectors, %s\n", disk_device, (unsigned long long)total_number_of_sectors, numstr6); printf("Logical sector size: %u\n", sector_size); printf("Disk identifier (GUID): "); gpt_print_guid(gpt_hdr->disk_guid); printf("\nPartition table holds up to %u entries\n", (int)SWAP_LE32(gpt_hdr->n_parts)); printf("First usable sector is %llu, last usable sector is %llu\n\n", (unsigned long long)SWAP_LE64(gpt_hdr->first_usable_lba), (unsigned long long)SWAP_LE64(gpt_hdr->last_usable_lba)); printf("Number Start (sector) End (sector) Size Code Name\n"); for (i = 0; i < n_parts; i++) { gpt_partition *p = gpt_part(i); if (p->lba_start) { smart_ulltoa5((1 + SWAP_LE64(p->lba_end) - SWAP_LE64(p->lba_start)) * sector_size, numstr6, " KMGTPEZY")[0] = '\0'; printf("%4u %15llu %15llu %11s %04x ", i + 1, (unsigned long long)SWAP_LE64(p->lba_start), (unsigned long long)SWAP_LE64(p->lba_end), numstr6, 0x0700 /* FIXME */); gpt_print_wide(p->name, 18); printf("\n"); } } }