rc = fdisk_write_disklabel(cxt);
if (rc)
err(EXIT_FAILURE, _("failed to write disklabel"));
+
+ fdisk_info(cxt, _("The partition table has been altered."));
if (fdisk_get_parent(cxt))
break; /* nested PT, don't leave */
- fdisk_info(cxt, _("The partition table has been altered."));
if (device_is_used)
rc = fdisk_reread_changes(cxt, original_layout);
if (cxt->parent) {
/* the first sector may be independent on parent */
- if (cxt->parent->firstsector != cxt->firstsector)
+ if (cxt->parent->firstsector != cxt->firstsector) {
+ DBG(CXT, ul_debugobj(cxt, " firstsector independent on parent (freeing)"));
free(cxt->firstsector);
+ }
} else {
/* we close device only in primary context */
if (cxt->dev_fd > -1 && cxt->private_fd)
close(cxt->dev_fd);
+ DBG(CXT, ul_debugobj(cxt, " freeing firstsector"));
free(cxt->firstsector);
}
if (ret != GPT_MBR_PROTECTIVE)
goto done;
- /* LBA of the GPT partition header */
- if (pmbr->partition_record[part].starting_lba !=
- cpu_to_le32(GPT_PRIMARY_PARTITION_TABLE_LBA))
- goto done;
for (i = 0 ; i < 4; i++) {
if ((pmbr->partition_record[i].os_type != EFI_PMBR_OSTYPE) &&
- (pmbr->partition_record[i].os_type != 0x00))
+ (pmbr->partition_record[i].os_type != 0x00)) {
ret = GPT_MBR_HYBRID;
+ goto done;
+ }
}
+ /* LBA of the GPT partition header */
+ if (pmbr->partition_record[part].starting_lba !=
+ cpu_to_le32(GPT_PRIMARY_PARTITION_TABLE_LBA))
+ goto done;
+
/*
* Protective MBRs take up the lesser of the whole disk
* or 2 TiB (32bit LBA), ignoring the rest of the disk.
}
}
done:
+ DBG(LABEL, ul_debug("PMBR type: %s",
+ ret == GPT_MBR_PROTECTIVE ? "protective" :
+ ret == GPT_MBR_HYBRID ? "hybrid" : "???" ));
return ret;
}
if (!mbr_type)
goto failed;
- DBG(LABEL, ul_debug("found a %s MBR", mbr_type == GPT_MBR_PROTECTIVE ?
- "protective" : "hybrid"));
-
/* primary header */
gpt->pheader = gpt_read_header(cxt, GPT_PRIMARY_PARTITION_TABLE_LBA,
&gpt->ents);
assert(cxt);
assert(cxt->firstsector);
+ DBG(LABEL, ul_debug("(over)writing PMBR"));
pmbr = (struct gpt_legacy_mbr *) cxt->firstsector;
/* zero out the legacy partitions */
goto err1;
if (mbr_type == GPT_MBR_HYBRID)
- fdisk_warnx(cxt, _("The device contains hybrid MBR -- writing GPT only. "
- "You have to sync the MBR manually."));
+ fdisk_warnx(cxt, _("The device contains hybrid MBR -- writing GPT only."));
else if (gpt_write_pmbr(cxt) != 0)
goto err1;