diff options
author | Niels de Vos <ndevos@redhat.com> | 2018-06-18 19:31:43 +0200 |
---|---|---|
committer | Nikolaus Rath <Nikolaus@rath.org> | 2018-11-19 12:33:56 +0000 |
commit | fe4f9428fc403fa8b99051f52d84ea5bd13f3855 (patch) | |
tree | b1a5256ba956152490d14a3acd05083a91bb2811 /lib/fuse_lowlevel.c | |
parent | 4c699e7debd99b178b9574e7dd20f36937ef296e (diff) | |
download | libfuse-fe4f9428fc403fa8b99051f52d84ea5bd13f3855.tar.gz |
libfuse: add copy_file_range() support
Add support for the relatively new copy_file_range() syscall. Backend
filesystems can now implement an efficient way of cloning/duplicating
data ranges within files. See 'man 2 copy_file_range' for more details.
Diffstat (limited to 'lib/fuse_lowlevel.c')
-rw-r--r-- | lib/fuse_lowlevel.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 844e797..cd59ec0 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -1810,6 +1810,27 @@ static void do_fallocate(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) fuse_reply_err(req, ENOSYS); } +static void do_copy_file_range(fuse_req_t req, fuse_ino_t nodeid_in, const void *inarg) +{ + struct fuse_copy_file_range_in *arg = (struct fuse_copy_file_range_in *) inarg; + struct fuse_file_info fi_in, fi_out; + + memset(&fi_in, 0, sizeof(fi_in)); + fi_in.fh = arg->fh_in; + + memset(&fi_out, 0, sizeof(fi_out)); + fi_out.fh = arg->fh_out; + + + if (req->se->op.copy_file_range) + req->se->op.copy_file_range(req, nodeid_in, arg->off_in, + &fi_in, arg->nodeid_out, + arg->off_out, &fi_out, arg->len, + arg->flags); + else + fuse_reply_err(req, ENOSYS); +} + static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { struct fuse_init_in *arg = (struct fuse_init_in *) inarg; @@ -2395,6 +2416,7 @@ static struct { [FUSE_BATCH_FORGET] = { do_batch_forget, "BATCH_FORGET" }, [FUSE_READDIRPLUS] = { do_readdirplus, "READDIRPLUS"}, [FUSE_RENAME2] = { do_rename2, "RENAME2" }, + [FUSE_COPY_FILE_RANGE] = { do_copy_file_range, "COPY_FILE_RANGE" }, [CUSE_INIT] = { cuse_lowlevel_init, "CUSE_INIT" }, }; |