diff options
author | Stefan Hajnoczi <stefanha@gmail.com> | 2019-09-04 15:59:18 +0100 |
---|---|---|
committer | Nikolaus Rath <Nikolaus@rath.org> | 2019-09-04 15:59:18 +0100 |
commit | 317181e8ea1b3406919b946ca5524f8b9f34817d (patch) | |
tree | 0d0e0a2eb0d3d309dbabbdcdd6cb62131507b592 /lib/fuse_loop_mt.c | |
parent | f39c71dcf99292c188bb6f0a117d7e118f92bfb1 (diff) | |
download | libfuse-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_loop_mt.c')
-rw-r--r-- | lib/fuse_loop_mt.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/fuse_loop_mt.c b/lib/fuse_loop_mt.c index 83f1641..445e9a0 100644 --- a/lib/fuse_loop_mt.c +++ b/lib/fuse_loop_mt.c @@ -58,7 +58,7 @@ static struct fuse_chan *fuse_chan_new(int fd) { struct fuse_chan *ch = (struct fuse_chan *) malloc(sizeof(*ch)); if (ch == NULL) { - fprintf(stderr, "fuse: failed to allocate channel\n"); + fuse_log(FUSE_LOG_ERR, "fuse: failed to allocate channel\n"); return NULL; } @@ -201,7 +201,7 @@ int fuse_start_thread(pthread_t *thread_id, void *(*func)(void *), void *arg) pthread_attr_init(&attr); stack_size = getenv(ENVNAME_THREAD_STACK); if (stack_size && pthread_attr_setstacksize(&attr, atoi(stack_size))) - fprintf(stderr, "fuse: invalid stack size: %s\n", stack_size); + fuse_log(FUSE_LOG_ERR, "fuse: invalid stack size: %s\n", stack_size); /* Disallow signal reception in worker threads */ sigemptyset(&newset); @@ -214,7 +214,7 @@ int fuse_start_thread(pthread_t *thread_id, void *(*func)(void *), void *arg) pthread_sigmask(SIG_SETMASK, &oldset, NULL); pthread_attr_destroy(&attr); if (res != 0) { - fprintf(stderr, "fuse: error creating thread: %s\n", + fuse_log(FUSE_LOG_ERR, "fuse: error creating thread: %s\n", strerror(res)); return -1; } @@ -235,7 +235,7 @@ static struct fuse_chan *fuse_clone_chan(struct fuse_mt *mt) #endif clonefd = open(devname, O_RDWR | O_CLOEXEC); if (clonefd == -1) { - fprintf(stderr, "fuse: failed to open %s: %s\n", devname, + fuse_log(FUSE_LOG_ERR, "fuse: failed to open %s: %s\n", devname, strerror(errno)); return NULL; } @@ -244,7 +244,7 @@ static struct fuse_chan *fuse_clone_chan(struct fuse_mt *mt) masterfd = mt->se->fd; res = ioctl(clonefd, FUSE_DEV_IOC_CLONE, &masterfd); if (res == -1) { - fprintf(stderr, "fuse: failed to clone device fd: %s\n", + fuse_log(FUSE_LOG_ERR, "fuse: failed to clone device fd: %s\n", strerror(errno)); close(clonefd); return NULL; @@ -262,7 +262,7 @@ static int fuse_loop_start_thread(struct fuse_mt *mt) struct fuse_worker *w = malloc(sizeof(struct fuse_worker)); if (!w) { - fprintf(stderr, "fuse: failed to allocate worker structure\n"); + fuse_log(FUSE_LOG_ERR, "fuse: failed to allocate worker structure\n"); return -1; } memset(w, 0, sizeof(struct fuse_worker)); @@ -274,7 +274,7 @@ static int fuse_loop_start_thread(struct fuse_mt *mt) w->ch = fuse_clone_chan(mt); if(!w->ch) { /* Don't attempt this again */ - fprintf(stderr, "fuse: trying to continue " + fuse_log(FUSE_LOG_ERR, "fuse: trying to continue " "without -o clone_fd.\n"); mt->clone_fd = 0; } |