2005-05-07 Theodore Ts'o <tytso@mit.edu>
+ * blkidP.h, cache.c, dev.c, read.c, tag.c: Clean up the debugging
+ code so that we don't use the inline functions DEB_DUMP_*
+ and instead use the private functions blkid_debug_dump_*().
+
* tag.c (blkid_dev_has_tag): New function which returns 1 if a tag
has a particular type and possibly value.
#endif
#ifdef CONFIG_BLKID_DEBUG
-static inline void DEB_DUMP_TAG(int mask, blkid_tag tag)
-{
- if (!(mask & blkid_debug_mask))
- return;
-
- if (!tag) {
- printf(" tag: NULL\n");
- return;
- }
-
- printf(" tag: %s=\"%s\"\n", tag->bit_name, tag->bit_val);
-}
-
-static inline void DEB_DUMP_DEV(int mask, blkid_dev dev)
-{
- struct list_head *p;
-
- if (!(mask & blkid_debug_mask))
- return;
-
- if (!dev) {
- printf(" dev: NULL\n");
- return;
- }
-
- printf(" dev: name = %s\n", dev->bid_name);
- printf(" dev: DEVNO=\"0x%0Lx\"\n", dev->bid_devno);
- printf(" dev: TIME=\"%lu\"\n", dev->bid_time);
- printf(" dev: PRI=\"%d\"\n", dev->bid_pri);
- printf(" dev: flags = 0x%08X\n", dev->bid_flags);
-
- list_for_each(p, &dev->bid_tags) {
- blkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags);
- DEB_DUMP_TAG(mask, tag);
- }
- printf("\n");
-}
-
-static inline void DEB_DUMP_CACHE(int mask, blkid_cache cache)
-{
- struct list_head *p;
-
- if (!cache || !(mask & blkid_debug_mask)) {
- printf("cache: NULL\n");
- return;
- }
-
- printf("cache: time = %lu\n", cache->bic_time);
- printf("cache: flags = 0x%08X\n", cache->bic_flags);
-
- list_for_each(p, &cache->bic_devs) {
- blkid_dev dev = list_entry(p, struct blkid_struct_dev, bid_devs);
- DEB_DUMP_DEV(mask, dev);
- }
-}
-#else
-#define DEB_DUMP_TAG(mask, tag) do {} while (0)
-#define DEB_DUMP_DEV(mask, dev) do {} while (0)
-#define DEB_DUMP_CACHE(mask, cache) do {} while (0)
+extern void blkid_debug_dump_dev(blkid_dev dev);
+extern void blkid_debug_dump_tag(blkid_tag tag);
#endif
/* lseek.c */
#endif
}
+#if 0 /* ifdef CONFIG_BLKID_DEBUG */
+static blkid_debug_dump_cache(int mask, blkid_cache cache)
+{
+ struct list_head *p;
+
+ if (!cache) {
+ printf("cache: NULL\n");
+ return;
+ }
+
+ printf("cache: time = %lu\n", cache->bic_time);
+ printf("cache: flags = 0x%08X\n", cache->bic_flags);
+
+ list_for_each(p, &cache->bic_devs) {
+ blkid_dev dev = list_entry(p, struct blkid_struct_dev, bid_devs);
+ blkid_debug_dump_dev(dev);
+ }
+}
+#endif
+
int blkid_get_cache(blkid_cache *ret_cache, const char *filename)
{
blkid_cache cache;
DBG(DEBUG_CACHE, printf("freeing cache struct\n"));
- /* DEB_DUMP_CACHE(cache); */
+ /* DBG(DEBUG_CACHE, blkid_debug_dump_cache(cache)); */
while (!list_empty(&cache->bic_devs)) {
blkid_dev dev = list_entry(cache->bic_devs.next,
DBG(DEBUG_DEV,
printf(" freeing dev %s (%s)\n", dev->bid_name, dev->bid_type));
- DEB_DUMP_DEV(DEBUG_DEV, dev);
+ DBG(DEBUG_DEV, blkid_debug_dump_dev(dev));
list_del(&dev->bid_devs);
while (!list_empty(&dev->bid_tags)) {
return dev->bid_name;
}
+#ifdef CONFIG_BLKID_DEBUG
+void blkid_debug_dump_dev(blkid_dev dev)
+{
+ struct list_head *p;
+
+ if (!dev) {
+ printf(" dev: NULL\n");
+ return;
+ }
+
+ printf(" dev: name = %s\n", dev->bid_name);
+ printf(" dev: DEVNO=\"0x%0Lx\"\n", dev->bid_devno);
+ printf(" dev: TIME=\"%lu\"\n", dev->bid_time);
+ printf(" dev: PRI=\"%d\"\n", dev->bid_pri);
+ printf(" dev: flags = 0x%08X\n", dev->bid_flags);
+
+ list_for_each(p, &dev->bid_tags) {
+ blkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags);
+ blkid_debug_dump_tag(tag);
+ }
+ printf("\n");
+}
+#endif
+
/*
* dev iteration routines for the public libblkid interface.
*
blkid_free_dev(dev);
}
- DEB_DUMP_DEV(DEBUG_READ, dev);
+ DBG(DEBUG_READ, blkid_debug_dump_dev(dev));
return ret;
}
return tag;
}
+#ifdef CONFIG_BLKID_DEBUG
+void blkid_debug_dump_tag(blkid_tag tag)
+{
+ if (!tag) {
+ printf(" tag: NULL\n");
+ return;
+ }
+
+ printf(" tag: %s=\"%s\"\n", tag->bit_name, tag->bit_val);
+}
+#endif
+
void blkid_free_tag(blkid_tag tag)
{
if (!tag)
DBG(DEBUG_TAG, printf(" freeing tag %s=%s\n", tag->bit_name,
tag->bit_val ? tag->bit_val : "(NULL)"));
- DEB_DUMP_TAG(DEBUG_TAG, tag);
+ DBG(DEBUG_TAG, blkid_debug_dump_tag(tag));
list_del(&tag->bit_tags); /* list of tags for this device */
list_del(&tag->bit_names); /* list of tags with this type */