aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorGravatar Nikolaus Rath <Nikolaus@rath.org>2017-06-05 06:57:36 -0400
committerGravatar Nikolaus Rath <Nikolaus@rath.org>2017-06-05 06:57:36 -0400
commitbb3770f38a01f4032a717b4a07087a166482d0fe (patch)
treeddde6d86af52095217cdb3ee0d47d81cd1b5e8c1 /example
parent8d092c2be9083319e1c9e05dd5da1e9b7caf9fe6 (diff)
example/passthrough_ll: added write support
Diffstat (limited to 'example')
-rw-r--r--example/passthrough_ll.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/example/passthrough_ll.c b/example/passthrough_ll.c
index 772a822..dd3166a 100644
--- a/example/passthrough_ll.c
+++ b/example/passthrough_ll.c
@@ -453,7 +453,7 @@ static void lo_release(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi
}
static void lo_read(fuse_req_t req, fuse_ino_t ino, size_t size,
- off_t offset, struct fuse_file_info *fi)
+ off_t offset, struct fuse_file_info *fi)
{
struct fuse_bufvec buf = FUSE_BUFVEC_INIT(size);
@@ -466,6 +466,25 @@ static void lo_read(fuse_req_t req, fuse_ino_t ino, size_t size,
fuse_reply_data(req, &buf, FUSE_BUF_SPLICE_MOVE);
}
+static void lo_write_buf(fuse_req_t req, fuse_ino_t ino,
+ struct fuse_bufvec *in_buf, off_t off,
+ struct fuse_file_info *fi)
+{
+ (void) ino;
+ ssize_t res;
+ struct fuse_bufvec out_buf = FUSE_BUFVEC_INIT(fuse_buf_size(in_buf));
+
+ out_buf.buf[0].flags = FUSE_BUF_IS_FD | FUSE_BUF_FD_SEEK;
+ out_buf.buf[0].fd = fi->fh;
+ out_buf.buf[0].pos = off;
+
+ res = fuse_buf_copy(&out_buf, in_buf, 0);
+ if(res < 0)
+ fuse_reply_err(req, -res);
+ else
+ fuse_reply_write(req, (size_t) res);
+}
+
static struct fuse_lowlevel_ops lo_oper = {
.init = lo_init,
.lookup = lo_lookup,
@@ -479,6 +498,7 @@ static struct fuse_lowlevel_ops lo_oper = {
.open = lo_open,
.release = lo_release,
.read = lo_read,
+ .write_buf = lo_write_buf
};
int main(int argc, char *argv[])