summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/init.c
diff options
context:
space:
mode:
authorKarel Zak2012-11-30 15:27:41 +0100
committerKarel Zak2013-03-11 11:20:40 +0100
commitd56a7c2330d2a361d3820f8ad9a5399fec47afae (patch)
tree79cb30cd341e869208dd79d74a45b2c7faedb815 /libfdisk/src/init.c
parenttests: add fdisk GPT test (diff)
downloadkernel-qcow2-util-linux-d56a7c2330d2a361d3820f8ad9a5399fec47afae.tar.gz
kernel-qcow2-util-linux-d56a7c2330d2a361d3820f8ad9a5399fec47afae.tar.xz
kernel-qcow2-util-linux-d56a7c2330d2a361d3820f8ad9a5399fec47afae.zip
libfdisk: add basic library files
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/init.c')
-rw-r--r--libfdisk/src/init.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/libfdisk/src/init.c b/libfdisk/src/init.c
new file mode 100644
index 000000000..7d875ee8f
--- /dev/null
+++ b/libfdisk/src/init.c
@@ -0,0 +1,33 @@
+
+#include "fdiskP.h"
+
+int fdisk_debug_mask;
+
+
+/**
+ * fdisk_init_debug:
+ * @mask: debug mask (0xffff to enable full debuging)
+ *
+ * If the @mask is not specified then this function reads
+ * FDISK_DEBUG environment variable to get the mask.
+ *
+ * Already initialized debugging stuff cannot be changed. It does not
+ * have effect to call this function twice.
+ */
+void fdisk_init_debug(int mask)
+{
+ if (fdisk_debug_mask & FDISK_DEBUG_INIT)
+ return;
+ if (!mask) {
+ char *str = getenv("LIBFDISK_DEBUG");
+ if (str)
+ fdisk_debug_mask = strtoul(str, 0, 0);
+ } else
+ fdisk_debug_mask = mask;
+
+ if (fdisk_debug_mask)
+ fprintf(stderr, "libfdisk: debug mask set to 0x%04x.\n",
+ fdisk_debug_mask);
+
+ fdisk_debug_mask |= FDISK_DEBUG_INIT;
+}