diff options
author | Karel Zak | 2013-04-09 13:12:15 +0200 |
---|---|---|
committer | Karel Zak | 2013-04-09 13:12:55 +0200 |
commit | 310f672874ed9d9c9b963f7a72e9edf3ea95de58 (patch) | |
tree | db186e8e6c9b2de7299c634ffffb011e41953b0d /libblkid/src/init.c | |
parent | libblkid: support LIBBLKID_DEBUG= only (diff) | |
download | kernel-qcow2-util-linux-310f672874ed9d9c9b963f7a72e9edf3ea95de58.tar.gz kernel-qcow2-util-linux-310f672874ed9d9c9b963f7a72e9edf3ea95de58.tar.xz kernel-qcow2-util-linux-310f672874ed9d9c9b963f7a72e9edf3ea95de58.zip |
libblkid: export blkid_init_debug()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libblkid/src/init.c')
-rw-r--r-- | libblkid/src/init.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/libblkid/src/init.c b/libblkid/src/init.c new file mode 100644 index 000000000..4ca4db171 --- /dev/null +++ b/libblkid/src/init.c @@ -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)); + } +} |