render / rpms / qemu

Forked from rpms/qemu 8 months ago
Clone
Blob Blame History Raw
From b5aa46fc7bb03877bbea711903e19ad4e27e8259 Mon Sep 17 00:00:00 2001
From: Michael Vogt <michael.vogt@gmail.com>
Date: Wed, 23 Oct 2024 09:50:56 +0200
Subject: [PATCH] linux-user: guard openat2 with `#if
 defined(TARGET_NR_openat2)`

This commit adds a bunch of `#ifdef` around the openat2 support.
We need this to build the `cris-linux-user` target which is still
present in this version but got dropped from upstream in commit
44e4075bf4 but is still present in v9.1.0.

This patch can be dropped once cris is also removed from the
package.
---
 linux-user/syscall.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 85d61db546..22e5ad3c5f 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -608,6 +608,7 @@ static int check_zeroed_user(abi_long addr, size_t ksize, size_t usize)
  *
  * Similar to kernels uaccess.h:copy_struct_from_user()
  */
+#if defined(TARGET_NR_openat2)
 static int
 copy_struct_from_user(void *dst, size_t ksize, abi_ptr src, size_t usize)
 {
@@ -629,6 +630,7 @@ copy_struct_from_user(void *dst, size_t ksize, abi_ptr src, size_t usize)
     }
     return 0;
 }
+#endif
 
 #define safe_syscall0(type, name) \
 static type safe_##name(void) \
@@ -682,6 +684,7 @@ safe_syscall3(ssize_t, write, int, fd, const void *, buff, size_t, count)
 safe_syscall4(int, openat, int, dirfd, const char *, pathname, \
               int, flags, mode_t, mode)
 
+#if defined(TARGET_NR_openat2)
 struct open_how_ver0 {
     __u64 flags;
     __u64 mode;
@@ -689,6 +692,7 @@ struct open_how_ver0 {
 };
 safe_syscall4(int, openat2, int, dirfd, const char *, pathname, \
               const struct open_how_ver0 *, how, size_t, size)
+#endif
 
 #if defined(TARGET_NR_wait4) || defined(TARGET_NR_waitpid)
 safe_syscall4(pid_t, wait4, pid_t, pid, int *, status, int, options, \
@@ -8480,7 +8484,7 @@ int do_guest_openat(CPUArchState *cpu_env, int dirfd, const char *pathname,
     }
 }
 
-
+#if defined(TARGET_NR_openat2)
 static int do_openat2(CPUArchState *cpu_env, abi_long dirfd,
                       abi_ptr guest_pathname, abi_ptr guest_open_how,
                       abi_ulong guest_size)
@@ -8522,6 +8526,7 @@ static int do_openat2(CPUArchState *cpu_env, abi_long dirfd,
     unlock_user(pathname, guest_pathname, 0);
     return ret;
 }
+#endif
 
 ssize_t do_guest_readlink(const char *pathname, char *buf, size_t bufsiz)
 {
@@ -9295,9 +9300,11 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
         fd_trans_unregister(ret);
         unlock_user(p, arg2, 0);
         return ret;
+#if defined(TARGET_NR_openat2)
     case TARGET_NR_openat2:
         ret = do_openat2(cpu_env, arg1, arg2, arg3, arg4);
         return ret;
+#endif
 #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
     case TARGET_NR_name_to_handle_at:
         ret = do_name_to_handle_at(arg1, arg2, arg3, arg4, arg5);
-- 
2.47.0