aboutsummaryrefslogtreecommitdiff
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
parent8d092c2be9083319e1c9e05dd5da1e9b7caf9fe6 (diff)
example/passthrough_ll: added write support
-rw-r--r--ChangeLog.rst2
-rw-r--r--example/passthrough_ll.c22
-rwxr-xr-xtest/test_examples.py2
3 files changed, 24 insertions, 2 deletions
diff --git a/ChangeLog.rst b/ChangeLog.rst
index 560ad98..ca166f9 100644
--- a/ChangeLog.rst
+++ b/ChangeLog.rst
@@ -1,6 +1,8 @@
Unreleased Changes
==================
+* The `example/passthrough_ll` filesystem now supports writing
+ to files.
* `fuse_main()` / `fuse_remove_signal_handlers()`: do not reset
`SIGPIPE` handler to `SIG_DFL` it was not set by us.
* Documented the `RENAME_EXCHANGE` and `RENAME_NOREPLACE` flags that
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[])
diff --git a/test/test_examples.py b/test/test_examples.py
index 953eeec..401f074 100755
--- a/test/test_examples.py
+++ b/test/test_examples.py
@@ -86,11 +86,11 @@ def test_passthrough(tmpdir, name, debug, capfd):
tst_statvfs(work_dir)
tst_readdir(src_dir, work_dir)
tst_open_read(src_dir, work_dir)
+ tst_open_write(src_dir, work_dir)
if not is_ll:
tst_mkdir(work_dir)
tst_rmdir(src_dir, work_dir)
tst_create(work_dir)
- tst_open_write(src_dir, work_dir)
tst_unlink(src_dir, work_dir)
tst_symlink(work_dir)
if os.getuid() == 0: