]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: clean up debug output
authorKarel Zak <kzak@redhat.com>
Fri, 21 Mar 2014 12:33:37 +0000 (13:33 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 21 Mar 2014 12:33:37 +0000 (13:33 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/alignment.c
libfdisk/src/ask.c
libfdisk/src/context.c
libfdisk/src/fdiskP.h
libfdisk/src/label.c
libfdisk/src/partition.c
libfdisk/src/parttype.c
libfdisk/src/table.c
libfdisk/src/utils.c

index da6be8fb3b46be98b82a00b2a79bd711bc45a990..a456b98b5c001b0bcb956ea4858c6ebfe9510e0c 100644 (file)
@@ -75,7 +75,7 @@ sector_t fdisk_align_lba(struct fdisk_context *cxt, sector_t lba, int direction)
        }
 
        if (lba != res)
-               DBG(TOPOLOGY, ul_debug("LBA %ju -aligned-to-> %ju",
+               DBG(CXT, ul_debugobj(cxt, "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, ul_debug("override C/H/S: %u/%u/%u",
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("user C/H/S: %u/%u/%u",
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("user phy/log sector size: %u/%u", phy, log));
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("appling user device properties"));
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("new C/H/S: %u/%u/%u",
+       DBG(CXT, ul_debugobj(cxt, "new C/H/S: %u/%u/%u",
                (unsigned) cxt->geom.cylinders,
                (unsigned) cxt->geom.heads,
                (unsigned) cxt->geom.sectors));
-       DBG(TOPOLOGY, ul_debug("new log/phy sector size: %u/%u",
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("*** reseting device properties"));
+       DBG(CXT, ul_debugobj(cxt, "*** 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, ul_debug("%s: discovering geometry...", cxt->dev_path));
+       DBG(CXT, ul_debugobj(cxt, "%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, ul_debug("result: C/H/S: %u/%u/%u",
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("%s: discovering topology...", cxt->dev_path));
+       DBG(CXT, ul_debugobj(cxt, "%s: discovering topology...", cxt->dev_path));
 #ifdef HAVE_LIBBLKID
-       DBG(TOPOLOGY, ul_debug("initialize libblkid prober"));
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("result: log/phy sector size: %ld/%ld",
+       DBG(CXT, ul_debugobj(cxt, "result: log/phy sector size: %ld/%ld",
                        cxt->sector_size, cxt->phy_sector_size));
-        DBG(TOPOLOGY, ul_debug("result: fdisk/min/optimal io: %ld/%ld/%ld",
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("reseting alignment..."));
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("%s alignment reseted to: "
+       DBG(CXT, ul_debugobj(cxt, "%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,
index f82fc7b83b4ebf1c0b01504de645169f6aca8248..56594ef3095b727ae5513b551d75ee4175669acc 100644 (file)
@@ -8,7 +8,9 @@ static void fdisk_ask_menu_reset_items(struct fdisk_ask *ask);
 
 struct fdisk_ask *fdisk_new_ask(void)
 {
-       return calloc(1, sizeof(struct fdisk_ask));
+       struct fdisk_ask *ask = calloc(1, sizeof(struct fdisk_ask));
+       DBG(ASK, ul_debugobj(ask, "alloc"));
+       return ask;
 }
 
 void fdisk_reset_ask(struct fdisk_ask *ask)
@@ -16,6 +18,8 @@ void fdisk_reset_ask(struct fdisk_ask *ask)
        assert(ask);
        free(ask->query);
 
+       DBG(ASK, ul_debugobj(ask, "reset"));
+
        if (fdisk_is_ask(ask, MENU))
                fdisk_ask_menu_reset_items(ask);
 
@@ -27,6 +31,7 @@ void fdisk_free_ask(struct fdisk_ask *ask)
        if (!ask)
                return;
        fdisk_reset_ask(ask);
+       DBG(ASK, ul_debugobj(ask, "free"));
        free(ask);
 }
 
@@ -75,7 +80,7 @@ int fdisk_do_ask(struct fdisk_context *cxt, struct fdisk_ask *ask)
        assert(ask);
        assert(cxt);
 
-       DBG(ASK, ul_debug("do_ask for '%s'",
+       DBG(ASK, ul_debugobj(ask, "do_ask for '%s'",
                                ask->query ? ask->query :
                                ask->type == FDISK_ASKTYPE_INFO  ? "info" :
                                ask->type == FDISK_ASKTYPE_WARNX ? "warnx" :
@@ -83,13 +88,13 @@ int fdisk_do_ask(struct fdisk_context *cxt, struct fdisk_ask *ask)
                                "?nothing?"));
 
        if (!cxt->ask_cb) {
-               DBG(ASK, ul_debug("no ask callback specified!"));
+               DBG(ASK, ul_debugobj(ask, "no ask callback specified!"));
                return -EINVAL;
        }
 
        rc = cxt->ask_cb(cxt, ask, cxt->ask_data);
 
-       DBG(ASK, ul_debug("do_ask done [rc=%d]", rc));
+       DBG(ASK, ul_debugobj(ask, "do_ask done [rc=%d]", rc));
        return rc;
 }
 
@@ -327,7 +332,7 @@ int fdisk_ask_partnum(struct fdisk_context *cxt, size_t *partnum, int wantnew)
                }
        }
 
-       DBG(ASK, ul_debug("ask limits: low: %ju, high: %ju, default: %ju",
+       DBG(ASK, ul_debugobj(ask, "ask limits: low: %ju, high: %ju, default: %ju",
                                num->low, num->hig, num->dfl));
 
        if (!rc && !wantnew && num->low == num->hig) {
@@ -369,7 +374,7 @@ dont_ask:
                if (*partnum)
                        *partnum -= 1;
        }
-       DBG(ASK, ul_debug("result: %ju [rc=%d]\n", fdisk_ask_number_get_result(ask), rc));
+       DBG(ASK, ul_debugobj(ask, "result: %ju [rc=%d]\n", fdisk_ask_number_get_result(ask), rc));
        fdisk_free_ask(ask);
        return rc;
 }
@@ -405,8 +410,8 @@ int fdisk_ask_number(struct fdisk_context *cxt,
        if (!rc)
                *result = fdisk_ask_number_get_result(ask);
 
+       DBG(ASK, ul_debugobj(ask, "result: %ju [rc=%d]\n", *result, rc));
        fdisk_free_ask(ask);
-       DBG(ASK, ul_debug("result: %ju [rc=%d]\n", *result, rc));
        return rc;
 }
 
@@ -451,8 +456,8 @@ int fdisk_ask_string(struct fdisk_context *cxt,
        if (!rc)
                *result = fdisk_ask_string_get_result(ask);
 
+       DBG(ASK, ul_debugobj(ask, "result: %s [rc=%d]\n", *result, rc));
        fdisk_free_ask(ask);
-       DBG(ASK, ul_debug("result: %s [rc=%d]\n", *result, rc));
        return rc;
 }
 
@@ -477,8 +482,8 @@ int fdisk_ask_yesno(struct fdisk_context *cxt,
        if (!rc)
                *result = fdisk_ask_yesno_get_result(ask);
 
+       DBG(ASK, ul_debugobj(ask, "result: %d [rc=%d]\n", *result, rc));
        fdisk_free_ask(ask);
-       DBG(ASK, ul_debug("result: %d [rc=%d]\n", *result, rc));
        return rc;
 }
 
@@ -519,7 +524,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, ul_debug("menu result: %c\n", key));
+       DBG(ASK, ul_debugobj(ask, "menu result: %c\n", key));
        return 0;
 
 }
@@ -611,7 +616,7 @@ int fdisk_ask_menu_add_item(struct fdisk_ask *ask, int key,
                last->next = mi;
        }
 
-       DBG(ASK, ul_debug("new menu item: %c, \"%s\" (%s)\n", mi->key, mi->name, mi->desc));
+       DBG(ASK, ul_debugobj(ask, "new menu item: %c, \"%s\" (%s)\n", mi->key, mi->name, mi->desc));
        return 0;
 }
 
index e5ab01f9902c1b86b51dc4d8dd36e89a9c4edee6..7d7b0c66899af0858b056e2f34a306f943e05ed2 100644 (file)
@@ -12,7 +12,7 @@ struct fdisk_context *fdisk_new_context(void)
        if (!cxt)
                return NULL;
 
-       DBG(LABEL, ul_debug("new context %p allocated", cxt));
+       DBG(CXT, ul_debugobj(cxt, "alloc"));
        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, ul_debug("new context %p allocated", cxt));
+       DBG(CXT, ul_debugobj(parent, "alloc nested [%p]", 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, ul_debug("probing for nested %s", lb->name));
+               DBG(CXT, ul_debugobj(cxt, "probing for nested %s", lb->name));
 
                cxt->label = lb;
 
                if (lb->op->probe(cxt) == 1)
                        __fdisk_context_switch_label(cxt, lb);
                else {
-                       DBG(LABEL, ul_debug("not found %s label", lb->name));
+                       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("failed to found %s label driver\n", name));
+       DBG(CXT, ul_debugobj(cxt, "failed to found %s label driver", 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, ul_debug("*** attempt to switch to disabled label %s -- ignore!", lb->name));
+               DBG(CXT, ul_debugobj(cxt, "*** attempt to switch to disabled label %s -- ignore!", lb->name));
                return -EINVAL;
        }
        cxt->label = lb;
-       DBG(LABEL, ul_debug("--> switching context to %s!", lb->name));
+       DBG(CXT, ul_debugobj(cxt, "--> 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, ul_debug("*** resetting context %p", cxt));
+       DBG(CXT, ul_debugobj(cxt, "*** resetting context"));
 
        /* 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, ul_debug("wipe check: initialize libblkid prober"));
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("assigning device %s", fname));
+       DBG(CXT, ul_debugobj(cxt, "assigning device %s", fname));
        assert(cxt);
 
        reset_context(cxt);
@@ -290,12 +290,11 @@ int fdisk_context_assign_device(struct fdisk_context *cxt,
        if (!fdisk_context_listonly(cxt) && !fdisk_dev_has_disklabel(cxt))
                warn_wipe(cxt);
 
-       DBG(CONTEXT, ul_debug("context %p initialized for %s [%s]",
-                             cxt, fname,
-                             readonly ? "READ-ONLY" : "READ-WRITE"));
+       DBG(CXT, ul_debugobj(cxt, "initialized for %s [%s]",
+                             fname, readonly ? "READ-ONLY" : "READ-WRITE"));
        return 0;
 fail:
-       DBG(CONTEXT, ul_debug("failed to assign device"));
+       DBG(CXT, ul_debugobj(cxt, "failed to assign device"));
        return -errno;
 }
 
@@ -329,7 +328,7 @@ void fdisk_free_context(struct fdisk_context *cxt)
        if (!cxt)
                return;
 
-       DBG(CONTEXT, ul_debug("freeing context %p for %s", cxt, cxt->dev_path));
+       DBG(CXT, ul_debugobj(cxt, "freeing context %p for %s", cxt, cxt->dev_path));
        reset_context(cxt);
 
        /* deallocate label's private stuff */
@@ -430,7 +429,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, ul_debug("display unit: %s", fdisk_context_get_unit(cxt, 0)));
+       DBG(CXT, ul_debugobj(cxt, "display unit: %s", fdisk_context_get_unit(cxt, 0)));
        return 0;
 }
 
index 7d2726a20da0055ea151d0d05239ec3b03343f7d..b5880df701a795aa4b44653b6358f97267a0fe91 100644 (file)
  * Debug
  */
 #define FDISK_DEBUG_INIT       (1 << 1)
-#define FDISK_DEBUG_CONTEXT    (1 << 2)
-#define FDISK_DEBUG_TOPOLOGY    (1 << 3)
-#define FDISK_DEBUG_GEOMETRY    (1 << 4)
-#define FDISK_DEBUG_LABEL       (1 << 5)
-#define FDISK_DEBUG_ASK         (1 << 6)
-#define FDISK_DEBUG_FRONTEND   (1 << 7)
-#define FDISK_DEBUG_PART       (1 << 8)
-#define FDISK_DEBUG_TAB                (1 << 9)
+#define FDISK_DEBUG_CXT                (1 << 2)
+#define FDISK_DEBUG_LABEL       (1 << 3)
+#define FDISK_DEBUG_ASK         (1 << 4)
+#define FDISK_DEBUG_FRONTEND   (1 << 5)
+#define FDISK_DEBUG_PART       (1 << 6)
+#define FDISK_DEBUG_PARTTYPE   (1 << 7)
+#define FDISK_DEBUG_TAB                (1 << 8)
 #define FDISK_DEBUG_ALL                0xFFFF
 
 UL_DEBUG_DECLARE_MASK(libfdisk);
index 5fadb37c06ee9b6a872b5d0fd77306483079de38..36008997230ef99513d9ac9ec548cf17c1d62ade 100644 (file)
@@ -18,10 +18,10 @@ int fdisk_probe_labels(struct fdisk_context *cxt)
                if (!lb->op->probe)
                        continue;
                if (lb->disabled) {
-                       DBG(LABEL, ul_debug("%s disabled -- ignore", lb->name));
+                       DBG(CXT, ul_debugobj(cxt, "%s: disabled -- ignore", lb->name));
                        continue;
                }
-               DBG(LABEL, ul_debug("probing for %s", lb->name));
+               DBG(CXT, ul_debugobj(cxt, "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, ul_debug("no label found"));
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("create a new %s label", lb->name));
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("locating %d chunk of %s.", n, cxt->label->name));
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("asking for disk %s ID", cxt->label->name));
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("setting %s disk ID", cxt->label->name));
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("partition: %zd: set type", partnum));
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("partition: %zd: toggle: 0x%04lx [rc=%d]", partnum, flag, rc));
+       DBG(CXT, ul_debugobj(cxt, "partition: %zd: toggle: 0x%04lx [rc=%d]", partnum, flag, rc));
        return rc;
 }
 
index a5d5f9ac30305df74f0a77d9e8235bb39975d26d..70f707cbb88a0199e3739e54a5efb8992f92d976 100644 (file)
@@ -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, ul_debug("new %p", pa));
+       DBG(PART, ul_debugobj(pa, "alloc"));
        return pa;
 }
 
@@ -23,6 +23,7 @@ void fdisk_reset_partition(struct fdisk_partition *pa)
        if (!pa)
                return;
 
+       DBG(PART, ul_debugobj(pa, "reset"));
        ref = pa->refcount;
        fdisk_free_parttype(pa->type);
        free(pa->name);
@@ -48,7 +49,7 @@ void fdisk_unref_partition(struct fdisk_partition *pa)
 
        pa->refcount--;
        if (pa->refcount <= 0) {
-               DBG(PART, ul_debug("free %p", pa));
+               DBG(PART, ul_debugobj(pa, "free"));
                fdisk_reset_partition(pa);
                list_del(&pa->parts);
                free(pa);
@@ -271,7 +272,7 @@ int fdisk_partition_next_partno(
        if (pa && pa->partno_follow_default) {
                size_t i;
 
-               DBG(LABEL, ul_debug("next partno (follow default)"));
+               DBG(PART, ul_debugobj(pa, "next partno (follow default)"));
 
                for (i = 0; i < cxt->label->nparts_max; i++) {
                        if (!fdisk_is_partition_used(cxt, i)) {
@@ -283,7 +284,7 @@ int fdisk_partition_next_partno(
 
        } else if (pa && pa->partno != FDISK_EMPTY_PARTNO) {
 
-               DBG(LABEL, ul_debug("next partno (specified=%zu)", pa->partno));
+               DBG(PART, ul_debugobj(pa, "next partno (specified=%zu)", pa->partno));
 
                if (pa->partno >= cxt->label->nparts_max)
                        return -ERANGE;
@@ -505,7 +506,7 @@ int fdisk_add_partition(struct fdisk_context *cxt,
        if (fdisk_missing_geometry(cxt))
                return -EINVAL;
 
-       DBG(LABEL, ul_debug("adding new partition (start=%ju, end=%ju, size=%ju, "
+       DBG(CXT, ul_debugobj(cxt, "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 +517,7 @@ int fdisk_add_partition(struct fdisk_context *cxt,
 
        rc = cxt->label->op->add_part(cxt, pa);
 
-       DBG(LABEL, ul_debug("add partition done (rc=%d)", rc));
+       DBG(CXT, ul_debugobj(cxt, "add partition done (rc=%d)", rc));
        return rc;
 }
 
@@ -536,7 +537,7 @@ int fdisk_delete_partition(struct fdisk_context *cxt, size_t partnum)
        if (!cxt->label->op->part_delete)
                return -ENOSYS;
 
-       DBG(LABEL, ul_debug("deleting %s partition number %zd",
+       DBG(CXT, ul_debugobj(cxt, "deleting %s partition number %zd",
                                cxt->label->name, partnum));
        return cxt->label->op->part_delete(cxt, partnum);
 }
index 830e6049e4f500899f13f28b8d146b4f69751556..5535e2fb3eaa19655f93d70800324c8c889612ca 100644 (file)
@@ -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, ul_debug("allocated new unknown type [%p]", t));
+       DBG(PARTTYPE, ul_debugobj(t, "allocated new unknown type"));
        return t;
 }
 
@@ -110,7 +110,7 @@ struct fdisk_parttype *fdisk_parse_parttype(
        if (!fdisk_get_nparttypes(cxt))
                return NULL;
 
-       DBG(LABEL, ul_debug("parsing '%s' partition type", str));
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("parsing failed: %m"));
+                       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("returns '%s' partition type", ret->name));
+       DBG(PARTTYPE, ul_debugobj(ret, "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, ul_debug("freeing %p partition type", t));
+               DBG(PARTTYPE, ul_debugobj(t, "free"));
                free(t->typestr);
                free(t);
        }
index 5867e1e7aa89bc1c44400e79b8d0822a9407ef9d..5365f2ccac571270068051b72bd8d3aea8e5f4d0 100644 (file)
@@ -18,7 +18,7 @@ struct fdisk_table *fdisk_new_table(void)
        if (!tb)
                return NULL;
 
-       DBG(TAB, ul_debug("alloc"));
+       DBG(TAB, ul_debugobj(tb, "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, ul_debug("reset"));
+       DBG(TAB, ul_debugobj(tb, "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, ul_debug("free"));
+               DBG(TAB, ul_debugobj(tb, "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, ul_debug("add entry %p [start=%ju, end=%ju, size=%ju, %s %s %s]",
+       DBG(TAB, ul_debugobj(tb, "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, ul_debug("insert entry %p pre=%p [start=%ju, end=%ju, size=%ju, %s %s %s]",
+       DBG(TAB, ul_debugobj(tb, "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, ul_debug("remove entry %p", pa));
+       DBG(TAB, ul_debugobj(tb, "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, ul_debug("get table"));
+       DBG(CXT, ul_debugobj(cxt, "get table"));
 
        if (!*tb && !(*tb = fdisk_new_table()))
                return -ENOMEM;
@@ -391,7 +391,7 @@ static int table_add_freespace(
                        }
                }
                if (!real_parent) {
-                       DBG(LABEL, ul_debug("not found freespace parent (partno=%ju)",
+                       DBG(TAB, ul_debugobj(tb, "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, ul_debug("get freespace"));
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("freespace analyze: partno=%zu, start=%ju, end=%ju",
+               DBG(CXT, ul_debugobj(cxt, "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, ul_debug("generate string"));
+       DBG(TAB, ul_debugobj(tb, "generate string"));
        *data = NULL;
 
        if (!fdisk_table_get_nents(tb))
@@ -583,7 +583,8 @@ int fdisk_table_to_string(struct fdisk_table *tb,
                        goto done;
                }
 
-               DBG(TAB, ul_debug("  string from part #%zu", pa->partno + 1));
+               DBG(TAB, ul_debugobj(tb, "  string from part #%zu [%p]",
+                                       pa->partno + 1, pa));
 
                /* set data for the columns */
                for (j = 0; j < ncols; j++) {
@@ -602,7 +603,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, ul_debug("tt empty"));
+               DBG(TAB, ul_debugobj(tb, "tt empty"));
 done:
        if (org_cols != cols)
                free(cols);
index 9032d65bf83fedc2c9db532d00039217f02452f2..65abfbc1cb26d8d37cfa78e175bd615b7171a411 100644 (file)
@@ -13,7 +13,7 @@ void fdisk_zeroize_firstsector(struct fdisk_context *cxt)
        if (!cxt || !cxt->firstsector)
                return;
 
-       DBG(CONTEXT, ul_debug("zeroize in-memory first sector buffer"));
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("initialize first sector "
+       DBG(CXT, ul_debugobj(cxt, "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, ul_debug("failed to read first sector %m"));
+               DBG(CXT, ul_debugobj(cxt, "failed to read first sector %m"));
                return -errno;
        }