summaryrefslogtreecommitdiffstats
path: root/libmount/src/init.c
diff options
context:
space:
mode:
authorOndrej Oprala2014-07-31 13:23:07 +0200
committerKarel Zak2014-08-13 12:33:47 +0200
commit14ad2353ccabc330412baff5fe86592f2618cdee (patch)
tree43e0d6eb8674c60ba1a6be0d879f3d62d28c9a51 /libmount/src/init.c
parentlibfdisk: rename fdisk_column to fdisk_field (diff)
downloadkernel-qcow2-util-linux-14ad2353ccabc330412baff5fe86592f2618cdee.tar.gz
kernel-qcow2-util-linux-14ad2353ccabc330412baff5fe86592f2618cdee.tar.xz
kernel-qcow2-util-linux-14ad2353ccabc330412baff5fe86592f2618cdee.zip
libs/debug: accept human readable names for _DEBUG=
For example $ LIBMOUNT_DEBUG=tab,cache findmnt to debug only TAB and CACHE subsystem. Signed-off-by: Ondrej Oprala <ooprala@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/init.c')
-rw-r--r--libmount/src/init.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/libmount/src/init.c b/libmount/src/init.c
index b3d10df44..e460788fb 100644
--- a/libmount/src/init.c
+++ b/libmount/src/init.c
@@ -16,7 +16,21 @@
#include "mountP.h"
UL_DEBUG_DEFINE_MASK(libmount);
-
+static const struct dbg_mask libmount_masknames [] = {
+ { "all", MNT_DEBUG_ALL },
+ { "init", MNT_DEBUG_INIT },
+ { "cache", MNT_DEBUG_CACHE },
+ { "options", MNT_DEBUG_OPTIONS },
+ { "locks", MNT_DEBUG_LOCKS },
+ { "tab", MNT_DEBUG_TAB },
+ { "fs", MNT_DEBUG_FS },
+ { "opts", MNT_DEBUG_OPTS },
+ { "update", MNT_DEBUG_UPDATE },
+ { "utils", MNT_DEBUG_UTILS },
+ { "cxt", MNT_DEBUG_CXT },
+ { "diff", MNT_DEBUG_DIFF },
+ { NULL, 0 }
+};
/**
* mnt_init_debug:
* @mask: debug mask (0xffff to enable full debugging)
@@ -44,3 +58,31 @@ void mnt_init_debug(int mask)
DBG(INIT, ul_debug(" feature: %s", *p++));
}
}
+
+#ifdef TEST_PROGRAM
+
+#include <errno.h>
+#include <stdlib.h>
+int main(int argc, char *argv[])
+{
+ if (argc == 2) {
+ int mask;
+
+ errno = 0;
+ mask = strtoul(argv[1], 0, 0);
+
+ if (errno)
+ return 1;
+
+ __UL_INIT_DEBUG(libmount, MNT_DEBUG_, mask, LIBMOUNT_DEBUG);
+ }
+ else if (argc == 1) {
+ __UL_INIT_DEBUG(libmount, MNT_DEBUG_, 0, LIBMOUNT_DEBUG);
+ }
+ else
+ return 1;
+
+ return 0;
+}
+#endif /* TEST_PROGRAM */
+