summaryrefslogtreecommitdiff
path: root/src/debug.c
blob: afa28e03abf8034465baf3f939a45ceb494e636f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
* License: BSD-style license
* Copyright: Radek Podgorny <radek@podgorny.cz>, 
*            Bernd Schubert <bernd.schubert@fastmail.fm>
*/
#include <stdio.h>
#include <errno.h>
#include <string.h>

#include "opts.h"
#include "debug.h"

static char default_debug_path[] = "./unionfs_debug.log";

FILE* dbgfile = NULL;

int debug_init(void) {
	char *dbgpath = uopt.dbgpath;

	if (!dbgpath) dbgpath = default_debug_path;

	printf("Debug mode, log will be written to %s\n", dbgpath);

	dbgfile = fopen(dbgpath, "w");
	if (!dbgfile) {
		printf("Failed to open %s for writing: %s.\nAborting!\n", 
		       dbgpath, strerror(errno));
		return 2;
	}
	return 0;
}