]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - libmount/src/init.c
2 * Copyright (C) 2008 Karel Zak <kzak@redhat.com>
4 * This file may be redistributed under the terms of the
5 * GNU Lesser General Public License.
10 * @title: Library initialization
11 * @short_description: initialize debugging
18 UL_DEBUG_DEFINE_MASK(libmount
);
19 UL_DEBUG_DEFINE_MASKNAMES(libmount
) =
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" },
28 { "loop", MNT_DEBUG_LOOP
, "loop devices routines" },
29 { "options", MNT_DEBUG_OPTIONS
, "mount options parsing" },
30 { "tab", MNT_DEBUG_TAB
, "fstab, mtab, mountinfo routines" },
31 { "update", MNT_DEBUG_UPDATE
, "mtab, utab updates" },
32 { "utils", MNT_DEBUG_UTILS
, "misc library utils" },
33 { "monitor", MNT_DEBUG_MONITOR
, "mount tables monitor" },
34 { "btrfs", MNT_DEBUG_BTRFS
, "btrfs specific routines" },
41 * @mask: debug mask (0xffff to enable full debugging)
43 * If the @mask is not specified, then this function reads
44 * the LIBMOUNT_DEBUG environment variable to get the mask.
46 * Already initialized debugging stuff cannot be changed. Calling
47 * this function twice has no effect.
49 void mnt_init_debug(int mask
)
51 if (libmount_debug_mask
)
54 __UL_INIT_DEBUG(libmount
, MNT_DEBUG_
, mask
, LIBMOUNT_DEBUG
);
56 if (libmount_debug_mask
!= MNT_DEBUG_INIT
57 && libmount_debug_mask
!= (MNT_DEBUG_HELP
|MNT_DEBUG_INIT
)) {
58 const char *ver
= NULL
;
59 const char **features
= NULL
, **p
;
61 mnt_get_library_version(&ver
);
62 mnt_get_library_features(&features
);
64 DBG(INIT
, ul_debug("library debug mask: 0x%04x", libmount_debug_mask
));
65 DBG(INIT
, ul_debug("library version: %s", ver
));
68 DBG(INIT
, ul_debug(" feature: %s", *p
++));
71 ON_DBG(HELP
, ul_debug_print_masks("LIBMOUNT_DEBUG",
72 UL_DEBUG_MASKNAMES(libmount
)));
79 int main(int argc
, char *argv
[])
85 mask
= strtoul(argv
[1], 0, 0);
99 #endif /* TEST_PROGRAM */