diff options
author | Karel Zak | 2016-05-25 15:06:22 +0200 |
---|---|---|
committer | Karel Zak | 2016-05-25 15:06:22 +0200 |
commit | 14308bc3f2a66c2f960c12fe831195aa997ca1cb (patch) | |
tree | fba7c71692f7278ff8d3a2fb6e4b2603a76ed1ae | |
parent | build-sys: add missing include/plymouth-ctrl.h (diff) | |
download | kernel-qcow2-util-linux-14308bc3f2a66c2f960c12fe831195aa997ca1cb.tar.gz kernel-qcow2-util-linux-14308bc3f2a66c2f960c12fe831195aa997ca1cb.tar.xz kernel-qcow2-util-linux-14308bc3f2a66c2f960c12fe831195aa997ca1cb.zip |
libblkid: improve debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | libblkid/src/blkidP.h | 1 | ||||
-rw-r--r-- | libblkid/src/cache.c | 11 | ||||
-rw-r--r-- | libblkid/src/dev.c | 6 | ||||
-rw-r--r-- | libblkid/src/read.c | 6 | ||||
-rw-r--r-- | libblkid/src/tag.c | 21 |
5 files changed, 16 insertions, 29 deletions
diff --git a/libblkid/src/blkidP.h b/libblkid/src/blkidP.h index e9a267e62..e298b41dd 100644 --- a/libblkid/src/blkidP.h +++ b/libblkid/src/blkidP.h @@ -326,7 +326,6 @@ UL_DEBUG_DECLARE_MASK(libblkid); #define ON_DBG(m, x) __UL_DBG_CALL(libblkid, BLKID_DEBUG_, m, x) extern void blkid_debug_dump_dev(blkid_dev dev); -extern void blkid_debug_dump_tag(blkid_tag tag); /* devno.c */ diff --git a/libblkid/src/cache.c b/libblkid/src/cache.c index c6d02a48b..fd0257cd7 100644 --- a/libblkid/src/cache.c +++ b/libblkid/src/cache.c @@ -99,12 +99,10 @@ int blkid_get_cache(blkid_cache *ret_cache, const char *filename) blkid_init_debug(0); - DBG(CACHE, ul_debug("creating blkid cache (using %s)", - filename ? filename : "default cache")); - if (!(cache = calloc(1, sizeof(struct blkid_struct_cache)))) return -BLKID_ERR_MEM; + DBG(CACHE, ul_debugobj(cache, "alloc (from %s)", filename ? filename : "default cache")); INIT_LIST_HEAD(&cache->bic_devs); INIT_LIST_HEAD(&cache->bic_tags); @@ -133,7 +131,7 @@ void blkid_put_cache(blkid_cache cache) (void) blkid_flush_cache(cache); - DBG(CACHE, ul_debug("freeing cache struct")); + DBG(CACHE, ul_debugobj(cache, "freeing cache struct")); /* DBG(CACHE, ul_debug_dump_cache(cache)); */ @@ -144,6 +142,7 @@ void blkid_put_cache(blkid_cache cache) blkid_free_dev(dev); } + DBG(CACHE, ul_debugobj(cache, "freeing cache tag heads")); while (!list_empty(&cache->bic_tags)) { blkid_tag tag = list_entry(cache->bic_tags.next, struct blkid_struct_tag, @@ -154,7 +153,7 @@ void blkid_put_cache(blkid_cache cache) struct blkid_struct_tag, bit_names); - DBG(CACHE, ul_debug("warning: unfreed tag %s=%s", + DBG(CACHE, ul_debugobj(cache, "warning: unfreed tag %s=%s", bad->bit_name, bad->bit_val)); blkid_free_tag(bad); } @@ -184,7 +183,7 @@ void blkid_gc_cache(blkid_cache cache) list_for_each_safe(p, pnext, &cache->bic_devs) { blkid_dev dev = list_entry(p, struct blkid_struct_dev, bid_devs); if (stat(dev->bid_name, &st) < 0) { - DBG(CACHE, ul_debug("freeing %s", dev->bid_name)); + DBG(CACHE, ul_debugobj(cache, "freeing non-exiting %s", dev->bid_name)); blkid_free_dev(dev); cache->bic_flags |= BLKID_BIC_FL_CHANGED; } else { diff --git a/libblkid/src/dev.c b/libblkid/src/dev.c index 8e5516bce..f35895da9 100644 --- a/libblkid/src/dev.c +++ b/libblkid/src/dev.c @@ -37,6 +37,7 @@ blkid_dev blkid_new_dev(void) if (!(dev = calloc(1, sizeof(struct blkid_struct_dev)))) return NULL; + DBG(DEV, ul_debugobj(dev, "alloc")); INIT_LIST_HEAD(&dev->bid_devs); INIT_LIST_HEAD(&dev->bid_tags); @@ -48,10 +49,7 @@ void blkid_free_dev(blkid_dev dev) if (!dev) return; - DBG(DEV, - ul_debug(" freeing dev %s (%s)", dev->bid_name, dev->bid_type ? - dev->bid_type : "(null)")); - DBG(DEV, blkid_debug_dump_dev(dev)); + DBG(DEV, ul_debugobj(dev, "freeing (%s)", dev->bid_name)); list_del(&dev->bid_devs); while (!list_empty(&dev->bid_tags)) { diff --git a/libblkid/src/read.c b/libblkid/src/read.c index 41e564f4e..b7afe2cd2 100644 --- a/libblkid/src/read.c +++ b/libblkid/src/read.c @@ -321,6 +321,8 @@ static int parse_tag(blkid_cache cache, blkid_dev dev, char **cp) (ret = parse_xml(&name, &value, cp)) <= 0 */) return ret; + DBG(READ, ul_debug("tag: %s=\"%s\"", name, value)); + /* Some tags are stored directly in the device struct */ if (!strcmp(name, "DEVNO")) dev->bid_devno = strtoull(value, 0, 0); @@ -334,8 +336,6 @@ static int parse_tag(blkid_cache cache, blkid_dev dev, char **cp) } else ret = blkid_set_tag(dev, name, value, strlen(value)); - DBG(READ, ul_debug(" tag: %s=\"%s\"", name, value)); - return ret < 0 ? ret : 1; } @@ -377,7 +377,7 @@ static int blkid_parse_line(blkid_cache cache, blkid_dev *dev_p, char *cp) goto done; } - DBG(READ, blkid_debug_dump_dev(dev)); + /*DBG(READ, blkid_debug_dump_dev(dev));*/ done: return ret; diff --git a/libblkid/src/tag.c b/libblkid/src/tag.c index 4dc7da139..40cac0166 100644 --- a/libblkid/src/tag.c +++ b/libblkid/src/tag.c @@ -24,30 +24,19 @@ static blkid_tag blkid_new_tag(void) if (!(tag = calloc(1, sizeof(struct blkid_struct_tag)))) return NULL; + DBG(TAG, ul_debugobj(tag, "alloc")); INIT_LIST_HEAD(&tag->bit_tags); INIT_LIST_HEAD(&tag->bit_names); return tag; } -void blkid_debug_dump_tag(blkid_tag tag) -{ - if (!tag) { - fprintf(stderr, " tag: NULL\n"); - return; - } - - fprintf(stderr, " tag: %s=\"%s\"\n", tag->bit_name, tag->bit_val); -} - void blkid_free_tag(blkid_tag tag) { if (!tag) return; - DBG(TAG, ul_debug(" freeing tag %s=%s", tag->bit_name, - tag->bit_val ? tag->bit_val : "(NULL)")); - DBG(TAG, blkid_debug_dump_tag(tag)); + DBG(TAG, ul_debugobj(tag, "freeing tag %s (%s)", tag->bit_name, tag->bit_val)); list_del(&tag->bit_tags); /* list of tags for this device */ list_del(&tag->bit_names); /* list of tags with this type */ @@ -107,7 +96,7 @@ static blkid_tag blkid_find_head_cache(blkid_cache cache, const char *type) list_for_each(p, &cache->bic_tags) { tmp = list_entry(p, struct blkid_struct_tag, bit_tags); if (!strcmp(tmp->bit_name, type)) { - DBG(TAG, ul_debug(" found cache tag head %s", type)); + DBG(TAG, ul_debug("found cache tag head %s", type)); head = tmp; break; } @@ -155,6 +144,7 @@ int blkid_set_tag(blkid_dev dev, const char *name, free(val); return 0; } + DBG(TAG, ul_debugobj(t, "update (%s) '%s' -> '%s'", t->bit_name, t->bit_val, val)); free(t->bit_val); t->bit_val = val; } else { @@ -165,6 +155,7 @@ int blkid_set_tag(blkid_dev dev, const char *name, t->bit_val = val; t->bit_dev = dev; + DBG(TAG, ul_debugobj(t, "setting (%s) '%s'", t->bit_name, t->bit_val)); list_add_tail(&t->bit_tags, &dev->bid_tags); if (dev->bid_cache) { @@ -175,7 +166,7 @@ int blkid_set_tag(blkid_dev dev, const char *name, if (!head) goto errout; - DBG(TAG, ul_debug(" creating new cache tag head %s", name)); + DBG(TAG, ul_debugobj(head, "creating new cache tag head %s", name)); head->bit_name = strdup(name); if (!head->bit_name) goto errout; |