summaryrefslogtreecommitdiff
path: root/lib/libfuse/debug.c
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2013-06-03 16:00:51 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2013-06-03 16:00:51 +0000
commitc91bd628edd89b9e31a1f3e4c33a5661d6866206 (patch)
tree616f70e97790d1a6339f13208649c195ade8d4a3 /lib/libfuse/debug.c
parentb4a8194468588718a4d3cab9eb823350ef367b47 (diff)
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