summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2014-11-03 13:12:20 +0100
committerKarel Zak2014-11-03 13:12:20 +0100
commitb7da851e5a022937ea4d8b777da5551f7e3a2966 (patch)
treef80793f7d2986f65e8837ab52324ac20674371cd
parentinclude/debug: improve and cleanup (diff)
downloadkernel-qcow2-util-linux-b7da851e5a022937ea4d8b777da5551f7e3a2966.tar.gz
kernel-qcow2-util-linux-b7da851e5a022937ea4d8b777da5551f7e3a2966.tar.xz
kernel-qcow2-util-linux-b7da851e5a022937ea4d8b777da5551f7e3a2966.zip
libblkid: clean up debug, add "help" debug mask
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--libblkid/src/blkidP.h32
-rw-r--r--libblkid/src/init.c40
-rw-r--r--libblkid/src/resolve.c4
3 files changed, 41 insertions, 35 deletions
diff --git a/libblkid/src/blkidP.h b/libblkid/src/blkidP.h
index 05d81e0d3..fbf4e719b 100644
--- a/libblkid/src/blkidP.h
+++ b/libblkid/src/blkidP.h
@@ -316,24 +316,24 @@ struct blkid_struct_cache
#define BLKID_PRI_LVM 20
#define BLKID_PRI_MD 10
-#define BLKID_DEBUG_CACHE 0x0001
-#define BLKID_DEBUG_DUMP 0x0002
-#define BLKID_DEBUG_DEV 0x0004
-#define BLKID_DEBUG_DEVNAME 0x0008
-#define BLKID_DEBUG_DEVNO 0x0010
-#define BLKID_DEBUG_PROBE 0x0020
-#define BLKID_DEBUG_READ 0x0040
-#define BLKID_DEBUG_RESOLVE 0x0080
-#define BLKID_DEBUG_SAVE 0x0100
-#define BLKID_DEBUG_TAG 0x0200
-#define BLKID_DEBUG_LOWPROBE 0x0400
-#define BLKID_DEBUG_CONFIG 0x0800
-#define BLKID_DEBUG_EVALUATE 0x1000
-#define BLKID_DEBUG_INIT 0x8000
-#define BLKID_DEBUG_ALL 0xFFFF
+#define BLKID_DEBUG_HELP (1 << 0)
+#define BLKID_DEBUG_INIT (1 << 1)
+#define BLKID_DEBUG_CACHE (1 << 2)
+#define BLKID_DEBUG_CONFIG (1 << 3)
+#define BLKID_DEBUG_DEV (1 << 4)
+#define BLKID_DEBUG_DEVNAME (1 << 5)
+#define BLKID_DEBUG_DEVNO (1 << 6)
+#define BLKID_DEBUG_EVALUATE (1 << 7)
+#define BLKID_DEBUG_LOWPROBE (1 << 8)
+#define BLKID_DEBUG_PROBE (1 << 9)
+#define BLKID_DEBUG_READ (1 << 10)
+#define BLKID_DEBUG_SAVE (1 << 11)
+#define BLKID_DEBUG_TAG (1 << 12)
+#define BLKID_DEBUG_ALL 0xFFFF /* (1 << 16) aka FFFF is expected by API */
UL_DEBUG_DECLARE_MASK(libblkid);
-#define DBG(m, x) __UL_DBG(libblkid, BLKID_DEBUG_, m, x)
+#define DBG(m, x) __UL_DBG(libblkid, BLKID_DEBUG_, m, x)
+#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);
diff --git a/libblkid/src/init.c b/libblkid/src/init.c
index 7d2651180..eead6c7df 100644
--- a/libblkid/src/init.c
+++ b/libblkid/src/init.c
@@ -18,22 +18,20 @@
UL_DEBUG_DEFINE_MASK(libblkid);
UL_DEBUG_DEFINE_MASKNAMES(libblkid) =
{
- { "all", BLKID_DEBUG_ALL },
- { "cache", BLKID_DEBUG_CACHE },
- { "dump", BLKID_DEBUG_DUMP },
- { "dev", BLKID_DEBUG_DEV },
- { "devname", BLKID_DEBUG_DEVNAME },
- { "devno", BLKID_DEBUG_DEVNO },
- { "probe", BLKID_DEBUG_PROBE },
- { "read", BLKID_DEBUG_READ },
- { "resolve", BLKID_DEBUG_RESOLVE },
- { "save", BLKID_DEBUG_SAVE },
- { "tag", BLKID_DEBUG_TAG },
- { "lowprobe", BLKID_DEBUG_LOWPROBE },
- { "config", BLKID_DEBUG_CONFIG },
- { "evaluate", BLKID_DEBUG_EVALUATE },
- { "init", BLKID_DEBUG_INIT },
- { NULL, 0 }
+ { "all", BLKID_DEBUG_ALL, "info about all subsystems" },
+ { "cache", BLKID_DEBUG_CACHE, "blkid tags cache" },
+ { "config", BLKID_DEBUG_CONFIG, "config file utils" },
+ { "dev", BLKID_DEBUG_DEV, "device utils" },
+ { "devname", BLKID_DEBUG_DEVNAME, "/proc/partitions evaluation" },
+ { "devno", BLKID_DEBUG_DEVNO, "convertions to device name" },
+ { "evaluate", BLKID_DEBUG_EVALUATE, "tags resolving" },
+ { "help", BLKID_DEBUG_HELP, "this help" },
+ { "lowprobe", BLKID_DEBUG_LOWPROBE, "superblock/raids/partitions probing" },
+ { "probe", BLKID_DEBUG_PROBE, "devices verification" },
+ { "read", BLKID_DEBUG_READ, "cache parsing" },
+ { "save", BLKID_DEBUG_SAVE, "cache writing" },
+ { "tag", BLKID_DEBUG_TAG, "tags utils" },
+ { NULL, 0, NULL }
};
/**
@@ -48,13 +46,21 @@ UL_DEBUG_DEFINE_MASKNAMES(libblkid) =
*/
void blkid_init_debug(int mask)
{
+ if (libblkid_debug_mask)
+ return;
+
__UL_INIT_DEBUG(libblkid, BLKID_DEBUG_, mask, LIBBLKID_DEBUG);
- if (libblkid_debug_mask != BLKID_DEBUG_INIT) {
+ if (libblkid_debug_mask != BLKID_DEBUG_INIT
+ && libblkid_debug_mask != (BLKID_DEBUG_HELP|BLKID_DEBUG_INIT)) {
const char *ver = NULL;
const char *date = NULL;
blkid_get_library_version(&ver, &date);
+ DBG(INIT, ul_debug("library debug mask: 0x%04x", libblkid_debug_mask));
DBG(INIT, ul_debug("library version: %s [%s]", ver, date));
+
}
+ ON_DBG(HELP, ul_debug_print_masks("LIBBLKID_DEBUG",
+ UL_DEBUG_MASKNAMES(libblkid)));
}
diff --git a/libblkid/src/resolve.c b/libblkid/src/resolve.c
index ea5e407c4..59f0fea2b 100644
--- a/libblkid/src/resolve.c
+++ b/libblkid/src/resolve.c
@@ -32,7 +32,7 @@ char *blkid_get_tag_value(blkid_cache cache, const char *tagname,
blkid_cache c = cache;
char *ret = NULL;
- DBG(RESOLVE, ul_debug("looking for %s on %s", tagname, devname));
+ DBG(TAG, ul_debug("looking for %s on %s", tagname, devname));
if (!devname)
return NULL;
@@ -68,7 +68,7 @@ char *blkid_get_devname(blkid_cache cache, const char *token,
if (!cache && blkid_get_cache(&c, NULL) < 0)
return NULL;
- DBG(RESOLVE, ul_debug("looking for %s%s%s %s", token, value ? "=" : "",
+ DBG(TAG, ul_debug("looking for %s%s%s %s", token, value ? "=" : "",
value ? value : "", cache ? "in cache" : "from disk"));
if (!value) {