diff options
Diffstat (limited to 'lib/fuse_lowlevel.c')
-rw-r--r-- | lib/fuse_lowlevel.c | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 918893e..f7fbc8f 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -150,7 +150,7 @@ static struct fuse_req *fuse_ll_alloc_req(struct fuse_session *se) req = (struct fuse_req *) calloc(1, sizeof(struct fuse_req)); if (req == NULL) { - fprintf(stderr, "fuse: failed to allocate request\n"); + fuse_log(FUSE_LOG_ERR, "fuse: failed to allocate request\n"); } else { req->se = se; req->ctr = 1; @@ -170,15 +170,15 @@ static int fuse_send_msg(struct fuse_session *se, struct fuse_chan *ch, out->len = iov_length(iov, count); if (se->debug) { if (out->unique == 0) { - fprintf(stderr, "NOTIFY: code=%d length=%u\n", + fuse_log(FUSE_LOG_DEBUG, "NOTIFY: code=%d length=%u\n", out->error, out->len); } else if (out->error) { - fprintf(stderr, + fuse_log(FUSE_LOG_DEBUG, " unique: %llu, error: %i (%s), outsize: %i\n", (unsigned long long) out->unique, out->error, strerror(-out->error), out->len); } else { - fprintf(stderr, + fuse_log(FUSE_LOG_DEBUG, " unique: %llu, success, outsize: %i\n", (unsigned long long) out->unique, out->len); } @@ -207,7 +207,7 @@ int fuse_send_reply_iov_nofree(fuse_req_t req, int error, struct iovec *iov, struct fuse_out_header out; if (error <= -1000 || error > 0) { - fprintf(stderr, "fuse: bad error value: %i\n", error); + fuse_log(FUSE_LOG_ERR, "fuse: bad error value: %i\n", error); error = -ERANGE; } @@ -601,11 +601,11 @@ static int read_back(int fd, char *buf, size_t len) res = read(fd, buf, len); if (res == -1) { - fprintf(stderr, "fuse: internal error: failed to read back from pipe: %s\n", strerror(errno)); + fuse_log(FUSE_LOG_ERR, "fuse: internal error: failed to read back from pipe: %s\n", strerror(errno)); return -EIO; } if (res != len) { - fprintf(stderr, "fuse: internal error: short read back from pipe: %i from %zi\n", res, len); + fuse_log(FUSE_LOG_ERR, "fuse: internal error: short read back from pipe: %i from %zi\n", res, len); return -EIO; } return 0; @@ -714,7 +714,7 @@ static int fuse_send_data_iov(struct fuse_session *se, struct fuse_chan *ch, if (res != headerlen) { res = -EIO; - fprintf(stderr, "fuse: short vmsplice to pipe: %u/%zu\n", res, + fuse_log(FUSE_LOG_ERR, "fuse: short vmsplice to pipe: %u/%zu\n", res, headerlen); goto clear_pipe; } @@ -807,7 +807,7 @@ static int fuse_send_data_iov(struct fuse_session *se, struct fuse_chan *ch, out->len = headerlen + len; if (se->debug) { - fprintf(stderr, + fuse_log(FUSE_LOG_DEBUG, " unique: %llu, success, outsize: %i (splice)\n", (unsigned long long) out->unique, out->len); } @@ -826,7 +826,7 @@ static int fuse_send_data_iov(struct fuse_session *se, struct fuse_chan *ch, } if (res != out->len) { res = -EIO; - fprintf(stderr, "fuse: short splice from pipe: %u/%u\n", + fuse_log(FUSE_LOG_ERR, "fuse: short splice from pipe: %u/%u\n", res, out->len); goto clear_pipe; } @@ -1396,7 +1396,7 @@ static void do_write_buf(fuse_req_t req, fuse_ino_t nodeid, const void *inarg, sizeof(struct fuse_write_in); } if (bufv.buf[0].size < arg->size) { - fprintf(stderr, "fuse: do_write_buf: buffer size too small\n"); + fuse_log(FUSE_LOG_ERR, "fuse: do_write_buf: buffer size too small\n"); fuse_reply_err(req, EIO); goto out; } @@ -1724,7 +1724,7 @@ static void do_interrupt(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) (void) nodeid; if (se->debug) - fprintf(stderr, "INTERRUPT: %llu\n", + fuse_log(FUSE_LOG_DEBUG, "INTERRUPT: %llu\n", (unsigned long long) arg->unique); req->u.i.unique = arg->unique; @@ -1877,10 +1877,10 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) (void) nodeid; if (se->debug) { - fprintf(stderr, "INIT: %u.%u\n", arg->major, arg->minor); + fuse_log(FUSE_LOG_DEBUG, "INIT: %u.%u\n", arg->major, arg->minor); if (arg->major == 7 && arg->minor >= 6) { - fprintf(stderr, "flags=0x%08x\n", arg->flags); - fprintf(stderr, "max_readahead=0x%08x\n", + fuse_log(FUSE_LOG_DEBUG, "flags=0x%08x\n", arg->flags); + fuse_log(FUSE_LOG_DEBUG, "max_readahead=0x%08x\n", arg->max_readahead); } } @@ -1894,7 +1894,7 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) outarg.minor = FUSE_KERNEL_MINOR_VERSION; if (arg->major < 7) { - fprintf(stderr, "fuse: unsupported protocol version: %u.%u\n", + fuse_log(FUSE_LOG_ERR, "fuse: unsupported protocol version: %u.%u\n", arg->major, arg->minor); fuse_reply_err(req, EPROTO); return; @@ -1991,7 +1991,7 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) se->conn.time_gran = 1; if (bufsize < FUSE_MIN_READ_BUFFER) { - fprintf(stderr, "fuse: warning: buffer size too small: %zu\n", + fuse_log(FUSE_LOG_ERR, "fuse: warning: buffer size too small: %zu\n", bufsize); bufsize = FUSE_MIN_READ_BUFFER; } @@ -2005,7 +2005,7 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) se->op.init(se->userdata, &se->conn); if (se->conn.want & (~se->conn.capable)) { - fprintf(stderr, "fuse: error: filesystem requested capabilities " + fuse_log(FUSE_LOG_ERR, "fuse: error: filesystem requested capabilities " "0x%x that are not supported by kernel, aborting.\n", se->conn.want & (~se->conn.capable)); fuse_reply_err(req, EPROTO); @@ -2016,7 +2016,7 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) unsigned max_read_mo = get_max_read(se->mo); if (se->conn.max_read != max_read_mo) { - fprintf(stderr, "fuse: error: init() and fuse_session_new() " + fuse_log(FUSE_LOG_ERR, "fuse: error: init() and fuse_session_new() " "requested different maximum read size (%u vs %u)\n", se->conn.max_read, max_read_mo); fuse_reply_err(req, EPROTO); @@ -2080,16 +2080,16 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) outarg.time_gran = se->conn.time_gran; if (se->debug) { - fprintf(stderr, " INIT: %u.%u\n", outarg.major, outarg.minor); - fprintf(stderr, " flags=0x%08x\n", outarg.flags); - fprintf(stderr, " max_readahead=0x%08x\n", + fuse_log(FUSE_LOG_DEBUG, " INIT: %u.%u\n", outarg.major, outarg.minor); + fuse_log(FUSE_LOG_DEBUG, " flags=0x%08x\n", outarg.flags); + fuse_log(FUSE_LOG_DEBUG, " max_readahead=0x%08x\n", outarg.max_readahead); - fprintf(stderr, " max_write=0x%08x\n", outarg.max_write); - fprintf(stderr, " max_background=%i\n", + fuse_log(FUSE_LOG_DEBUG, " max_write=0x%08x\n", outarg.max_write); + fuse_log(FUSE_LOG_DEBUG, " max_background=%i\n", outarg.max_background); - fprintf(stderr, " congestion_threshold=%i\n", + fuse_log(FUSE_LOG_DEBUG, " congestion_threshold=%i\n", outarg.congestion_threshold); - fprintf(stderr, " time_gran=%u\n", + fuse_log(FUSE_LOG_DEBUG, " time_gran=%u\n", outarg.time_gran); } if (arg->minor < 5) @@ -2326,7 +2326,7 @@ static void fuse_ll_retrieve_reply(struct fuse_notify_req *nreq, sizeof(struct fuse_notify_retrieve_in); if (bufv.buf[0].size < arg->size) { - fprintf(stderr, "fuse: retrieve reply: buffer size too small\n"); + fuse_log(FUSE_LOG_ERR, "fuse: retrieve reply: buffer size too small\n"); fuse_reply_none(req); goto out; } @@ -2489,11 +2489,11 @@ static int fuse_ll_copy_from_pipe(struct fuse_bufvec *dst, { ssize_t res = fuse_buf_copy(dst, src, 0); if (res < 0) { - fprintf(stderr, "fuse: copy from pipe: %s\n", strerror(-res)); + fuse_log(FUSE_LOG_ERR, "fuse: copy from pipe: %s\n", strerror(-res)); return res; } if ((size_t)res < fuse_buf_size(dst)) { - fprintf(stderr, "fuse: copy from pipe: short read\n"); + fuse_log(FUSE_LOG_ERR, "fuse: copy from pipe: short read\n"); return -1; } return 0; @@ -2525,7 +2525,7 @@ void fuse_session_process_buf_int(struct fuse_session *se, mbuf = malloc(tmpbuf.buf[0].size); if (mbuf == NULL) { - fprintf(stderr, "fuse: failed to allocate header\n"); + fuse_log(FUSE_LOG_ERR, "fuse: failed to allocate header\n"); goto clear_pipe; } tmpbuf.buf[0].mem = mbuf; @@ -2540,7 +2540,7 @@ void fuse_session_process_buf_int(struct fuse_session *se, } if (se->debug) { - fprintf(stderr, + fuse_log(FUSE_LOG_DEBUG, "unique: %llu, opcode: %s (%i), nodeid: %llu, insize: %zu, pid: %u\n", (unsigned long long) in->unique, opname((enum fuse_opcode) in->opcode), in->opcode, @@ -2757,7 +2757,7 @@ int fuse_session_receive_buf_int(struct fuse_session *se, struct fuse_buf *buf, } if (res < sizeof(struct fuse_in_header)) { - fprintf(stderr, "short splice from fuse device\n"); + fuse_log(FUSE_LOG_ERR, "short splice from fuse device\n"); return -EIO; } @@ -2780,7 +2780,7 @@ int fuse_session_receive_buf_int(struct fuse_session *se, struct fuse_buf *buf, if (!buf->mem) { buf->mem = malloc(se->bufsize); if (!buf->mem) { - fprintf(stderr, + fuse_log(FUSE_LOG_ERR, "fuse: failed to allocate read buffer\n"); return -ENOMEM; } @@ -2791,13 +2791,13 @@ int fuse_session_receive_buf_int(struct fuse_session *se, struct fuse_buf *buf, res = fuse_buf_copy(&dst, &src, 0); if (res < 0) { - fprintf(stderr, "fuse: copy from pipe: %s\n", + fuse_log(FUSE_LOG_ERR, "fuse: copy from pipe: %s\n", strerror(-res)); fuse_ll_clear_pipe(se); return res; } if (res < tmpbuf.size) { - fprintf(stderr, "fuse: copy from pipe: short read\n"); + fuse_log(FUSE_LOG_ERR, "fuse: copy from pipe: short read\n"); fuse_ll_clear_pipe(se); return -EIO; } @@ -2817,7 +2817,7 @@ fallback: if (!buf->mem) { buf->mem = malloc(se->bufsize); if (!buf->mem) { - fprintf(stderr, + fuse_log(FUSE_LOG_ERR, "fuse: failed to allocate read buffer\n"); return -ENOMEM; } @@ -2849,7 +2849,7 @@ restart: return -err; } if ((size_t) res < sizeof(struct fuse_in_header)) { - fprintf(stderr, "short read on fuse device\n"); + fuse_log(FUSE_LOG_ERR, "short read on fuse device\n"); return -EIO; } @@ -2867,18 +2867,18 @@ struct fuse_session *fuse_session_new(struct fuse_args *args, struct mount_opts *mo; if (sizeof(struct fuse_lowlevel_ops) < op_size) { - fprintf(stderr, "fuse: warning: library too old, some operations may not work\n"); + fuse_log(FUSE_LOG_ERR, "fuse: warning: library too old, some operations may not work\n"); op_size = sizeof(struct fuse_lowlevel_ops); } if (args->argc == 0) { - fprintf(stderr, "fuse: empty argv passed to fuse_session_new().\n"); + fuse_log(FUSE_LOG_ERR, "fuse: empty argv passed to fuse_session_new().\n"); return NULL; } se = (struct fuse_session *) calloc(1, sizeof(struct fuse_session)); if (se == NULL) { - fprintf(stderr, "fuse: failed to allocate fuse object\n"); + fuse_log(FUSE_LOG_ERR, "fuse: failed to allocate fuse object\n"); goto out1; } se->fd = -1; @@ -2904,19 +2904,19 @@ struct fuse_session *fuse_session_new(struct fuse_args *args, if(args->argc == 1 && args->argv[0][0] == '-') { - fprintf(stderr, "fuse: warning: argv[0] looks like an option, but " + fuse_log(FUSE_LOG_ERR, "fuse: warning: argv[0] looks like an option, but " "will be ignored\n"); } else if (args->argc != 1) { int i; - fprintf(stderr, "fuse: unknown option(s): `"); + fuse_log(FUSE_LOG_ERR, "fuse: unknown option(s): `"); for(i = 1; i < args->argc-1; i++) - fprintf(stderr, "%s ", args->argv[i]); - fprintf(stderr, "%s'\n", args->argv[i]); + fuse_log(FUSE_LOG_ERR, "%s ", args->argv[i]); + fuse_log(FUSE_LOG_ERR, "%s'\n", args->argv[i]); goto out4; } if (se->debug) - fprintf(stderr, "FUSE library version: %s\n", PACKAGE_VERSION); + fuse_log(FUSE_LOG_DEBUG, "FUSE library version: %s\n", PACKAGE_VERSION); se->bufsize = FUSE_MAX_MAX_PAGES * getpagesize() + FUSE_BUFFER_HEADER_SIZE; @@ -2929,7 +2929,7 @@ struct fuse_session *fuse_session_new(struct fuse_args *args, err = pthread_key_create(&se->pipe_key, fuse_ll_pipe_destructor); if (err) { - fprintf(stderr, "fuse: failed to create thread specific key: %s\n", + fuse_log(FUSE_LOG_ERR, "fuse: failed to create thread specific key: %s\n", strerror(err)); goto out5; } @@ -2976,7 +2976,7 @@ int fuse_session_mount(struct fuse_session *se, const char *mountpoint) fd = fuse_mnt_parse_fuse_fd(mountpoint); if (fd != -1) { if (fcntl(fd, F_GETFD) == -1) { - fprintf(stderr, + fuse_log(FUSE_LOG_ERR, "fuse: Invalid file descriptor /dev/fd/%u\n", fd); return -1; |