Le 30/09/2024 à 19:07, Michael Vogt a écrit :
This commit adds support for the `openat2()` to `QEMU_STRACE`. It
will use the `openat2.h` header if available to create user
readable flags for the `resolve` argument but does not require
the header otherwise.
It also makes `copy_struct_from_user()` available via `qemu.h`
and `open_how_ver0` via `syscall_defs.h` so that strace.c can use
them.
Signed-off-by: Michael Vogt <mv...@redhat.com>
---
linux-user/qemu.h | 9 +++++++++
linux-user/strace.c | 40 +++++++++++++++++++++++++++++++++++++++
linux-user/strace.list | 3 +++
linux-user/syscall.c | 8 +-------
linux-user/syscall_defs.h | 5 +++++
meson.build | 1 +
6 files changed, 59 insertions(+), 7 deletions(-)
...
index b4d1098170..42a34e599d 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
...
+#ifdef TARGET_NR_openat2
+static void
+print_openat2(CPUArchState *cpu_env, const struct syscallname *name,
+ abi_long arg0, abi_long arg1, abi_long arg2,
+ abi_long arg3, abi_long arg4, abi_long arg5)
+{
+ struct open_how_ver0 how = {0};
+
+ print_syscall_prologue(name);
+ print_at_dirfd(arg0, 0);
+ print_string(arg1, 0);
+ if (copy_struct_from_user(&how, sizeof(how), arg2, arg3) == 0) {
+ print_open_flags(how.flags, 0);
+ if (how.flags & TARGET_O_CREAT) {
+ print_file_mode(how.mode, 0);
+ }
+ print_flags(openat2_resolve_flags, how.resolve, 0);
A tswap64() is needed with how.flags, how.mode and how.resolve.
(they use guest endianness, and print functions use host endianness)
Thanks,
Laurent