Skip to content

Commit

Permalink
bsd-user: Implement shm_rename(2) system call
Browse files Browse the repository at this point in the history
Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Warner Losh <imp@bsdimp.com>
Message-Id: <20230925182709.4834-7-kariem.taha2.7@gmail.com>
  • Loading branch information
kevans91 authored and bsdimp committed Oct 3, 2023
1 parent 0c35298 commit 182ea72
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
24 changes: 24 additions & 0 deletions bsd-user/freebsd/os-misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,29 @@ static inline abi_long do_freebsd_shm_open2(abi_ulong pathptr, abi_ulong flags,
}
#endif /* __FreeBSD_version >= 1300048 */

#if defined(__FreeBSD_version) && __FreeBSD_version >= 1300049
/* shm_rename(2) */
static inline abi_long do_freebsd_shm_rename(abi_ulong fromptr, abi_ulong toptr,
abi_ulong flags)
{
int ret;
void *ufrom, *uto;

ufrom = lock_user_string(fromptr);
if (ufrom == NULL) {
return -TARGET_EFAULT;
}
uto = lock_user_string(toptr);
if (uto == NULL) {
unlock_user(ufrom, fromptr, 0);
return -TARGET_EFAULT;
}
ret = get_errno(shm_rename(ufrom, uto, flags));
unlock_user(ufrom, fromptr, 0);
unlock_user(uto, toptr, 0);

return ret;
}
#endif /* __FreeBSD_version >= 1300049 */

#endif /* OS_MISC_H */
6 changes: 6 additions & 0 deletions bsd-user/freebsd/os-syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,12 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1,
break;
#endif

#if defined(__FreeBSD_version) && __FreeBSD_version >= 1300049
case TARGET_FREEBSD_NR_shm_rename: /* shm_rename(2) */
ret = do_freebsd_shm_rename(arg1, arg2, arg3);
break;
#endif

/*
* sys{ctl, arch, call}
*/
Expand Down

0 comments on commit 182ea72

Please sign in to comment.