aboutsummaryrefslogtreecommitdiffstats
path: root/lib/fuse_opt.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@gmail.com>2019-09-04 15:59:18 +0100
committerNikolaus Rath <Nikolaus@rath.org>2019-09-04 15:59:18 +0100
commit317181e8ea1b3406919b946ca5524f8b9f34817d (patch)
tree0d0e0a2eb0d3d309dbabbdcdd6cb62131507b592 /lib/fuse_opt.c
parentf39c71dcf99292c188bb6f0a117d7e118f92bfb1 (diff)
downloadlibfuse-317181e8ea1b3406919b946ca5524f8b9f34817d.tar.gz
Introduce callback for logging
Introduce an API for custom log handler functions. This allows libfuse applications to send messages to syslog(3) or other logging systems. See include/fuse_log.h for details. Convert libfuse from fprintf(stderr, ...) to log_fuse(level, ...). Most messages are error messages with FUSE_LOG_ERR log level. There are also some debug messages which now use the FUSE_LOG_DEBUG log level. Note that lib/mount_util.c is used by both libfuse and fusermount3. Since fusermount3 does not link against libfuse, we cannot call fuse_log() from lib/mount_util.c. This file will continue to use fprintf(stderr, ...) until someone figures out how to split it up. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'lib/fuse_opt.c')
-rw-r--r--lib/fuse_opt.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/fuse_opt.c b/lib/fuse_opt.c
index f6cae4f..93066b9 100644
--- a/lib/fuse_opt.c
+++ b/lib/fuse_opt.c
@@ -10,6 +10,7 @@
*/
#include "config.h"
+#include "fuse_i.h"
#include "fuse_opt.h"
#include "fuse_misc.h"
@@ -47,7 +48,7 @@ void fuse_opt_free_args(struct fuse_args *args)
static int alloc_failed(void)
{
- fprintf(stderr, "fuse: memory allocation failed\n");
+ fuse_log(FUSE_LOG_ERR, "fuse: memory allocation failed\n");
return -1;
}
@@ -99,7 +100,7 @@ int fuse_opt_insert_arg(struct fuse_args *args, int pos, const char *arg)
static int next_arg(struct fuse_opt_context *ctx, const char *opt)
{
if (ctx->argctr + 1 >= ctx->argc) {
- fprintf(stderr, "fuse: missing argument after `%s'\n", opt);
+ fuse_log(FUSE_LOG_ERR, "fuse: missing argument after `%s'\n", opt);
return -1;
}
ctx->argctr++;
@@ -217,7 +218,7 @@ static int process_opt_param(void *var, const char *format, const char *param,
*s = copy;
} else {
if (sscanf(param, format, var) != 1) {
- fprintf(stderr, "fuse: invalid parameter in option `%s'\n", arg);
+ fuse_log(FUSE_LOG_ERR, "fuse: invalid parameter in option `%s'\n", arg);
return -1;
}
}
@@ -336,7 +337,7 @@ static int process_option_group(struct fuse_opt_context *ctx, const char *opts)
char *copy = strdup(opts);
if (!copy) {
- fprintf(stderr, "fuse: memory allocation failed\n");
+ fuse_log(FUSE_LOG_ERR, "fuse: memory allocation failed\n");
return -1;
}
res = process_real_option_group(ctx, copy);