render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame 0001-linux-user-guard-openat2-with-if-defined-TARGET_NR_o.patch

Michael Vogt 0cab45
From b5aa46fc7bb03877bbea711903e19ad4e27e8259 Mon Sep 17 00:00:00 2001
Michael Vogt 0cab45
From: Michael Vogt <michael.vogt@gmail.com>
Michael Vogt 0cab45
Date: Wed, 23 Oct 2024 09:50:56 +0200
Michael Vogt 0cab45
Subject: [PATCH] linux-user: guard openat2 with `#if
Michael Vogt 0cab45
 defined(TARGET_NR_openat2)`
Michael Vogt 0cab45
Michael Vogt 0cab45
This commit adds a bunch of `#ifdef` around the openat2 support.
Michael Vogt 0cab45
We need this to build the `cris-linux-user` target which is still
Michael Vogt 0cab45
present in this version but got dropped from upstream in commit
Michael Vogt 0cab45
44e4075bf4 but is still present in v9.1.0.
Michael Vogt 0cab45
Michael Vogt 0cab45
This patch can be dropped once cris is also removed from the
Michael Vogt 0cab45
package.
Michael Vogt 0cab45
---
Michael Vogt 0cab45
 linux-user/syscall.c | 9 ++++++++-
Michael Vogt 0cab45
 1 file changed, 8 insertions(+), 1 deletion(-)
Michael Vogt 0cab45
Michael Vogt 0cab45
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
Michael Vogt 0cab45
index 85d61db546..22e5ad3c5f 100644
Michael Vogt 0cab45
--- a/linux-user/syscall.c
Michael Vogt 0cab45
+++ b/linux-user/syscall.c
Michael Vogt 0cab45
@@ -608,6 +608,7 @@ static int check_zeroed_user(abi_long addr, size_t ksize, size_t usize)
Michael Vogt 0cab45
  *
Michael Vogt 0cab45
  * Similar to kernels uaccess.h:copy_struct_from_user()
Michael Vogt 0cab45
  */
Michael Vogt 0cab45
+#if defined(TARGET_NR_openat2)
Michael Vogt 0cab45
 static int
Michael Vogt 0cab45
 copy_struct_from_user(void *dst, size_t ksize, abi_ptr src, size_t usize)
Michael Vogt 0cab45
 {
Michael Vogt 0cab45
@@ -629,6 +630,7 @@ copy_struct_from_user(void *dst, size_t ksize, abi_ptr src, size_t usize)
Michael Vogt 0cab45
     }
Michael Vogt 0cab45
     return 0;
Michael Vogt 0cab45
 }
Michael Vogt 0cab45
+#endif
Michael Vogt 0cab45
 
Michael Vogt 0cab45
 #define safe_syscall0(type, name) \
Michael Vogt 0cab45
 static type safe_##name(void) \
Michael Vogt 0cab45
@@ -682,6 +684,7 @@ safe_syscall3(ssize_t, write, int, fd, const void *, buff, size_t, count)
Michael Vogt 0cab45
 safe_syscall4(int, openat, int, dirfd, const char *, pathname, \
Michael Vogt 0cab45
               int, flags, mode_t, mode)
Michael Vogt 0cab45
 
Michael Vogt 0cab45
+#if defined(TARGET_NR_openat2)
Michael Vogt 0cab45
 struct open_how_ver0 {
Michael Vogt 0cab45
     __u64 flags;
Michael Vogt 0cab45
     __u64 mode;
Michael Vogt 0cab45
@@ -689,6 +692,7 @@ struct open_how_ver0 {
Michael Vogt 0cab45
 };
Michael Vogt 0cab45
 safe_syscall4(int, openat2, int, dirfd, const char *, pathname, \
Michael Vogt 0cab45
               const struct open_how_ver0 *, how, size_t, size)
Michael Vogt 0cab45
+#endif
Michael Vogt 0cab45
 
Michael Vogt 0cab45
 #if defined(TARGET_NR_wait4) || defined(TARGET_NR_waitpid)
Michael Vogt 0cab45
 safe_syscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, \
Michael Vogt 0cab45
@@ -8480,7 +8484,7 @@ int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *pathname,
Michael Vogt 0cab45
     }
Michael Vogt 0cab45
 }
Michael Vogt 0cab45
 
Michael Vogt 0cab45
-
Michael Vogt 0cab45
+#if defined(TARGET_NR_openat2)
Michael Vogt 0cab45
 static int do_openat2(CPUArchState *cpu_env, abi_long dirfd,
Michael Vogt 0cab45
                       abi_ptr guest_pathname, abi_ptr guest_open_how,
Michael Vogt 0cab45
                       abi_ulong guest_size)
Michael Vogt 0cab45
@@ -8522,6 +8526,7 @@ static int do_openat2(CPUArchState *cpu_env, abi_long dirfd,
Michael Vogt 0cab45
     unlock_user(pathname, guest_pathname, 0);
Michael Vogt 0cab45
     return ret;
Michael Vogt 0cab45
 }
Michael Vogt 0cab45
+#endif
Michael Vogt 0cab45
 
Michael Vogt 0cab45
 ssize_t do_guest_readlink(const char *pathname, char *buf, size_t bufsiz)
Michael Vogt 0cab45
 {
Michael Vogt 0cab45
@@ -9295,9 +9300,11 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
Michael Vogt 0cab45
         fd_trans_unregister(ret);
Michael Vogt 0cab45
         unlock_user(p, arg2, 0);
Michael Vogt 0cab45
         return ret;
Michael Vogt 0cab45
+#if defined(TARGET_NR_openat2)
Michael Vogt 0cab45
     case TARGET_NR_openat2:
Michael Vogt 0cab45
         ret = do_openat2(cpu_env, arg1, arg2, arg3, arg4);
Michael Vogt 0cab45
         return ret;
Michael Vogt 0cab45
+#endif
Michael Vogt 0cab45
 #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
Michael Vogt 0cab45
     case TARGET_NR_name_to_handle_at:
Michael Vogt 0cab45
         ret = do_name_to_handle_at(arg1, arg2, arg3, arg4, arg5);
Michael Vogt 0cab45
-- 
Michael Vogt 0cab45
2.47.0
Michael Vogt 0cab45