aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Nikolaus Rath <Nikolaus@rath.org>2017-06-05 07:00:56 -0400
committerGravatar Nikolaus Rath <Nikolaus@rath.org>2017-06-05 07:01:30 -0400
commitf13526ed66d76bb36dc8a145d803f4913d772a2c (patch)
tree4878923ec4a6c76351ca6f49b95cf033b0f66be2
parentbb3770f38a01f4032a717b4a07087a166482d0fe (diff)
examples/passthrough_ll: added support for create()
-rw-r--r--ChangeLog.rst4
-rw-r--r--example/passthrough_ll.c24
-rwxr-xr-xtest/test_examples.py4
3 files changed, 27 insertions, 5 deletions
diff --git a/ChangeLog.rst b/ChangeLog.rst
index ca166f9..285ef5a 100644
--- a/ChangeLog.rst
+++ b/ChangeLog.rst
@@ -1,8 +1,8 @@
Unreleased Changes
==================
-* The `example/passthrough_ll` filesystem now supports writing
- to files.
+* The `example/passthrough_ll` filesystem now supports creating
+ and 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 dd3166a..84dd847 100644
--- a/example/passthrough_ll.c
+++ b/example/passthrough_ll.c
@@ -429,8 +429,29 @@ static void lo_releasedir(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info
fuse_reply_err(req, 0);
}
+static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
+ mode_t mode, struct fuse_file_info *fi)
+{
+ int fd;
+ struct fuse_entry_param e;
+ int err;
+
+ fd = openat(lo_fd(req, parent), name,
+ (fi->flags | O_CREAT) & ~O_NOFOLLOW, mode);
+ if (fd == -1)
+ return (void) fuse_reply_err(req, errno);
+
+ fi->fh = fd;
+
+ err = lo_do_lookup(req, parent, name, &e);
+ if (err)
+ fuse_reply_err(req, err);
+ else
+ fuse_reply_create(req, &e, fi);
+}
+
static void lo_open(fuse_req_t req, fuse_ino_t ino,
- struct fuse_file_info *fi)
+ struct fuse_file_info *fi)
{
int fd;
char buf[64];
@@ -495,6 +516,7 @@ static struct fuse_lowlevel_ops lo_oper = {
.readdir = lo_readdir,
.readdirplus = lo_readdirplus,
.releasedir = lo_releasedir,
+ .create = lo_create,
.open = lo_open,
.release = lo_release,
.read = lo_read,
diff --git a/test/test_examples.py b/test/test_examples.py
index 401f074..794b31c 100755
--- a/test/test_examples.py
+++ b/test/test_examples.py
@@ -87,10 +87,11 @@ def test_passthrough(tmpdir, name, debug, capfd):
tst_readdir(src_dir, work_dir)
tst_open_read(src_dir, work_dir)
tst_open_write(src_dir, work_dir)
+ tst_create(work_dir)
+ tst_passthrough(src_dir, work_dir)
if not is_ll:
tst_mkdir(work_dir)
tst_rmdir(src_dir, work_dir)
- tst_create(work_dir)
tst_unlink(src_dir, work_dir)
tst_symlink(work_dir)
if os.getuid() == 0:
@@ -103,7 +104,6 @@ def test_passthrough(tmpdir, name, debug, capfd):
tst_truncate_path(work_dir)
tst_truncate_fd(work_dir)
tst_open_unlink(work_dir)
- tst_passthrough(src_dir, work_dir)
subprocess.check_call([ os.path.join(basename, 'test', 'test_syscalls'),
work_dir, ':' + src_dir ])