summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2014-03-21 12:35:21 +0100
committerKarel Zak2014-03-21 12:35:21 +0100
commit881410671f24fc7910cfcec66f37abb94008bbfd (patch)
treee72c403befcca2cd89f86456eebc1dbe9b6273a6
parentlibblkid: use new debug functions (diff)
downloadkernel-qcow2-util-linux-881410671f24fc7910cfcec66f37abb94008bbfd.tar.gz
kernel-qcow2-util-linux-881410671f24fc7910cfcec66f37abb94008bbfd.tar.xz
kernel-qcow2-util-linux-881410671f24fc7910cfcec66f37abb94008bbfd.zip
libfdisk: use new debug functions
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--disk-utils/cfdisk.c58
-rw-r--r--disk-utils/fdisk-menu.c30
-rw-r--r--disk-utils/fdisk.c18
-rw-r--r--libfdisk/src/alignment.c32
-rw-r--r--libfdisk/src/ask.c22
-rw-r--r--libfdisk/src/bsd.c6
-rw-r--r--libfdisk/src/context.c28
-rw-r--r--libfdisk/src/dos.c54
-rw-r--r--libfdisk/src/fdiskP.h40
-rw-r--r--libfdisk/src/gpt.c38
-rw-r--r--libfdisk/src/label.c20
-rw-r--r--libfdisk/src/partition.c14
-rw-r--r--libfdisk/src/parttype.c10
-rw-r--r--libfdisk/src/sgi.c10
-rw-r--r--libfdisk/src/table.c26
-rw-r--r--libfdisk/src/utils.c6
16 files changed, 190 insertions, 222 deletions
diff --git a/disk-utils/cfdisk.c b/disk-utils/cfdisk.c
index 0b1641eb2..6a07ced25 100644
--- a/disk-utils/cfdisk.c
+++ b/disk-utils/cfdisk.c
@@ -172,7 +172,7 @@ static char *table_to_string(struct cfdisk *cf, struct fdisk_table *tb)
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);
@@ -189,7 +189,7 @@ static char *table_to_string(struct cfdisk *cf, struct fdisk_table *tb)
/* 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;
}
@@ -276,7 +276,7 @@ static int lines_refresh(struct cfdisk *cf)
assert(cf);
- DBG(FRONTEND, dbgprint("refreshing buffer"));
+ DBG(FRONTEND, ul_debug("refreshing buffer"));
free(cf->linesbuf);
free(cf->lines);
@@ -562,7 +562,7 @@ static void ui_clean_hint(void)
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);
}
@@ -582,7 +582,7 @@ static void menu_update_ignore(struct cfdisk *cf)
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';
@@ -621,7 +621,7 @@ static struct cfdisk_menu *menu_push(
assert(cf);
- DBG(FRONTEND, dbgprint("menu: new menu"));
+ DBG(FRONTEND, ul_debug("menu: new menu"));
m->prev = cf->menu;
m->items = items;
@@ -645,7 +645,7 @@ static struct cfdisk_menu *menu_pop(struct cfdisk *cf)
assert(cf);
- DBG(FRONTEND, dbgprint("menu: rem menu"));
+ DBG(FRONTEND, ul_debug("menu: rem menu"));
if (cf->menu) {
m = cf->menu->prev;
@@ -675,7 +675,7 @@ static int ui_init(struct cfdisk *cf __attribute__((__unused__)))
{
struct sigaction sa;
- DBG(FRONTEND, dbgprint("ui: init"));
+ DBG(FRONTEND, ul_debug("ui: init"));
/* setup SIGCHLD handler */
sigemptyset(&sa.sa_mask);
@@ -807,7 +807,7 @@ static void ui_draw_menuitem(struct cfdisk *cf,
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) {
@@ -836,7 +836,7 @@ static void ui_draw_menu(struct cfdisk *cf)
assert(cf);
assert(cf->menu);
- DBG(FRONTEND, dbgprint("ui: menu: draw start"));
+ DBG(FRONTEND, ul_debug("ui: menu: draw start"));
m = cf->menu;
@@ -891,7 +891,7 @@ static void ui_draw_menu(struct cfdisk *cf)
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)
@@ -941,7 +941,7 @@ static int ui_menu_move(struct cfdisk *cf, int key)
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)
{
@@ -1013,7 +1013,7 @@ static void ui_draw_partition(struct cfdisk *cf, size_t i)
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));
@@ -1053,7 +1053,7 @@ static int ui_draw_table(struct cfdisk *cf)
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);
@@ -1088,7 +1088,7 @@ static int ui_table_goto(struct cfdisk *cf, int where)
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;
@@ -1261,7 +1261,7 @@ static int ui_get_size(struct cfdisk *cf, const char *prompt, uintmax_t *res,
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();
@@ -1291,7 +1291,7 @@ static int ui_get_size(struct cfdisk *cf, const char *prompt, uintmax_t *res,
}
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;
@@ -1316,7 +1316,7 @@ static int ui_get_size(struct cfdisk *cf, const char *prompt, uintmax_t *res,
*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;
}
@@ -1328,7 +1328,7 @@ static struct fdisk_parttype *ui_get_parttype(struct cfdisk *cf,
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 */
@@ -1395,7 +1395,7 @@ done:
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;
}
@@ -1409,7 +1409,7 @@ static int ui_create_label(struct cfdisk *cf)
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 */
@@ -1456,7 +1456,7 @@ static int ui_create_label(struct cfdisk *cf)
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;
}
@@ -1550,17 +1550,17 @@ static int main_menu_action(struct cfdisk *cf, int key)
} 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();
@@ -1686,7 +1686,7 @@ static int ui_run(struct cfdisk *cf)
{
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);
@@ -1715,7 +1715,7 @@ static int ui_run(struct cfdisk *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:
@@ -1762,7 +1762,7 @@ static int ui_run(struct cfdisk *cf)
menu_pop(cf);
- DBG(FRONTEND, dbgprint("ui: end"));
+ DBG(FRONTEND, ul_debug("ui: end"));
return 0;
}
@@ -1849,6 +1849,6 @@ int main(int argc, char *argv[])
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;
}
diff --git a/disk-utils/fdisk-menu.c b/disk-utils/fdisk-menu.c
index d7b852deb..822761568 100644
--- a/disk-utils/fdisk-menu.c
+++ b/disk-utils/fdisk-menu.c
@@ -325,15 +325,15 @@ static int menu_detect_collisions(struct fdisk_context *cxt)
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();
}
}
@@ -414,18 +414,18 @@ int process_fdisk_menu(struct fdisk_context **cxt0)
}
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;
}
@@ -550,7 +550,7 @@ static int gpt_menu_cb(struct fdisk_context **cxt0,
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) {
@@ -608,7 +608,7 @@ static int dos_menu_cb(struct fdisk_context **cxt0,
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) {
@@ -681,13 +681,13 @@ static int sun_menu_cb(struct fdisk_context **cxt0,
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) {
@@ -736,7 +736,7 @@ static int sgi_menu_cb(struct fdisk_context **cxt0,
int rc = -EINVAL;
size_t n = 0;
- DBG(FRONTEND, dbgprint("enter SGI menu"));
+ DBG(FRONTEND, ul_debug("enter SGI menu"));
assert(cxt);
assert(ent);
@@ -782,7 +782,7 @@ static int bsd_menu_cb(struct fdisk_context **cxt0,
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':
@@ -814,7 +814,7 @@ static int geo_menu_cb(struct fdisk_context **cxt0,
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);
@@ -846,7 +846,7 @@ static int createlabel_menu_cb(struct fdisk_context **cxt0,
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);
diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c
index e003baf64..fa7f248cc 100644
--- a/disk-utils/fdisk.c
+++ b/disk-utils/fdisk.c
@@ -104,7 +104,7 @@ int get_user_reply(struct fdisk_context *cxt, const char *prompt,
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;
}
@@ -170,7 +170,7 @@ static int ask_number(struct fdisk_context *cxt,
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));
@@ -241,7 +241,7 @@ static int ask_offset(struct fdisk_context *cxt,
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)
@@ -271,7 +271,7 @@ static int ask_offset(struct fdisk_context *cxt,
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);
@@ -283,7 +283,7 @@ static int ask_offset(struct fdisk_context *cxt,
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) {
@@ -386,7 +386,7 @@ int ask_callback(struct fdisk_context *cxt, struct fdisk_ask *ask,
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:
{
@@ -396,7 +396,7 @@ int ask_callback(struct fdisk_context *cxt, struct fdisk_ask *ask,
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:
@@ -731,7 +731,7 @@ static void print_all_devices_pt(struct fdisk_context *cxt)
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];
@@ -741,7 +741,7 @@ static void print_all_devices_pt(struct fdisk_context *cxt)
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);
diff --git a/libfdisk/src/alignment.c b/libfdisk/src/alignment.c
index b0cd30e14..da6be8fb3 100644
--- a/libfdisk/src/alignment.c
+++ b/libfdisk/src/alignment.c
@@ -75,7 +75,7 @@ sector_t fdisk_align_lba(struct fdisk_context *cxt, sector_t lba, int direction)
}
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;
@@ -160,7 +160,7 @@ int fdisk_override_geometry(struct fdisk_context *cxt,
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));
@@ -183,7 +183,7 @@ int fdisk_save_user_geometry(struct fdisk_context *cxt,
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));
@@ -198,7 +198,7 @@ int fdisk_save_user_sector_size(struct fdisk_context *cxt,
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;
@@ -220,7 +220,7 @@ int fdisk_apply_user_device_properties(struct fdisk_context *cxt)
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;
@@ -240,11 +240,11 @@ int fdisk_apply_user_device_properties(struct fdisk_context *cxt)
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));
@@ -276,7 +276,7 @@ int fdisk_reset_device_properties(struct fdisk_context *cxt)
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);
@@ -300,7 +300,7 @@ int fdisk_discover_geometry(struct fdisk_context *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))
@@ -312,7 +312,7 @@ int fdisk_discover_geometry(struct fdisk_context *cxt)
/* 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));
@@ -327,9 +327,9 @@ int fdisk_discover_topology(struct fdisk_context *cxt)
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) {
@@ -361,9 +361,9 @@ int fdisk_discover_topology(struct fdisk_context *cxt)
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;
}
@@ -473,7 +473,7 @@ int fdisk_reset_alignment(struct fdisk_context *cxt)
if (!cxt)
return -EINVAL;
- DBG(TOPOLOGY, dbgprint("reseting alignment..."));
+ DBG(TOPOLOGY, ul_debug("reseting alignment..."));
/* default */
cxt->grain = fdisk_topology_get_grain(cxt);
@@ -484,7 +484,7 @@ int fdisk_reset_alignment(struct fdisk_context *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,
diff --git a/libfdisk/src/ask.c b/libfdisk/src/ask.c
index 8647817af..f82fc7b83 100644
--- a/libfdisk/src/ask.c
+++ b/libfdisk/src/ask.c
@@ -75,7 +75,7 @@ int fdisk_do_ask(struct fdisk_context *cxt, struct fdisk_ask *ask)
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" :
@@ -83,13 +83,13 @@ int fdisk_do_ask(struct fdisk_context *cxt, struct fdisk_ask *ask)
"?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;
}
@@ -291,7 +291,7 @@ int fdisk_ask_partnum(struct fdisk_context *cxt, size_t *partnum, int wantnew)
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",
@@ -327,7 +327,7 @@ int fdisk_ask_partnum(struct fdisk_context *cxt, size_t *partnum, int wantnew)
}
}
- 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) {
@@ -369,7 +369,7 @@ dont_ask:
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;
}
@@ -406,7 +406,7 @@ int fdisk_ask_number(struct fdisk_context *cxt,
*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;
}
@@ -452,7 +452,7 @@ int fdisk_ask_string(struct fdisk_context *cxt,
*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;
}
@@ -478,7 +478,7 @@ int fdisk_ask_yesno(struct fdisk_context *cxt,
*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;
}
@@ -519,7 +519,7 @@ int fdisk_ask_menu_set_result(struct fdisk_ask *ask, int key)
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;
}
@@ -611,7 +611,7 @@ int fdisk_ask_menu_add_item(struct fdisk_ask *ask, int key,
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;
}
diff --git a/libfdisk/src/bsd.c b/libfdisk/src/bsd.c
index a9ce650f2..3a4b0e4b6 100644
--- a/libfdisk/src/bsd.c
+++ b/libfdisk/src/bsd.c
@@ -168,7 +168,7 @@ static int bsd_assign_dos_partition(struct fdisk_context *cxt)
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;
}
@@ -697,7 +697,7 @@ static int bsd_readlabel(struct fdisk_context *cxt)
+ 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;
}
@@ -718,7 +718,7 @@ static int bsd_readlabel(struct fdisk_context *cxt)
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;
}
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c
index 1a702901a..e5ab01f99 100644
--- a/libfdisk/src/context.c
+++ b/libfdisk/src/context.c
@@ -12,7 +12,7 @@ struct fdisk_context *fdisk_new_context(void)
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;
/*
@@ -42,7 +42,7 @@ struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *parent,
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;
@@ -70,14 +70,14 @@ struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *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;
@@ -105,7 +105,7 @@ struct fdisk_label *fdisk_context_get_label(struct fdisk_context *cxt, const cha
&& 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;
}
@@ -143,11 +143,11 @@ int __fdisk_context_switch_label(struct fdisk_context *cxt,
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;
}
@@ -162,7 +162,7 @@ static void reset_context(struct fdisk_context *cxt)
{
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++)
@@ -204,7 +204,7 @@ static int warn_wipe(struct fdisk_context *cxt)
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)
@@ -255,7 +255,7 @@ int fdisk_context_assign_device(struct fdisk_context *cxt,
{
int fd;
- DBG(CONTEXT, dbgprint("assigning device %s", fname));
+ DBG(CONTEXT, ul_debug("assigning device %s", fname));
assert(cxt);
reset_context(cxt);
@@ -290,12 +290,12 @@ int fdisk_context_assign_device(struct fdisk_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;
}
@@ -329,7 +329,7 @@ void fdisk_free_context(struct fdisk_context *cxt)
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 */
@@ -430,7 +430,7 @@ int fdisk_context_set_unit(struct fdisk_context *cxt, const char *str)
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;
}
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c
index be73b805d..612f562a6 100644
--- a/libfdisk/src/dos.c
+++ b/libfdisk/src/dos.c
@@ -151,7 +151,7 @@ static void partition_set_changed(
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;
@@ -235,7 +235,7 @@ static int read_pte(struct fdisk_context *cxt, size_t pno, sector_t offset)
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;
@@ -275,7 +275,7 @@ static void dos_init(struct fdisk_context *cxt)
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 */
@@ -343,7 +343,7 @@ static void dos_deinit(struct fdisk_label *lb)
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);
}
@@ -369,7 +369,7 @@ static int dos_delete_partition(struct fdisk_context *cxt, size_t partnum)
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);
@@ -379,7 +379,7 @@ static int dos_delete_partition(struct fdisk_context *cxt, size_t partnum)
/* 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;
@@ -389,15 +389,15 @@ static int dos_delete_partition(struct fdisk_context *cxt, size_t partnum)
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));
@@ -405,7 +405,7 @@ static int dos_delete_partition(struct fdisk_context *cxt, size_t partnum)
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 */
@@ -417,28 +417,28 @@ static int dos_delete_partition(struct fdisk_context *cxt, size_t partnum)
}
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);
}
@@ -469,7 +469,7 @@ static void read_extended(struct fdisk_context *cxt, size_t ext)
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);
@@ -579,7 +579,7 @@ static int dos_create_disklabel(struct fdisk_context *cxt)
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));
@@ -611,7 +611,7 @@ static int dos_set_disklabel_id(struct fdisk_context *cxt)
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);
@@ -667,7 +667,7 @@ static void get_partition_table_geometry(struct fdisk_context *cxt,
*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)
@@ -678,7 +678,7 @@ 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 */
@@ -777,7 +777,7 @@ static void set_partition(struct fdisk_context *cxt,
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));
@@ -860,7 +860,7 @@ static int get_start_from_user( struct fdisk_context *cxt,
*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) {
@@ -912,7 +912,7 @@ static int add_partition(struct fdisk_context *cxt, size_t n,
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;
@@ -1093,7 +1093,7 @@ static int add_partition(struct fdisk_context *cxt, size_t n,
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;
@@ -1119,7 +1119,7 @@ static int add_logical(struct fdisk_context *cxt, struct fdisk_partition *pa)
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;
@@ -1459,7 +1459,7 @@ static int write_sector(struct fdisk_context *cxt, sector_t secno,
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;
diff --git a/libfdisk/src/fdiskP.h b/libfdisk/src/fdiskP.h
index a945ed3a7..7d2726a20 100644
--- a/libfdisk/src/fdiskP.h
+++ b/libfdisk/src/fdiskP.h
@@ -24,10 +24,11 @@
#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>
@@ -36,14 +37,6 @@
/*
* 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)
@@ -55,33 +48,10 @@
#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 {
diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c
index 32dcd3b54..84babf958 100644
--- a/libfdisk/src/gpt.c
+++ b/libfdisk/src/gpt.c
@@ -268,9 +268,8 @@ static uint64_t gpt_partition_size(const struct gpt_entry *e)
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;
@@ -283,7 +282,6 @@ static void dbgprint_uuid(const char *mesg, struct gpt_guid *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
@@ -766,20 +764,20 @@ static int gpt_check_lba_sanity(struct fdisk_context *cxt, struct gpt_header *he
/* 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;
}
@@ -849,13 +847,13 @@ static struct gpt_header *gpt_read_header(struct fdisk_context *cxt,
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;
}
@@ -978,7 +976,7 @@ static uint32_t partition_check_overlaps(struct gpt_header *header, struct gpt_e
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;
}
}
@@ -1173,7 +1171,7 @@ static int gpt_probe_label(struct fdisk_context *cxt)
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 */
@@ -1215,7 +1213,7 @@ static int gpt_probe_label(struct fdisk_context *cxt)
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;
}
@@ -1540,14 +1538,14 @@ static int gpt_write_disklabel(struct fdisk_context *cxt)
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;
}
@@ -1706,7 +1704,7 @@ static int gpt_delete_partition(struct fdisk_context *cxt,
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)));
}
/*
@@ -1726,7 +1724,7 @@ static int gpt_create_new_partition(struct fdisk_context *cxt,
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);
@@ -1785,7 +1783,7 @@ static int gpt_add_partition(
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])) {
@@ -2110,7 +2108,7 @@ int fdisk_gpt_partition_set_uuid(struct fdisk_context *cxt, size_t i)
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);
@@ -2156,7 +2154,7 @@ int fdisk_gpt_partition_set_name(struct fdisk_context *cxt, size_t i)
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);
@@ -2214,7 +2212,7 @@ static int gpt_toggle_partition_flag(
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))
diff --git a/libfdisk/src/label.c b/libfdisk/src/label.c
index d04363a1d..5fadb37c0 100644
--- a/libfdisk/src/label.c
+++ b/libfdisk/src/label.c
@@ -18,10 +18,10 @@ int fdisk_probe_labels(struct fdisk_context *cxt)
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);
@@ -37,7 +37,7 @@ int fdisk_probe_labels(struct fdisk_context *cxt)
return 0;
}
- DBG(LABEL, dbgprint("no label found"));
+ DBG(LABEL, ul_debug("no label found"));
return 1; /* not found */
}
@@ -260,7 +260,7 @@ int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name)
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);
}
@@ -273,7 +273,7 @@ int fdisk_locate_disklabel(struct fdisk_context *cxt, int n, const char **name,
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);
}
@@ -292,7 +292,7 @@ int fdisk_get_disklabel_id(struct fdisk_context *cxt, char **id)
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);
}
@@ -309,7 +309,7 @@ int fdisk_set_disklabel_id(struct fdisk_context *cxt)
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);
}
@@ -330,7 +330,7 @@ int fdisk_set_partition_type(struct fdisk_context *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);
}
@@ -369,7 +369,7 @@ int fdisk_partition_toggle_flag(struct fdisk_context *cxt,
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;
}
@@ -401,7 +401,7 @@ void fdisk_label_set_disabled(struct fdisk_label *lb, int disabled)
{
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;
diff --git a/libfdisk/src/partition.c b/libfdisk/src/partition.c
index 4b46eafb9..a5d5f9ac3 100644
--- a/libfdisk/src/partition.c
+++ b/libfdisk/src/partition.c
@@ -12,7 +12,7 @@ struct fdisk_partition *fdisk_new_partition(void)
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;
}
@@ -48,7 +48,7 @@ void fdisk_unref_partition(struct fdisk_partition *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);
@@ -271,7 +271,7 @@ int fdisk_partition_next_partno(
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)) {
@@ -283,7 +283,7 @@ int fdisk_partition_next_partno(
} 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;
@@ -505,7 +505,7 @@ int fdisk_add_partition(struct fdisk_context *cxt,
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,
@@ -516,7 +516,7 @@ int fdisk_add_partition(struct fdisk_context *cxt,
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;
}
@@ -536,7 +536,7 @@ int fdisk_delete_partition(struct fdisk_context *cxt, size_t partnum)
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);
}
diff --git a/libfdisk/src/parttype.c b/libfdisk/src/parttype.c
index 8a13d7211..830e6049e 100644
--- a/libfdisk/src/parttype.c
+++ b/libfdisk/src/parttype.c
@@ -86,7 +86,7 @@ struct fdisk_parttype *fdisk_new_unknown_parttype(unsigned int type,
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;
}
@@ -110,7 +110,7 @@ struct fdisk_parttype *fdisk_parse_parttype(
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;
@@ -120,7 +120,7 @@ struct fdisk_parttype *fdisk_parse_parttype(
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);
@@ -146,7 +146,7 @@ struct fdisk_parttype *fdisk_parse_parttype(
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;
}
@@ -159,7 +159,7 @@ done:
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);
}
diff --git a/libfdisk/src/sgi.c b/libfdisk/src/sgi.c
index c782ef3fa..d32b06b94 100644
--- a/libfdisk/src/sgi.c
+++ b/libfdisk/src/sgi.c
@@ -567,14 +567,14 @@ static int verify_disklabel(struct fdisk_context *cxt, int verbose)
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++) {
@@ -582,12 +582,12 @@ static int verify_disklabel(struct fdisk_context *cxt, int verbose)
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. */
@@ -623,7 +623,7 @@ static int verify_disklabel(struct fdisk_context *cxt, int verbose)
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])));
diff --git a/libfdisk/src/table.c b/libfdisk/src/table.c
index dfa5dc80e..5867e1e7a 100644
--- a/libfdisk/src/table.c
+++ b/libfdisk/src/table.c
@@ -18,7 +18,7 @@ struct fdisk_table *fdisk_new_table(void)
if (!tb)
return NULL;
- DBG(TAB, dbgprint("alloc"));
+ DBG(TAB, ul_debug("alloc"));
tb->refcount = 1;
INIT_LIST_HEAD(&tb->parts);
return tb;
@@ -38,7 +38,7 @@ int fdisk_reset_table(struct fdisk_table *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,
@@ -78,7 +78,7 @@ void fdisk_unref_table(struct fdisk_table *tb)
if (tb->refcount <= 0) {
fdisk_reset_table(tb);
- DBG(TAB, dbgprint("free"));
+ DBG(TAB, ul_debug("free"));
free(tb);
}
}
@@ -192,7 +192,7 @@ int fdisk_table_add_partition(struct fdisk_table *tb, struct fdisk_partition *pa
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" : "",
@@ -216,7 +216,7 @@ static int table_insert_partition(
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" : "",
@@ -244,7 +244,7 @@ int fdisk_table_remove_partition(struct fdisk_table *tb, struct fdisk_partition
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);
@@ -273,7 +273,7 @@ int fdisk_get_partitions(struct fdisk_context *cxt, struct fdisk_table **tb)
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;
@@ -391,7 +391,7 @@ static int table_add_freespace(
}
}
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);
}
@@ -469,7 +469,7 @@ int fdisk_get_freespaces(struct fdisk_context *cxt, struct fdisk_table **tb)
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;
@@ -488,7 +488,7 @@ int fdisk_get_freespaces(struct fdisk_context *cxt, struct fdisk_table **tb)
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,
@@ -548,7 +548,7 @@ int fdisk_table_to_string(struct fdisk_table *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))
@@ -583,7 +583,7 @@ int fdisk_table_to_string(struct fdisk_table *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++) {
@@ -602,7 +602,7 @@ int fdisk_table_to_string(struct fdisk_table *tb,
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);
diff --git a/libfdisk/src/utils.c b/libfdisk/src/utils.c
index 20b8cf7bb..9032d65bf 100644
--- a/libfdisk/src/utils.c
+++ b/libfdisk/src/utils.c
@@ -13,7 +13,7 @@ void fdisk_zeroize_firstsector(struct fdisk_context *cxt)
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);
}
@@ -24,7 +24,7 @@ int fdisk_read_firstsector(struct fdisk_context *cxt)
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) {
@@ -39,7 +39,7 @@ int fdisk_read_firstsector(struct fdisk_context *cxt)
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;
}