summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2013-04-08 18:22:13 +0200
committerKarel Zak2013-04-08 18:22:13 +0200
commit0540ea544d4b459bc148d29645225190b76ca8b7 (patch)
treef0902ec8cb04f8148ffd87170c2f1bdd7534564e
parentbash-completion: Symlink runuser symlink to su so it gets loaded on demand. (diff)
downloadkernel-qcow2-util-linux-0540ea544d4b459bc148d29645225190b76ca8b7.tar.gz
kernel-qcow2-util-linux-0540ea544d4b459bc148d29645225190b76ca8b7.tar.xz
kernel-qcow2-util-linux-0540ea544d4b459bc148d29645225190b76ca8b7.zip
libblkid: clean up DBG()
- use stderr only - use BLKID_ prefix for debug masks - don't use \n in in messages and don't use printf(), but use generic blkid_debug(). Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--libblkid/src/blkidP.h46
-rw-r--r--libblkid/src/cache.c43
-rw-r--r--libblkid/src/config.c23
-rw-r--r--libblkid/src/dev.c21
-rw-r--r--libblkid/src/devname.c42
-rw-r--r--libblkid/src/devno.c15
-rw-r--r--libblkid/src/evaluate.c26
-rw-r--r--libblkid/src/partitions/bsd.c16
-rw-r--r--libblkid/src/partitions/dos.c6
-rw-r--r--libblkid/src/partitions/gpt.c22
-rw-r--r--libblkid/src/partitions/mac.c4
-rw-r--r--libblkid/src/partitions/minix.c4
-rw-r--r--libblkid/src/partitions/partitions.c67
-rw-r--r--libblkid/src/partitions/sgi.c4
-rw-r--r--libblkid/src/partitions/solaris_x86.c8
-rw-r--r--libblkid/src/partitions/sun.c7
-rw-r--r--libblkid/src/partitions/unixware.c4
-rw-r--r--libblkid/src/probe.c85
-rw-r--r--libblkid/src/read.c37
-rw-r--r--libblkid/src/resolve.c7
-rw-r--r--libblkid/src/save.c30
-rw-r--r--libblkid/src/superblocks/btrfs.c2
-rw-r--r--libblkid/src/superblocks/ext.c2
-rw-r--r--libblkid/src/superblocks/lvm.c3
-rw-r--r--libblkid/src/superblocks/ntfs.c4
-rw-r--r--libblkid/src/superblocks/silicon_raid.c2
-rw-r--r--libblkid/src/superblocks/superblocks.c24
-rw-r--r--libblkid/src/superblocks/vfat.c8
-rw-r--r--libblkid/src/superblocks/zfs.c4
-rw-r--r--libblkid/src/tag.c18
-rw-r--r--libblkid/src/topology/dm.c9
-rw-r--r--libblkid/src/topology/lvm.c9
-rw-r--r--libblkid/src/topology/topology.c14
-rw-r--r--libblkid/src/verify.c23
34 files changed, 278 insertions, 361 deletions
diff --git a/libblkid/src/blkidP.h b/libblkid/src/blkidP.h
index 2d5e8cb78..4dadfe7f2 100644
--- a/libblkid/src/blkidP.h
+++ b/libblkid/src/blkidP.h
@@ -321,21 +321,21 @@ struct blkid_struct_cache
#define CONFIG_BLKID_DEBUG
#endif
-#define DEBUG_CACHE 0x0001
-#define DEBUG_DUMP 0x0002
-#define DEBUG_DEV 0x0004
-#define DEBUG_DEVNAME 0x0008
-#define DEBUG_DEVNO 0x0010
-#define DEBUG_PROBE 0x0020
-#define DEBUG_READ 0x0040
-#define DEBUG_RESOLVE 0x0080
-#define DEBUG_SAVE 0x0100
-#define DEBUG_TAG 0x0200
-#define DEBUG_LOWPROBE 0x0400
-#define DEBUG_CONFIG 0x0800
-#define DEBUG_EVALUATE 0x1000
-#define DEBUG_INIT 0x8000
-#define DEBUG_ALL 0xFFFF
+#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
#ifdef CONFIG_BLKID_DEBUG
extern int blkid_debug_mask;
@@ -343,7 +343,21 @@ extern void blkid_init_debug(int mask);
extern void blkid_debug_dump_dev(blkid_dev dev);
extern void blkid_debug_dump_tag(blkid_tag tag);
-#define DBG(m,x) do { if ((m) & blkid_debug_mask) x; } while (0)
+#define DBG(m,x) do { \
+ if ((BLKID_DEBUG_ ## m) & blkid_debug_mask) \
+ fprintf(stderr, "%d: libblkid: %8s: ", getpid(), # m); \
+ x; \
+ } while (0)
+
+static inline void __attribute__ ((__format__ (__printf__, 1, 2)))
+blkid_debug(const char *mesg, ...)
+{
+ va_list ap;
+ va_start(ap, mesg);
+ vfprintf(stderr, mesg, ap);
+ va_end(ap);
+ fputc('\n', stderr);
+}
#else /* !CONFIG_BLKID_DEBUG */
#define DBG(m,x)
diff --git a/libblkid/src/cache.c b/libblkid/src/cache.c
index cc2cf8e94..06020e96b 100644
--- a/libblkid/src/cache.c
+++ b/libblkid/src/cache.c
@@ -50,31 +50,10 @@ int blkid_debug_mask = 0;
* locate these devices without enumerating only visible devices, so the use of
* the cache file is required in this situation.
*/
-
-#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
-
#ifdef CONFIG_BLKID_DEBUG
void blkid_init_debug(int mask)
{
- if (blkid_debug_mask & DEBUG_INIT)
+ if (blkid_debug_mask & BLKID_DEBUG_INIT)
return;
if (!mask)
@@ -89,9 +68,9 @@ void blkid_init_debug(int mask)
blkid_debug_mask = mask;
if (blkid_debug_mask)
- printf("libblkid: debug mask set to 0x%04x.\n", blkid_debug_mask);
+ fprintf(stderr, "libblkid: debug mask set to 0x%04x.\n", blkid_debug_mask);
- blkid_debug_mask |= DEBUG_INIT;
+ blkid_debug_mask |= BLKID_DEBUG_INIT;
}
#endif
@@ -146,7 +125,7 @@ int blkid_get_cache(blkid_cache *ret_cache, const char *filename)
blkid_init_debug(0);
- DBG(DEBUG_CACHE, printf("creating blkid cache (using %s)\n",
+ DBG(CACHE, blkid_debug("creating blkid cache (using %s)",
filename ? filename : "default cache"));
if (!(cache = (blkid_cache) calloc(1, sizeof(struct blkid_struct_cache))))
@@ -180,9 +159,9 @@ void blkid_put_cache(blkid_cache cache)
(void) blkid_flush_cache(cache);
- DBG(DEBUG_CACHE, printf("freeing cache struct\n"));
+ DBG(CACHE, blkid_debug("freeing cache struct"));
- /* DBG(DEBUG_CACHE, blkid_debug_dump_cache(cache)); */
+ /* DBG(CACHE, blkid_debug_dump_cache(cache)); */
while (!list_empty(&cache->bic_devs)) {
blkid_dev dev = list_entry(cache->bic_devs.next,
@@ -201,7 +180,7 @@ void blkid_put_cache(blkid_cache cache)
struct blkid_struct_tag,
bit_names);
- DBG(DEBUG_CACHE, printf("warning: unfreed tag %s=%s\n",
+ DBG(CACHE, blkid_debug("warning: unfreed tag %s=%s",
bad->bit_name, bad->bit_val));
blkid_free_tag(bad);
}
@@ -231,13 +210,11 @@ 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(DEBUG_CACHE,
- printf("freeing %s\n", dev->bid_name));
+ DBG(CACHE, blkid_debug("freeing %s", dev->bid_name));
blkid_free_dev(dev);
cache->bic_flags |= BLKID_BIC_FL_CHANGED;
} else {
- DBG(DEBUG_CACHE,
- printf("Device %s exists\n", dev->bid_name));
+ DBG(CACHE, blkid_debug("Device %s exists", dev->bid_name));
}
}
}
@@ -248,7 +225,7 @@ int main(int argc, char** argv)
blkid_cache cache = NULL;
int ret;
- blkid_init_debug(DEBUG_ALL);
+ blkid_init_debug(BLKID_DEBUG_ALL);
if ((argc > 2)) {
fprintf(stderr, "Usage: %s [filename] \n", argv[0]);
diff --git a/libblkid/src/config.c b/libblkid/src/config.c
index 0b2ef20c3..124e8a78e 100644
--- a/libblkid/src/config.c
+++ b/libblkid/src/config.c
@@ -50,8 +50,8 @@ static int parse_evaluate(struct blkid_config *conf, char *s)
}
return 0;
err:
- DBG(DEBUG_CONFIG, printf(
- "config file: unknown evaluation method '%s'.\n", s));
+ DBG(CONFIG, blkid_debug(
+ "config file: unknown evaluation method '%s'.", s));
return -1;
}
@@ -71,8 +71,8 @@ static int parse_next(FILE *fd, struct blkid_config *conf)
if (feof(fd))
s = strchr (buf, '\0');
else {
- DBG(DEBUG_CONFIG, fprintf(stderr,
- "libblkid: config file: missing newline at line '%s'.\n",
+ DBG(CONFIG, blkid_debug(
+ "config file: missing newline at line '%s'.",
buf));
return -1;
}
@@ -102,8 +102,8 @@ static int parse_next(FILE *fd, struct blkid_config *conf)
if (*s && parse_evaluate(conf, s) == -1)
return -1;
} else {
- DBG(DEBUG_CONFIG, printf(
- "config file: unknown option '%s'.\n", s));
+ DBG(CONFIG, blkid_debug(
+ "config file: unknown option '%s'.", s));
return -1;
}
return 0;
@@ -125,19 +125,16 @@ struct blkid_config *blkid_read_config(const char *filename)
return NULL;
conf->uevent = -1;
- DBG(DEBUG_CONFIG, fprintf(stderr,
- "reading config file: %s.\n", filename));
+ DBG(CONFIG, blkid_debug("reading config file: %s.", filename));
f = fopen(filename, "r" UL_CLOEXECSTR);
if (!f) {
- DBG(DEBUG_CONFIG, fprintf(stderr,
- "%s: does not exist, using built-in default\n", filename));
+ DBG(CONFIG, blkid_debug("%s: does not exist, using built-in default", filename));
goto dflt;
}
while (!feof(f)) {
if (parse_next(f, conf)) {
- DBG(DEBUG_CONFIG, fprintf(stderr,
- "%s: parse error\n", filename));
+ DBG(CONFIG, blkid_debug("%s: parse error", filename));
goto err;
}
}
@@ -178,7 +175,7 @@ int main(int argc, char *argv[])
struct blkid_config *conf;
char *filename = NULL;
- blkid_init_debug(DEBUG_ALL);
+ blkid_init_debug(BLKID_DEBUG_ALL);
if (argc == 2)
filename = argv[1];
diff --git a/libblkid/src/dev.c b/libblkid/src/dev.c
index 9180e4823..11d0a02ec 100644
--- a/libblkid/src/dev.c
+++ b/libblkid/src/dev.c
@@ -48,10 +48,10 @@ void blkid_free_dev(blkid_dev dev)
if (!dev)
return;
- DBG(DEBUG_DEV,
- printf(" freeing dev %s (%s)\n", dev->bid_name, dev->bid_type ?
+ DBG(DEV,
+ blkid_debug(" freeing dev %s (%s)", dev->bid_name, dev->bid_type ?
dev->bid_type : "(null)"));
- DBG(DEBUG_DEV, blkid_debug_dump_dev(dev));
+ DBG(DEV, blkid_debug_dump_dev(dev));
list_del(&dev->bid_devs);
while (!list_empty(&dev->bid_tags)) {
@@ -82,21 +82,20 @@ void blkid_debug_dump_dev(blkid_dev dev)
return;
}
- printf(" dev: name = %s\n", dev->bid_name);
- printf(" dev: DEVNO=\"0x%0llx\"\n", (long long)dev->bid_devno);
- printf(" dev: TIME=\"%ld.%ld\"\n", (long)dev->bid_time, (long)dev->bid_utime);
- printf(" dev: PRI=\"%d\"\n", dev->bid_pri);
- printf(" dev: flags = 0x%08X\n", dev->bid_flags);
+ fprintf(stderr, " dev: name = %s\n", dev->bid_name);
+ fprintf(stderr, " dev: DEVNO=\"0x%0llx\"\n", (long long)dev->bid_devno);
+ fprintf(stderr, " dev: TIME=\"%ld.%ld\"\n", (long)dev->bid_time, (long)dev->bid_utime);
+ fprintf(stderr, " dev: PRI=\"%d\"\n", dev->bid_pri);
+ fprintf(stderr, " 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);
if (tag)
- printf(" tag: %s=\"%s\"\n", tag->bit_name,
+ fprintf(stderr, " tag: %s=\"%s\"\n", tag->bit_name,
tag->bit_val);
else
- printf(" tag: NULL\n");
+ fprintf(stderr, " tag: NULL\n");
}
- printf("\n");
}
#endif
diff --git a/libblkid/src/devname.c b/libblkid/src/devname.c
index 68270d911..1c1ab07f8 100644
--- a/libblkid/src/devname.c
+++ b/libblkid/src/devname.c
@@ -60,8 +60,7 @@ blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags)
if (strcmp(tmp->bid_name, devname))
continue;
- DBG(DEBUG_DEVNAME,
- printf("found devname %s in cache\n", tmp->bid_name));
+ DBG(DEVNAME, blkid_debug("found devname %s in cache", tmp->bid_name));
dev = tmp;
break;
}
@@ -258,9 +257,9 @@ static dev_t lvm_get_devno(const char *lvm_device)
int ma, mi;
dev_t ret = 0;
- DBG(DEBUG_DEVNAME, printf("opening %s\n", lvm_device));
+ DBG(DEVNAME, blkid_debug("opening %s", lvm_device));
if ((lvf = fopen(lvm_device, "r" UL_CLOEXECSTR)) == NULL) {
- DBG(DEBUG_DEVNAME, printf("%s: (%d) %m\n", lvm_device, errno));
+ DBG(DEVNAME, blkid_debug("%s: (%d) %m", lvm_device, errno));
return 0;
}
@@ -285,7 +284,7 @@ static void lvm_probe_all(blkid_cache cache, int only_if_new)
if ((vg_list = opendir(VG_DIR)) == NULL)
return;
- DBG(DEBUG_DEVNAME, printf("probing LVM devices under %s\n", VG_DIR));
+ DBG(DEVNAME, blkid_debug("probing LVM devices under %s", VG_DIR));
while ((vg_iter = readdir(vg_list)) != NULL) {
DIR *lv_list;
@@ -323,7 +322,7 @@ static void lvm_probe_all(blkid_cache cache, int only_if_new)
lv_name);
dev = lvm_get_devno(lvm_device);
sprintf(lvm_device, "%s/%s", vg_name, lv_name);
- DBG(DEBUG_DEVNAME, printf("LVM dev %s: devno 0x%04X\n",
+ DBG(DEVNAME, blkid_debug("LVM dev %s: devno 0x%04X",
lvm_device,
(unsigned int) dev));
probe_one(cache, lvm_device, dev, BLKID_PRI_LVM,
@@ -355,7 +354,7 @@ evms_probe_all(blkid_cache cache, int only_if_new)
&ma, &mi, &sz, device) != 4)
continue;
- DBG(DEBUG_DEVNAME, printf("Checking partition %s (%d, %d)\n",
+ DBG(DEVNAME, blkid_debug("Checking partition %s (%d, %d)",
device, ma, mi));
probe_one(cache, device, makedev(ma, mi), BLKID_PRI_EVMS,
@@ -372,7 +371,7 @@ ubi_probe_all(blkid_cache cache, int only_if_new)
const char **dirname;
for (dirname = dirlist; *dirname; dirname++) {
- DBG(DEBUG_DEVNAME, printf("probing UBI volumes under %s\n",
+ DBG(DEVNAME, blkid_debug("probing UBI volumes under %s",
*dirname));
DIR *dir;
@@ -405,7 +404,7 @@ ubi_probe_all(blkid_cache cache, int only_if_new)
if (!S_ISCHR(st.st_mode) || !minor(dev))
continue;
- DBG(DEBUG_DEVNAME, printf("UBI vol %s/%s: devno 0x%04X\n",
+ DBG(DEVNAME, blkid_debug("UBI vol %s/%s: devno 0x%04X",
*dirname, name, (int) dev));
probe_one(cache, name, dev, BLKID_PRI_UBI, only_if_new, 0);
}
@@ -460,7 +459,7 @@ static int probe_all(blkid_cache cache, int only_if_new)
continue;
devs[which] = makedev(ma, mi);
- DBG(DEBUG_DEVNAME, printf("read partition name %s\n", ptname));
+ DBG(DEVNAME, blkid_debug("read partition name %s", ptname));
/* Skip whole disk devs unless they have no partitions.
* If base name of device has changed, also
@@ -478,8 +477,7 @@ static int probe_all(blkid_cache cache, int only_if_new)
/* ends in a digit, clearly a partition, so check */
if (isdigit(ptname[lens[which] - 1])) {
- DBG(DEBUG_DEVNAME,
- printf("partition dev %s, devno 0x%04X\n",
+ DBG(DEVNAME, blkid_debug("partition dev %s, devno 0x%04X",
ptname, (unsigned int) devs[which]));
if (sz > 1)
@@ -501,8 +499,7 @@ static int probe_all(blkid_cache cache, int only_if_new)
tmp = list_entry(p, struct blkid_struct_dev,
bid_devs);
if (tmp->bid_devno == devs[last]) {
- DBG(DEBUG_DEVNAME,
- printf("freeing %s\n",
+ DBG(DEVNAME, blkid_debug("freeing %s",
tmp->bid_name));
blkid_free_dev(tmp);
cache->bic_flags |= BLKID_BIC_FL_CHANGED;
@@ -517,8 +514,7 @@ static int probe_all(blkid_cache cache, int only_if_new)
* check last as well.
*/
if (lens[last] && strncmp(ptnames[last], ptname, lens[last])) {
- DBG(DEBUG_DEVNAME,
- printf("whole dev %s, devno 0x%04X\n",
+ DBG(DEVNAME, blkid_debug("whole dev %s, devno 0x%04X",
ptnames[last], (unsigned int) devs[last]));
probe_one(cache, ptnames[last], devs[last], 0,
only_if_new, 0);
@@ -594,13 +590,13 @@ int blkid_probe_all(blkid_cache cache)
{
int ret;
- DBG(DEBUG_PROBE, printf("Begin blkid_probe_all()\n"));
+ DBG(PROBE, blkid_debug("Begin blkid_probe_all()"));
ret = probe_all(cache, 0);
if (ret == 0) {
cache->bic_time = time(0);
cache->bic_flags |= BLKID_BIC_FL_PROBED;
}
- DBG(DEBUG_PROBE, printf("End blkid_probe_all() [rc=%d]\n", ret));
+ DBG(PROBE, blkid_debug("End blkid_probe_all() [rc=%d]", ret));
return ret;
}
@@ -616,9 +612,9 @@ int blkid_probe_all_new(blkid_cache cache)
{
int ret;
- DBG(DEBUG_PROBE, printf("Begin blkid_probe_all_new()\n"));
+ DBG(PROBE, blkid_debug("Begin blkid_probe_all_new()"));
ret = probe_all(cache, 1);
- DBG(DEBUG_PROBE, printf("End blkid_probe_all_new() [rc=%d]\n", ret));
+ DBG(PROBE, blkid_debug("End blkid_probe_all_new() [rc=%d]", ret));
return ret;
}
@@ -644,9 +640,9 @@ int blkid_probe_all_removable(blkid_cache cache)
{
int ret;
- DBG(DEBUG_PROBE, printf("Begin blkid_probe_all_removable()\n"));
+ DBG(PROBE, blkid_debug("Begin blkid_probe_all_removable()"));
ret = probe_all_removable(cache);
- DBG(DEBUG_PROBE, printf("End blkid_probe_all_removable() [rc=%d]\n", ret));
+ DBG(PROBE, blkid_debug("End blkid_probe_all_removable() [rc=%d]", ret));
return ret;
}
@@ -656,7 +652,7 @@ int main(int argc, char **argv)
blkid_cache cache = NULL;
int ret;
- blkid_init_debug(DEBUG_ALL);
+ blkid_init_debug(BLKID_DEBUG_ALL);
if (argc != 1) {
fprintf(stderr, "Usage: %s\n"
"Probe all devices and exit\n", argv[0]);
diff --git a/libblkid/src/devno.c b/libblkid/src/devno.c
index cdf3d5bfc..56f4531a5 100644
--- a/libblkid/src/devno.c
+++ b/libblkid/src/devno.c
@@ -131,8 +131,7 @@ void blkid__scan_dir(char *dirname, dev_t devno, struct dir_list **list,
if (S_ISBLK(st.st_mode) && st.st_rdev == devno) {
*devname = blkid_strconcat(dirname, "/", dp->d_name);
- DBG(DEBUG_DEVNO,
- printf("found 0x%llx at %s\n", (long long)devno,
+ DBG(DEVNO, blkid_debug("found 0x%llx at %s", (long long)devno,
*devname));
break;
}
@@ -194,7 +193,7 @@ static char *scandev_devno_to_devpath(dev_t devno)
struct dir_list *current = list;
list = list->next;
- DBG(DEBUG_DEVNO, printf("directory %s\n", current->name));
+ DBG(DEVNO, blkid_debug("directory %s", current->name));
blkid__scan_dir(current->name, devno, &new_list, &devname);
free(current->name);
free(current);
@@ -237,12 +236,10 @@ char *blkid_devno_to_devname(dev_t devno)
path = scandev_devno_to_devpath(devno);
if (!path) {
- DBG(DEBUG_DEVNO,
- printf("blkid: couldn't find devno 0x%04lx\n",
+ DBG(DEVNO, blkid_debug("blkid: couldn't find devno 0x%04lx",
(unsigned long) devno));
} else {
- DBG(DEBUG_DEVNO,
- printf("found devno 0x%04llx as %s\n", (long long)devno, path));
+ DBG(DEVNO, blkid_debug("found devno 0x%04llx as %s", (long long)devno, path));
}
return path;
@@ -324,7 +321,7 @@ int blkid_driver_has_major(const char *drvname, int major)
fclose(f);
- DBG(DEBUG_DEVNO, printf("major %d %s associated with '%s' driver\n",
+ DBG(DEVNO, blkid_debug("major %d %s associated with '%s' driver",
major, match ? "is" : "is NOT", drvname));
return match;
}
@@ -339,7 +336,7 @@ int main(int argc, char** argv)
dev_t devno, disk_devno;
const char *errmsg = "Couldn't parse %s: %s\n";
- blkid_init_debug(DEBUG_ALL);
+ blkid_init_debug(BLKID_DEBUG_ALL);
if ((argc != 2) && (argc != 3)) {
fprintf(stderr, "Usage:\t%s device_number\n\t%s major minor\n"
"Resolve a device number to a device name\n",
diff --git a/libblkid/src/evaluate.c b/libblkid/src/evaluate.c
index e03370750..8853009c9 100644
--- a/libblkid/src/evaluate.c
+++ b/libblkid/src/evaluate.c
@@ -83,7 +83,7 @@ static int verify_tag(const char *devname, const char *name, const char *value)
if (!rc)
rc = memcmp(value, data, len);
done:
- DBG(DEBUG_EVALUATE, printf("%s: %s verification %s\n",
+ DBG(EVALUATE, blkid_debug("%s: %s verification %s",
devname, name, rc == 0 ? "PASS" : "FAILED"));
if (fd >= 0)
close(fd);
@@ -108,7 +108,7 @@ int blkid_send_uevent(const char *devname, const char *action)
FILE *f;
int rc = -1;
- DBG(DEBUG_EVALUATE, printf("%s: uevent '%s' requested\n", devname, action));
+ DBG(EVALUATE, blkid_debug("%s: uevent '%s' requested", devname, action));
if (!devname || !action)
return -1;
@@ -125,7 +125,7 @@ int blkid_send_uevent(const char *devname, const char *action)
rc = 0;
fclose(f);
}
- DBG(DEBUG_EVALUATE, printf("%s: send uevent %s\n",
+ DBG(EVALUATE, blkid_debug("%s: send uevent %s",
uevent, rc == 0 ? "SUCCES" : "FAILED"));
return rc;
}
@@ -137,8 +137,7 @@ static char *evaluate_by_udev(const char *token, const char *value, int uevent)
size_t len;
struct stat st;
- DBG(DEBUG_EVALUATE,
- printf("evaluating by udev %s=%s\n", token, value));
+ DBG(EVALUATE, blkid_debug("evaluating by udev %s=%s", token, value));
if (!strcmp(token, "UUID"))
strcpy(dev, _PATH_DEV_BYUUID "/");
@@ -149,8 +148,7 @@ static char *evaluate_by_udev(const char *token, const char *value, int uevent)
else if (!strcmp(token, "PARTUUID"))
strcpy(dev, _PATH_DEV_BYPARTUUID "/");
else {
- DBG(DEBUG_EVALUATE,
- printf("unsupported token %s\n", token));
+ DBG(EVALUATE, blkid_debug("unsupported token %s", token));
return NULL; /* unsupported tag */
}
@@ -158,8 +156,7 @@ static char *evaluate_by_udev(const char *token, const char *value, int uevent)
if (blkid_encode_string(value, &dev[len], sizeof(dev) - len) != 0)
return NULL;
- DBG(DEBUG_EVALUATE,
- printf("expected udev link: %s\n", dev));
+ DBG(EVALUATE, blkid_debug("expected udev link: %s", dev));
if (stat(dev, &st))
goto failed; /* link or device does not exist */
@@ -178,7 +175,7 @@ static char *evaluate_by_udev(const char *token, const char *value, int uevent)
return path;
failed:
- DBG(DEBUG_EVALUATE, printf("failed to evaluate by udev\n"));
+ DBG(EVALUATE, blkid_debug("failed to evaluate by udev"));
if (uevent && path)
blkid_send_uevent(path, "change");
@@ -192,8 +189,7 @@ static char *evaluate_by_scan(const char *token, const char *value,
blkid_cache c = cache ? *cache : NULL;
char *res;
- DBG(DEBUG_EVALUATE,
- printf("evaluating by blkid scan %s=%s\n", token, value));
+ DBG(EVALUATE, blkid_debug("evaluating by blkid scan %s=%s", token, value));
if (!c) {
char *cachefile = blkid_get_cache_filename(conf);
@@ -234,8 +230,7 @@ char *blkid_evaluate_tag(const char *token, const char *value, blkid_cache *cach
if (!cache || !*cache)
blkid_init_debug(0);
- DBG(DEBUG_EVALUATE,
- printf("evaluating %s%s%s\n", token, value ? "=" : "",
+ DBG(EVALUATE, blkid_debug("evaluating %s%s%s", token, value ? "=" : "",
value ? value : ""));
if (!value) {
@@ -263,8 +258,7 @@ char *blkid_evaluate_tag(const char *token, const char *value, blkid_cache *cach
break;
}
- DBG(DEBUG_EVALUATE,
- printf("%s=%s evaluated as %s\n", token, value, ret));
+ DBG(EVALUATE, blkid_debug("%s=%s evaluated as %s", token, value, ret));
out:
blkid_free_config(conf);
free(t);
diff --git a/libblkid/src/partitions/bsd.c b/libblkid/src/partitions/bsd.c
index c39c78aa4..08fcad892 100644
--- a/libblkid/src/partitions/bsd.c
+++ b/libblkid/src/partitions/bsd.c
@@ -143,9 +143,9 @@ static int probe_bsd_pt(blkid_probe pr, const struct blkid_idmag *mag)
name = "openbsd";
break;
default:
- DBG(DEBUG_LOWPROBE, printf(
+ DBG(LOWPROBE, blkid_debug(
"WARNING: BSD label detected on unknown (0x%x) "
- "primary partition\n",
+ "primary partition",
blkid_partition_get_type(parent)));
break;
}
@@ -159,8 +159,8 @@ static int probe_bsd_pt(blkid_probe pr, const struct blkid_idmag *mag)
nparts = le16_to_cpu(l->d_npartitions);
else if (le16_to_cpu(l->d_npartitions) > BSD_MAXPARTITIONS)
- DBG(DEBUG_LOWPROBE, printf(
- "WARNING: ignore %d more BSD partitions\n",
+ DBG(LOWPROBE, blkid_debug(
+ "WARNING: ignore %d more BSD partitions",
le16_to_cpu(l->d_npartitions) - BSD_MAXPARTITIONS));
for (i = 0, p = l->d_partitions; i < nparts; i++, p++) {
@@ -176,15 +176,15 @@ static int probe_bsd_pt(blkid_probe pr, const struct blkid_idmag *mag)
if (parent && blkid_partition_get_start(parent) == start
&& blkid_partition_get_size(parent) == size) {
- DBG(DEBUG_LOWPROBE, printf(
+ DBG(LOWPROBE, blkid_debug(
"WARNING: BSD partition (%d) same like parent, "
- "ignore\n", i));
+ "ignore", i));
continue;
}
if (parent && !blkid_is_nested_dimension(parent, start, size)) {
- DBG(DEBUG_LOWPROBE, printf(
+ DBG(LOWPROBE, blkid_debug(
"WARNING: BSD partition (%d) overflow "
- "detected, ignore\n", i));
+ "detected, ignore", i));
continue;
}
diff --git a/libblkid/src/partitions/dos.c b/libblkid/src/partitions/dos.c
index 58877691d..3a0a6d73e 100644
--- a/libblkid/src/partitions/dos.c
+++ b/libblkid/src/partitions/dos.c
@@ -153,7 +153,7 @@ static int probe_dos_pt(blkid_probe pr,
* partition table.
*/
if (blkid_probe_is_vfat(pr)) {
- DBG(DEBUG_LOWPROBE, printf("probably FAT -- ignore\n"));
+ DBG(LOWPROBE, blkid_debug("probably FAT -- ignore"));
goto nothing;
}
@@ -164,7 +164,7 @@ static int probe_dos_pt(blkid_probe pr,
*/
for (p = p0, i = 0; i < 4; i++, p++)
if (p->boot_ind != 0 && p->boot_ind != 0x80) {
- DBG(DEBUG_LOWPROBE, printf("missing boot indicator -- ignore\n"));
+ DBG(LOWPROBE, blkid_debug("missing boot indicator -- ignore"));
goto nothing;
}
@@ -173,7 +173,7 @@ static int probe_dos_pt(blkid_probe pr,
*/
for (p = p0, i = 0; i < 4; i++, p++) {
if (p->sys_type == BLKID_GPT_PARTITION) {
- DBG(DEBUG_LOWPROBE, printf("probably GPT -- ignore\n"));
+ DBG(LOWPROBE, blkid_debug("probably GPT -- ignore"));
goto nothing;
}
}
diff --git a/libblkid/src/partitions/gpt.c b/libblkid/src/partitions/gpt.c
index 7288d683e..444193929 100644
--- a/libblkid/src/partitions/gpt.c
+++ b/libblkid/src/partitions/gpt.c
@@ -232,14 +232,14 @@ static struct gpt_header *get_gpt_header(
h->header_crc32 = orgcrc;
if (crc != le32_to_cpu(orgcrc)) {
- DBG(DEBUG_LOWPROBE, printf("GPT header corrupted\n"));
+ DBG(LOWPROBE, blkid_debug("GPT header corrupted"));
return NULL;
}
/* Valid header has to be at MyLBA */
if (le64_to_cpu(h->my_lba) != lba) {
- DBG(DEBUG_LOWPROBE, printf(
- "GPT->MyLBA mismatch with real position\n"));
+ DBG(LOWPROBE, blkid_debug(
+ "GPT->MyLBA mismatch with real position"));
return NULL;
}
@@ -248,14 +248,14 @@ static struct gpt_header *get_gpt_header(
/* Check if First and Last usable LBA makes sense */
if (lu < fu || fu > lastlba || lu > lastlba) {
- DBG(DEBUG_LOWPROBE, printf(
- "GPT->{First,Last}UsableLBA out of range\n"));
+ DBG(LOWPROBE, blkid_debug(
+ "GPT->{First,Last}UsableLBA out of range"));
return NULL;
}
/* The header has to be outside usable range */
if (fu < lba && lba < lu) {
- DBG(DEBUG_LOWPROBE, printf("GPT header is inside usable area\n"));
+ DBG(LOWPROBE, blkid_debug("GPT header is inside usable area"));
return NULL;
}
@@ -263,7 +263,7 @@ static struct gpt_header *get_gpt_header(
esz = le32_to_cpu(h->num_partition_entries) *
le32_to_cpu(h->sizeof_partition_entry);
if (!esz) {
- DBG(DEBUG_LOWPROBE, printf("GPT entries undefined\n"));
+ DBG(LOWPROBE, blkid_debug("GPT entries undefined"));
return NULL;
}
@@ -276,14 +276,14 @@ static struct gpt_header *get_gpt_header(
*ents = (struct gpt_entry *) get_lba_buffer(pr,
le64_to_cpu(h->partition_entries_lba), esz);
if (!*ents) {
- DBG(DEBUG_LOWPROBE, printf("GPT entries unreadable\n"));
+ DBG(LOWPROBE, blkid_debug("GPT entries unreadable"));
return NULL;
}
/* Validate entries */
crc = count_crc32((unsigned char *) *ents, esz);
if (crc != le32_to_cpu(h->partition_entry_array_crc32)) {
- DBG(DEBUG_LOWPROBE, printf("GPT entries corrupted\n"));
+ DBG(LOWPROBE, blkid_debug("GPT entries corrupted"));
return NULL;
}
@@ -357,8 +357,8 @@ static int probe_gpt_pt(blkid_probe pr,
}
/* the partition has to inside usable range */
if (start < fu || start + size - 1 > lu) {
- DBG(DEBUG_LOWPROBE, printf(
- "GPT entry[%d] overflows usable area - ignore\n",
+ DBG(LOWPROBE, blkid_debug(
+ "GPT entry[%d] overflows usable area - ignore",
i));
blkid_partlist_increment_partno(ls);
continue;
diff --git a/libblkid/src/partitions/mac.c b/libblkid/src/partitions/mac.c
index e18896cba..7f8bb75ef 100644
--- a/libblkid/src/partitions/mac.c
+++ b/libblkid/src/partitions/mac.c
@@ -130,9 +130,9 @@ static int probe_mac_pt(blkid_probe pr,
goto nothing;
if (be32_to_cpu(p->map_count) != nblks) {
- DBG(DEBUG_LOWPROBE, printf(
+ DBG(LOWPROBE, blkid_debug(
"mac: inconsisten map_count in partition map, "
- "entry[0]: %d, entry[%d]: %d\n",
+ "entry[0]: %d, entry[%d]: %d",
nblks, i - 1,
be32_to_cpu(p->map_count)));
}
diff --git a/libblkid/src/partitions/minix.c b/libblkid/src/partitions/minix.c
index bd57a6d4b..0cd9f432e 100644
--- a/libblkid/src/partitions/minix.c
+++ b/libblkid/src/partitions/minix.c
@@ -64,9 +64,9 @@ static int probe_minix_pt(blkid_probe pr,
size = dos_partition_size(p);
if (parent && !blkid_is_nested_dimension(parent, start, size)) {
- DBG(DEBUG_LOWPROBE, printf(
+ DBG(LOWPROBE, blkid_debug(
"WARNING: minix partition (%d) overflow "
- "detected, ignore\n", i));
+ "detected, ignore", i));
continue;
}
diff --git a/libblkid/src/partitions/partitions.c b/libblkid/src/partitions/partitions.c
index 93ec4d224..87ca0c1f8 100644
--- a/libblkid/src/partitions/partitions.c
+++ b/libblkid/src/partitions/partitions.c
@@ -361,7 +361,7 @@ static void reset_partlist(blkid_partlist ls)
ls->next_partno = 1;
INIT_LIST_HEAD(&ls->l_tabs);
- DBG(DEBUG_LOWPROBE, printf("partlist reset\n"));
+ DBG(LOWPROBE, blkid_debug("partlist reset"));
}
static blkid_partlist partitions_init_data(struct blkid_chain *chn)
@@ -380,8 +380,7 @@ static blkid_partlist partitions_init_data(struct blkid_chain *chn)
reset_partlist(ls);
- DBG(DEBUG_LOWPROBE,
- printf("parts: initialized partitions list (%p, size=%d)\n",
+ DBG(LOWPROBE, blkid_debug("parts: initialized partitions list (%p, size=%d)",
ls, ls->nparts_max));
return ls;
}
@@ -416,9 +415,8 @@ blkid_parttable blkid_partlist_new_parttable(blkid_partlist ls,
INIT_LIST_HEAD(&tab->t_tabs);
list_add_tail(&tab->t_tabs, &ls->l_tabs);
- DBG(DEBUG_LOWPROBE,
- printf("parts: create a new partition table "
- "(%p, type=%s, offset=%"PRId64")\n", tab, type, offset));
+ DBG(LOWPROBE, blkid_debug("parts: create a new partition table "
+ "(%p, type=%s, offset=%"PRId64")", tab, type, offset));
return tab;
}
@@ -459,9 +457,8 @@ blkid_partition blkid_partlist_add_partition(blkid_partlist ls,
par->start = start;
par->size = size;
- DBG(DEBUG_LOWPROBE,
- printf("parts: add partition (%p start=%"
- PRId64 ", size=%" PRId64 ", table=%p)\n",
+ DBG(LOWPROBE, blkid_debug("parts: add partition (%p start=%"
+ PRId64 ", size=%" PRId64 ", table=%p)",
par, par->start, par->size, tab));
return par;
}
@@ -545,23 +542,21 @@ static int idinfo_probe(blkid_probe pr, const struct blkid_idinfo *id,
/* final check by probing function */
if (id->probefunc) {
- DBG(DEBUG_LOWPROBE, printf(
- "%s: ---> call probefunc()\n", id->name));
+ DBG(LOWPROBE, blkid_debug(
+ "%s: ---> call probefunc()", id->name));
rc = id->probefunc(pr, mag);
if (rc == -1) {
/* reset after error */
reset_partlist(blkid_probe_get_partlist(pr));
if (chn && !chn->binary)
blkid_probe_chain_reset_vals(pr, chn);
- DBG(DEBUG_LOWPROBE, printf(
- "%s probefunc failed\n", id->name));
+ DBG(LOWPROBE, blkid_debug("%s probefunc failed", id->name));
}
if (rc == 0 && mag && chn && !chn->binary)
rc = blkid_probe_set_magic(pr, off, mag->len,
(unsigned char *) mag->magic);
- DBG(DEBUG_LOWPROBE, printf(
- "%s: <--- (rc = %d)\n", id->name, rc));
+ DBG(LOWPROBE, blkid_debug("%s: <--- (rc = %d)", id->name, rc));
}
nothing:
@@ -586,8 +581,7 @@ static int partitions_probe(blkid_probe pr, struct blkid_chain *chn)
if (!pr->wipe_size && (pr->prob_flags & BLKID_PROBE_FL_IGNORE_PT))
goto details_only;
- DBG(DEBUG_LOWPROBE,
- printf("--> starting probing loop [PARTS idx=%d]\n",
+ DBG(LOWPROBE, blkid_debug("--> starting probing loop [PARTS idx=%d]",
chn->idx));
i = chn->idx < 0 ? 0 : chn->idx + 1U;
@@ -612,16 +606,14 @@ static int partitions_probe(blkid_probe pr, struct blkid_chain *chn)
blkid_probe_set_value(pr, "PTTYPE",
(unsigned char *) name,
strlen(name) + 1);
- DBG(DEBUG_LOWPROBE,
- printf("<-- leaving probing loop (type=%s) [PARTS idx=%d]\n",
+ DBG(LOWPROBE, blkid_debug("<-- leaving probing loop (type=%s) [PARTS idx=%d]",
name, chn->idx));
rc = 0;
break;
}
if (rc == 1) {
- DBG(DEBUG_LOWPROBE,
- printf("<-- leaving probing loop (failed) [PARTS idx=%d]\n",
+ DBG(LOWPROBE, blkid_debug("<-- leaving probing loop (failed) [PARTS idx=%d]",
chn->idx));
}
@@ -648,8 +640,8 @@ int blkid_partitions_do_subprobe(blkid_probe pr, blkid_partition parent,
blkid_partlist ls;
blkid_loff_t sz, off;
- DBG(DEBUG_LOWPROBE, printf(
- "parts: ----> %s subprobe requested (parent=%p)\n",
+ DBG(LOWPROBE, blkid_debug(
+ "parts: ----> %s subprobe requested (parent=%p)",
id->name, parent));
if (!pr || !parent || !parent->size)
@@ -660,8 +652,8 @@ int blkid_partitions_do_subprobe(blkid_probe pr, blkid_partition parent,
off = ((blkid_loff_t) parent->start) << 9;
if (off < pr->off || pr->off + pr->size < off + sz) {
- DBG(DEBUG_LOWPROBE, printf(
- "ERROR: parts: <---- '%s' subprobe: overflow detected.\n",
+ DBG(LOWPROBE, blkid_debug(
+ "ERROR: parts: <---- '%s' subprobe: overflow detected.",
id->name));
return -1;
}
@@ -693,8 +685,8 @@ int blkid_partitions_do_subprobe(blkid_probe pr, blkid_partition parent,
blkid_free_probe(prc); /* free cloned prober */
- DBG(DEBUG_LOWPROBE, printf(
- "parts: <---- %s subprobe done (parent=%p, rc=%d)\n",
+ DBG(LOWPROBE, blkid_debug(
+ "parts: <---- %s subprobe done (parent=%p, rc=%d)",
id->name, parent, rc));
return rc;
@@ -785,8 +777,8 @@ int blkid_probe_is_covered_by_pt(blkid_probe pr,
blkid_loff_t start, end;
int nparts, i, rc = 0;
- DBG(DEBUG_LOWPROBE, printf(
- "=> checking if off=%jd size=%jd covered by PT\n",
+ DBG(LOWPROBE, blkid_debug(
+ "=> checking if off=%jd size=%jd covered by PT",
offset, size));
prc = blkid_clone_probe(pr);
@@ -809,8 +801,8 @@ int blkid_probe_is_covered_by_pt(blkid_probe pr,
blkid_partition par = &ls->parts[i];
if (par->start + par->size > (pr->size >> 9)) {
- DBG(DEBUG_LOWPROBE, printf("partition #%d overflows "
- "device (off=%" PRId64 " size=%" PRId64 ")\n",
+ DBG(LOWPROBE, blkid_debug("partition #%d overflows "
+ "device (off=%" PRId64 " size=%" PRId64 ")",
par->partno, par->start, par->size));
goto done;
}
@@ -828,7 +820,7 @@ int blkid_probe_is_covered_by_pt(blkid_probe pr,
done:
blkid_free_probe(prc);
- DBG(DEBUG_LOWPROBE, printf("<= %s covered by PT\n", rc ? "IS" : "NOT"));
+ DBG(LOWPROBE, blkid_debug("<= %s covered by PT", rc ? "IS" : "NOT"));
return rc;
}
@@ -924,12 +916,11 @@ blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno
if (!ls)
return NULL;
- DBG(DEBUG_LOWPROBE,
- printf("triyng to convert devno 0x%llx to partition\n",
+ DBG(LOWPROBE, blkid_debug("triyng to convert devno 0x%llx to partition",
(long long) devno));
if (sysfs_init(&sysfs, devno, NULL)) {
- DBG(DEBUG_LOWPROBE, printf("failed t init sysfs context\n"));
+ DBG(LOWPROBE, blkid_debug("failed t init sysfs context"));
return NULL;
}
rc = sysfs_read_u64(&sysfs, "size", &size);
@@ -961,7 +952,7 @@ blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno
return NULL;
if (partno) {
- DBG(DEBUG_LOWPROBE, printf("mapped by DM, using partno %d\n", partno));
+ DBG(LOWPROBE, blkid_debug("mapped by DM, using partno %d", partno));
/*
* Partition mapped by kpartx does not provide "start" offset
@@ -983,7 +974,7 @@ blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno
return NULL;
}
- DBG(DEBUG_LOWPROBE, printf("searching by offset/size\n"));
+ DBG(LOWPROBE, blkid_debug("searching by offset/size"));
for (i = 0; i < ls->nparts; i++) {
blkid_partition par = &ls->parts[i];
@@ -999,7 +990,7 @@ blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno
}
- DBG(DEBUG_LOWPROBE, printf("not found partition for device\n"));
+ DBG(LOWPROBE, blkid_debug("not found partition for device"));
return NULL;
}
diff --git a/libblkid/src/partitions/sgi.c b/libblkid/src/partitions/sgi.c
index b89e46320..b292e7150 100644
--- a/libblkid/src/partitions/sgi.c
+++ b/libblkid/src/partitions/sgi.c
@@ -103,8 +103,8 @@ static int probe_sgi_pt(blkid_probe pr,
goto nothing;
if (count_checksum(l)) {
- DBG(DEBUG_LOWPROBE, printf(
- "detected corrupted sgi disk label -- ignore\n"));
+ DBG(LOWPROBE, blkid_debug(
+ "detected corrupted sgi disk label -- ignore"));
goto nothing;
}
diff --git a/libblkid/src/partitions/solaris_x86.c b/libblkid/src/partitions/solaris_x86.c
index 7824f4ee7..4e08caf20 100644
--- a/libblkid/src/partitions/solaris_x86.c
+++ b/libblkid/src/partitions/solaris_x86.c
@@ -73,8 +73,8 @@ static int probe_solaris_pt(blkid_probe pr,
goto nothing;
if (le32_to_cpu(l->v_version) != 1) {
- DBG(DEBUG_LOWPROBE, printf(
- "WARNING: unsupported solaris x86 version %d, ignore\n",
+ DBG(LOWPROBE, blkid_debug(
+ "WARNING: unsupported solaris x86 version %d, ignore",
le32_to_cpu(l->v_version)));
goto nothing;
}
@@ -112,9 +112,9 @@ static int probe_solaris_pt(blkid_probe pr,
start += blkid_partition_get_start(parent);
if (parent && !blkid_is_nested_dimension(parent, start, size)) {
- DBG(DEBUG_LOWPROBE, printf(
+ DBG(LOWPROBE, blkid_debug(
"WARNING: solaris partition (%d) overflow "
- "detected, ignore\n", i));
+ "detected, ignore", i));
continue;
}
diff --git a/libblkid/src/partitions/sun.c b/libblkid/src/partitions/sun.c
index c2c700d96..ba7ca3a5e 100644
--- a/libblkid/src/partitions/sun.c
+++ b/libblkid/src/partitions/sun.c
@@ -31,8 +31,8 @@ static int probe_sun_pt(blkid_probe pr,
goto nothing;
if (sun_pt_checksum(l)) {
- DBG(DEBUG_LOWPROBE, printf(
- "detected corrupted sun disk label -- ignore\n"));
+ DBG(LOWPROBE, blkid_debug(
+ "detected corrupted sun disk label -- ignore"));
goto nothing;
}
@@ -51,8 +51,7 @@ static int probe_sun_pt(blkid_probe pr,
/* sectors per cylinder (partition offset is in cylinders...) */
spc = be16_to_cpu(l->nhead) * be16_to_cpu(l->nsect);
- DBG(DEBUG_LOWPROBE,
- printf("Sun VTOC sanity=%u version=%u nparts=%u\n",
+ DBG(LOWPROBE, blkid_debug("Sun VTOC sanity=%u version=%u nparts=%u",
be32_to_cpu(l->vtoc.sanity),
be32_to_cpu(l->vtoc.version),
be16_to_cpu(l->vtoc.nparts)));
diff --git a/libblkid/src/partitions/unixware.c b/libblkid/src/partitions/unixware.c
index e9bcba358..ce176b8d0 100644
--- a/libblkid/src/partitions/unixware.c
+++ b/libblkid/src/partitions/unixware.c
@@ -147,9 +147,9 @@ static int probe_unixware_pt(blkid_probe pr,
size = le32_to_cpu(p->nr_sects);
if (parent && !blkid_is_nested_dimension(parent, start, size)) {
- DBG(DEBUG_LOWPROBE, printf(
+ DBG(LOWPROBE, blkid_debug(
"WARNING: unixware partition (%d) overflow "
- "detected, ignore\n", i));
+ "detected, ignore", i));
continue;
}
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c
index 5db48b72f..954b08708 100644
--- a/libblkid/src/probe.c
+++ b/libblkid/src/probe.c
@@ -143,7 +143,7 @@ blkid_probe blkid_new_probe(void)
if (!pr)
return NULL;
- DBG(DEBUG_LOWPROBE, printf("allocate a new probe %p\n", pr));
+ DBG(LOWPROBE, blkid_debug("allocate a new probe %p", pr));
/* initialize chains */
for (i = 0; i < BLKID_NCHAINS; i++) {
@@ -168,7 +168,7 @@ blkid_probe blkid_clone_probe(blkid_probe parent)
if (!parent)
return NULL;
- DBG(DEBUG_LOWPROBE, printf("allocate a probe clone\n"));
+ DBG(LOWPROBE, blkid_debug("allocate a probe clone"));
pr = blkid_new_probe();
if (!pr)
@@ -258,7 +258,7 @@ void blkid_free_probe(blkid_probe pr)
blkid_probe_reset_buffer(pr);
blkid_free_probe(pr->disk_probe);
- DBG(DEBUG_LOWPROBE, printf("free probe %p\n", pr));
+ DBG(LOWPROBE, blkid_debug("free probe %p", pr));
free(pr);
}
@@ -368,8 +368,7 @@ void *blkid_probe_get_binary_data(blkid_probe pr, struct blkid_chain *chn)
if (rc != 0)
return NULL;
- DBG(DEBUG_LOWPROBE,
- printf("returning %s binary data\n", chn->driver->name));
+ DBG(LOWPROBE, blkid_debug("returning %s binary data", chn->driver->name));
return chn->data;
}
@@ -415,7 +414,7 @@ static int blkid_probe_dump_filter(blkid_probe pr, int chain)
for (i = 0; i < chn->driver->nidinfos; i++) {
const struct blkid_idinfo *id = chn->driver->idinfos[i];
- DBG(DEBUG_LOWPROBE, printf("%d: %s: %s\n",
+ DBG(LOWPROBE, blkid_debug("%d: %s: %s",
i,
id->name,
blkid_bmp_get_item(chn->fltr, i)
@@ -474,7 +473,7 @@ int __blkid_probe_invert_filter(blkid_probe pr, int chain)
for (i = 0; i < blkid_bmp_nwords(chn->driver->nidinfos); i++)
chn->fltr[i] = ~chn->fltr[i];
- DBG(DEBUG_LOWPROBE, printf("probing filter inverted\n"));
+ DBG(LOWPROBE, blkid_debug("probing filter inverted"));
/* blkid_probe_dump_filter(pr, chain); */
return 0;
}
@@ -516,8 +515,7 @@ int __blkid_probe_filter_types(blkid_probe pr, int chain, int flag, char *names[
}
}
- DBG(DEBUG_LOWPROBE,
- printf("%s: a new probing type-filter initialized\n",
+ DBG(LOWPROBE, blkid_debug("%s: a new probing type-filter initialized",
chn->driver->name));
/* blkid_probe_dump_filter(pr, chain); */
return 0;
@@ -552,8 +550,7 @@ unsigned char *blkid_probe_get_buffer(blkid_probe pr,
list_entry(p, struct blkid_bufinfo, bufs);
if (x->off <= off && off + len <= x->off + x->len) {
- DBG(DEBUG_LOWPROBE,
- printf("\treuse buffer: off=%jd len=%jd pr=%p\n",
+ DBG(LOWPROBE, blkid_debug("\treuse buffer: off=%jd len=%jd pr=%p",
x->off, x->len, pr));
bf = x;
break;
@@ -575,8 +572,7 @@ unsigned char *blkid_probe_get_buffer(blkid_probe pr,
bf->off = off;
INIT_LIST_HEAD(&bf->bufs);
- DBG(DEBUG_LOWPROBE,
- printf("\tbuffer read: off=%jd len=%jd pr=%p\n",
+ DBG(LOWPROBE, blkid_debug("\tbuffer read: off=%jd len=%jd pr=%p",
off, len, pr));
ret = read(pr->fd, bf->data, len);
@@ -598,7 +594,7 @@ static void blkid_probe_reset_buffer(blkid_probe pr)
if (!pr || list_empty(&pr->buffers))
return;
- DBG(DEBUG_LOWPROBE, printf("reseting probing buffers pr=%p\n", pr));
+ DBG(LOWPROBE, blkid_debug("reseting probing buffers pr=%p", pr));
while (!list_empty(&pr->buffers)) {
struct blkid_bufinfo *bf = list_entry(pr->buffers.next,
@@ -609,9 +605,8 @@ static void blkid_probe_reset_buffer(blkid_probe pr)
free(bf);
}
- DBG(DEBUG_LOWPROBE,
- printf("buffers summary: %"PRIu64" bytes "
- "by %"PRIu64" read() call(s)\n",
+ DBG(LOWPROBE, blkid_debug("buffers summary: %"PRIu64" bytes "
+ "by %"PRIu64" read() call(s)",
len_ct, read_ct));
INIT_LIST_HEAD(&pr->buffers);
@@ -693,8 +688,7 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
else {
if (S_ISBLK(sb.st_mode)) {
if (blkdev_get_size(fd, (unsigned long long *) &pr->size)) {
- DBG(DEBUG_LOWPROBE, printf(
- "failed to get device size\n"));
+ DBG(LOWPROBE, blkid_debug("failed to get device size"));
goto err;
}
} else if (S_ISCHR(sb.st_mode))
@@ -721,16 +715,15 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
pr->flags |= BLKID_FL_CDROM_DEV;
#endif
- DBG(DEBUG_LOWPROBE, printf("ready for low-probing, offset=%jd, size=%jd\n",
+ DBG(LOWPROBE, blkid_debug("ready for low-probing, offset=%jd, size=%jd",
pr->off, pr->size));
- DBG(DEBUG_LOWPROBE, printf("whole-disk: %s, regfile: %s\n",
+ DBG(LOWPROBE, blkid_debug("whole-disk: %s, regfile: %s",
blkid_probe_is_wholedisk(pr) ?"YES" : "NO",
S_ISREG(pr->mode) ? "YES" : "NO"));
return 0;
err:
- DBG(DEBUG_LOWPROBE,
- printf("failed to prepare a device for low-probing\n"));
+ DBG(LOWPROBE, blkid_debug("failed to prepare a device for low-probing"));
return -1;
}
@@ -752,9 +745,9 @@ int blkid_probe_set_dimension(blkid_probe pr,
if (!pr)
return -1;
- DBG(DEBUG_LOWPROBE, printf(
+ DBG(LOWPROBE, blkid_debug(
"changing probing area pr=%p: size=%llu, off=%llu "
- "-to-> size=%llu, off=%llu\n",
+ "-to-> size=%llu, off=%llu",
pr,
(unsigned long long) pr->size,
(unsigned long long) pr->off,
@@ -793,8 +786,7 @@ int blkid_probe_get_idmag(blkid_probe pr, const struct blkid_idinfo *id,
if (buf && !memcmp(mag->magic,
buf + (mag->sboff & 0x3ff), mag->len)) {
- DBG(DEBUG_LOWPROBE, printf(
- "\tmagic sboff=%u, kboff=%ld\n",
+ DBG(LOWPROBE, blkid_debug("\tmagic sboff=%u, kboff=%ld",
mag->sboff, mag->kboff));
if (offset)
*offset = off + (mag->sboff & 0x3ff);
@@ -815,7 +807,7 @@ int blkid_probe_get_idmag(blkid_probe pr, const struct blkid_idinfo *id,
static inline void blkid_probe_start(blkid_probe pr)
{
if (pr) {
- DBG(DEBUG_LOWPROBE, printf("%p: start probe\n", pr));
+ DBG(LOWPROBE, blkid_debug("%p: start probe", pr));
pr->cur_chain = NULL;
pr->prob_flags = 0;
blkid_probe_set_wiper(pr, 0, 0);
@@ -825,7 +817,7 @@ static inline void blkid_probe_start(blkid_probe pr)
static inline void blkid_probe_end(blkid_probe pr)
{
if (pr) {
- DBG(DEBUG_LOWPROBE, printf("%p: end probe\n", pr));
+ DBG(LOWPROBE, blkid_debug("%p: end probe", pr));
pr->cur_chain = NULL;
pr->prob_flags = 0;
blkid_probe_set_wiper(pr, 0, 0);
@@ -909,7 +901,7 @@ int blkid_do_probe(blkid_probe pr)
chn->binary = FALSE; /* for sure... */
- DBG(DEBUG_LOWPROBE, printf("chain probe %s %s (idx=%d)\n",
+ DBG(LOWPROBE, blkid_debug("chain probe %s %s (idx=%d)",
chn->driver->name,
chn->enabled? "ENABLED" : "DISABLED",
chn->idx));
@@ -999,7 +991,7 @@ int blkid_do_wipe(blkid_probe pr, int dryrun)
if (len > sizeof(buf))
len = sizeof(buf);
- DBG(DEBUG_LOWPROBE, printf(
+ DBG(LOWPROBE, blkid_debug(
"do_wipe [offset=0x%jx, len=%zd, chain=%s, idx=%d, dryrun=%s]\n",
offset, len, chn->driver->name, chn->idx, dryrun ? "yes" : "not"));
@@ -1083,8 +1075,7 @@ int blkid_probe_step_back(blkid_probe pr)
if (chn->idx >= 0) {
chn->idx--;
- DBG(DEBUG_LOWPROBE,
- printf("step back: moving %s chain index to %d\n",
+ DBG(LOWPROBE, blkid_debug("step back: moving %s chain index to %d",
chn->driver->name,
chn->idx));
}
@@ -1096,7 +1087,7 @@ int blkid_probe_step_back(blkid_probe pr)
*/
size_t idx = chn->driver->id > 0 ? chn->driver->id - 1 : 0;
- DBG(DEBUG_LOWPROBE, printf("step back: moving to previous chain\n"));
+ DBG(LOWPROBE, blkid_debug("step back: moving to previous chain"));
if (idx > 0)
pr->cur_chain = &pr->chains[idx];
@@ -1142,7 +1133,7 @@ int blkid_do_safeprobe(blkid_probe pr)
chn = pr->cur_chain = &pr->chains[i];
chn->binary = FALSE; /* for sure... */
- DBG(DEBUG_LOWPROBE, printf("chain safeprobe %s %s\n",
+ DBG(LOWPROBE, blkid_debug("chain safeprobe %s %s",
chn->driver->name,
chn->enabled? "ENABLED" : "DISABLED"));
@@ -1196,7 +1187,7 @@ int blkid_do_fullprobe(blkid_probe pr)
chn = pr->cur_chain = &pr->chains[i];
chn->binary = FALSE; /* for sure... */
- DBG(DEBUG_LOWPROBE, printf("chain fullprobe %s: %s\n",
+ DBG(LOWPROBE, blkid_debug("chain fullprobe %s: %s",
chn->driver->name,
chn->enabled? "ENABLED" : "DISABLED"));
@@ -1245,8 +1236,7 @@ struct blkid_prval *blkid_probe_assign_value(
v->chain = pr->cur_chain;
pr->nvals++;
- DBG(DEBUG_LOWPROBE,
- printf("assigning %s [%s]\n", name, v->chain->driver->name));
+ DBG(LOWPROBE, blkid_debug("assigning %s [%s]", name, v->chain->driver->name));
return v;
}
@@ -1259,8 +1249,7 @@ int blkid_probe_reset_last_value(blkid_probe pr)
v = &pr->vals[pr->nvals - 1];
- DBG(DEBUG_LOWPROBE,
- printf("un-assigning %s [%s]\n", v->name, v->chain->driver->name));
+ DBG(LOWPROBE, blkid_debug("un-assigning %s [%s]", v->name, v->chain->driver->name));
memset(v, 0, sizeof(struct blkid_prval));
pr->nvals--;
@@ -1431,7 +1420,7 @@ blkid_probe blkid_probe_get_wholedisk_probe(blkid_probe pr)
if (!disk_path)
return NULL;
- DBG(DEBUG_LOWPROBE, printf("allocate a wholedisk probe\n"));
+ DBG(LOWPROBE, blkid_debug("allocate a wholedisk probe"));
pr->disk_probe = blkid_new_probe_from_filename(disk_path);
@@ -1556,7 +1545,7 @@ int blkid_probe_get_value(blkid_probe pr, int num, const char **name,
if (len)
*len = v->len;
- DBG(DEBUG_LOWPROBE, printf("returning %s value\n", v->name));
+ DBG(LOWPROBE, blkid_debug("returning %s value", v->name));
return 0;
}
@@ -1619,7 +1608,7 @@ struct blkid_prval *__blkid_probe_lookup_value(blkid_probe pr, const char *name)
struct blkid_prval *v = &pr->vals[i];
if (v->name && strcmp(name, v->name) == 0) {
- DBG(DEBUG_LOWPROBE, printf("returning %s value\n", v->name));
+ DBG(LOWPROBE, blkid_debug("returning %s value", v->name));
return v;
}
}
@@ -1719,7 +1708,7 @@ void blkid_probe_set_wiper(blkid_probe pr, blkid_loff_t off, blkid_loff_t size)
return;
if (!size) {
- DBG(DEBUG_LOWPROBE, printf("zeroize wiper\n"));
+ DBG(LOWPROBE, blkid_debug("zeroize wiper"));
pr->wipe_size = pr->wipe_off = 0;
pr->wipe_chain = NULL;
return;
@@ -1735,8 +1724,8 @@ void blkid_probe_set_wiper(blkid_probe pr, blkid_loff_t off, blkid_loff_t size)
pr->wipe_off = off;
pr->wipe_chain = chn;
- DBG(DEBUG_LOWPROBE,
- printf("wiper set to %s::%s off=%jd size=%jd\n",
+ DBG(LOWPROBE,
+ blkid_debug("wiper set to %s::%s off=%jd size=%jd",
chn->driver->name,
chn->driver->idinfos[chn->idx]->name,
pr->wipe_off, pr->wipe_size));
@@ -1769,8 +1758,8 @@ void blkid_probe_use_wiper(blkid_probe pr, blkid_loff_t off, blkid_loff_t size)
struct blkid_chain *chn = NULL;
if (blkid_probe_is_wiped(pr, &chn, off, size) && chn) {
- DBG(DEBUG_LOWPROBE, printf("previously wiped area modified "
- " -- ignore previous results\n"));
+ DBG(LOWPROBE, blkid_debug("previously wiped area modified "
+ " -- ignore previous results"));
blkid_probe_set_wiper(pr, 0, 0);
blkid_probe_chain_reset_vals(pr, chn);
}
diff --git a/libblkid/src/read.c b/libblkid/src/read.c
index 0065b4854..59ceb019e 100644
--- a/libblkid/src/read.c
+++ b/libblkid/src/read.c
@@ -150,7 +150,7 @@ static int parse_start(char **cp)
return 0;
if (!strncmp(p, "<device", 7)) {
- DBG(DEBUG_READ, printf("found device header: %8s\n", p));
+ DBG(READ, blkid_debug("found device header: %8s", p));
p += 7;
*cp = p;
@@ -169,7 +169,7 @@ static int parse_end(char **cp)
*cp = skip_over_blank(*cp);
if (!strncmp(*cp, "</device>", 9)) {
- DBG(DEBUG_READ, printf("found device trailer %9s\n", *cp));
+ DBG(READ, blkid_debug("found device trailer %9s", *cp));
*cp += 9;
return 0;
}
@@ -193,14 +193,13 @@ static int parse_dev(blkid_cache cache, blkid_dev *dev, char **cp)
start = tmp = strchr(*cp, '>');
if (!start) {
- DBG(DEBUG_READ,
- printf("blkid: short line parsing dev: %s\n", *cp));
+ DBG(READ, blkid_debug("blkid: short line parsing dev: %s", *cp));
return -BLKID_ERR_CACHE;
}
start = skip_over_blank(start + 1);
end = skip_over_word(start);
- DBG(DEBUG_READ, printf("device should be %*s\n",
+ DBG(READ, blkid_debug("device should be %*s",
(int)(end - start), start));
if (**cp == '>')
@@ -211,13 +210,12 @@ static int parse_dev(blkid_cache cache, blkid_dev *dev, char **cp)
*tmp = '\0';
if (!(tmp = strrchr(end, '<')) || parse_end(&tmp) < 0) {
- DBG(DEBUG_READ,
- printf("blkid: missing </device> ending: %s\n", end));
+ DBG(READ, blkid_debug("blkid: missing </device> ending: %s", end));
} else if (tmp)
*tmp = '\0';
if (end - start <= 1) {
- DBG(DEBUG_READ, printf("blkid: empty device name: %s\n", *cp));
+ DBG(READ, blkid_debug("blkid: empty device name: %s", *cp));
return -BLKID_ERR_CACHE;
}
@@ -225,7 +223,7 @@ static int parse_dev(blkid_cache cache, blkid_dev *dev, char **cp)
if (name == NULL)
return -BLKID_ERR_MEM;
- DBG(DEBUG_READ, printf("found dev %s\n", name));
+ DBG(READ, blkid_debug("found dev %s", name));
if (!(*dev = blkid_get_dev(cache, name, BLKID_DEV_CREATE))) {
free(name);
@@ -256,8 +254,7 @@ static int parse_token(char **name, char **value, char **cp)
if (**value == '"') {
end = strchr(*value + 1, '"');
if (!end) {
- DBG(DEBUG_READ,
- printf("unbalanced quotes at: %s\n", *value));
+ DBG(READ, blkid_debug("unbalanced quotes at: %s", *value));
*cp = *value;
return -BLKID_ERR_CACHE;
}
@@ -329,7 +326,7 @@ static int parse_tag(blkid_cache cache, blkid_dev dev, char **cp)
} else
ret = blkid_set_tag(dev, name, value, strlen(value));
- DBG(DEBUG_READ, printf(" tag: %s=\"%s\"\n", name, value));
+ DBG(READ, blkid_debug(" tag: %s=\"%s\"", name, value));
return ret < 0 ? ret : 1;
}
@@ -355,7 +352,7 @@ static int blkid_parse_line(blkid_cache cache, blkid_dev *dev_p, char *cp)
*dev_p = NULL;
- DBG(DEBUG_READ, printf("line: %s\n", cp));
+ DBG(READ, blkid_debug("line: %s", cp));
if ((ret = parse_dev(cache, dev_p, &cp)) <= 0)
return ret;
@@ -367,13 +364,12 @@ static int blkid_parse_line(blkid_cache cache, blkid_dev *dev_p, char *cp)
}
if (dev->bid_type == NULL) {
- DBG(DEBUG_READ,
- printf("blkid: device %s has no TYPE\n",dev->bid_name));
+ DBG(READ, blkid_debug("blkid: device %s has no TYPE",dev->bid_name));
blkid_free_dev(dev);
goto done;
}
- DBG(DEBUG_READ, blkid_debug_dump_dev(dev));
+ DBG(READ, blkid_debug_dump_dev(dev));
done:
return ret;
@@ -404,12 +400,12 @@ void blkid_read_cache(blkid_cache cache)
goto errout;
if ((st.st_mtime == cache->bic_ftime) ||
(cache->bic_flags & BLKID_BIC_FL_CHANGED)) {
- DBG(DEBUG_CACHE, printf("skipping re-read of %s\n",
+ DBG(CACHE, blkid_debug("skipping re-read of %s",
cache->bic_filename));
goto errout;
}
- DBG(DEBUG_CACHE, printf("reading cache file %s\n",
+ DBG(CACHE, blkid_debug("reading cache file %s",
cache->bic_filename));
file = fdopen(fd, "r" UL_CLOEXECSTR);
@@ -432,8 +428,7 @@ void blkid_read_cache(blkid_cache cache)
}
if (blkid_parse_line(cache, &dev, buf) < 0) {
- DBG(DEBUG_READ,
- printf("blkid: bad format on line %d\n", lineno));
+ DBG(READ, blkid_debug("blkid: bad format on line %d", lineno));
continue;
}
}
@@ -483,7 +478,7 @@ int main(int argc, char**argv)
blkid_cache cache = NULL;
int ret;
- blkid_init_debug(DEBUG_ALL);
+ blkid_init_debug(BLKID_DEBUG_ALL);
if (argc > 2) {
fprintf(stderr, "Usage: %s [filename]\n"
"Test parsing of the cache (filename)\n", argv[0]);
diff --git a/libblkid/src/resolve.c b/libblkid/src/resolve.c
index 96749b3ec..3a93f53dc 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(DEBUG_RESOLVE, printf("looking for %s on %s\n", tagname, devname));
+ DBG(RESOLVE, blkid_debug("looking for %s on %s", tagname, devname));
if (!devname)
return NULL;
@@ -68,8 +68,7 @@ char *blkid_get_devname(blkid_cache cache, const char *token,
if (!cache && blkid_get_cache(&c, NULL) < 0)
return NULL;
- DBG(DEBUG_RESOLVE,
- printf("looking for %s%s%s %s\n", token, value ? "=" : "",
+ DBG(RESOLVE, blkid_debug("looking for %s%s%s %s", token, value ? "=" : "",
value ? value : "", cache ? "in cache" : "from disk"));
if (!value) {
@@ -103,7 +102,7 @@ int main(int argc, char **argv)
char *value;
blkid_cache cache;
- blkid_init_debug(DEBUG_ALL);
+ blkid_init_debug(BLKID_DEBUG_ALL);
if (argc != 2 && argc != 3) {
fprintf(stderr, "Usage:\t%s tagname=value\n"
"\t%s tagname devname\n"
diff --git a/libblkid/src/save.c b/libblkid/src/save.c
index 849632f79..86eda6cbc 100644
--- a/libblkid/src/save.c
+++ b/libblkid/src/save.c
@@ -30,8 +30,7 @@ static int save_dev(blkid_dev dev, FILE *file)
if (!dev || dev->bid_name[0] != '/')
return 0;
- DBG(DEBUG_SAVE,
- printf("device %s, type %s\n", dev->bid_name, dev->bid_type ?
+ DBG(SAVE, blkid_debug("device %s, type %s", dev->bid_name, dev->bid_type ?
dev->bid_type : "(null)"));
fprintf(file, "<device DEVNO=\"0x%04lx\" TIME=\"%ld.%ld\"",
@@ -68,7 +67,7 @@ int blkid_flush_cache(blkid_cache cache)
if (list_empty(&cache->bic_devs) ||
!(cache->bic_flags & BLKID_BIC_FL_CHANGED)) {
- DBG(DEBUG_SAVE, printf("skipping cache file write\n"));
+ DBG(SAVE, blkid_debug("skipping cache file write"));
return 0;
}
@@ -87,8 +86,7 @@ int blkid_flush_cache(blkid_cache cache)
S_IRUSR|S_IRGRP|S_IROTH|
S_IXUSR|S_IXGRP|S_IXOTH) != 0
&& errno != EEXIST) {
- DBG(DEBUG_SAVE,
- printf("can't create %s directory for cache file\n",
+ DBG(SAVE, blkid_debug("can't create %s directory for cache file",
BLKID_RUNTIME_DIR));
return 0;
}
@@ -97,8 +95,7 @@ int blkid_flush_cache(blkid_cache cache)
/* If we can't write to the cache file, then don't even try */
if (((ret = stat(filename, &st)) < 0 && errno != ENOENT) ||
(ret == 0 && access(filename, W_OK) < 0)) {
- DBG(DEBUG_SAVE,
- printf("can't write to cache file %s\n", filename));
+ DBG(SAVE, blkid_debug("can't write to cache file %s", filename));
return 0;
}
@@ -116,7 +113,7 @@ int blkid_flush_cache(blkid_cache cache)
fd = mkostemp(tmp, O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC);
if (fd >= 0) {
if (fchmod(fd, 0644) != 0)
- DBG(DEBUG_SAVE, printf("%s: fchmod failed\n", filename));
+ DBG(SAVE, blkid_debug("%s: fchmod failed", filename));
else if ((file = fdopen(fd, "w" UL_CLOEXECSTR)))
opened = tmp;
if (!file)
@@ -130,8 +127,7 @@ int blkid_flush_cache(blkid_cache cache)
opened = filename;
}
- DBG(DEBUG_SAVE,
- printf("writing cache file %s (really %s)\n",
+ DBG(SAVE, blkid_debug("writing cache file %s (really %s)",
filename, opened));
if (!file) {
@@ -156,8 +152,7 @@ int blkid_flush_cache(blkid_cache cache)
if (opened != filename) {
if (ret < 0) {
unlink(opened);
- DBG(DEBUG_SAVE,
- printf("unlinked temp cache %s\n", opened));
+ DBG(SAVE, blkid_debug("unlinked temp cache %s", opened));
} else {
char *backup;
@@ -166,20 +161,17 @@ int blkid_flush_cache(blkid_cache cache)
sprintf(backup, "%s.old", filename);
unlink(backup);
if (link(filename, backup)) {
- DBG(DEBUG_SAVE,
- printf("can't link %s to %s\n",
+ DBG(SAVE, blkid_debug("can't link %s to %s",
filename, backup));
}
free(backup);
}
if (rename(opened, filename)) {
ret = errno;
- DBG(DEBUG_SAVE,
- printf("can't rename %s to %s\n",
+ DBG(SAVE, blkid_debug("can't rename %s to %s",
opened, filename));
} else {
- DBG(DEBUG_SAVE,
- printf("moved temp cache %s\n", opened));
+ DBG(SAVE, blkid_debug("moved temp cache %s", opened));
}
}
}
@@ -197,7 +189,7 @@ int main(int argc, char **argv)
blkid_cache cache = NULL;
int ret;
- blkid_init_debug(DEBUG_ALL);
+ blkid_init_debug(BLKID_DEBUG_ALL);
if (argc > 2) {
fprintf(stderr, "Usage: %s [filename]\n"
"Test loading/saving a cache (filename)\n", argv[0]);
diff --git a/libblkid/src/superblocks/btrfs.c b/libblkid/src/superblocks/btrfs.c
index 5813035f3..034683b4e 100644
--- a/libblkid/src/superblocks/btrfs.c
+++ b/libblkid/src/superblocks/btrfs.c
@@ -64,7 +64,7 @@ static int probe_btrfs(blkid_probe pr, const struct blkid_idmag *mag)
struct btrfs_super_block *bfs;
if (mag->kboff > 64 && blkid_probe_ignore_backup(pr)) {
- DBG(DEBUG_LOWPROBE, printf("btrfs: found backup superblock, ignore\n"));
+ DBG(LOWPROBE, blkid_debug("btrfs: found backup superblock, ignore"));
return 1;
}
diff --git a/libblkid/src/superblocks/ext.c b/libblkid/src/superblocks/ext.c
index f36556bca..c23959322 100644
--- a/libblkid/src/superblocks/ext.c
+++ b/libblkid/src/superblocks/ext.c
@@ -295,7 +295,7 @@ static void ext_get_info(blkid_probe pr, int ver, struct ext2_super_block *es)
{
struct blkid_chain *chn = blkid_probe_get_chain(pr);
- DBG(DEBUG_PROBE, printf("ext2_sb.compat = %08X:%08X:%08X\n",
+ DBG(PROBE, blkid_debug("ext2_sb.compat = %08X:%08X:%08X",
le32_to_cpu(es->s_feature_compat),
le32_to_cpu(es->s_feature_incompat),
le32_to_cpu(es->s_feature_ro_compat)));
diff --git a/libblkid/src/superblocks/lvm.c b/libblkid/src/superblocks/lvm.c
index 0afc77322..dc38f2e2c 100644
--- a/libblkid/src/superblocks/lvm.c
+++ b/libblkid/src/superblocks/lvm.c
@@ -100,8 +100,7 @@ static int probe_lvm2(blkid_probe pr, const struct blkid_idmag *mag)
if (lvm2_calc_crc(&label->offset_xl, LVM2_LABEL_SIZE -
((char *) &label->offset_xl - (char *) label)) !=
le32_to_cpu(label->crc_xl)) {
- DBG(DEBUG_PROBE,
- printf("LVM2: label checksum incorrect at sector %d\n",
+ DBG(PROBE, blkid_debug("LVM2: label checksum incorrect at sector %d",
sector));
return 1;
}
diff --git a/libblkid/src/superblocks/ntfs.c b/libblkid/src/superblocks/ntfs.c
index c60a1519b..d767cb46d 100644
--- a/libblkid/src/superblocks/ntfs.c
+++ b/libblkid/src/superblocks/ntfs.c
@@ -149,9 +149,9 @@ static int probe_ntfs(blkid_probe pr, const struct blkid_idmag *mag)
off = le64_to_cpu(ns->mft_cluster_location) * sector_size *
sectors_per_cluster;
- DBG(DEBUG_LOWPROBE, printf("NTFS: sector_size=%d, mft_record_size=%d, "
+ DBG(LOWPROBE, blkid_debug("NTFS: sector_size=%d, mft_record_size=%d, "
"sectors_per_cluster=%d, nr_clusters=%ju "
- "cluster_offset=%jd\n",
+ "cluster_offset=%jd",
(int) sector_size, mft_record_size,
sectors_per_cluster, nr_clusters,
off));
diff --git a/libblkid/src/superblocks/silicon_raid.c b/libblkid/src/superblocks/silicon_raid.c
index 496a3e7b0..1dab12f09 100644
--- a/libblkid/src/superblocks/silicon_raid.c
+++ b/libblkid/src/superblocks/silicon_raid.c
@@ -103,7 +103,7 @@ static int probe_silraid(blkid_probe pr,
if (sil->disk_number >= 8)
return -1;
if (!checksum(sil)) {
- DBG(DEBUG_LOWPROBE, printf("silicon raid: incorrect checksum\n"));
+ DBG(LOWPROBE, blkid_debug("silicon raid: incorrect checksum"));
return -1;
}
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
index 384d2cad7..7648675a2 100644
--- a/libblkid/src/superblocks/superblocks.c
+++ b/libblkid/src/superblocks/superblocks.c
@@ -279,7 +279,7 @@ int blkid_probe_filter_superblocks_usage(blkid_probe pr, int flag, int usage)
} else if (flag & BLKID_FLTR_ONLYIN)
blkid_bmp_set_item(chn->fltr, i);
}
- DBG(DEBUG_LOWPROBE, printf("a new probing usage-filter initialized\n"));
+ DBG(LOWPROBE, blkid_debug("a new probing usage-filter initialized"));
return 0;
}
@@ -335,8 +335,7 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn)
return -1;
blkid_probe_chain_reset_vals(pr, chn);
- DBG(DEBUG_LOWPROBE,
- printf("--> starting probing loop [SUBLKS idx=%d]\n",
+ DBG(LOWPROBE, blkid_debug("--> starting probing loop [SUBLKS idx=%d]",
chn->idx));
if (pr->size <= 0 || (pr->size <= 1024 && !S_ISCHR(pr->mode)))
@@ -357,7 +356,7 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn)
id = idinfos[i];
if (chn->fltr && blkid_bmp_get_item(chn->fltr, i)) {
- DBG(DEBUG_LOWPROBE, printf("filter out: %s\n", id->name));
+ DBG(LOWPROBE, blkid_debug("filter out: %s", id->name));
continue;
}
@@ -373,14 +372,14 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn)
if ((id->usage & BLKID_USAGE_RAID) && blkid_probe_is_tiny(pr))
continue;
- DBG(DEBUG_LOWPROBE, printf("[%zd] %s:\n", i, id->name));
+ DBG(LOWPROBE, blkid_debug("[%zd] %s:", i, id->name));
if (blkid_probe_get_idmag(pr, id, &off, &mag))
continue;
/* final check by probing function */
if (id->probefunc) {
- DBG(DEBUG_LOWPROBE, printf("\tcall probefunc()\n"));
+ DBG(LOWPROBE, blkid_debug("\tcall probefunc()"));
if (id->probefunc(pr, mag) != 0) {
blkid_probe_chain_reset_vals(pr, chn);
continue;
@@ -401,19 +400,17 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn)
(unsigned char *) mag->magic);
if (rc) {
blkid_probe_chain_reset_vals(pr, chn);
- DBG(DEBUG_LOWPROBE, printf("failed to set result -- ingnore\n"));
+ DBG(LOWPROBE, blkid_debug("failed to set result -- ingnore"));
continue;
}
- DBG(DEBUG_LOWPROBE,
- printf("<-- leaving probing loop (type=%s) [SUBLKS idx=%d]\n",
+ DBG(LOWPROBE, blkid_debug("<-- leaving probing loop (type=%s) [SUBLKS idx=%d]",
id->name, chn->idx));
return 0;
}
nothing:
- DBG(DEBUG_LOWPROBE,
- printf("<-- leaving probing loop (failed) [SUBLKS idx=%d]\n",
+ DBG(LOWPROBE, blkid_debug("<-- leaving probing loop (failed) [SUBLKS idx=%d]",
chn->idx));
return 1;
}
@@ -466,9 +463,8 @@ static int superblocks_safeprobe(blkid_probe pr, struct blkid_chain *chn)
return rc; /* error */
if (count > 1 && intol) {
- DBG(DEBUG_LOWPROBE,
- printf("ERROR: superblocks chain: "
- "ambivalent result detected (%d filesystems)!\n",
+ DBG(LOWPROBE, blkid_debug("ERROR: superblocks chain: "
+ "ambivalent result detected (%d filesystems)!",
count));
return -2; /* error, ambivalent result (more FS) */
}
diff --git a/libblkid/src/superblocks/vfat.c b/libblkid/src/superblocks/vfat.c
index 2feb818a9..8ff241b93 100644
--- a/libblkid/src/superblocks/vfat.c
+++ b/libblkid/src/superblocks/vfat.c
@@ -123,9 +123,8 @@ static unsigned char *search_fat_label(blkid_probe pr,
struct vfat_dir_entry *ent, *dir = NULL;
uint32_t i;
- DBG(DEBUG_LOWPROBE,
- printf("\tlook for label in root-dir "
- "(entries: %d, offset: %jd)\n", entries, offset));
+ DBG(LOWPROBE, blkid_debug("\tlook for label in root-dir "
+ "(entries: %d, offset: %jd)", entries, offset));
if (!blkid_probe_is_tiny(pr)) {
/* large disk, read whole root directory */
@@ -163,8 +162,7 @@ static unsigned char *search_fat_label(blkid_probe pr,
if ((ent->attr & (FAT_ATTR_VOLUME_ID | FAT_ATTR_DIR)) ==
FAT_ATTR_VOLUME_ID) {
- DBG(DEBUG_LOWPROBE,
- printf("\tfound fs LABEL at entry %d\n", i));
+ DBG(LOWPROBE, blkid_debug("\tfound fs LABEL at entry %d", i));
return ent->name;
}
}
diff --git a/libblkid/src/superblocks/zfs.c b/libblkid/src/superblocks/zfs.c
index b96c5df45..04036c471 100644
--- a/libblkid/src/superblocks/zfs.c
+++ b/libblkid/src/superblocks/zfs.c
@@ -64,7 +64,7 @@ struct nvlist {
};
#define nvdebug(fmt, ...) do { } while(0)
-/*#define nvdebug(fmt, a...) printf(fmt, ##a)*/
+/*#define nvdebug(fmt, a...) fprintf(stderr, fmt, ##a)*/
static void zfs_extract_guid_name(blkid_probe pr, loff_t offset)
{
@@ -157,7 +157,7 @@ static void zfs_extract_guid_name(blkid_probe pr, loff_t offset)
}
#define zdebug(fmt, ...) do {} while(0)
-/*#define zdebug(fmt, a...) printf(fmt, ##a)*/
+/*#define zdebug(fmt, a...) fprintf(stderr, fmt, ##a)*/
/* ZFS has 128x1kB host-endian root blocks, stored in 2 areas at the start
* of the disk, and 2 areas at the end of the disk. Check only some of them...
diff --git a/libblkid/src/tag.c b/libblkid/src/tag.c
index 5b1f356bf..55df90ede 100644
--- a/libblkid/src/tag.c
+++ b/libblkid/src/tag.c
@@ -34,11 +34,11 @@ static blkid_tag blkid_new_tag(void)
void blkid_debug_dump_tag(blkid_tag tag)
{
if (!tag) {
- printf(" tag: NULL\n");
+ fprintf(stderr, " tag: NULL\n");
return;
}
- printf(" tag: %s=\"%s\"\n", tag->bit_name, tag->bit_val);
+ fprintf(stderr, " tag: %s=\"%s\"\n", tag->bit_name, tag->bit_val);
}
#endif
@@ -47,9 +47,9 @@ void blkid_free_tag(blkid_tag tag)
if (!tag)
return;
- DBG(DEBUG_TAG, printf(" freeing tag %s=%s\n", tag->bit_name,
+ DBG(TAG, blkid_debug(" freeing tag %s=%s", tag->bit_name,
tag->bit_val ? tag->bit_val : "(NULL)"));
- DBG(DEBUG_TAG, blkid_debug_dump_tag(tag));
+ DBG(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 */
@@ -109,8 +109,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(DEBUG_TAG,
- printf(" found cache tag head %s\n", type));
+ DBG(TAG, blkid_debug(" found cache tag head %s", type));
head = tmp;
break;
}
@@ -178,8 +177,7 @@ int blkid_set_tag(blkid_dev dev, const char *name,
if (!head)
goto errout;
- DBG(DEBUG_TAG,
- printf(" creating new cache tag head %s\n", name));
+ DBG(TAG, blkid_debug(" creating new cache tag head %s", name));
head->bit_name = name ? strdup(name) : NULL;
if (!head->bit_name)
goto errout;
@@ -223,7 +221,7 @@ int blkid_parse_tag_string(const char *token, char **ret_type, char **ret_val)
{
char *name, *value, *cp;
- DBG(DEBUG_TAG, printf("trying to parse '%s' as a tag\n", token));
+ DBG(TAG, blkid_debug("trying to parse '%s' as a tag", token));
if (!token || !(cp = strchr(token, '=')))
return -1;
@@ -348,7 +346,7 @@ extern blkid_dev blkid_find_dev_with_tag(blkid_cache cache,
blkid_read_cache(cache);
- DBG(DEBUG_TAG, printf("looking for %s=%s in cache\n", type, value));
+ DBG(TAG, blkid_debug("looking for %s=%s in cache", type, value));
try_again:
pri = -1;
diff --git a/libblkid/src/topology/dm.c b/libblkid/src/topology/dm.c
index dd058536c..42a2f2f7e 100644
--- a/libblkid/src/topology/dm.c
+++ b/libblkid/src/topology/dm.c
@@ -57,8 +57,7 @@ static int probe_dm_tp(blkid_probe pr,
if (!cmd)
goto nothing;
if (pipe(dmpipe) < 0) {
- DBG(DEBUG_LOWPROBE,
- printf("Failed to open pipe: errno=%d", errno));
+ DBG(LOWPROBE, blkid_debug("Failed to open pipe: errno=%d", errno));
goto nothing;
}
@@ -92,13 +91,11 @@ static int probe_dm_tp(blkid_probe pr,
execv(dmargv[0], dmargv);
- DBG(DEBUG_LOWPROBE,
- printf("Failed to execute %s: errno=%d", cmd, errno));
+ DBG(LOWPROBE, blkid_debug("Failed to execute %s: errno=%d", cmd, errno));
exit(1);
}
case -1:
- DBG(DEBUG_LOWPROBE,
- printf("Failed to forking: errno=%d", errno));
+ DBG(LOWPROBE, blkid_debug("Failed to forking: errno=%d", errno));
goto nothing;
default:
break;
diff --git a/libblkid/src/topology/lvm.c b/libblkid/src/topology/lvm.c
index d5bce28fb..71097a5a4 100644
--- a/libblkid/src/topology/lvm.c
+++ b/libblkid/src/topology/lvm.c
@@ -67,8 +67,7 @@ static int probe_lvm_tp(blkid_probe pr,
goto nothing;
if (pipe(lvpipe) < 0) {
- DBG(DEBUG_LOWPROBE,
- printf("Failed to open pipe: errno=%d", errno));
+ DBG(LOWPROBE, blkid_debug("Failed to open pipe: errno=%d", errno));
goto nothing;
}
@@ -95,13 +94,11 @@ static int probe_lvm_tp(blkid_probe pr,
execv(lvargv[0], lvargv);
- DBG(DEBUG_LOWPROBE,
- printf("Failed to execute %s: errno=%d", cmd, errno));
+ DBG(LOWPROBE, blkid_debug("Failed to execute %s: errno=%d", cmd, errno));
exit(1);
}
case -1:
- DBG(DEBUG_LOWPROBE,
- printf("Failed to forking: errno=%d", errno));
+ DBG(LOWPROBE, blkid_debug("Failed to forking: errno=%d", errno));
goto nothing;
default:
break;
diff --git a/libblkid/src/topology/topology.c b/libblkid/src/topology/topology.c
index 9d4e7bdf1..75cb7dd50 100644
--- a/libblkid/src/topology/topology.c
+++ b/libblkid/src/topology/topology.c
@@ -153,7 +153,7 @@ static int topology_probe(blkid_probe pr, struct blkid_chain *chn)
return -1; /* nothing, works with block devices only */
if (chn->binary) {
- DBG(DEBUG_LOWPROBE, printf("initialize topology binary data\n"));
+ DBG(LOWPROBE, blkid_debug("initialize topology binary data"));
if (chn->data)
/* reset binary data */
@@ -169,8 +169,7 @@ static int topology_probe(blkid_probe pr, struct blkid_chain *chn)
blkid_probe_chain_reset_vals(pr, chn);
- DBG(DEBUG_LOWPROBE,
- printf("--> starting probing loop [TOPOLOGY idx=%d]\n",
+ DBG(LOWPROBE, blkid_debug("--> starting probing loop [TOPOLOGY idx=%d]",
chn->idx));
i = chn->idx < 0 ? 0 : chn->idx + 1U;
@@ -181,8 +180,7 @@ static int topology_probe(blkid_probe pr, struct blkid_chain *chn)
chn->idx = i;
if (id->probefunc) {
- DBG(DEBUG_LOWPROBE, printf(
- "%s: call probefunc()\n", id->name));
+ DBG(LOWPROBE, blkid_debug("%s: call probefunc()", id->name));
if (id->probefunc(pr, NULL) != 0)
continue;
}
@@ -193,14 +191,12 @@ static int topology_probe(blkid_probe pr, struct blkid_chain *chn)
/* generic for all probing drivers */
topology_set_logical_sector_size(pr);
- DBG(DEBUG_LOWPROBE,
- printf("<-- leaving probing loop (type=%s) [TOPOLOGY idx=%d]\n",
+ DBG(LOWPROBE, blkid_debug("<-- leaving probing loop (type=%s) [TOPOLOGY idx=%d]",
id->name, chn->idx));
return 0;
}
- DBG(DEBUG_LOWPROBE,
- printf("<-- leaving probing loop (failed) [TOPOLOGY idx=%d]\n",
+ DBG(LOWPROBE, blkid_debug("<-- leaving probing loop (failed) [TOPOLOGY idx=%d]",
chn->idx));
return 1;
}
diff --git a/libblkid/src/verify.c b/libblkid/src/verify.c
index bd756e7a7..1c0ca0f7d 100644
--- a/libblkid/src/verify.c
+++ b/libblkid/src/verify.c
@@ -71,14 +71,13 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
diff = now - dev->bid_time;
if (stat(dev->bid_name, &st) < 0) {
- DBG(DEBUG_PROBE,
- printf("blkid_verify: error %m (%d) while "
- "trying to stat %s\n", errno,
+ DBG(PROBE, blkid_debug("blkid_verify: error %m (%d) while "
+ "trying to stat %s", errno,
dev->bid_name));
open_err:
if ((errno == EPERM) || (errno == EACCES) || (errno == ENOENT)) {
/* We don't have read permission, just return cache data. */
- DBG(DEBUG_PROBE, printf("returning unverified data for %s\n",
+ DBG(PROBE, blkid_debug("returning unverified data for %s",
dev->bid_name));
return dev;
}
@@ -100,15 +99,13 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
return dev;
#ifndef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
- DBG(DEBUG_PROBE,
- printf("need to revalidate %s (cache time %lu, stat time %lu,\n\t"
- "time since last check %lu)\n",
+ DBG(PROBE, blkid_debug("need to revalidate %s (cache time %lu, stat time %lu,\t"
+ "time since last check %lu)",
dev->bid_name, (unsigned long)dev->bid_time,
(unsigned long)st.st_mtime, (unsigned long)diff));
#else
- DBG(DEBUG_PROBE,
- printf("need to revalidate %s (cache time %lu.%lu, stat time %lu.%lu,\n\t"
- "time since last check %lu)\n",
+ DBG(PROBE, blkid_debug("need to revalidate %s (cache time %lu.%lu, stat time %lu.%lu,\t"
+ "time since last check %lu)",
dev->bid_name,
(unsigned long)dev->bid_time, (unsigned long)dev->bid_utime,
(unsigned long)st.st_mtime, (unsigned long)st.st_mtim.tv_nsec / 1000,
@@ -125,8 +122,8 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
fd = open(dev->bid_name, O_RDONLY|O_CLOEXEC);
if (fd < 0) {
- DBG(DEBUG_PROBE, printf("blkid_verify: error %m (%d) while "
- "opening %s\n", errno,
+ DBG(PROBE, blkid_debug("blkid_verify: error %m (%d) while "
+ "opening %s", errno,
dev->bid_name));
goto open_err;
}
@@ -177,7 +174,7 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
blkid_probe_to_tags(cache->probe, dev);
- DBG(DEBUG_PROBE, printf("%s: devno 0x%04llx, type %s\n",
+ DBG(PROBE, blkid_debug("%s: devno 0x%04llx, type %s",
dev->bid_name, (long long)st.st_rdev, dev->bid_type));
}