chiark / gitweb /
volume_id: provide a custom debug function
authorKay Sievers <kay.sievers@suse.de>
Mon, 27 Mar 2006 15:59:22 +0000 (17:59 +0200)
committerKay Sievers <kay.sievers@suse.de>
Mon, 27 Mar 2006 15:59:22 +0000 (17:59 +0200)
36 files changed:
extras/volume_id/libvolume_id/Makefile
extras/volume_id/libvolume_id/cramfs.c
extras/volume_id/libvolume_id/ext.c
extras/volume_id/libvolume_id/fat.c
extras/volume_id/libvolume_id/hfs.c
extras/volume_id/libvolume_id/highpoint.c
extras/volume_id/libvolume_id/hpfs.c
extras/volume_id/libvolume_id/iso9660.c
extras/volume_id/libvolume_id/isw_raid.c
extras/volume_id/libvolume_id/jfs.c
extras/volume_id/libvolume_id/libvolume_id.h
extras/volume_id/libvolume_id/linux_raid.c
extras/volume_id/libvolume_id/linux_swap.c
extras/volume_id/libvolume_id/logging.h [deleted file]
extras/volume_id/libvolume_id/lsi_raid.c
extras/volume_id/libvolume_id/luks.c
extras/volume_id/libvolume_id/lvm.c
extras/volume_id/libvolume_id/minix.c
extras/volume_id/libvolume_id/ntfs.c
extras/volume_id/libvolume_id/nvidia_raid.c
extras/volume_id/libvolume_id/ocfs.c
extras/volume_id/libvolume_id/promise_raid.c
extras/volume_id/libvolume_id/reiserfs.c
extras/volume_id/libvolume_id/romfs.c
extras/volume_id/libvolume_id/silicon_raid.c
extras/volume_id/libvolume_id/squashfs.c
extras/volume_id/libvolume_id/sysv.c
extras/volume_id/libvolume_id/udf.c
extras/volume_id/libvolume_id/ufs.c
extras/volume_id/libvolume_id/util.c
extras/volume_id/libvolume_id/util.h
extras/volume_id/libvolume_id/via_raid.c
extras/volume_id/libvolume_id/volume_id.c
extras/volume_id/libvolume_id/vxfs.c
extras/volume_id/libvolume_id/xfs.c
extras/volume_id/vol_id.c

index 5d188a23d42595ec542057325dd26e5862282401..6a12f0e67a7ffa655a87be453eb79cea84cc412f 100644 (file)
@@ -13,7 +13,7 @@ INSTALL_DATA  = ${INSTALL} -m 644
 INSTALL_LIB = ${INSTALL} -m 755
 
 SHLIB_CUR = 0
-SHLIB_REV = 60
+SHLIB_REV = 61
 SHLIB_AGE = 0
 SHLIB = libvolume_id.so.$(SHLIB_CUR).$(SHLIB_REV).$(SHLIB_AGE)
 
