[Qemu-devel] [PATCH] linux-user: fix special case pwrite64 with count = 0

Carlo Marcelo Arenas Belón posted 1 patch 6 years, 6 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20171001003442.26211-1-carenas@gmail.com
Test checkpatch passed
Test docker passed
Test s390x passed
linux-user/syscall.c | 4 ++++
1 file changed, 4 insertions(+)
[Qemu-devel] [PATCH] linux-user: fix special case pwrite64 with count = 0
Posted by Carlo Marcelo Arenas Belón 6 years, 6 months ago
building on the work from Zhuowei Zhang for making write return 0 instead
of -1 when called with: write(fd, NULL, 0)

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
 linux-user/syscall.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 9b6364a266..89e883f187 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -10509,6 +10509,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             arg4 = arg5;
             arg5 = arg6;
         }
+        if (arg2 == 0 && arg3 == 0) {
+            ret = get_errno(pwrite64(arg1, NULL, arg3, target_offset64(arg4, arg5)));
+            break;
+        }
         if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
             goto efault;
         ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5)));
-- 
2.14.2