| 1 |
/* |
| 2 |
* Copyright (C) 2008-2013 Karel Zak <[email protected]> |
| 3 |
* |
| 4 |
* This file may be redistributed under the terms of the |
| 5 |
* GNU Lesser General Public License. |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* SECTION: init |
| 10 |
* @title: Library initialization |
| 11 |
* @short_description: initialize debugging |
| 12 |
*/ |
| 13 |
|
| 14 |
#include <stdarg.h> |
| 15 |
|
| 16 |
#include "blkidP.h" |
| 17 |
|
| 18 |
UL_DEBUG_DEFINE_MASK(libblkid); |
| 19 |
UL_DEBUG_DEFINE_MASKNAMES(libblkid) = |
| 20 |
{ |
| 21 |
{ "all", BLKID_DEBUG_ALL, "info about all subsystems" }, |
| 22 |
{ "cache", BLKID_DEBUG_CACHE, "blkid tags cache" }, |
| 23 |
{ "config", BLKID_DEBUG_CONFIG, "config file utils" }, |
| 24 |
{ "dev", BLKID_DEBUG_DEV, "device utils" }, |
| 25 |
{ "devname", BLKID_DEBUG_DEVNAME, "/proc/partitions evaluation" }, |
| 26 |
{ "devno", BLKID_DEBUG_DEVNO, "conversions to device name" }, |
| 27 |
{ "evaluate", BLKID_DEBUG_EVALUATE, "tags resolving" }, |
| 28 |
{ "help", BLKID_DEBUG_HELP, "this help" }, |
| 29 |
{ "lowprobe", BLKID_DEBUG_LOWPROBE, "superblock/raids/partitions probing" }, |
| 30 |
{ "buffer", BLKID_DEBUG_BUFFER, "low-probing buffers" }, |
| 31 |
{ "probe", BLKID_DEBUG_PROBE, "devices verification" }, |
| 32 |
{ "read", BLKID_DEBUG_READ, "cache parsing" }, |
| 33 |
{ "save", BLKID_DEBUG_SAVE, "cache writing" }, |
| 34 |
{ "tag", BLKID_DEBUG_TAG, "tags utils" }, |
| 35 |
{ NULL, 0, NULL } |
| 36 |
}; |
| 37 |
|
| 38 |
/** |
| 39 |
* blkid_init_debug: |
| 40 |
* @mask: debug mask (0xffff to enable full debugging) |
| 41 |
* |
| 42 |
* If the @mask is not specified then this function reads |
| 43 |
* LIBBLKID_DEBUG environment variable to get the mask. |
| 44 |
* |
| 45 |
* Already initialized debugging stuff cannot be changed. It does not |
| 46 |
* have effect to call this function twice. |
| 47 |
*/ |
| 48 |
void blkid_init_debug(int mask) |
| 49 |
{ |
| 50 |
if (libblkid_debug_mask) |
| 51 |
return; |
| 52 |
|
| 53 |
__UL_INIT_DEBUG_FROM_ENV(libblkid, BLKID_DEBUG_, mask, LIBBLKID_DEBUG); |
| 54 |
|
| 55 |
if (libblkid_debug_mask != BLKID_DEBUG_INIT |
| 56 |
&& libblkid_debug_mask != (BLKID_DEBUG_HELP|BLKID_DEBUG_INIT)) { |
| 57 |
const char *ver = NULL; |
| 58 |
const char *date = NULL; |
| 59 |
|
| 60 |
blkid_get_library_version(&ver, &date); |
| 61 |
DBG(INIT, ul_debug("library debug mask: 0x%04x", libblkid_debug_mask)); |
| 62 |
DBG(INIT, ul_debug("library version: %s [%s]", ver, date)); |
| 63 |
|
| 64 |
} |
| 65 |
ON_DBG(HELP, ul_debug_print_masks("LIBBLKID_DEBUG", |
| 66 |
UL_DEBUG_MASKNAMES(libblkid))); |
| 67 |
} |
| 68 |
|
| 69 |
static void __attribute__ ((constructor)) blkid_init_default_debug(void) |
| 70 |
{ |
| 71 |
blkid_init_debug(0); |
| 72 |
} |