index 5a7c29d353dd03a8efcbb072b7c5a7f411088cba..beb34d5bc0442e13202cdaa891aa74371a3a7f7e 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct cramfs_super {
index d1c46471c619c2297297aab422167f3c6bc140f0..51c0011218f5ac1551acdd3d40f62f4d686344a2 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "libvolume_id.h"
 #include "util.h"
-#include "logging.h"
 
 struct ext2_super_block {
        uint32_t        s_inodes_count;
index 4b32263fd6164065f3dd943525f63f88b712452a..4840a2a23c73f2c74b9328ea51a4bae5c75802d8 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 #define FAT12_MAX                      0xff5
index 627166df98dddf1c88ceba74097e8dbcb206e68c..a6e378dd283d6792207bad5fa566d65ae12eb75e 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct hfs_finder_info{
index fa580b7b8c4f5972e99faf81c809e0bf4e48c18d..deba540ad586f14ce70bff48d2501f7c7569c091 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct hpt37x_meta {
index 41b8013bb1677b743ee62820664adbfe9825199b..3e9589fccafb80e9a9a53d6a5b2425a1512341e1 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct hpfs_super
index 02575f8dc2b6d81aa25e27dd3bbf336ba393ad75..7b78a7e99285b964b3ddfb01adb5e2c1c9e2122f 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 #define ISO_SUPERBLOCK_OFFSET          0x8000
index cf7c62f8175c0550592557e79862b8906b75b4d8..6465a31bf52914ad29582af13ff664b430b5826d 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct isw_meta {
index f8d857878db3475c031d967d6965db91a5b18c36..b230fb258c49ad933764853b1a1ff221d45ad566 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct jfs_super_block {
index b08a650dc80ac051de8cb0eff5275e76648dc147..7faf8d8af3d20e05140ea2e987fecc7188c6178e 100644 (file)
 #define PACKED                         __attribute__((packed))
 #endif
 
+
+typedef void (*volume_id_log_fn)(int priority, const char *file, int line, const char *format, ...)
+            __attribute__ ((format(printf, 4, 5)));
+
+extern volume_id_log_fn volume_id_log;
+
 #define VOLUME_ID_LABEL_SIZE           64
 #define VOLUME_ID_UUID_SIZE            36
 #define VOLUME_ID_FORMAT_SIZE          32
index ee5ed2875d6d38bc72286cf7fe8d66081175e52b..85e8d8109b769facb09e38ee45a43055165dbefd 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct mdp_super_block {
index c87ef63df93bcb9b2be0ed321a997d34e1997379..0193648c9ef460c1d3c9e4439e6f185ed3ceba8e 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct swap_header_v1_2 {
diff --git a/extras/volume_id/libvolume_id/logging.h b/extras/volume_id/libvolume_id/logging.h
deleted file mode 100644 (file)
index 4a8aa50..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * volume_id_logging - this file is used to map the dbg() function
- *                     to the user's logging facility
- *
- *     This program is free software; you can redistribute it and/or modify it
- *     under the terms of the GNU General Public License as published by the
- *     Free Software Foundation version 2 of the License.
- */
-
-#ifndef _VOLUME_ID_LOGGING_H_
-#define _VOLUME_ID_LOGGING_H_
-
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE 1
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-/* just use the udev version */
-#include "../../../logging.h"
-
-#endif /* _VOLUME_ID_LOGGING_H_ */
index 4e6c095b86f6562daf17d806357dc447280d6ab7..f1db4a6e50b305c8c246c3d2007edbcd633d8915 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct lsi_meta {
index 5346450ecc7893a6a2a9031a4bc3dca78638454e..64de85ac217679b59ad8ce4d2a30f7a63a449fae 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "libvolume_id.h"
 #include "util.h"
-#include "logging.h"
 
 #define SECTOR_SHIFT                   9
 #define SECTOR_SIZE                    (1 << SECTOR_SHIFT)
index 4a1620e8a42e9a39c759e42d430c166b75a73452..47d84b09686206b26be93441e383dea2f52a91b2 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct lvm1_super_block {
index 957925fe1fbe92fc76ed8a31c0622ba3292ea37e..75e9c3acbd8b1c0dfb5a29ebbb9891489392253a 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct minix_super_block
index a46359268eb55ed35e4ddb0f5221d13cd9501701..23c64fc3071ee251f5df9bd1c9793f83c175a1f6 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct ntfs_super_block {
index 7e1b58ba55c7f64b18e39ba586068aeb0cb7a2cd..10c1c714f7a477a0c599a9428eaeaeb9ae77ad90 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct nvidia_meta {
index c55b7234f4343e843082e462584642a86ab1168d..b376ead8330d50380ecad57dc8a0df595842aed0 100644 (file)
@@ -25,7 +25,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 
index f58dab28e9bcc729950869647e650c9b0abd8635..2a2ce1689e01273a1105b1e8c5cd2d71f8d373bf 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct promise_meta {
index 5a9d71b53d984ece320a46d1477585ef81285aa3..b5706f86e0ff9024e5a03bf63545a6ba306b2fa5 100644 (file)
@@ -25,7 +25,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct reiserfs_super_block {
index 171bb5a2a0a501f1785a439f8f5e80eb49c2191f..8bb2a0018afabfdb409aceef29950a662b82c990 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct romfs_super {
index e9ce4e0b78220e7eb91c8e8dabc54cc4bfef3ed3..017b023e27ecdad75f3c1911a7a92f9e6c797762 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct silicon_meta {
index 3eabce71ae58e44c865abae8988e5d7601db9698..bdb1f16628b7345e8fa8d2109181ae9fdaeaf472 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 #define SQUASHFS_MAGIC         0x73717368
index 41a32bbaa26b37095d5cd7263b712a56cd933a05..52349c0623961a264a4e7086b606b7c0b04fb5aa 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 #define SYSV_NICINOD                   100
index 54e66b4e86aecc702002997987f8f68ea1f8cdd2..d7497ec51b8e06d1513acfeec667b5a8c159f5c6 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct volume_descriptor {
index be6fa9e9ea75a7e414b0b50f1b536986c2bdd2bb..d3960b1bec3754251651409faad9b5e278f739dd 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct ufs_super_block {
index b49dd6dd14e7d7e56988fa6a73da7e5850e2a65e..cf5392cf9aba7fe1512b9f0b6b3fa0f15bbd4466 100644 (file)
@@ -26,7 +26,6 @@
 #include <sys/stat.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 void volume_id_set_unicode16(char *str, size_t len, const uint8_t *buf, enum endian endianess, size_t count)
index 8cb1abd360046b896a7e5e285e24734119085c99..1d1b53bb5753043800f49bcf19e3400cae6521d7 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * volume_id - reads filesystem label and uuid
  *
- * Copyright (C) 2005 Kay Sievers <kay.sievers@vrfy.org>
+ * Copyright (C) 2005-2006 Kay Sievers <kay.sievers@vrfy.org>
  *
  *     This program is free software; you can redistribute it and/or modify it
  *     under the terms of the GNU General Public License as published by the
 
 #include <endian.h>
 #include <byteswap.h>
+#include <syslog.h>
+
+#define err(format, arg...)    volume_id_log(LOG_ERR, __FILE__, __LINE__, format, ##arg)
+#define info(format, arg...)   volume_id_log(LOG_INFO, __FILE__, __LINE__, format, ##arg)
+#ifdef DEBUG
+#define dbg(format, arg...)    volume_id_log(LOG_DEBUG, __FILE__, __LINE__, format, ##arg)
+#else
+#define dbg(format, arg...)    do { } while (0)
+#endif
 
 /* size of superblock buffer, reiserfs block is at 64k */
 #define SB_BUFFER_SIZE                         0x11000
index e70cfa1241494474261b56d0b9f34645b637e7a0..42cb0980651ad46ca6d1a2bc7eb63e9d01afc50a 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct via_meta {
index e5f0d90ee8414068a95c273da592b3355f6b7182..073ad79c7723834e7f72291ea3557353a5466e46 100644 (file)
 #include <sys/stat.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
+/* the user can overwrite this log function */
+static void default_log(int priority, const char *file, int line, const char *format, ...)
+{
+       return;
+}
+
+volume_id_log_fn volume_id_log = default_log;
 
 int volume_id_probe_raid(struct volume_id *id, uint64_t off, uint64_t size)
 {
index 406391bf0e1be0c98017a2672b74c89a8f52029f..d10cc377621146653b18211e6af1cd85f283f97b 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 #define VXFS_SUPER_MAGIC       0xa501FCF5
index 4b48ff12505980fc79438b316838bd29bda2aea3..3d870c41e73ca724ab8fa0346413668b943714a7 100644 (file)
@@ -24,7 +24,6 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "logging.h"
 #include "util.h"
 
 struct xfs_super_block {
index 518962c10bd5ddd6b649ef7910ff168ace04cc3d..b086b3710ca65c1b19c589880a5bfd5d84c3073c 100644 (file)
@@ -60,6 +60,18 @@ void log_message(int priority, const char *format, ...)
 }
 #endif
 
+static void vid_log(int priority, const char *file, int line, const char *format, ...)
+{
+#ifdef USE_LOG
+       va_list args;
+
+       va_start(args, format);
+       log_message(priority, format, args);
+       va_end(args);
+#endif
+       return;
+}
+
 static void set_str(char *to, const char *from, size_t count)
 {
        size_t i, j, len;
@@ -117,6 +129,9 @@ int main(int argc, char *argv[])
 
        logging_init("vol_id");
 
+       /* hook in our debug into libvolume_id */
+       volume_id_log = vid_log;
+
        for (i = 1 ; i < argc; i++) {
                char *arg = argv[i];