]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - libmount/src/init.c
869be507f4cb3f15e9011ba45e46c88d85769b64
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
3 * This file is part of libmount from util-linux project.
5 * Copyright (C) 2008-2018 Karel Zak <kzak@redhat.com>
7 * libmount is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
15 * @title: Library initialization
16 * @short_description: initialize debugging
23 UL_DEBUG_DEFINE_MASK(libmount
);
24 UL_DEBUG_DEFINE_MASKNAMES(libmount
) =
26 { "all", MNT_DEBUG_ALL
, "info about all subsystems" },
27 { "cache", MNT_DEBUG_CACHE
, "paths and tags cache" },
28 { "cxt", MNT_DEBUG_CXT
, "library context (handler)" },
29 { "diff", MNT_DEBUG_DIFF
, "mountinfo changes tracking" },
30 { "fs", MNT_DEBUG_FS
, "FS abstraction" },
31 { "help", MNT_DEBUG_HELP
, "this help" },
32 { "hook", MNT_DEBUG_HOOK
, "hooks functionality" },
33 { "locks", MNT_DEBUG_LOCKS
, "mtab and utab locking" },
34 { "loop", MNT_DEBUG_LOOP
, "loop devices routines" },
35 { "options", MNT_DEBUG_OPTIONS
, "mount options parsing" },
36 { "optlist", MNT_DEBUG_OPTLIST
, "mount options container" },
37 { "tab", MNT_DEBUG_TAB
, "fstab, mtab, mountinfo routines" },
38 { "update", MNT_DEBUG_UPDATE
, "mtab, utab updates" },
39 { "utils", MNT_DEBUG_UTILS
, "misc library utils" },
40 { "monitor", MNT_DEBUG_MONITOR
, "mount tables monitor" },
41 { "btrfs", MNT_DEBUG_BTRFS
, "btrfs specific routines" },
42 { "verity", MNT_DEBUG_VERITY
, "verity specific routines" },
49 * @mask: debug mask (0xffff to enable full debugging)
51 * If the @mask is not specified, then this function reads
52 * the LIBMOUNT_DEBUG environment variable to get the mask.
54 * Already initialized debugging stuff cannot be changed. Calling
55 * this function twice has no effect.
57 void mnt_init_debug(int mask
)
59 if (libmount_debug_mask
)
62 __UL_INIT_DEBUG_FROM_ENV(libmount
, MNT_DEBUG_
, mask
, LIBMOUNT_DEBUG
);
64 if (libmount_debug_mask
!= MNT_DEBUG_INIT
65 && libmount_debug_mask
!= (MNT_DEBUG_HELP
|MNT_DEBUG_INIT
)) {
66 const char *ver
= NULL
;
67 const char **features
= NULL
, **p
;
69 mnt_get_library_version(&ver
);
70 mnt_get_library_features(&features
);
72 DBG(INIT
, ul_debug("library debug mask: 0x%06x", libmount_debug_mask
));
73 DBG(INIT
, ul_debug("library version: %s", ver
));
76 DBG(INIT
, ul_debug(" feature: %s", *p
++));
79 ON_DBG(HELP
, ul_debug_print_masks("LIBMOUNT_DEBUG",
80 UL_DEBUG_MASKNAMES(libmount
)));
87 int main(int argc
, char *argv
[])
93 mask
= strtoul(argv
[1], 0, 0);
100 else if (argc
== 1) {
107 #endif /* TEST_PROGRAM */