aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linux/linux_file.c
diff options
context:
space:
mode:
authorPawel Biernacki <kaktus@FreeBSD.org>2019-12-30 18:11:06 +0000
committerPawel Biernacki <kaktus@FreeBSD.org>2019-12-30 18:11:06 +0000
commit54666dffa80b1f9a9f38e9d627b0bb4be62ef6d8 (patch)
treec42872a20ed4563c3ecff8bda33d146c470e3fab /sys/compat/linux/linux_file.c
parentc5ccc92c416a32ca6e0092b0c8113bd9309743b9 (diff)
downloadsrc-54666dffa80b1f9a9f38e9d627b0bb4be62ef6d8.tar.gz
src-54666dffa80b1f9a9f38e9d627b0bb4be62ef6d8.zip
linux(4): implement copy_file_range(2)
copy_file_range(2) is implemented natively since r350315, make it available for Linux binaries too. Reviewed by: kib (mentor), trasz (previous version) Approved by: kib (mentor) Differential Revision: https://reviews.freebsd.org/D22959
Notes
Notes: svn path=/head/; revision=356206
Diffstat (limited to 'sys/compat/linux/linux_file.c')
-rw-r--r--sys/compat/linux/linux_file.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c
index d48132440dbc..565fc562fdf8 100644
--- a/sys/compat/linux/linux_file.c
+++ b/sys/compat/linux/linux_file.c
@@ -1565,3 +1565,44 @@ linux_fallocate(struct thread *td, struct linux_fallocate_args *args)
return (kern_posix_fallocate(td, args->fd, args->offset,
args->len));
}
+
+int
+linux_copy_file_range(struct thread *td, struct linux_copy_file_range_args
+ *args)
+{
+ l_loff_t inoff, outoff, *inoffp, *outoffp;
+ int error, flags;
+
+ /*
+ * copy_file_range(2) on Linux doesn't define any flags (yet), so is
+ * the native implementation. Enforce it.
+ */
+ if (args->flags != 0) {
+ linux_msg(td, "copy_file_range unsupported flags 0x%x",
+ args->flags);
+ return (EINVAL);
+ }
+ flags = 0;
+ inoffp = outoffp = NULL;
+ if (args->off_in != NULL) {
+ error = copyin(args->off_in, &inoff, sizeof(l_loff_t));
+ if (error != 0)
+ return (error);
+ inoffp = &inoff;
+ }
+ if (args->off_out != NULL) {
+ error = copyin(args->off_out, &outoff, sizeof(l_loff_t));
+ if (error != 0)
+ return (error);
+ outoffp = &outoff;
+ }
+
+ error = kern_copy_file_range(td, args->fd_in, inoffp, args->fd_out,
+ outoffp, args->len, flags);
+ if (error == 0 && args->off_in != NULL)
+ error = copyout(inoffp, args->off_in, sizeof(l_loff_t));
+ if (error == 0 && args->off_out != NULL)
+ error = copyout(outoffp, args->off_out, sizeof(l_loff_t));
+ return (error);
+}
+