[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/14] linux-user: Implement copy_file_range
From: |
Laurent Vivier |
Subject: |
[PULL 09/14] linux-user: Implement copy_file_range |
Date: |
Fri, 18 Dec 2020 11:24:02 +0100 |
From: Andreas Schwab <schwab@suse.de>
Signed-off-by: Andreas Schwab <schwab@suse.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <mvm361eer3n.fsf@suse.de>
[lv: copy back offset only if there is no error]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/syscall.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 7bf99beb1814..6091a449fbf0 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -813,6 +813,12 @@ safe_syscall5(int, mq_timedsend, int, mqdes, const char *,
msg_ptr,
safe_syscall5(int, mq_timedreceive, int, mqdes, char *, msg_ptr,
size_t, len, unsigned *, prio, const struct timespec *, timeout)
#endif
+#if defined(TARGET_NR_copy_file_range) && defined(__NR_copy_file_range)
+safe_syscall6(ssize_t, copy_file_range, int, infd, loff_t *, pinoff,
+ int, outfd, loff_t *, poutoff, size_t, length,
+ unsigned int, flags)
+#endif
+
/* We do ioctl like this rather than via safe_syscall3 to preserve the
* "third argument might be integer or pointer or not present" behaviour of
* the libc function.
@@ -13065,6 +13071,42 @@ static abi_long do_syscall1(void *cpu_env, int num,
abi_long arg1,
return get_errno(membarrier(arg1, arg2));
#endif
+#if defined(TARGET_NR_copy_file_range) && defined(__NR_copy_file_range)
+ case TARGET_NR_copy_file_range:
+ {
+ loff_t inoff, outoff;
+ loff_t *pinoff = NULL, *poutoff = NULL;
+
+ if (arg2) {
+ if (get_user_u64(inoff, arg2)) {
+ return -TARGET_EFAULT;
+ }
+ pinoff = &inoff;
+ }
+ if (arg4) {
+ if (get_user_u64(outoff, arg4)) {
+ return -TARGET_EFAULT;
+ }
+ poutoff = &outoff;
+ }
+ ret = get_errno(safe_copy_file_range(arg1, pinoff, arg3, poutoff,
+ arg5, arg6));
+ if (!is_error(ret) && ret > 0) {
+ if (arg2) {
+ if (put_user_u64(inoff, arg2)) {
+ return -TARGET_EFAULT;
+ }
+ }
+ if (arg4) {
+ if (put_user_u64(outoff, arg4)) {
+ return -TARGET_EFAULT;
+ }
+ }
+ }
+ }
+ return ret;
+#endif
+
default:
qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
return -TARGET_ENOSYS;
--
2.29.2
- [PULL 00/14] Linux user for 6.0 patches, Laurent Vivier, 2020/12/18
- [PULL 01/14] linux-user/mmap.c: check range of mremap result in target address space, Laurent Vivier, 2020/12/18
- [PULL 04/14] linux-user/elfload: Introduce MIPS GET_FEATURE_REG_SET() macro, Laurent Vivier, 2020/12/18
- [PULL 02/14] linux-user/elfload: Move GET_FEATURE macro out of get_elf_hwcap() body, Laurent Vivier, 2020/12/18
- [PULL 05/14] linux-user/elfload: Introduce MIPS GET_FEATURE_REG_EQU() macro, Laurent Vivier, 2020/12/18
- [PULL 10/14] linux-user: Add most IFTUN ioctls, Laurent Vivier, 2020/12/18
- [PULL 03/14] linux-user/elfload: Rename MIPS GET_FEATURE() as GET_FEATURE_INSN(), Laurent Vivier, 2020/12/18
- [PULL 09/14] linux-user: Implement copy_file_range,
Laurent Vivier <=
- [PULL 06/14] linux-user/elfload: Update HWCAP bits from linux 5.7, Laurent Vivier, 2020/12/18
- [PULL 11/14] linux-user/sparc: Correct sparc64_get/set_context() FPU handling, Laurent Vivier, 2020/12/18
- [PULL 12/14] linux-user/sparc: Remove unneeded checks of 'err' from sparc64_get_context(), Laurent Vivier, 2020/12/18
- [PULL 14/14] linux-user/sparc: Handle tstate in sparc64_get/set_context(), Laurent Vivier, 2020/12/18
- [PULL 08/14] docs/user: Display linux-user binaries nicely, Laurent Vivier, 2020/12/18
- [PULL 13/14] linux-user/sparc: Don't restore %g7 in sparc64_set_context(), Laurent Vivier, 2020/12/18
- [PULL 07/14] linux-user: Add support for MIPS Loongson 2F/3A, Laurent Vivier, 2020/12/18
- Re: [PULL 00/14] Linux user for 6.0 patches, Peter Maydell, 2020/12/31