]> git.ipfire.org Git - thirdparty/util-linux.git/blame - libblkid/src/init.c
Merge branch 'topic/irq'
[thirdparty/util-linux.git] / libblkid / src / init.c
CommitLineData
310f6728
KZ
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
9e930041 11 * @short_description: initialize debugging
310f6728
KZ
12 */
13
14#include <stdarg.h>
15
16#include "blkidP.h"
17
ed640286 18UL_DEBUG_DEFINE_MASK(libblkid);
819d9a29 19UL_DEBUG_DEFINE_MASKNAMES(libblkid) =
03e4220d 20{
b7da851e
KZ
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" },
9e930041 26 { "devno", BLKID_DEBUG_DEVNO, "conversions to device name" },
b7da851e
KZ
27 { "evaluate", BLKID_DEBUG_EVALUATE, "tags resolving" },
28 { "help", BLKID_DEBUG_HELP, "this help" },
29 { "lowprobe", BLKID_DEBUG_LOWPROBE, "superblock/raids/partitions probing" },
a674a0ab 30 { "buffer", BLKID_DEBUG_BUFFER, "low-probing buffers" },
b7da851e
KZ
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 }
14ad2353
OO
36};
37
310f6728
KZ
38/**
39 * blkid_init_debug:
9e930041 40 * @mask: debug mask (0xffff to enable full debugging)
310f6728
KZ
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 */
48void blkid_init_debug(int mask)
49{
b7da851e
KZ
50 if (libblkid_debug_mask)
51 return;
52
a15dca2f 53 __UL_INIT_DEBUG_FROM_ENV(libblkid, BLKID_DEBUG_, mask, LIBBLKID_DEBUG);
310f6728 54
b7da851e
KZ
55 if (libblkid_debug_mask != BLKID_DEBUG_INIT
56 && libblkid_debug_mask != (BLKID_DEBUG_HELP|BLKID_DEBUG_INIT)) {
310f6728
KZ
57 const char *ver = NULL;
58 const char *date = NULL;
59
310f6728 60 blkid_get_library_version(&ver, &date);
b7da851e 61 DBG(INIT, ul_debug("library debug mask: 0x%04x", libblkid_debug_mask));
c62a6311 62 DBG(INIT, ul_debug("library version: %s [%s]", ver, date));
b7da851e 63
310f6728 64 }
b7da851e
KZ
65 ON_DBG(HELP, ul_debug_print_masks("LIBBLKID_DEBUG",
66 UL_DEBUG_MASKNAMES(libblkid)));
310f6728 67}