qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 05/22] Implement shm_open2(2) system call


From: Richard Henderson
Subject: Re: [PATCH 05/22] Implement shm_open2(2) system call
Date: Sat, 19 Aug 2023 08:10:51 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 8/19/23 02:47, Karim Taha wrote:
From: Kyle Evans <kevans@FreeBSD.org>

Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com>
---
  bsd-user/freebsd/os-misc.h    | 52 +++++++++++++++++++++++++++++++++++
  bsd-user/freebsd/os-syscall.c | 13 +++++++++
  2 files changed, 65 insertions(+)

diff --git a/bsd-user/freebsd/os-misc.h b/bsd-user/freebsd/os-misc.h
index 8436ccb2f7..993e4598f9 100644
--- a/bsd-user/freebsd/os-misc.h
+++ b/bsd-user/freebsd/os-misc.h
@@ -24,5 +24,57 @@
  #include <sys/random.h>
  #include <sched.h>
+int shm_open2(const char *path, int flags, mode_t mode, int shmflags,
+    const char *);
+
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048
+/* shm_open2(2) */
+static inline abi_long do_freebsd_shm_open2(abi_ulong pathptr, abi_ulong flags,
+    abi_long mode, abi_ulong shmflags, abi_ulong nameptr)
+{
+    int ret;
+    void *uname, *upath;
+
+#ifdef SHM_ANON

Why would SHM_ANON not be defined? You've already restricted the function to freebsd13+ (presumably so that shm_open2() is in libc.a).


+#define SHM_PATH(p) (p) == SHM_ANON ? (p) : path(p)
+    if (pathptr == (uintptr_t)SHM_ANON) {
+        upath = SHM_ANON;
+    } else
+#else
+#define SHM_PATH(p) path(p)
+#endif
+    {
+        upath = lock_user_string(pathptr);
+        if (upath == NULL) {
+            return -TARGET_EFAULT;
+        }
+    }
+
+    uname = NULL;
+    if (nameptr != 0) {
+        uname = lock_user_string(nameptr);
+        if (uname == NULL) {
+            unlock_user(upath, pathptr, 0);
+            return -TARGET_EFAULT;
+        }
+    }
+    ret = get_errno(shm_open2(SHM_PATH(upath),

There is no need for SHM_PATH because you've already handled the condition while setting upath above.



r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]