if (!header)
goto unknown;
- switch (header->revision) {
+ switch (le32_to_cpu(header->revision)) {
case GPT_HEADER_REVISION_V1_02:
return "1.2";
case GPT_HEADER_REVISION_V1_00:
if (fdisk_is_details(cxt)) {
struct gpt_header *h = self_label(cxt)->pheader;
- fdisk_info(cxt, _("First LBA: %ju"), h->first_usable_lba);
- fdisk_info(cxt, _("Last LBA: %ju"), h->last_usable_lba);
+ fdisk_info(cxt, _("First LBA: %ju"), le64_to_cpu(h->first_usable_lba));
+ fdisk_info(cxt, _("Last LBA: %ju"), le64_to_cpu(h->last_usable_lba));
/* TRANSLATORS: The LBA (Logical Block Address) of the backup GPT header. */
- fdisk_info(cxt, _("Alternative LBA: %ju"), h->alternative_lba);
+ fdisk_info(cxt, _("Alternative LBA: %ju"), le64_to_cpu(h->alternative_lba));
/* TRANSLATORS: The start of the array of partition entries. */
- fdisk_info(cxt, _("Partition entries LBA: %ju"), h->partition_entry_lba);
- fdisk_info(cxt, _("Allocated partition entries: %u"), h->npartition_entries);
+ fdisk_info(cxt, _("Partition entries LBA: %ju"), le64_to_cpu(h->partition_entry_lba));
+ fdisk_info(cxt, _("Allocated partition entries: %u"), le32_to_cpu(h->npartition_entries));
}
return 0;
if (rc)
return rc;
- disk_f = find_first_available(pheader, ents, pheader->first_usable_lba);
+ disk_f = find_first_available(pheader, ents, le64_to_cpu(pheader->first_usable_lba));
/* if first sector no explicitly defined then ignore small gaps before
* the first partition */
} while(1);
if (disk_f == 0)
- disk_f = find_first_available(pheader, ents, pheader->first_usable_lba);
+ disk_f = find_first_available(pheader, ents, le64_to_cpu(pheader->first_usable_lba));
}
disk_l = find_last_free_sector(pheader, ents);
if (h) {
/* always follow existing table */
- cxt->first_lba = h->first_usable_lba;
- cxt->last_lba = h->last_usable_lba;
+ cxt->first_lba = le64_to_cpu(h->first_usable_lba);
+ cxt->last_lba = le64_to_cpu(h->last_usable_lba);
} else {
/* estimate ranges for GPT */
uint64_t first, last;