@samitouri / QOSamiQemu / commits / fb4c08147b

linux-user: add preadv2/preadv2

Some programs apparently use these, like the python test suite. The flags argument (rwf_t) is an int, with values shared on all arches and does not need translating. This was tested manually with the following python script: ``` import os fd = os.open('test', os.O_RDWR|os.O_CREAT) os.pwritev(fd, [b'test', b'ok'], 0, os.RWF_HIPRI) buf = [bytearray(3), bytearray(10)] os.preadv(fd, buf, 0, os.RWF_HIPRI) print(buf[0]) print(buf[1]) ``` Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com> Reviewed-by: Helge Deller <deller@gmx.de> Signed-off-by: Helge Deller <deller@gmx.de>

Dominique Martinet committed Jun 10, 2026 at 07:54 UTC fb4c08147ba79c552897427a42e3b24b38712786
1 file changed +38
linux-user/syscall.c
+38
@@ -741,6 +741,11 @@ safe_syscall5(ssize_t, preadv, int, fd, const struct iovec *, iov, int, iovcnt,
741 unsigned long, pos_l, unsigned long, pos_h)
742 safe_syscall5(ssize_t, pwritev, int, fd, const struct iovec *, iov, int, iovcnt,
743 unsigned long, pos_l, unsigned long, pos_h)
744 +safe_syscall6(ssize_t, preadv2, int, fd, const struct iovec *, iov, int, iovcnt,
745 + unsigned long, pos_l, unsigned long, pos_h, __kernel_rwf_t, flags)
746 +safe_syscall6(ssize_t, pwritev2, int, fd, const struct iovec *, iov,
747 + int, iovcnt, unsigned long, pos_l, unsigned long, pos_h,
748 + __kernel_rwf_t, flags)
749 safe_syscall3(int, connect, int, fd, const struct sockaddr *, addr,
750 socklen_t, addrlen)
751 safe_syscall6(ssize_t, sendto, int, fd, const void *, buf, size_t, len,
@@ -11907,6 +11912,39 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
11912 }
11913 }
11914 return ret;
11915 +#endif
11916 +#if defined(TARGET_NR_preadv2)
11917 + case TARGET_NR_preadv2:
11918 + {
11919 + struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0);
11920 + if (vec != NULL) {
11921 + unsigned long low, high;
11922 +
11923 + target_to_host_low_high(arg4, arg5, &low, &high);
11924 + ret = get_errno(safe_preadv2(arg1, vec, arg3, low, high, arg6));
11925 + unlock_iovec(vec, arg2, arg3, 1);
11926 + } else {
11927 + ret = -host_to_target_errno(errno);
11928 + }
11929 + }
11930 + return ret;
11931 +#endif
11932 +#if defined(TARGET_NR_pwritev2)
11933 + case TARGET_NR_pwritev2:
11934 + {
11935 + struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1);
11936 + if (vec != NULL) {
11937 + unsigned long low, high;
11938 +
11939 + target_to_host_low_high(arg4, arg5, &low, &high);
11940 + ret = get_errno(safe_pwritev2(arg1, vec, arg3, low, high,
11941 + arg6));
11942 + unlock_iovec(vec, arg2, arg3, 0);
11943 + } else {
11944 + ret = -host_to_target_errno(errno);
11945 + }
11946 + }
11947 + return ret;
11948 #endif
11949 case TARGET_NR_getsid:
11950 return get_errno(getsid(arg1));