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/mount.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/mount.c')
-rw-r--r-- | lib/mount.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/mount.c b/lib/mount.c index 7a18c11..979f8d9 100644 --- a/lib/mount.c +++ b/lib/mount.c @@ -175,7 +175,7 @@ static void set_mount_flag(const char *s, int *flags) return; } } - fprintf(stderr, "fuse: internal error, can't find mount flag\n"); + fuse_log(FUSE_LOG_ERR, "fuse: internal error, can't find mount flag\n"); abort(); } @@ -248,7 +248,7 @@ static int receive_fd(int fd) cmsg = CMSG_FIRSTHDR(&msg); if (cmsg->cmsg_type != SCM_RIGHTS) { - fprintf(stderr, "got control message of unknown type %d\n", + fuse_log(FUSE_LOG_ERR, "got control message of unknown type %d\n", cmsg->cmsg_type); return -1; } @@ -312,7 +312,7 @@ static int fuse_mount_fusermount(const char *mountpoint, struct mount_opts *mo, int rv; if (!mountpoint) { - fprintf(stderr, "fuse: missing mountpoint parameter\n"); + fuse_log(FUSE_LOG_ERR, "fuse: missing mountpoint parameter\n"); return -1; } @@ -393,13 +393,13 @@ static int fuse_mount_sys(const char *mnt, struct mount_opts *mo, int res; if (!mnt) { - fprintf(stderr, "fuse: missing mountpoint parameter\n"); + fuse_log(FUSE_LOG_ERR, "fuse: missing mountpoint parameter\n"); return -1; } res = stat(mnt, &stbuf); if (res == -1) { - fprintf(stderr ,"fuse: failed to access mountpoint %s: %s\n", + fuse_log(FUSE_LOG_ERR, "fuse: failed to access mountpoint %s: %s\n", mnt, strerror(errno)); return -1; } @@ -413,9 +413,9 @@ static int fuse_mount_sys(const char *mnt, struct mount_opts *mo, fd = open(devname, O_RDWR | O_CLOEXEC); if (fd == -1) { if (errno == ENODEV || errno == ENOENT) - fprintf(stderr, "fuse: device not found, try 'modprobe fuse' first\n"); + fuse_log(FUSE_LOG_ERR, "fuse: device not found, try 'modprobe fuse' first\n"); else - fprintf(stderr, "fuse: failed to open %s: %s\n", + fuse_log(FUSE_LOG_ERR, "fuse: failed to open %s: %s\n", devname, strerror(errno)); return -1; } @@ -435,7 +435,7 @@ static int fuse_mount_sys(const char *mnt, struct mount_opts *mo, type = malloc((mo->subtype ? strlen(mo->subtype) : 0) + 32); if (!type || !source) { - fprintf(stderr, "fuse: failed to allocate memory\n"); + fuse_log(FUSE_LOG_ERR, "fuse: failed to allocate memory\n"); goto out_close; } @@ -471,10 +471,10 @@ static int fuse_mount_sys(const char *mnt, struct mount_opts *mo, int errno_save = errno; if (mo->blkdev && errno == ENODEV && !fuse_mnt_check_fuseblk()) - fprintf(stderr, + fuse_log(FUSE_LOG_ERR, "fuse: 'fuseblk' support missing\n"); else - fprintf(stderr, "fuse: mount failed: %s\n", + fuse_log(FUSE_LOG_ERR, "fuse: mount failed: %s\n", strerror(errno_save)); } |