diff options
author | Niels de Vos <ndevos@redhat.com> | 2018-06-26 21:40:21 +0200 |
---|---|---|
committer | Nikolaus Rath <Nikolaus@rath.org> | 2018-11-19 12:33:56 +0000 |
commit | 2548c4b83a0871fb92b8ca55cf580a7c58c2f9c6 (patch) | |
tree | 609571da349b5a06c7fd555d7c8044744883a345 /example/passthrough_fh.c | |
parent | fe4f9428fc403fa8b99051f52d84ea5bd13f3855 (diff) | |
download | libfuse-2548c4b83a0871fb92b8ca55cf580a7c58c2f9c6.tar.gz |
examples: add copy_file_range() support to passthrough(_fh)
The passthrough example filesystem can be used for validating the API
and the implementation in the FUSE kernel module.
Diffstat (limited to 'example/passthrough_fh.c')
-rw-r--r-- | example/passthrough_fh.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/example/passthrough_fh.c b/example/passthrough_fh.c index 2b1ed1c..3fc80f8 100644 --- a/example/passthrough_fh.c +++ b/example/passthrough_fh.c @@ -576,6 +576,26 @@ static int xmp_flock(const char *path, struct fuse_file_info *fi, int op) return 0; } +#ifdef HAVE_COPY_FILE_RANGE +static ssize_t xmp_copy_file_range(const char *path_in, + struct fuse_file_info *fi_in, + off_t off_in, const char *path_out, + struct fuse_file_info *fi_out, + off_t off_out, size_t len, int flags) +{ + ssize_t res; + (void) path_in; + (void) path_out; + + res = copy_file_range(fi_in->fh, &off_in, fi_out->fh, &off_out, len, + flags); + if (res == -1) + return -errno; + + return res; +} +#endif + static struct fuse_operations xmp_oper = { .init = xmp_init, .getattr = xmp_getattr, @@ -620,6 +640,9 @@ static struct fuse_operations xmp_oper = { .lock = xmp_lock, #endif .flock = xmp_flock, +#ifdef HAVE_COPY_FILE_RANGE + .copy_file_range = xmp_copy_file_range, +#endif }; int main(int argc, char *argv[]) |