diff options
Diffstat (limited to 'libblkid/src/save.c')
-rw-r--r-- | libblkid/src/save.c | 30 |
1 files changed, 11 insertions, 19 deletions
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]); |