static int string_to_guid(const char *in, struct gpt_guid *guid)
{
if (uuid_parse(in, (unsigned char *) guid)) { /* BE */
- DBG(LABEL, ul_debug("GPT: failed to parse GUID: %s", in));
+ DBG(GPT, ul_debug("failed to parse GUID: %s", in));
return -EINVAL;
}
swap_efi_guid(guid); /* LE */
static void gpt_entry_set_type(struct gpt_entry *e, struct gpt_guid *uuid)
{
e->type = *uuid;
- DBG(LABEL, gpt_debug_uuid("new type", uuid));
+ DBG(GPT, gpt_debug_uuid("new type", uuid));
}
static int gpt_entry_set_name(struct gpt_entry *e, char *str)
sizeof(struct gpt_entry);
if (nents == 0 || esz == 0 || SIZE_MAX/esz < nents) {
- DBG(LABEL, ul_debug("GPT entreis array size check failed"));
+ DBG(GPT, ul_debug("entreis array size check failed"));
return -ERANGE;
}
p->last_usable_lba = cpu_to_le64(x);
b->last_usable_lba = cpu_to_le64(x);
- DBG(LABEL, ul_debug("Alternative-LBA updated to: %"PRIu64, le64_to_cpu(p->alternative_lba)));
+ DBG(GPT, ul_debug("Alternative-LBA updated to: %"PRIu64, le64_to_cpu(p->alternative_lba)));
}
/* some universal differences between the headers */
if (rc < 0)
return rc;
- DBG(LABEL, ul_debug("FirstLBA: script=%"PRIu64", uefi=%"PRIu64", topology=%ju.",
+ DBG(GPT, ul_debug("FirstLBA: script=%"PRIu64", uefi=%"PRIu64", topology=%ju.",
*first, flba, (uintmax_t)cxt->first_lba));
if (rc == 0 && (*first < flba || *first > llba)) {
if (rc < 0)
return rc;
- DBG(LABEL, ul_debug("LastLBA: script=%"PRIu64", uefi=%"PRIu64", topology=%ju.",
+ DBG(GPT, ul_debug("LastLBA: script=%"PRIu64", uefi=%"PRIu64", topology=%ju.",
*last, llba, (uintmax_t)cxt->last_lba));
if (rc == 0 && (*last > llba || *last < flba)) {
}
}
done:
- DBG(LABEL, ul_debug("PMBR type: %s",
+ DBG(GPT, ul_debug("PMBR type: %s",
ret == GPT_MBR_PROTECTIVE ? "protective" :
ret == GPT_MBR_HYBRID ? "hybrid" : "???" ));
return ret;
else
fdisk_warnx(cxt, _("gpt: cannot handle files with mode %o"), s.st_mode);
- DBG(LABEL, ul_debug("GPT last LBA: %"PRIu64"", sectors));
+ DBG(GPT, ul_debug("last LBA: %"PRIu64"", sectors));
return sectors;
}
return NULL;
if (sz > (size_t) SSIZE_MAX) {
- DBG(LABEL, ul_debug("GPT entries array too large to read()"));
+ DBG(GPT, ul_debug("entries array too large to read()"));
return NULL;
}
/* check if first and last usable LBA make sense */
if (lu < fu) {
- DBG(LABEL, ul_debug("error: header last LBA is before first LBA"));
+ DBG(GPT, ul_debug("error: header last LBA is before first LBA"));
goto done;
}
/* check if first and last usable LBAs with the disk's last LBA */
if (fu > lastlba || lu > lastlba) {
- DBG(LABEL, ul_debug("error: header LBAs are after the disk's last LBA"));
+ DBG(GPT, ul_debug("error: header LBAs are after the disk's last LBA"));
goto done;
}
/* the header has to be outside usable range */
if (fu < GPT_PRIMARY_PARTITION_TABLE_LBA &&
GPT_PRIMARY_PARTITION_TABLE_LBA < lu) {
- DBG(LABEL, ul_debug("error: header outside of usable range"));
+ DBG(GPT, ul_debug("error: header outside of usable range"));
goto done;
}
else
free(ents);
- DBG(LABEL, ul_debug("found valid GPT Header on LBA %"PRIu64"", lba));
+ DBG(GPT, ul_debug("found valid header on LBA %"PRIu64"", lba));
return header;
invalid:
free(header);
free(ents);
- DBG(LABEL, ul_debug("read GPT Header on LBA %"PRIu64" failed", lba));
+ DBG(GPT, ul_debug("read header on LBA %"PRIu64" failed", lba));
return NULL;
}
if (!gpt_entry_is_used(ei) || !gpt_entry_is_used(ej))
continue;
if (partition_overlap(ei, ej)) {
- DBG(LABEL, ul_debug("GPT partitions overlap detected [%zu vs. %zu]", i, j));
+ DBG(GPT, ul_debug("partitions overlap detected [%zu vs. %zu]", i, j));
return i + 1;
}
}
cxt->label->nparts_cur = partitions_in_use(gpt);
return 1;
failed:
- DBG(LABEL, ul_debug("GPT probe failed"));
+ DBG(GPT, ul_debug("probe failed"));
gpt_deinit(cxt->label);
return 0;
}
assert(e);
assert(p);
- DBG(LABEL, ul_debug("GPT: parsing string attributes '%s'", p));
+ DBG(GPT, ul_debug("parsing string attributes '%s'", p));
bits = (char *) &attrs;
if (!*p)
break;
- DBG(LABEL, ul_debug(" parsing item '%s'", p));
+ DBG(GPT, ul_debug(" item '%s'", p));
if (strncmp(p, GPT_ATTRSTR_REQ,
sizeof(GPT_ATTRSTR_REQ) - 1) == 0) {
fsync(cxt->dev_fd);
- DBG(LABEL, ul_debug("GPT write OK [offset=%zu, size=%zu]",
+ DBG(GPT, ul_debug(" write OK [offset=%zu, size=%zu]",
(size_t) offset, count));
return 0;
}
assert(cxt);
assert(cxt->firstsector);
- DBG(LABEL, ul_debug("(over)writing PMBR"));
+ DBG(GPT, ul_debug("(over)writing PMBR"));
pmbr = (struct gpt_legacy_mbr *) cxt->firstsector;
/* zero out the legacy partitions */
assert(cxt->label);
assert(fdisk_is_label(cxt, GPT));
+ DBG(GPT, ul_debug("writting..."));
+
gpt = self_label(cxt);
mbr_type = valid_pmbr(cxt);
else if (gpt_write_pmbr(cxt) != 0)
goto err1;
- DBG(LABEL, ul_debug("GPT write success"));
+ DBG(GPT, ul_debug("...write success"));
return 0;
err0:
- DBG(LABEL, ul_debug("GPT write failed: incorrect input"));
+ DBG(GPT, ul_debug("...write failed: incorrect input"));
errno = EINVAL;
return -EINVAL;
err1:
- DBG(LABEL, ul_debug("GPT write failed: %m"));
+ DBG(GPT, ul_debug("...write failed: %m"));
return -errno;
}
rc = fdisk_partition_next_partno(pa, cxt, &partnum);
if (rc) {
- DBG(LABEL, ul_debug("GPT failed to get next partno"));
+ DBG(GPT, ul_debug("failed to get next partno"));
return rc;
}
do {
uint64_t x;
- DBG(LABEL, ul_debug("testing first sector %"PRIu64"", disk_f));
+ DBG(GPT, ul_debug("testing first sector %"PRIu64"", disk_f));
disk_f = find_first_available(gpt, disk_f);
if (!disk_f)
break;
x = find_last_free(gpt, disk_f);
if (x - disk_f >= cxt->grain / cxt->sector_size)
break;
- DBG(LABEL, ul_debug("first sector %"PRIu64" addresses to small space, continue...", disk_f));
+ DBG(GPT, ul_debug("first sector %"PRIu64" addresses to small space, continue...", disk_f));
disk_f = x + 1ULL;
} while(1);
user_f = dflt_f;
} else if (pa && fdisk_partition_has_start(pa)) {
- DBG(LABEL, ul_debug("first sector defined: %ju", (uintmax_t)pa->start));
+ DBG(GPT, ul_debug("first sector defined: %ju", (uintmax_t)pa->start));
if (pa->start != find_first_available(gpt, pa->start)) {
fdisk_warnx(cxt, _("Sector %ju already used."), (uintmax_t)pa->start);
return -ERANGE;
} else if (pa && fdisk_partition_has_size(pa)) {
user_l = user_f + pa->size - 1;
- DBG(LABEL, ul_debug("size defined: %ju, end: %"PRIu64" (last possible: %"PRIu64")",
+ DBG(GPT, ul_debug("size defined: %ju, end: %"PRIu64" (last possible: %"PRIu64")",
(uintmax_t)pa->size, user_l, dflt_l));
if (user_l != dflt_l
if (pa && pa->attrs)
gpt_entry_attrs_from_string(cxt, e, pa->attrs);
- DBG(LABEL, ul_debug("GPT new partition: partno=%zu, start=%"PRIu64", end=%"PRIu64", size=%"PRIu64"",
+ DBG(GPT, ul_debug("new partition: partno=%zu, start=%"PRIu64", end=%"PRIu64", size=%"PRIu64"",
partnum,
gpt_partition_start(e),
gpt_partition_end(e),
if (!fdisk_is_label(cxt, GPT))
return -EINVAL;
- DBG(LABEL, ul_debug("GPT entry attributes change requested partno=%zu", partnum));
+ DBG(GPT, ul_debug("entry attributes change requested partno=%zu", partnum));
gpt = self_label(cxt);
if (partnum >= gpt_get_nentries(gpt))
assert(cxt->label);
assert(fdisk_is_label(cxt, GPT));
- DBG(LABEL, ul_debug("GPT entry attribute change requested partno=%zu", i));
+ DBG(GPT, ul_debug("entry attribute change requested partno=%zu", i));
gpt = self_label(cxt);
if (i >= gpt_get_nentries(gpt))