]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: export blkid_init_debug()
authorKarel Zak <kzak@redhat.com>
Tue, 9 Apr 2013 11:12:15 +0000 (13:12 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 9 Apr 2013 11:12:55 +0000 (13:12 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/docs/libblkid-sections.txt
libblkid/src/Makemodule.am
libblkid/src/blkid.h.in
libblkid/src/blkid.sym
libblkid/src/blkidP.h
libblkid/src/cache.c
libblkid/src/init.c [new file with mode: 0644]

index 149dd3831592ec82f11db0a21b507a43fa23da0a..86b8040faa8e6c8c0ecceb623e90ad539316da81 100644 (file)
@@ -4,6 +4,11 @@ blkid_evaluate_tag
 blkid_evaluate_spec
 </SECTION>
 
+<SECTION>
+<FILE>init</FILE>
+blkid_init_debug
+</SECTION>
+
 <SECTION>
 <FILE>cache</FILE>
 blkid_cache
index 1c3c7bb71d4d546d1d079421354a0654225ddf34..ec6b754af3f989d463cc840ea9da2e2bf5d355bd 100644 (file)
@@ -8,6 +8,7 @@ libblkid_la_SOURCES = \
        include/list.h \
        \
        libblkid/src/blkidP.h \
+       libblkid/src/init.c \
        libblkid/src/cache.c \
        libblkid/src/config.c \
        libblkid/src/dev.c \
index 6d9c8e3e35c75315d27ff92499128bf5a25cfb21..2a7d6b47c3a5dea490162f24e580985dc14ad35a 100644 (file)
@@ -138,6 +138,7 @@ typedef struct blkid_struct_dev_iterate *blkid_dev_iterate;
 #endif
 
 /* cache.c */
+extern void blkid_init_debug(int mask);
 extern void blkid_put_cache(blkid_cache cache);
 extern int blkid_get_cache(blkid_cache *cache, const char *filename);
 extern void blkid_gc_cache(blkid_cache cache);
index 012fe26c17f172c63646e6a57be38aef78e24b0f..7d3b71d2e5afe11ec03f5763c2593eb5fc195203 100644 (file)
@@ -153,4 +153,5 @@ BLKID_2.23 {
 global:
        blkid_probe_step_back;
        blkid_parttable_get_id;
+       blkid_init_debug;
 } BLKID_2.21;
index 6c62a057daa4868ed1652fd9f0e56f81f4877713..83fccfbe714048620dcb716ea9b41f8d85d77883 100644 (file)
@@ -340,13 +340,12 @@ struct blkid_struct_cache
 #ifdef CONFIG_BLKID_DEBUG
 # include <stdio.h>
 # include <stdarg.h>
-extern int blkid_debug_mask;
-extern void blkid_init_debug(int mask);
+extern int libblkid_debug_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 ((BLKID_DEBUG_ ## m) & blkid_debug_mask) { \
+                               if ((BLKID_DEBUG_ ## m) & libblkid_debug_mask) { \
                                        fprintf(stderr, "%d: libblkid: %8s: ", getpid(), # m); \
                                        x; \
                                } \
@@ -364,7 +363,6 @@ blkid_debug(const char *mesg, ...)
 
 #else /* !CONFIG_BLKID_DEBUG */
 # define DBG(m,x) do { ; } while (0)
-# define blkid_init_debug(x)
 #endif /* CONFIG_BLKID_DEBUG */
 
 /* devno.c */
index 8c67eef02cb83efac4d7c3d7b2a3a531e988e3a4..dfbf7e034be0076b98020687ed89dd5782ebd097 100644 (file)
@@ -24,8 +24,6 @@
 #include "blkidP.h"
 #include "env.h"
 
-int blkid_debug_mask = 0;
-
 /**
  * SECTION:cache
  * @title: Cache
@@ -50,27 +48,6 @@ 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.
  */
-#ifdef CONFIG_BLKID_DEBUG
-void blkid_init_debug(int mask)
-{
-       if (blkid_debug_mask & BLKID_DEBUG_INIT)
-               return;
-
-       if (!mask)
-       {
-               char *dstr = getenv("LIBBLKID_DEBUG");
-               if (dstr)
-                       blkid_debug_mask = strtoul(dstr, 0, 0);
-       } else
-               blkid_debug_mask = mask;
-
-       if (blkid_debug_mask)
-               fprintf(stderr, "libblkid: debug mask set to 0x%04x.\n", blkid_debug_mask);
-
-       blkid_debug_mask |= BLKID_DEBUG_INIT;
-}
-#endif
-
 static const char *get_default_cache_filename(void)
 {
        struct stat st;
diff --git a/libblkid/src/init.c b/libblkid/src/init.c
new file mode 100644 (file)
index 0000000..4ca4db1
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2008-2013 Karel Zak <kzak@redhat.com>
+ *
+ * This file may be redistributed under the terms of the
+ * GNU Lesser General Public License.
+ */
+
+/**
+ * SECTION: init
+ * @title: Library initialization
+ * @short_description: initialize debuging
+ */
+
+#include <stdarg.h>
+
+#include "blkidP.h"
+
+int libblkid_debug_mask;
+
+/**
+ * blkid_init_debug:
+ * @mask: debug mask (0xffff to enable full debuging)
+ *
+ * If the @mask is not specified then this function reads
+ * LIBBLKID_DEBUG environment variable to get the mask.
+ *
+ * Already initialized debugging stuff cannot be changed. It does not
+ * have effect to call this function twice.
+ */
+void blkid_init_debug(int mask)
+{
+       if (libblkid_debug_mask & BLKID_DEBUG_INIT)
+               return;
+       if (!mask) {
+               char *str = getenv("LIBBLKID_DEBUG");
+               if (str)
+                       libblkid_debug_mask = strtoul(str, 0, 0);
+       } else
+               libblkid_debug_mask = mask;
+
+       libblkid_debug_mask |= BLKID_DEBUG_INIT;
+
+       if (libblkid_debug_mask && libblkid_debug_mask != BLKID_DEBUG_INIT) {
+               const char *ver = NULL;
+               const char *date = NULL;
+
+               DBG(INIT, blkid_debug("library debug mask: 0x%04x",
+                               libblkid_debug_mask));
+
+               blkid_get_library_version(&ver, &date);
+               DBG(INIT, blkid_debug("library version: %s [%s]", ver, date));
+       }
+}