summaryrefslogtreecommitdiffstats
path: root/lib/libfuse/debug.c
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2013-06-03 16:00:50 +0000
committertedu <tedu@openbsd.org>2013-06-03 16:00:50 +0000
commit75af46c27426caeef507b802297485ce236cc7ce (patch)
tree9839ad5e27d8b0bccb5696ce6897c6604300a3f6 /lib/libfuse/debug.c
parentcall SSL_read() again if there is data pending in the SSL buffer. (diff)
downloadwireguard-openbsd-75af46c27426caeef507b802297485ce236cc7ce.tar.xz
wireguard-openbsd-75af46c27426caeef507b802297485ce236cc7ce.zip
add userland fuse library. ok beck deraadt
from Sylvestre Gallon ccna.syl gmail.com
Diffstat (limited to 'lib/libfuse/debug.c')
-rw-r--r--lib/libfuse/debug.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/libfuse/debug.c b/lib/libfuse/debug.c
new file mode 100644
index 00000000000..e6262136451
--- /dev/null
+++ b/lib/libfuse/debug.c
@@ -0,0 +1,40 @@
+/* $OpenBSD: debug.c,v 1.1 2013/06/03 16:00:50 tedu Exp $ */
+/*
+ * Copyright (c) 2011 Alexandre Ratchov <alex@caoua.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "debug.h"
+
+#ifdef DEBUG
+/*
+ * debug level, -1 means uninitialized
+ */
+int ifuse_debug = -1;
+
+void
+ifuse_debug_init(void)
+{
+ char *dbg;
+
+ if (ifuse_debug < 0) {
+ dbg = issetugid() ? NULL : getenv("FUSE_DEBUG");
+ if (!dbg || sscanf(dbg, "%u", &ifuse_debug) != 1)
+ ifuse_debug = 0;
+ }
+}
+#endif