int tree = 0;
struct tt_line *ln, *ln_cont = NULL;
- DBG(FRONTEND, dbgprint("table: convert to string"));
+ DBG(FRONTEND, ul_debug("table: convert to string"));
assert(cf);
assert(cf->cxt);
/* get container (e.g. extended partition) */
while (fdisk_table_next_partition(tb, itr, &pa) == 0) {
if (fdisk_partition_is_nested(pa)) {
- DBG(FRONTEND, dbgprint("table: nested detected, using tree"));
+ DBG(FRONTEND, ul_debug("table: nested detected, using tree"));
tree = TT_FL_TREE;
break;
}
assert(cf);
- DBG(FRONTEND, dbgprint("refreshing buffer"));
+ DBG(FRONTEND, ul_debug("refreshing buffer"));
free(cf->linesbuf);
free(cf->lines);
static void die_on_signal(int dummy __attribute__((__unused__)))
{
- DBG(FRONTEND, dbgprint("die on signal."));
+ DBG(FRONTEND, ul_debug("die on signal."));
ui_end();
exit(EXIT_FAILURE);
}
m = cf->menu;
org = menu_get_menuitem(cf, m->idx);
- DBG(FRONTEND, dbgprint("menu: update menu ignored keys"));
+ DBG(FRONTEND, ul_debug("menu: update menu ignored keys"));
i = m->ignore_cb(cf, ignore, sizeof(ignore));
ignore[i] = '\0';
assert(cf);
- DBG(FRONTEND, dbgprint("menu: new menu"));
+ DBG(FRONTEND, ul_debug("menu: new menu"));
m->prev = cf->menu;
m->items = items;
assert(cf);
- DBG(FRONTEND, dbgprint("menu: rem menu"));
+ DBG(FRONTEND, ul_debug("menu: rem menu"));
if (cf->menu) {
m = cf->menu->prev;
{
struct sigaction sa;
- DBG(FRONTEND, dbgprint("ui: init"));
+ DBG(FRONTEND, ul_debug("ui: init"));
/* setup SIGCHLD handler */
sigemptyset(&sa.sa_mask);
vert ? MBS_ALIGN_LEFT : MBS_ALIGN_CENTER,
0);
- DBG(FRONTEND, dbgprint("ui: menuitem: cl=%d, ln=%d, item='%s'",
+ DBG(FRONTEND, ul_debug("ui: menuitem: cl=%d, ln=%d, item='%s'",
cl, ln, buf));
if (vert) {
assert(cf);
assert(cf->menu);
- DBG(FRONTEND, dbgprint("ui: menu: draw start"));
+ DBG(FRONTEND, ul_debug("ui: menu: draw start"));
m = cf->menu;
mvaddch(ln + nlines, cl + m->width + 3, ACS_DARROW);
}
- DBG(FRONTEND, dbgprint("ui: menu: draw end."));
+ DBG(FRONTEND, ul_debug("ui: menu: draw end."));
}
static void ui_menu_goto(struct cfdisk *cf, int where)
m = cf->menu;
- DBG(FRONTEND, dbgprint("ui: menu move key >%c<.", key));
+ DBG(FRONTEND, ul_debug("ui: menu move key >%c<.", key));
if (m->vertical)
{
curpg = cf->lines_idx / cf->page_sz;
}
- DBG(FRONTEND, dbgprint(
+ DBG(FRONTEND, ul_debug(
"ui: draw partition %zu [page_sz=%zu, "
"line=%d, idx=%zu]",
i, cf->page_sz, ln, cf->lines_idx));
size_t i, nparts = fdisk_table_get_nents(cf->table);
size_t curpg = cf->page_sz ? cf->lines_idx / cf->page_sz : 0;
- DBG(FRONTEND, dbgprint("ui: draw table"));
+ DBG(FRONTEND, ul_debug("ui: draw table"));
for (i = TABLE_START_LINE; i <= TABLE_START_LINE + cf->page_sz; i++) {
move(i, 0);
size_t old;
size_t nparts = fdisk_table_get_nents(cf->table);
- DBG(FRONTEND, dbgprint("ui: goto table %d", where));
+ DBG(FRONTEND, ul_debug("ui: goto table %d", where));
if (where < 0)
where = 0;
ssize_t rc;
char *dflt = size_to_human_string(0, *res);
- DBG(FRONTEND, dbgprint("ui: get_size (default=%ju)", *res));
+ DBG(FRONTEND, ul_debug("ui: get_size (default=%ju)", *res));
ui_clean_info();
}
if (rc == 0) {
- DBG(FRONTEND, dbgprint("ui: get_size user=%ju, power=%d, sectors=%s",
+ DBG(FRONTEND, ul_debug("ui: get_size user=%ju, power=%d, sectors=%s",
user, pwr, insec ? "yes" : "no"));
if (insec)
user *= cf->cxt->sector_size;
*res = user;
free(dflt);
- DBG(FRONTEND, dbgprint("ui: get_size (result=%ju, rc=%zd)", *res, rc));
+ DBG(FRONTEND, ul_debug("ui: get_size (result=%ju, rc=%zd)", *res, rc));
return rc;
}
struct fdisk_parttype *t = NULL;
int has_typestr = 0;
- DBG(FRONTEND, dbgprint("ui: asking for parttype."));
+ DBG(FRONTEND, ul_debug("ui: asking for parttype."));
/* create cfdisk menu according to label types, note that the
* last cm[] item has to be empty -- so nitems + 1 */
free((char *) cm[i].name);
}
free(cm);
- DBG(FRONTEND, dbgprint("ui: get parrtype done [type=%s] ", t ? t->name : NULL));
+ DBG(FRONTEND, ul_debug("ui: get parrtype done [type=%s] ", t ? t->name : NULL));
return t;
}
assert(cf);
- DBG(FRONTEND, dbgprint("ui: asking for new disklabe."));
+ DBG(FRONTEND, ul_debug("ui: asking for new disklabe."));
/* create cfdisk menu according to libfdisk labels, note that the
* last cm[] item has to be empty -- so nitems + 1 */
done:
menu_pop(cf);
free(cm);
- DBG(FRONTEND, dbgprint("ui: create label done [rc=%d] ", rc));
+ DBG(FRONTEND, ul_debug("ui: create label done [rc=%d] ", rc));
return rc;
}
} else if (key != 'w' && key != 'W')
key = tolower(key); /* case insensitive except 'W'rite */
- DBG(FRONTEND, dbgprint("ui: main menu action: key=%c", key));
+ DBG(FRONTEND, ul_debug("ui: main menu action: key=%c", key));
if (cf->menu->ignore && strchr(cf->menu->ignore, key)) {
- DBG(FRONTEND, dbgprint(" ignore '%c'", key));
+ DBG(FRONTEND, ul_debug(" ignore '%c'", key));
return 0;
}
pa = get_current_partition(cf);
n = fdisk_partition_get_partno(pa);
- DBG(FRONTEND, dbgprint("menu action on %p", pa));
+ DBG(FRONTEND, ul_debug("menu action on %p", pa));
ui_clean_hint();
ui_clean_info();
{
int rc = 0;
- DBG(FRONTEND, dbgprint("ui: start COLS=%d, LINES=%d", COLS, LINES));
+ DBG(FRONTEND, ul_debug("ui: start COLS=%d, LINES=%d", COLS, LINES));
if (!fdisk_dev_has_disklabel(cf->cxt)) {
rc = ui_create_label(cf);
if (ui_menu_move(cf, key) == 0)
continue;
- DBG(FRONTEND, dbgprint("ui: main action key >%c<.", key));
+ DBG(FRONTEND, ul_debug("ui: main action key >%c<.", key));
switch (key) {
case KEY_DOWN:
menu_pop(cf);
- DBG(FRONTEND, dbgprint("ui: end"));
+ DBG(FRONTEND, ul_debug("ui: end"));
return 0;
}
rc = fdisk_context_deassign_device(cf->cxt);
fdisk_free_context(cf->cxt);
- DBG(FRONTEND, dbgprint("bye! [rc=%d]", rc));
+ DBG(FRONTEND, ul_debug("bye! [rc=%d]", rc));
return rc == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
r = get_fdisk_menu_entry(cxt, e->key, NULL);
if (!r) {
- DBG(FRONTEND, dbgprint("warning: not found "
+ DBG(FRONTEND, ul_debug("warning: not found "
"entry for %c", e->key));
return -1;
}
if (r != e) {
- DBG(FRONTEND, dbgprint("warning: duplicate key '%c'",
+ DBG(FRONTEND, ul_debug("warning: duplicate key '%c'",
e->key));
- DBG(FRONTEND, dbgprint(" : %s", e->title));
- DBG(FRONTEND, dbgprint(" : %s", r->title));
+ DBG(FRONTEND, ul_debug(" : %s", e->title));
+ DBG(FRONTEND, ul_debug(" : %s", r->title));
abort();
}
}
}
rc = 0;
- DBG(FRONTEND, dbgprint("selected: key=%c, entry='%s'",
+ DBG(FRONTEND, ul_debug("selected: key=%c, entry='%s'",
key, ent->title));
/* menu has implemented callback, use it */
if (menu->callback)
rc = menu->callback(cxt0, menu, ent);
else {
- DBG(FRONTEND, dbgprint("no callback for key '%c'", key));
+ DBG(FRONTEND, ul_debug("no callback for key '%c'", key));
rc = -EINVAL;
}
- DBG(FRONTEND, dbgprint("process menu done [rc=%d]", rc));
+ DBG(FRONTEND, ul_debug("process menu done [rc=%d]", rc));
return rc;
}
assert(ent);
assert(fdisk_is_disklabel(cxt, GPT));
- DBG(FRONTEND, dbgprint("enter GPT menu"));
+ DBG(FRONTEND, ul_debug("enter GPT menu"));
if (ent->expert) {
switch (ent->key) {
struct fdisk_context *cxt = *cxt0;
int rc = 0;
- DBG(FRONTEND, dbgprint("enter DOS menu"));
+ DBG(FRONTEND, ul_debug("enter DOS menu"));
if (!ent->expert) {
switch (ent->key) {
struct fdisk_context *cxt = *cxt0;
int rc = 0;
- DBG(FRONTEND, dbgprint("enter SUN menu"));
+ DBG(FRONTEND, ul_debug("enter SUN menu"));
assert(cxt);
assert(ent);
assert(fdisk_is_disklabel(cxt, SUN));
- DBG(FRONTEND, dbgprint("enter SUN menu"));
+ DBG(FRONTEND, ul_debug("enter SUN menu"));
/* normal mode */
if (!ent->expert) {
int rc = -EINVAL;
size_t n = 0;
- DBG(FRONTEND, dbgprint("enter SGI menu"));
+ DBG(FRONTEND, ul_debug("enter SGI menu"));
assert(cxt);
assert(ent);
assert(ent);
assert(fdisk_is_disklabel(cxt, BSD));
- DBG(FRONTEND, dbgprint("enter BSD menu"));
+ DBG(FRONTEND, ul_debug("enter BSD menu"));
switch(ent->key) {
case 'e':
int rc = -EINVAL;
uintmax_t c = 0, h = 0, s = 0;
- DBG(FRONTEND, dbgprint("enter GEO menu"));
+ DBG(FRONTEND, ul_debug("enter GEO menu"));
assert(cxt);
assert(ent);
struct fdisk_context *cxt = *cxt0;
int rc = -EINVAL;
- DBG(FRONTEND, dbgprint("enter Create label menu"));
+ DBG(FRONTEND, ul_debug("enter Create label menu"));
assert(cxt);
assert(ent);
if (sz && *(buf + sz - 1) == '\n')
*(buf + sz - 1) = '\0';
- DBG(ASK, dbgprint("user's reply: >>>%s<<<", buf));
+ DBG(ASK, ul_debug("user's reply: >>>%s<<<", buf));
return 0;
}
assert(q);
- DBG(ASK, dbgprint("asking for number "
+ DBG(ASK, ul_debug("asking for number "
"['%s', <%ju,%ju>, default=%ju, range: %s]",
q, low, high, dflt, range));
assert(q);
- DBG(ASK, dbgprint("asking for offset ['%s', <%ju,%ju>, base=%ju, default=%ju, range: %s]",
+ DBG(ASK, ul_debug("asking for offset ['%s', <%ju,%ju>, base=%ju, default=%ju, range: %s]",
q, low, high, base, dflt, range));
if (range && dflt >= low && dflt <= high)
rc = parse_size(p, &num, &pwr);
if (rc)
continue;
- DBG(ASK, dbgprint("parsed size: %ju", num));
+ DBG(ASK, ul_debug("parsed size: %ju", num));
if (sig && pwr) {
/* +{size}{K,M,...} specified, the "num" is in bytes */
uint64_t unit = fdisk_ask_number_get_unit(ask);
else if (sig == '-')
num = base - num;
- DBG(ASK, dbgprint("final offset: %ju [sig: %c, power: %d, %s]",
+ DBG(ASK, ul_debug("final offset: %ju [sig: %c, power: %d, %s]",
num, sig, pwr,
sig ? "relative" : "absolute"));
if (num >= low && num <= high) {
rc = get_user_reply(cxt, _(" [Y]es/[N]o: "), buf, sizeof(buf));
if (rc == 0)
fdisk_ask_yesno_set_result(ask, rpmatch(buf));
- DBG(ASK, dbgprint("yes-no ask: reply '%s' [rc=%d]", buf, rc));
+ DBG(ASK, ul_debug("yes-no ask: reply '%s' [rc=%d]", buf, rc));
break;
case FDISK_ASKTYPE_STRING:
{
rc = get_user_reply(cxt, prmt, buf, sizeof(buf));
if (rc == 0)
fdisk_ask_string_set_result(ask, xstrdup(buf));
- DBG(ASK, dbgprint("string ask: reply '%s' [rc=%d]", buf, rc));
+ DBG(ASK, ul_debug("string ask: reply '%s' [rc=%d]", buf, rc));
break;
}
default:
return;
}
- DBG(FRONTEND, dbgprint("reading "_PATH_PROC_PARTITIONS));
+ DBG(FRONTEND, ul_debug("reading "_PATH_PROC_PARTITIONS));
while (fgets(line, sizeof(line), f)) {
char ptname[128 + 1], devname[256];
snprintf(devname, sizeof(devname), "/dev/%s", ptname);
- DBG(FRONTEND, dbgprint("listing %s", devname));
+ DBG(FRONTEND, ul_debug("listing %s", devname));
if (is_whole_disk(devname)) {
char *cn = canonicalize_path(devname);
}
if (lba != res)
- DBG(TOPOLOGY, dbgprint("LBA %ju -aligned-to-> %ju",
+ DBG(TOPOLOGY, ul_debug("LBA %ju -aligned-to-> %ju",
(uintmax_t) lba,
(uintmax_t) res));
return res;
fdisk_reset_alignment(cxt);
- DBG(GEOMETRY, dbgprint("override C/H/S: %u/%u/%u",
+ DBG(GEOMETRY, ul_debug("override C/H/S: %u/%u/%u",
(unsigned) cxt->geom.cylinders,
(unsigned) cxt->geom.heads,
(unsigned) cxt->geom.sectors));
if (cylinders)
cxt->user_geom.cylinders = cylinders;
- DBG(GEOMETRY, dbgprint("user C/H/S: %u/%u/%u",
+ DBG(GEOMETRY, ul_debug("user C/H/S: %u/%u/%u",
(unsigned) cxt->user_geom.cylinders,
(unsigned) cxt->user_geom.heads,
(unsigned) cxt->user_geom.sectors));
if (!cxt)
return -EINVAL;
- DBG(TOPOLOGY, dbgprint("user phy/log sector size: %u/%u", phy, log));
+ DBG(TOPOLOGY, ul_debug("user phy/log sector size: %u/%u", phy, log));
cxt->user_pyh_sector = phy;
cxt->user_log_sector = log;
if (!cxt)
return -EINVAL;
- DBG(TOPOLOGY, dbgprint("appling user device properties"));
+ DBG(TOPOLOGY, ul_debug("appling user device properties"));
if (cxt->user_pyh_sector)
cxt->phy_sector_size = cxt->user_pyh_sector;
fdisk_reset_alignment(cxt);
- DBG(GEOMETRY, dbgprint("new C/H/S: %u/%u/%u",
+ DBG(GEOMETRY, ul_debug("new C/H/S: %u/%u/%u",
(unsigned) cxt->geom.cylinders,
(unsigned) cxt->geom.heads,
(unsigned) cxt->geom.sectors));
- DBG(TOPOLOGY, dbgprint("new log/phy sector size: %u/%u",
+ DBG(TOPOLOGY, ul_debug("new log/phy sector size: %u/%u",
(unsigned) cxt->sector_size,
(unsigned) cxt->phy_sector_size));
if (!cxt)
return -EINVAL;
- DBG(TOPOLOGY, dbgprint("*** reseting device properties"));
+ DBG(TOPOLOGY, ul_debug("*** reseting device properties"));
fdisk_zeroize_device_properties(cxt);
fdisk_discover_topology(cxt);
assert(cxt);
assert(cxt->geom.heads == 0);
- DBG(GEOMETRY, dbgprint("%s: discovering geometry...", cxt->dev_path));
+ DBG(GEOMETRY, ul_debug("%s: discovering geometry...", cxt->dev_path));
/* get number of 512-byte sectors, and convert it the real sectors */
if (!blkdev_get_sectors(cxt->dev_fd, &nsects))
/* obtained heads and sectors */
recount_geometry(cxt);
- DBG(GEOMETRY, dbgprint("result: C/H/S: %u/%u/%u",
+ DBG(GEOMETRY, ul_debug("result: C/H/S: %u/%u/%u",
(unsigned) cxt->geom.cylinders,
(unsigned) cxt->geom.heads,
(unsigned) cxt->geom.sectors));
assert(cxt);
assert(cxt->sector_size == 0);
- DBG(TOPOLOGY, dbgprint("%s: discovering topology...", cxt->dev_path));
+ DBG(TOPOLOGY, ul_debug("%s: discovering topology...", cxt->dev_path));
#ifdef HAVE_LIBBLKID
- DBG(TOPOLOGY, dbgprint("initialize libblkid prober"));
+ DBG(TOPOLOGY, ul_debug("initialize libblkid prober"));
pr = blkid_new_probe();
if (pr && blkid_probe_set_device(pr, cxt->dev_fd, 0, 0) == 0) {
if (!cxt->io_size)
cxt->io_size = cxt->sector_size;
- DBG(TOPOLOGY, dbgprint("result: log/phy sector size: %ld/%ld",
+ DBG(TOPOLOGY, ul_debug("result: log/phy sector size: %ld/%ld",
cxt->sector_size, cxt->phy_sector_size));
- DBG(TOPOLOGY, dbgprint("result: fdisk/min/optimal io: %ld/%ld/%ld",
+ DBG(TOPOLOGY, ul_debug("result: fdisk/min/optimal io: %ld/%ld/%ld",
cxt->io_size, cxt->optimal_io_size, cxt->min_io_size));
return 0;
}
if (!cxt)
return -EINVAL;
- DBG(TOPOLOGY, dbgprint("reseting alignment..."));
+ DBG(TOPOLOGY, ul_debug("reseting alignment..."));
/* default */
cxt->grain = fdisk_topology_get_grain(cxt);
if (cxt->label && cxt->label->op->reset_alignment)
rc = cxt->label->op->reset_alignment(cxt);
- DBG(TOPOLOGY, dbgprint("%s alignment reseted to: "
+ DBG(TOPOLOGY, ul_debug("%s alignment reseted to: "
"first LBA=%ju, last LBA=%ju, grain=%lu [rc=%d]",
cxt->label ? cxt->label->name : NULL,
(uintmax_t) cxt->first_lba, (uintmax_t) cxt->last_lba,
assert(ask);
assert(cxt);
- DBG(ASK, dbgprint("do_ask for '%s'",
+ DBG(ASK, ul_debug("do_ask for '%s'",
ask->query ? ask->query :
ask->type == FDISK_ASKTYPE_INFO ? "info" :
ask->type == FDISK_ASKTYPE_WARNX ? "warnx" :
"?nothing?"));
if (!cxt->ask_cb) {
- DBG(ASK, dbgprint("no ask callback specified!"));
+ DBG(ASK, ul_debug("no ask callback specified!"));
return -EINVAL;
}
rc = cxt->ask_cb(cxt, ask, cxt->ask_data);
- DBG(ASK, dbgprint("do_ask done [rc=%d]", rc));
+ DBG(ASK, ul_debug("do_ask done [rc=%d]", rc));
return rc;
}
if (cxt->label && cxt->label->flags & FDISK_LABEL_FL_INCHARS_PARTNO)
inchar = 1;
- DBG(ASK, dbgprint("%s: asking for %s partition number "
+ DBG(ASK, ul_debug("%s: asking for %s partition number "
"(max: %zu, inchar: %s)",
cxt->label->name,
wantnew ? "new" : "used",
}
}
- DBG(ASK, dbgprint("ask limits: low: %ju, high: %ju, default: %ju",
+ DBG(ASK, ul_debug("ask limits: low: %ju, high: %ju, default: %ju",
num->low, num->hig, num->dfl));
if (!rc && !wantnew && num->low == num->hig) {
if (*partnum)
*partnum -= 1;
}
- DBG(ASK, dbgprint("result: %ju [rc=%d]\n", fdisk_ask_number_get_result(ask), rc));
+ DBG(ASK, ul_debug("result: %ju [rc=%d]\n", fdisk_ask_number_get_result(ask), rc));
fdisk_free_ask(ask);
return rc;
}
*result = fdisk_ask_number_get_result(ask);
fdisk_free_ask(ask);
- DBG(ASK, dbgprint("result: %ju [rc=%d]\n", *result, rc));
+ DBG(ASK, ul_debug("result: %ju [rc=%d]\n", *result, rc));
return rc;
}
*result = fdisk_ask_string_get_result(ask);
fdisk_free_ask(ask);
- DBG(ASK, dbgprint("result: %s [rc=%d]\n", *result, rc));
+ DBG(ASK, ul_debug("result: %s [rc=%d]\n", *result, rc));
return rc;
}
*result = fdisk_ask_yesno_get_result(ask);
fdisk_free_ask(ask);
- DBG(ASK, dbgprint("result: %d [rc=%d]\n", *result, rc));
+ DBG(ASK, ul_debug("result: %d [rc=%d]\n", *result, rc));
return rc;
}
assert(ask);
assert(fdisk_is_ask(ask, MENU));
ask->data.menu.result = key;
- DBG(ASK, dbgprint("menu result: %c\n", key));
+ DBG(ASK, ul_debug("menu result: %c\n", key));
return 0;
}
last->next = mi;
}
- DBG(ASK, dbgprint("new menu item: %c, \"%s\" (%s)\n", mi->key, mi->name, mi->desc));
+ DBG(ASK, ul_debug("new menu item: %c, \"%s\" (%s)\n", mi->key, mi->name, mi->desc));
return 0;
}
cxt->parent->dev_path, i + 1);
}
- DBG(LABEL, dbgprint("partition %zu assigned to BSD", i + 1));
+ DBG(LABEL, ul_debug("partition %zu assigned to BSD", i + 1));
return 0;
}
+ BSD_LABELOFFSET], sizeof(*d));
if (d->d_magic != BSD_DISKMAGIC || d->d_magic2 != BSD_DISKMAGIC) {
- DBG(LABEL, dbgprint("not found magic"));
+ DBG(LABEL, ul_debug("not found magic"));
return -1;
}
cxt->label->nparts_cur = d->d_npartitions;
cxt->label->nparts_max = BSD_MAXPARTITIONS;
- DBG(LABEL, dbgprint("read BSD label"));
+ DBG(LABEL, ul_debug("read BSD label"));
return 0;
}
if (!cxt)
return NULL;
- DBG(LABEL, dbgprint("new context %p allocated", cxt));
+ DBG(LABEL, ul_debug("new context %p allocated", cxt));
cxt->dev_fd = -1;
/*
if (!cxt)
return NULL;
- DBG(LABEL, dbgprint("new context %p allocated", cxt));
+ DBG(LABEL, ul_debug("new context %p allocated", cxt));
cxt->dev_fd = parent->dev_fd;
cxt->parent = parent;
}
if (lb) {
- DBG(LABEL, dbgprint("probing for nested %s", lb->name));
+ DBG(LABEL, ul_debug("probing for nested %s", lb->name));
cxt->label = lb;
if (lb->op->probe(cxt) == 1)
__fdisk_context_switch_label(cxt, lb);
else {
- DBG(LABEL, dbgprint("not found %s label", lb->name));
+ DBG(LABEL, ul_debug("not found %s label", lb->name));
if (lb->op->deinit)
lb->op->deinit(lb);
cxt->label = NULL;
&& strcmp(cxt->labels[i]->name, name) == 0)
return cxt->labels[i];
- DBG(LABEL, dbgprint("failed to found %s label driver\n", name));
+ DBG(LABEL, ul_debug("failed to found %s label driver\n", name));
return NULL;
}
if (!lb || !cxt)
return -EINVAL;
if (lb->disabled) {
- DBG(LABEL, dbgprint("*** attempt to switch to disabled label %s -- ignore!", lb->name));
+ DBG(LABEL, ul_debug("*** attempt to switch to disabled label %s -- ignore!", lb->name));
return -EINVAL;
}
cxt->label = lb;
- DBG(LABEL, dbgprint("--> switching context to %s!", lb->name));
+ DBG(LABEL, ul_debug("--> switching context to %s!", lb->name));
return 0;
}
{
size_t i;
- DBG(CONTEXT, dbgprint("*** resetting context %p", cxt));
+ DBG(CONTEXT, ul_debug("*** resetting context %p", cxt));
/* reset drives' private data */
for (i = 0; i < cxt->nlabels; i++)
if (fdisk_dev_has_disklabel(cxt) || cxt->dev_fd < 0)
return -EINVAL;
#ifdef HAVE_LIBBLKID
- DBG(LABEL, dbgprint("wipe check: initialize libblkid prober"));
+ DBG(LABEL, ul_debug("wipe check: initialize libblkid prober"));
pr = blkid_new_probe();
if (!pr)
{
int fd;
- DBG(CONTEXT, dbgprint("assigning device %s", fname));
+ DBG(CONTEXT, ul_debug("assigning device %s", fname));
assert(cxt);
reset_context(cxt);
if (!fdisk_context_listonly(cxt) && !fdisk_dev_has_disklabel(cxt))
warn_wipe(cxt);
- DBG(CONTEXT, dbgprint("context %p initialized for %s [%s]",
+ DBG(CONTEXT, ul_debug("context %p initialized for %s [%s]",
cxt, fname,
readonly ? "READ-ONLY" : "READ-WRITE"));
return 0;
fail:
- DBG(CONTEXT, dbgprint("failed to assign device"));
+ DBG(CONTEXT, ul_debug("failed to assign device"));
return -errno;
}
if (!cxt)
return;
- DBG(CONTEXT, dbgprint("freeing context %p for %s", cxt, cxt->dev_path));
+ DBG(CONTEXT, ul_debug("freeing context %p for %s", cxt, cxt->dev_path));
reset_context(cxt);
/* deallocate label's private stuff */
else if (strcmp(str, "sector") == 0 || strcmp(str, "sectors") == 0)
cxt->display_in_cyl_units = 0;
- DBG(CONTEXT, dbgprint("display unit: %s", fdisk_context_get_unit(cxt, 0)));
+ DBG(CONTEXT, ul_debug("display unit: %s", fdisk_context_get_unit(cxt, 0)));
return 0;
}
if (!pe)
return;
- DBG(LABEL, dbgprint("DOS: setting %zu partition to %s", i,
+ DBG(LABEL, ul_debug("DOS: setting %zu partition to %s", i,
changed ? "changed" : "unchnaged"));
pe->changed = changed ? 1 : 0;
if (!buf)
return -ENOMEM;
- DBG(LABEL, dbgprint("DOS: reading pte %zu sector buffer %p", pno, buf));
+ DBG(LABEL, ul_debug("DOS: reading pte %zu sector buffer %p", pno, buf));
pe->offset = offset;
pe->sectorbuffer = buf;
assert(cxt->label);
assert(fdisk_is_disklabel(cxt, DOS));
- DBG(LABEL, dbgprint("DOS: initialize, first sector buffer %p", cxt->firstsector));
+ DBG(LABEL, ul_debug("DOS: initialize, first sector buffer %p", cxt->firstsector));
cxt->label->nparts_max = 4; /* default, unlimited number of logical */
struct pte *pe = &l->ptes[i];
if (pe->private_sectorbuffer && pe->sectorbuffer) {
- DBG(LABEL, dbgprint("DOS: freeing pte %zu sector buffer %p",
+ DBG(LABEL, ul_debug("DOS: freeing pte %zu sector buffer %p",
i, pe->sectorbuffer));
free(pe->sectorbuffer);
}
if (!pe)
return -EINVAL;
- DBG(LABEL, dbgprint("DOS: delete partiton %zu (max=%zu)", partnum,
+ DBG(LABEL, ul_debug("DOS: delete partiton %zu (max=%zu)", partnum,
cxt->label->nparts_max));
l = self_label(cxt);
/* Note that for the fifth partition (partnum == 4) we don't actually
decrement partitions. */
if (partnum < 4) {
- DBG(LABEL, dbgprint("--> delete primary"));
+ DBG(LABEL, ul_debug("--> delete primary"));
if (IS_EXTENDED(p->sys_ind) && partnum == l->ext_index) {
cxt->label->nparts_max = 4;
l->ptes[l->ext_index].ex_entry = NULL;
partition_set_changed(cxt, partnum, 1);
clear_partition(p);
} else if (!q->sys_ind && partnum > 4) {
- DBG(LABEL, dbgprint("--> delete logical [last in the chain]"));
+ DBG(LABEL, ul_debug("--> delete logical [last in the chain]"));
--cxt->label->nparts_max;
--partnum;
clear_partition(l->ptes[partnum].ex_entry);
partition_set_changed(cxt, partnum, 1);
} else {
- DBG(LABEL, dbgprint("--> delete logical [move down]"));
+ DBG(LABEL, ul_debug("--> delete logical [move down]"));
if (partnum > 4) {
- DBG(LABEL, dbgprint(" --> delete %zu logical link", partnum));
+ DBG(LABEL, ul_debug(" --> delete %zu logical link", partnum));
p = l->ptes[partnum - 1].ex_entry;
*p = *q;
dos_partition_set_start(p, dos_partition_get_start(q));
partition_set_changed(cxt, partnum - 1, 1);
} else if (cxt->label->nparts_max > 5) {
- DBG(LABEL, dbgprint(" --> delete first logical link"));
+ DBG(LABEL, ul_debug(" --> delete first logical link"));
pe = &l->ptes[5]; /* second logical */
if (pe->pt_entry) /* prevent SEGFAULT */
}
if (cxt->label->nparts_max > 5) {
- DBG(LABEL, dbgprint(" --> move ptes"));
+ DBG(LABEL, ul_debug(" --> move ptes"));
cxt->label->nparts_max--;
if (l->ptes[partnum].private_sectorbuffer) {
- DBG(LABEL, dbgprint(" --> freeing pte %zu sector buffer %p",
+ DBG(LABEL, ul_debug(" --> freeing pte %zu sector buffer %p",
partnum, l->ptes[partnum].sectorbuffer));
free(l->ptes[partnum].sectorbuffer);
}
while (partnum < cxt->label->nparts_max) {
- DBG(LABEL, dbgprint(" --> moving pte %zu <-- %zu", partnum, partnum + 1));
+ DBG(LABEL, ul_debug(" --> moving pte %zu <-- %zu", partnum, partnum + 1));
l->ptes[partnum] = l->ptes[partnum + 1];
partnum++;
}
memset(&l->ptes[partnum], 0, sizeof(struct pte));
} else {
- DBG(LABEL, dbgprint(" --> the only logical: clear only"));
+ DBG(LABEL, ul_debug(" --> the only logical: clear only"));
clear_partition(l->ptes[partnum].pt_entry);
cxt->label->nparts_max--;
if (partnum == 4) {
- DBG(LABEL, dbgprint(" --> clear last logical"));
+ DBG(LABEL, ul_debug(" --> clear last logical"));
if (l->ptes[partnum].private_sectorbuffer) {
- DBG(LABEL, dbgprint(" --> freeing pte %zu sector buffer %p",
+ DBG(LABEL, ul_debug(" --> freeing pte %zu sector buffer %p",
partnum, l->ptes[partnum].sectorbuffer));
free(l->ptes[partnum].sectorbuffer);
}
return;
}
- DBG(LABEL, dbgprint("DOS: Reading extended %zu", ext));
+ DBG(LABEL, ul_debug("DOS: Reading extended %zu", ext));
while (IS_EXTENDED (p->sys_ind)) {
struct pte *pe = self_pte(cxt, cxt->label->nparts_max);
assert(cxt->label);
assert(fdisk_is_disklabel(cxt, DOS));
- DBG(LABEL, dbgprint("DOS: creating new disklabel"));
+ DBG(LABEL, ul_debug("DOS: creating new disklabel"));
/* random disk signature */
random_get_bytes(&id, sizeof(id));
assert(cxt->label);
assert(fdisk_is_disklabel(cxt, DOS));
- DBG(LABEL, dbgprint("DOS: setting Id"));
+ DBG(LABEL, ul_debug("DOS: setting Id"));
l = self_label(cxt);
old = mbr_get_id(cxt->firstsector);
*ps = ss;
}
- DBG(LABEL, dbgprint("DOS PT geometry: heads=%u, sectors=%u", *ph, *ps));
+ DBG(LABEL, ul_debug("DOS PT geometry: heads=%u, sectors=%u", *ph, *ps));
}
static int dos_reset_alignment(struct fdisk_context *cxt)
/* overwrite necessary stuff by DOS deprecated stuff */
if (is_dos_compatible(cxt)) {
- DBG(LABEL, dbgprint("DOS: reseting alignemnt for DOS-comaptiblem PT"));
+ DBG(LABEL, ul_debug("DOS: reseting alignemnt for DOS-comaptiblem PT"));
if (cxt->geom.sectors)
cxt->first_lba = cxt->geom.sectors; /* usually 63 */
struct dos_partition *p;
sector_t offset;
- DBG(LABEL, dbgprint("DOS: setting partition %d%s, start=%zu, stop=%zu, sysid=%02x",
+ DBG(LABEL, ul_debug("DOS: setting partition %d%s, start=%zu, stop=%zu, sysid=%02x",
i, doext ? " [extended]" : "",
(size_t) start, (size_t) stop, sysid));
*start = dflt;
else if (pa && pa->start) {
- DBG(LABEL, dbgprint("DOS: start: wanted=%ju, low=%ju, limit=%ju",
+ DBG(LABEL, ul_debug("DOS: start: wanted=%ju, low=%ju, limit=%ju",
(uintmax_t) pa->start, (uintmax_t) low, (uintmax_t) limit));
*start = pa->start;
if (*start < low || *start > limit) {
first[cxt->label->nparts_max],
last[cxt->label->nparts_max];
- DBG(LABEL, dbgprint("DOS: adding partition %zu", n));
+ DBG(LABEL, ul_debug("DOS: adding partition %zu", n));
sys = pa && pa->type ? pa->type->type : MBR_LINUX_DATA_PARTITION;
pe4->sectorbuffer = calloc(1, cxt->sector_size);
if (!pe4->sectorbuffer)
return -ENOMEM;
- DBG(LABEL, dbgprint("DOS: add partition, sector buffer %p", pe4->sectorbuffer));
+ DBG(LABEL, ul_debug("DOS: add partition, sector buffer %p", pe4->sectorbuffer));
pe4->private_sectorbuffer = 1;
pe4->pt_entry = mbr_get_partition(pe4->sectorbuffer, 0);
pe4->ex_entry = pe4->pt_entry + 1;
pe->sectorbuffer = calloc(1, cxt->sector_size);
if (!pe->sectorbuffer)
return -ENOMEM;
- DBG(LABEL, dbgprint("DOS: add logical, sector buffer %p", pe->sectorbuffer));
+ DBG(LABEL, ul_debug("DOS: add logical, sector buffer %p", pe->sectorbuffer));
pe->private_sectorbuffer = 1;
pe->pt_entry = mbr_get_partition(pe->sectorbuffer, 0);
pe->ex_entry = pe->pt_entry + 1;
return rc;
}
- DBG(LABEL, dbgprint("DOS: writting to sector %ju", (uintmax_t) secno));
+ DBG(LABEL, ul_debug("DOS: writting to sector %ju", (uintmax_t) secno));
if (write(cxt->dev_fd, buf, cxt->sector_size) != (ssize_t) cxt->sector_size)
return -errno;
#include "list.h"
#include "tt.h"
#include "debug.h"
+#include <stdio.h>
+#include <stdarg.h>
/* features */
#define CONFIG_LIBFDISK_ASSERT
-#define CONFIG_LIBFDISK_DEBUG
#ifdef CONFIG_LIBFDISK_ASSERT
#include <assert.h>
/*
* Debug
*/
-#if defined(TEST_PROGRAM) && !defined(LIBFDISK_DEBUG)
-#define CONFIG_LIBFDISK_DEBUG
-#endif
-
-# include <stdio.h>
-# include <stdarg.h>
-
-/* fdisk debugging flags/options */
#define FDISK_DEBUG_INIT (1 << 1)
#define FDISK_DEBUG_CONTEXT (1 << 2)
#define FDISK_DEBUG_TOPOLOGY (1 << 3)
#define FDISK_DEBUG_TAB (1 << 9)
#define FDISK_DEBUG_ALL 0xFFFF
-#define FDISK_DEF_FLAG(m) UL_DEFINE_FLAG(FDISK_DEBUG_, m)
-
-#define DBG(m, x) do { __UL_DBG(libfdisk, FDISK_DEBUG_, m, x); } while (0)
-
-# define ON_DBG(m, x) do { \
- if ((FDISK_DEBUG_ ## m) & libfdisk_debug_mask) { \
- x; \
- } \
- } while (0)
-
-# define DBG_FLUSH do { \
- if (libfdisk_debug_mask && \
- libfdisk_debug_mask != FDISK_DEBUG_INIT) \
- fflush(stderr); \
- } while(0)
-
-static inline void __attribute__ ((__format__ (__printf__, 1, 2)))
-dbgprint(const char *mesg, ...)
-{
- va_list ap;
- va_start(ap, mesg);
- vfprintf(stderr, mesg, ap);
- va_end(ap);
- fputc('\n', stderr);
-}
-
UL_DEBUG_DECLARE_MASK(libfdisk);
+#define DBG(m, x) __UL_DBG(libfdisk, FDISK_DEBUG_, m, x)
+#define ON_DBG(m, x) __UL_DBG_CALL(libfdisk, FDISK_DEBUG_, m, x)
+#define DBG_FLUSH __UL_DBG_FLUSH(libfdisk, FDISK_DEBUG_)
#ifdef TEST_PROGRAM
struct fdisk_test {
return start > end ? 0 : end - start + 1ULL;
}
-#ifdef CONFIG_LIBFDISK_DEBUG
/* prints UUID in the real byte order! */
-static void dbgprint_uuid(const char *mesg, struct gpt_guid *guid)
+static void gpt_debug_uuid(const char *mesg, struct gpt_guid *guid)
{
const unsigned char *uuid = (unsigned char *) guid;
uuid[8], uuid[9],
uuid[10], uuid[11], uuid[12], uuid[13], uuid[14],uuid[15]);
}
-#endif
/*
* UUID is traditionally 16 byte big-endian array, except Intel EFI
/* check if first and last usable LBA make sense */
if (lu < fu) {
- DBG(LABEL, dbgprint("error: header last LBA is before first LBA"));
+ DBG(LABEL, 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, dbgprint("error: header LBAs are after the disk's last LBA"));
+ DBG(LABEL, 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, dbgprint("error: header outside of usable range"));
+ DBG(LABEL, ul_debug("error: header outside of usable range"));
goto done;
}
else
free(ents);
- DBG(LABEL, dbgprint("found valid GPT Header on LBA %ju", lba));
+ DBG(LABEL, ul_debug("found valid GPT Header on LBA %ju", lba));
return header;
invalid:
free(header);
free(ents);
- DBG(LABEL, dbgprint("read GPT Header on LBA %ju failed", lba));
+ DBG(LABEL, ul_debug("read GPT Header on LBA %ju failed", lba));
return NULL;
}
partition_unused(&e[j]))
continue;
if (partition_overlap(&e[i], &e[j])) {
- DBG(LABEL, dbgprint("GPT partitions overlap detected [%u vs. %u]", i, j));
+ DBG(LABEL, ul_debug("GPT partitions overlap detected [%u vs. %u]", i, j));
return i + 1;
}
}
if (!mbr_type)
goto failed;
- DBG(LABEL, dbgprint("found a %s MBR", mbr_type == GPT_MBR_PROTECTIVE ?
+ DBG(LABEL, ul_debug("found a %s MBR", mbr_type == GPT_MBR_PROTECTIVE ?
"protective" : "hybrid"));
/* primary header */
cxt->label->nparts_cur = partitions_in_use(gpt->pheader, gpt->ents);
return 1;
failed:
- DBG(LABEL, dbgprint("GPT probe failed"));
+ DBG(LABEL, ul_debug("GPT probe failed"));
gpt_deinit(cxt->label);
return 0;
}
else if (gpt_write_pmbr(cxt) != 0)
goto err1;
- DBG(LABEL, dbgprint("GPT write success"));
+ DBG(LABEL, ul_debug("GPT write success"));
return 0;
err0:
- DBG(LABEL, dbgprint("GPT write failed: incorrect input"));
+ DBG(LABEL, ul_debug("GPT write failed: incorrect input"));
errno = EINVAL;
return -EINVAL;
err1:
- DBG(LABEL, dbgprint("GPT write failed: %m"));
+ DBG(LABEL, ul_debug("GPT write failed: %m"));
return -errno;
}
static void gpt_entry_set_type(struct gpt_entry *e, struct gpt_guid *uuid)
{
e->type = *uuid;
- DBG(LABEL, dbgprint_uuid("new type", &(e->type)));
+ DBG(LABEL, gpt_debug_uuid("new type", &(e->type)));
}
/*
assert(cxt->label);
assert(fdisk_is_disklabel(cxt, GPT));
- DBG(LABEL, dbgprint("GPT new partition: partno=%zu, start=%ju, end=%ju",
+ DBG(LABEL, ul_debug("GPT new partition: partno=%zu, start=%ju, end=%ju",
partnum, fsect, lsect));
gpt = self_label(cxt);
rc = fdisk_partition_next_partno(pa, cxt, &partnum);
if (rc) {
- DBG(LABEL, dbgprint("GPT failed to get next partno"));
+ DBG(LABEL, ul_debug("GPT failed to get next partno"));
return rc;
}
if (!partition_unused(&ents[partnum])) {
assert(cxt->label);
assert(fdisk_is_disklabel(cxt, GPT));
- DBG(LABEL, dbgprint("UUID change requested partno=%zu", i));
+ DBG(LABEL, ul_debug("UUID change requested partno=%zu", i));
gpt = self_label(cxt);
assert(cxt->label);
assert(fdisk_is_disklabel(cxt, GPT));
- DBG(LABEL, dbgprint("NAME change requested partno=%zu", i));
+ DBG(LABEL, ul_debug("NAME change requested partno=%zu", i));
gpt = self_label(cxt);
assert(cxt->label);
assert(fdisk_is_disklabel(cxt, GPT));
- DBG(LABEL, dbgprint("GPT entry attribute change requested partno=%zu", i));
+ DBG(LABEL, ul_debug("GPT entry attribute change requested partno=%zu", i));
gpt = self_label(cxt);
if ((uint32_t) i >= le32_to_cpu(gpt->pheader->npartition_entries))
if (!lb->op->probe)
continue;
if (lb->disabled) {
- DBG(LABEL, dbgprint("%s disabled -- ignore", lb->name));
+ DBG(LABEL, ul_debug("%s disabled -- ignore", lb->name));
continue;
}
- DBG(LABEL, dbgprint("probing for %s", lb->name));
+ DBG(LABEL, ul_debug("probing for %s", lb->name));
cxt->label = lb;
rc = lb->op->probe(cxt);
return 0;
}
- DBG(LABEL, dbgprint("no label found"));
+ DBG(LABEL, ul_debug("no label found"));
return 1; /* not found */
}
if (haslabel && !cxt->parent)
fdisk_reset_device_properties(cxt);
- DBG(LABEL, dbgprint("create a new %s label", lb->name));
+ DBG(LABEL, ul_debug("create a new %s label", lb->name));
return cxt->label->op->create(cxt);
}
if (!cxt->label->op->locate)
return -ENOSYS;
- DBG(LABEL, dbgprint("locating %d chunk of %s.", n, cxt->label->name));
+ DBG(LABEL, ul_debug("locating %d chunk of %s.", n, cxt->label->name));
return cxt->label->op->locate(cxt, n, name, offset, size);
}
if (!cxt->label->op->get_id)
return -ENOSYS;
- DBG(LABEL, dbgprint("asking for disk %s ID", cxt->label->name));
+ DBG(LABEL, ul_debug("asking for disk %s ID", cxt->label->name));
return cxt->label->op->get_id(cxt, id);
}
if (!cxt->label->op->set_id)
return -ENOSYS;
- DBG(LABEL, dbgprint("setting %s disk ID", cxt->label->name));
+ DBG(LABEL, ul_debug("setting %s disk ID", cxt->label->name));
return cxt->label->op->set_id(cxt);
}
if (!cxt->label->op->part_set_type)
return -ENOSYS;
- DBG(LABEL, dbgprint("partition: %zd: set type", partnum));
+ DBG(LABEL, ul_debug("partition: %zd: set type", partnum));
return cxt->label->op->part_set_type(cxt, partnum, t);
}
rc = cxt->label->op->part_toggle_flag(cxt, partnum, flag);
- DBG(LABEL, dbgprint("partition: %zd: toggle: 0x%04lx [rc=%d]", partnum, flag, rc));
+ DBG(LABEL, ul_debug("partition: %zd: toggle: 0x%04lx [rc=%d]", partnum, flag, rc));
return rc;
}
{
assert(lb);
- DBG(LABEL, dbgprint("%s label %s",
+ DBG(LABEL, ul_debug("%s label %s",
lb->name,
disabled ? "DISABLED" : "ENABLED"));
lb->disabled = disabled ? 1 : 0;
INIT_LIST_HEAD(&pa->parts);
pa->partno = FDISK_EMPTY_PARTNO;
pa->parent_partno = FDISK_EMPTY_PARTNO;
- DBG(PART, dbgprint("new %p", pa));
+ DBG(PART, ul_debug("new %p", pa));
return pa;
}
pa->refcount--;
if (pa->refcount <= 0) {
- DBG(PART, dbgprint("free %p", pa));
+ DBG(PART, ul_debug("free %p", pa));
fdisk_reset_partition(pa);
list_del(&pa->parts);
free(pa);
if (pa && pa->partno_follow_default) {
size_t i;
- DBG(LABEL, dbgprint("next partno (follow default)"));
+ DBG(LABEL, ul_debug("next partno (follow default)"));
for (i = 0; i < cxt->label->nparts_max; i++) {
if (!fdisk_is_partition_used(cxt, i)) {
} else if (pa && pa->partno != FDISK_EMPTY_PARTNO) {
- DBG(LABEL, dbgprint("next partno (specified=%zu)", pa->partno));
+ DBG(LABEL, ul_debug("next partno (specified=%zu)", pa->partno));
if (pa->partno >= cxt->label->nparts_max)
return -ERANGE;
if (fdisk_missing_geometry(cxt))
return -EINVAL;
- DBG(LABEL, dbgprint("adding new partition (start=%ju, end=%ju, size=%ju, "
+ DBG(LABEL, ul_debug("adding new partition (start=%ju, end=%ju, size=%ju, "
"defaults(start=%s, end=%s, partno=%s)",
pa ? pa->start : 0,
pa ? pa->end : 0,
rc = cxt->label->op->add_part(cxt, pa);
- DBG(LABEL, dbgprint("add partition done (rc=%d)", rc));
+ DBG(LABEL, ul_debug("add partition done (rc=%d)", rc));
return rc;
}
if (!cxt->label->op->part_delete)
return -ENOSYS;
- DBG(LABEL, dbgprint("deleting %s partition number %zd",
+ DBG(LABEL, ul_debug("deleting %s partition number %zd",
cxt->label->name, partnum));
return cxt->label->op->part_delete(cxt, partnum);
}
t->type = type;
t->flags |= FDISK_PARTTYPE_UNKNOWN | FDISK_PARTTYPE_ALLOCATED;
- DBG(LABEL, dbgprint("allocated new unknown type [%p]", t));
+ DBG(LABEL, ul_debug("allocated new unknown type [%p]", t));
return t;
}
if (!fdisk_get_nparttypes(cxt))
return NULL;
- DBG(LABEL, dbgprint("parsing '%s' partition type", str));
+ DBG(LABEL, ul_debug("parsing '%s' partition type", str));
types = cxt->label->parttypes;
code = strtol(str, &end, 16);
if (errno || *end != '\0') {
- DBG(LABEL, dbgprint("parsing failed: %m"));
+ DBG(LABEL, ul_debug("parsing failed: %m"));
return NULL;
}
ret = fdisk_get_parttype_from_code(cxt, code);
ret = fdisk_new_unknown_parttype(code, typestr);
done:
- DBG(LABEL, dbgprint("returns '%s' partition type", ret->name));
+ DBG(LABEL, ul_debug("returns '%s' partition type", ret->name));
return ret;
}
void fdisk_free_parttype(struct fdisk_parttype *t)
{
if (t && (t->flags & FDISK_PARTTYPE_ALLOCATED)) {
- DBG(LABEL, dbgprint("freeing %p partition type", t));
+ DBG(LABEL, ul_debug("freeing %p partition type", t));
free(t->typestr);
free(t);
}
sgi_get_start_sector(cxt, Index[0]));
if (verbose && sgi_get_num_sectors(cxt, Index[0]) != lastblock)
- DBG(LABEL, dbgprint(
+ DBG(LABEL, ul_debug(
"entire disk partition=%ds, but disk=%ds",
sgi_get_num_sectors(cxt, Index[0]),
lastblock));
lastblock = sgi_get_num_sectors(cxt, Index[0]);
} else if (verbose) {
fdisk_info(cxt, _("Partition 11 should cover the entire disk."));
- DBG(LABEL, dbgprint("sysid=%d\tpartition=%d",
+ DBG(LABEL, ul_debug("sysid=%d\tpartition=%d",
sgi_get_sysid(cxt, Index[0]), Index[0]+1));
}
for (i=1, start=0; i<sortcount; i++) {
if (verbose && cylsize
&& (sgi_get_start_sector(cxt, Index[i]) % cylsize) != 0)
- DBG(LABEL, dbgprint("partition %d does not start on "
+ DBG(LABEL, ul_debug("partition %d does not start on "
"cylinder boundary.", Index[i]+1));
if (verbose && cylsize
&& sgi_get_num_sectors(cxt, Index[i]) % cylsize != 0)
- DBG(LABEL, dbgprint("partition %d does not end on "
+ DBG(LABEL, ul_debug("partition %d does not end on "
"cylinder boundary.", Index[i]+1));
/* We cannot handle several "entire disk" entries. */
if (cylsize && start % cylsize)
start += cylsize - (start % cylsize);
- DBG(LABEL, dbgprint("%2d:%12d\t%12d\t%12d", Index[i],
+ DBG(LABEL, ul_debug("%2d:%12d\t%12d\t%12d", Index[i],
sgi_get_start_sector(cxt, Index[i]),
sgi_get_num_sectors(cxt, Index[i]),
sgi_get_sysid(cxt, Index[i])));
if (!tb)
return NULL;
- DBG(TAB, dbgprint("alloc"));
+ DBG(TAB, ul_debug("alloc"));
tb->refcount = 1;
INIT_LIST_HEAD(&tb->parts);
return tb;
if (!tb)
return -EINVAL;
- DBG(TAB, dbgprint("reset"));
+ DBG(TAB, ul_debug("reset"));
while (!list_empty(&tb->parts)) {
struct fdisk_partition *pa = list_entry(tb->parts.next,
if (tb->refcount <= 0) {
fdisk_reset_table(tb);
- DBG(TAB, dbgprint("free"));
+ DBG(TAB, ul_debug("free"));
free(tb);
}
}
list_add_tail(&pa->parts, &tb->parts);
tb->nents++;
- DBG(TAB, dbgprint("add entry %p [start=%ju, end=%ju, size=%ju, %s %s %s]",
+ DBG(TAB, ul_debug("add entry %p [start=%ju, end=%ju, size=%ju, %s %s %s]",
pa, pa->start, pa->end, pa->size,
fdisk_partition_is_freespace(pa) ? "freespace" : "",
fdisk_partition_is_nested(pa) ? "nested" : "",
list_add(&pa->parts, &tb->parts);
tb->nents++;
- DBG(TAB, dbgprint("insert entry %p pre=%p [start=%ju, end=%ju, size=%ju, %s %s %s]",
+ DBG(TAB, ul_debug("insert entry %p pre=%p [start=%ju, end=%ju, size=%ju, %s %s %s]",
pa, poz ? poz : NULL, pa->start, pa->end, pa->size,
fdisk_partition_is_freespace(pa) ? "freespace" : "",
fdisk_partition_is_nested(pa) ? "nested" : "",
if (!tb || !pa)
return -EINVAL;
- DBG(TAB, dbgprint("remove entry %p", pa));
+ DBG(TAB, ul_debug("remove entry %p", pa));
list_del(&pa->parts);
INIT_LIST_HEAD(&pa->parts);
if (!cxt->label->op->get_part)
return -ENOSYS;
- DBG(LABEL, dbgprint("get table"));
+ DBG(LABEL, ul_debug("get table"));
if (!*tb && !(*tb = fdisk_new_table()))
return -ENOMEM;
}
}
if (!real_parent) {
- DBG(LABEL, dbgprint("not found freespace parent (partno=%ju)",
+ DBG(LABEL, ul_debug("not found freespace parent (partno=%ju)",
parent->partno));
fdisk_reset_iter(&itr, FDISK_ITER_FORWARD);
}
struct fdisk_partition *pa;
struct fdisk_iter itr;
- DBG(LABEL, dbgprint("get freespace"));
+ DBG(LABEL, ul_debug("get freespace"));
if (!cxt || !cxt->label || !tb)
return -EINVAL;
while (rc == 0 && fdisk_table_next_partition(parts, &itr, &pa) == 0) {
if (!pa->used || pa->wholedisk || fdisk_partition_is_nested(pa))
continue;
- DBG(LABEL, dbgprint("freespace analyze: partno=%zu, start=%ju, end=%ju",
+ DBG(LABEL, ul_debug("freespace analyze: partno=%zu, start=%ju, end=%ju",
pa->partno, pa->start, pa->end));
if (last + grain < pa->start) {
rc = table_add_freespace(cxt, *tb,
if (!cxt || !tb || !data)
return -EINVAL;
- DBG(TAB, dbgprint("generate string"));
+ DBG(TAB, ul_debug("generate string"));
*data = NULL;
if (!fdisk_table_get_nents(tb))
goto done;
}
- DBG(TAB, dbgprint(" string from part #%zu", pa->partno + 1));
+ DBG(TAB, ul_debug(" string from part #%zu", pa->partno + 1));
/* set data for the columns */
for (j = 0; j < ncols; j++) {
if (!tt_is_empty(tt))
rc = tt_print_table_to_string(tt, data);
else
- DBG(TAB, dbgprint("tt empty"));
+ DBG(TAB, ul_debug("tt empty"));
done:
if (org_cols != cols)
free(cols);
if (!cxt || !cxt->firstsector)
return;
- DBG(CONTEXT, dbgprint("zeroize in-memory first sector buffer"));
+ DBG(CONTEXT, ul_debug("zeroize in-memory first sector buffer"));
memset(cxt->firstsector, 0, cxt->sector_size);
}
assert(cxt);
assert(cxt->sector_size);
- DBG(TOPOLOGY, dbgprint("initialize first sector "
+ DBG(TOPOLOGY, ul_debug("initialize first sector "
"buffer [sector_size=%lu]", cxt->sector_size));
if (!cxt->firstsector) {
if (r != cxt->sector_size) {
if (!errno)
errno = EINVAL; /* probably too small file/device */
- DBG(TOPOLOGY, dbgprint("failed to read first sector %m"));
+ DBG(TOPOLOGY, ul_debug("failed to read first sector %m"));
return -errno;
}