bigbiff | 7b4c7a6 | 2015-01-01 19:44:14 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008-2013 Karel Zak <kzak@redhat.com> |
| 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 debuging |
| 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, "convertions 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 | { "probe", BLKID_DEBUG_PROBE, "devices verification" }, |
| 31 | { "read", BLKID_DEBUG_READ, "cache parsing" }, |
| 32 | { "save", BLKID_DEBUG_SAVE, "cache writing" }, |
| 33 | { "tag", BLKID_DEBUG_TAG, "tags utils" }, |
| 34 | { NULL, 0, NULL } |
| 35 | }; |
| 36 | |
| 37 | /** |
| 38 | * blkid_init_debug: |
| 39 | * @mask: debug mask (0xffff to enable full debuging) |
| 40 | * |
| 41 | * If the @mask is not specified then this function reads |
| 42 | * LIBBLKID_DEBUG environment variable to get the mask. |
| 43 | * |
| 44 | * Already initialized debugging stuff cannot be changed. It does not |
| 45 | * have effect to call this function twice. |
| 46 | */ |
| 47 | void blkid_init_debug(int mask) |
| 48 | { |
| 49 | if (libblkid_debug_mask) |
| 50 | return; |
| 51 | |
| 52 | __UL_INIT_DEBUG(libblkid, BLKID_DEBUG_, mask, LIBBLKID_DEBUG); |
| 53 | |
| 54 | if (libblkid_debug_mask != BLKID_DEBUG_INIT |
| 55 | && libblkid_debug_mask != (BLKID_DEBUG_HELP|BLKID_DEBUG_INIT)) { |
| 56 | const char *ver = NULL; |
| 57 | const char *date = NULL; |
| 58 | |
| 59 | blkid_get_library_version(&ver, &date); |
| 60 | DBG(INIT, ul_debug("library debug mask: 0x%04x", libblkid_debug_mask)); |
| 61 | DBG(INIT, ul_debug("library version: %s [%s]", ver, date)); |
| 62 | |
| 63 | } |
| 64 | ON_DBG(HELP, ul_debug_print_masks("LIBBLKID_DEBUG", |
| 65 | UL_DEBUG_MASKNAMES(libblkid))); |
| 66 | } |