Skip to content

Commit fc61742

Browse files
committed
Merge tag 'linux-user-fcntl64-pull-request' of https://github.com/hdeller/qemu-hppa into staging
linux-user: Fix fcntl64() and accept4() for 32-bit targets A set of 3 patches: The first two patches fix fcntl64() and accept4(). the 3rd patch enhances the strace output for pread64/pwrite64(). This pull request does not includes Richard's mmap2 patch: https://patchew.org/QEMU/[email protected]/[email protected]/ Changes: v3: - added r-b from Richard to patches #1 and qemu#2 v2: - rephrased commmit logs - return O_LARGFILE for fcntl() syscall too - dropped #ifdefs in accept4() patch - Dropped my mmap2() patch (former patch qemu#3) - added r-b from Richard to 3rd patch Helge # -----BEGIN PGP SIGNATURE----- # # iHUEABYKAB0WIQS86RI+GtKfB8BJu973ErUQojoPXwUCZKl5RQAKCRD3ErUQojoP # X82sAQDnW53s7YkU4sZ1YREPWPVoCXZXgm587jTrmwT4v9AenQEAlbKdsw4hzzr/ # ptuKvgZfZaIp5QjBUl/Dh/CI5aVOLgc= # =hd4O # -----END PGP SIGNATURE----- # gpg: Signature made Sat 08 Jul 2023 03:57:09 PM BST # gpg: using EDDSA key BCE9123E1AD29F07C049BBDEF712B510A23A0F5F # gpg: Good signature from "Helge Deller <[email protected]>" [unknown] # gpg: aka "Helge Deller <[email protected]>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 4544 8228 2CD9 10DB EF3D 25F8 3E5F 3D04 A7A2 4603 # Subkey fingerprint: BCE9 123E 1AD2 9F07 C049 BBDE F712 B510 A23A 0F5F * tag 'linux-user-fcntl64-pull-request' of https://github.com/hdeller/qemu-hppa: linux-user: Improve strace output of pread64() and pwrite64() linux-user: Fix accept4(SOCK_NONBLOCK) syscall linux-user: Fix fcntl() and fcntl64() to return O_LARGEFILE for 32-bit targets Signed-off-by: Richard Henderson <[email protected]>
2 parents 9e7ce9e + 036cf16 commit fc61742

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

linux-user/strace.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3999,6 +3999,25 @@ print_tgkill(CPUArchState *cpu_env, const struct syscallname *name,
39993999
}
40004000
#endif
40014001

4002+
#if defined(TARGET_NR_pread64) || defined(TARGET_NR_pwrite64)
4003+
static void
4004+
print_pread64(CPUArchState *cpu_env, const struct syscallname *name,
4005+
abi_long arg0, abi_long arg1, abi_long arg2,
4006+
abi_long arg3, abi_long arg4, abi_long arg5)
4007+
{
4008+
if (regpairs_aligned(cpu_env, TARGET_NR_pread64)) {
4009+
arg3 = arg4;
4010+
arg4 = arg5;
4011+
}
4012+
print_syscall_prologue(name);
4013+
print_raw_param("%d", arg0, 0);
4014+
print_pointer(arg1, 0);
4015+
print_raw_param("%d", arg2, 0);
4016+
print_raw_param("%" PRIu64, target_offset64(arg3, arg4), 1);
4017+
print_syscall_epilogue(name);
4018+
}
4019+
#endif
4020+
40024021
#ifdef TARGET_NR_statx
40034022
static void
40044023
print_statx(CPUArchState *cpu_env, const struct syscallname *name,

linux-user/strace.list

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@
10681068
{ TARGET_NR_prctl, "prctl" , NULL, NULL, NULL },
10691069
#endif
10701070
#ifdef TARGET_NR_pread64
1071-
{ TARGET_NR_pread64, "pread64" , NULL, NULL, NULL },
1071+
{ TARGET_NR_pread64, "pread64" , NULL, print_pread64, NULL },
10721072
#endif
10731073
#ifdef TARGET_NR_preadv
10741074
{ TARGET_NR_preadv, "preadv" , NULL, NULL, NULL },
@@ -1099,7 +1099,7 @@
10991099
{ TARGET_NR_putpmsg, "putpmsg" , NULL, NULL, NULL },
11001100
#endif
11011101
#ifdef TARGET_NR_pwrite64
1102-
{ TARGET_NR_pwrite64, "pwrite64" , NULL, NULL, NULL },
1102+
{ TARGET_NR_pwrite64, "pwrite64" , NULL, print_pread64, NULL },
11031103
#endif
11041104
#ifdef TARGET_NR_pwritev
11051105
{ TARGET_NR_pwritev, "pwritev" , NULL, NULL, NULL },

linux-user/syscall.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3440,7 +3440,17 @@ static abi_long do_accept4(int fd, abi_ulong target_addr,
34403440
abi_long ret;
34413441
int host_flags;
34423442

3443-
host_flags = target_to_host_bitmask(flags, fcntl_flags_tbl);
3443+
if (flags & ~(TARGET_SOCK_CLOEXEC | TARGET_SOCK_NONBLOCK)) {
3444+
return -TARGET_EINVAL;
3445+
}
3446+
3447+
host_flags = 0;
3448+
if (flags & TARGET_SOCK_NONBLOCK) {
3449+
host_flags |= SOCK_NONBLOCK;
3450+
}
3451+
if (flags & TARGET_SOCK_CLOEXEC) {
3452+
host_flags |= SOCK_CLOEXEC;
3453+
}
34443454

34453455
if (target_addr == 0) {
34463456
return get_errno(safe_accept4(fd, NULL, NULL, host_flags));
@@ -7132,6 +7142,10 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg)
71327142
ret = get_errno(safe_fcntl(fd, host_cmd, arg));
71337143
if (ret >= 0) {
71347144
ret = host_to_target_bitmask(ret, fcntl_flags_tbl);
7145+
/* tell 32-bit guests it uses largefile on 64-bit hosts: */
7146+
if (O_LARGEFILE == 0 && HOST_LONG_BITS == 64) {
7147+
ret |= TARGET_O_LARGEFILE;
7148+
}
71357149
}
71367150
break;
71377151

0 commit comments

Comments
 (0)