[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 19/23] bsd-user: Implement shm_open(2)
From: |
Karim Taha |
Subject: |
[PATCH v2 19/23] bsd-user: Implement shm_open(2) |
Date: |
Thu, 7 Sep 2023 09:42:58 +0200 |
From: Stacey Son <sson@FreeBSD.org>
Co-authored-by: Kyle Evans <kevans@FreeBSD.org>
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com>
---
bsd-user/bsd-mem.h | 25 +++++++++++++++++++++++++
bsd-user/freebsd/os-syscall.c | 4 ++++
2 files changed, 29 insertions(+)
diff --git a/bsd-user/bsd-mem.h b/bsd-user/bsd-mem.h
index 563f82996b..a48f919ff2 100644
--- a/bsd-user/bsd-mem.h
+++ b/bsd-user/bsd-mem.h
@@ -256,4 +256,29 @@ static inline abi_long do_obreak(abi_ulong brk_val)
return target_brk;
}
+/* shm_open(2) */
+static inline abi_long do_bsd_shm_open(abi_ulong arg1, abi_long arg2,
+ abi_long arg3)
+{
+ int ret;
+ void *p;
+
+ if (arg1 == (uintptr_t)SHM_ANON) {
+ p = SHM_ANON;
+ } else {
+ p = lock_user_string(arg1);
+ if (p == NULL) {
+ return -TARGET_EFAULT;
+ }
+ }
+ ret = get_errno(shm_open(p, target_to_host_bitmask(arg2, fcntl_flags_tbl),
+ arg3));
+
+ if (p != SHM_ANON) {
+ unlock_user(p, arg1, 0);
+ }
+
+ return ret;
+}
+
#endif /* BSD_USER_BSD_MEM_H */
diff --git a/bsd-user/freebsd/os-syscall.c b/bsd-user/freebsd/os-syscall.c
index 8dd29fddde..7404b0aa72 100644
--- a/bsd-user/freebsd/os-syscall.c
+++ b/bsd-user/freebsd/os-syscall.c
@@ -531,6 +531,10 @@ static abi_long freebsd_syscall(void *cpu_env, int num,
abi_long arg1,
ret = do_bsd_mincore(arg1, arg2, arg3);
break;
+ case TARGET_FREEBSD_NR_freebsd12_shm_open: /* shm_open(2) */
+ ret = do_bsd_shm_open(arg1, arg2, arg3);
+ break;
+
#if defined(__FreeBSD_version) && __FreeBSD_version >= 1300048
case TARGET_FREEBSD_NR_shm_open2: /* shm_open2(2) */
ret = do_freebsd_shm_open2(arg1, arg2, arg3, arg4, arg5);
--
2.42.0
- [PATCH v2 09/23] bsd-user: Implement ipc_perm conversion between host and target., (continued)
- [PATCH v2 09/23] bsd-user: Implement ipc_perm conversion between host and target., Karim Taha, 2023/09/09
- [PATCH v2 11/23] bsd-user: Introduce bsd-mem.h to the source tree, Karim Taha, 2023/09/09
- [PATCH v2 12/23] bsd-user: Implement mmap(2) and munmap(2), Karim Taha, 2023/09/09
- [PATCH v2 15/23] bsd-user: Implement mlock(2), munlock(2), mlockall(2), munlockall(2), minherit(2), Karim Taha, 2023/09/09
- [PATCH v2 13/23] bsd-user: Implement mprotect(2), Karim Taha, 2023/09/09
- [PATCH v2 14/23] bsd-user: Implement msync(2), Karim Taha, 2023/09/09
- [PATCH v2 16/23] bsd-user: Implment madvise(2) to match the linux-user implementation., Karim Taha, 2023/09/09
- [PATCH v2 10/23] bsd-user: Implement shmid_ds conversion between host and target., Karim Taha, 2023/09/09
- [PATCH v2 17/23] bsd-user: Implement mincore(2), Karim Taha, 2023/09/09
- [PATCH v2 18/23] bsd-user: Implement do_obreak function, Karim Taha, 2023/09/09
- [PATCH v2 19/23] bsd-user: Implement shm_open(2),
Karim Taha <=
- [PATCH v2 20/23] bsd-user: Implement shm_unlink(2) and shmget(2), Karim Taha, 2023/09/09
- [PATCH v2 21/23] bsd-user: Implement shmctl(2), Karim Taha, 2023/09/09
- [PATCH v2 23/23] bsd-user: Add stubs for vadvise(), sbrk() and sstk(), Karim Taha, 2023/09/09
- [PATCH v2 22/23] bsd-user: Implement shmat(2) and shmdt(2), Karim Taha, 2023/09/09