]> git.ipfire.org Git - thirdparty/util-linux.git/blame - libmount/src/init.c
misc: Fix various typos
[thirdparty/util-linux.git] / libmount / src / init.c
CommitLineData
c12cec75
KZ
1/*
2 * Copyright (C) 2008 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
192c6aad
KZ
8/**
9 * SECTION: init
10 * @title: Library initialization
d58b3157 11 * @short_description: initialize debugging
192c6aad
KZ
12 */
13
3f31a959 14#include <stdarg.h>
c12cec75
KZ
15
16#include "mountP.h"
17
d7365821 18UL_DEBUG_DEFINE_MASK(libmount);
819d9a29 19UL_DEBUG_DEFINE_MASKNAMES(libmount) =
03e4220d 20{
35333416
KZ
21 { "all", MNT_DEBUG_ALL, "info about all subsystems" },
22 { "cache", MNT_DEBUG_CACHE, "paths and tags cache" },
23 { "cxt", MNT_DEBUG_CXT, "library context (handler)" },
24 { "diff", MNT_DEBUG_DIFF, "mountinfo changes tracking" },
25 { "fs", MNT_DEBUG_FS, "FS abstraction" },
26 { "help", MNT_DEBUG_HELP, "this help" },
27 { "locks", MNT_DEBUG_LOCKS, "mtab and utab locking" },
7bbde59c 28 { "loop", MNT_DEBUG_LOOP, "loop devices routines" },
35333416 29 { "options", MNT_DEBUG_OPTIONS, "mount options parsing" },
9e930041 30 { "tab", MNT_DEBUG_TAB, "fstab, mtab, mountinfo routines" },
35333416
KZ
31 { "update", MNT_DEBUG_UPDATE, "mtab, utab updates" },
32 { "utils", MNT_DEBUG_UTILS, "misc library utils" },
372112e9 33 { "monitor", MNT_DEBUG_MONITOR, "mount tables monitor" },
2cd28fc8 34 { "btrfs", MNT_DEBUG_BTRFS, "btrfs specific routines" },
372112e9 35
14ad2353
OO
36 { NULL, 0 }
37};
03e4220d 38
192c6aad
KZ
39/**
40 * mnt_init_debug:
d58b3157 41 * @mask: debug mask (0xffff to enable full debugging)
192c6aad 42 *
d58b3157
OO
43 * If the @mask is not specified, then this function reads
44 * the LIBMOUNT_DEBUG environment variable to get the mask.
192c6aad 45 *
d58b3157
OO
46 * Already initialized debugging stuff cannot be changed. Calling
47 * this function twice has no effect.
192c6aad 48 */
c12cec75
KZ
49void mnt_init_debug(int mask)
50{
35333416
KZ
51 if (libmount_debug_mask)
52 return;
53
274228fe 54 __UL_INIT_DEBUG(libmount, MNT_DEBUG_, mask, LIBMOUNT_DEBUG);
39de73f5 55
35333416
KZ
56 if (libmount_debug_mask != MNT_DEBUG_INIT
57 && libmount_debug_mask != (MNT_DEBUG_HELP|MNT_DEBUG_INIT)) {
39de73f5
KZ
58 const char *ver = NULL;
59 const char **features = NULL, **p;
60
39de73f5
KZ
61 mnt_get_library_version(&ver);
62 mnt_get_library_features(&features);
63
35333416 64 DBG(INIT, ul_debug("library debug mask: 0x%04x", libmount_debug_mask));
83a78332 65 DBG(INIT, ul_debug("library version: %s", ver));
39de73f5
KZ
66 p = features;
67 while (p && *p)
83a78332 68 DBG(INIT, ul_debug(" feature: %s", *p++));
39de73f5 69 }
35333416
KZ
70
71 ON_DBG(HELP, ul_debug_print_masks("LIBMOUNT_DEBUG",
72 UL_DEBUG_MASKNAMES(libmount)));
c12cec75 73}
14ad2353
OO
74
75#ifdef TEST_PROGRAM
76
77#include <errno.h>
78#include <stdlib.h>
79int main(int argc, char *argv[])
80{
81 if (argc == 2) {
82 int mask;
83
84 errno = 0;
85 mask = strtoul(argv[1], 0, 0);
86
87 if (errno)
88 return 1;
89
74d70957 90 mnt_init_debug(mask);
14ad2353
OO
91 }
92 else if (argc == 1) {
74d70957
KZ
93 mnt_init_debug(0);
94 } else
14ad2353
OO
95 return 1;
96
97 return 0;
98}
99#endif /* TEST_PROGRAM */
100