Two minor changes to the copyright and license marking for these files: (1) Stacey D Son is used instead of variations of his name. (2) The GPL boilerplate is replaced by SPDX markings. No change to the terms of the license are intended, and this matches current QEMU practice. There's no changes to the license or additional claims to any IP that others may hold in these files. All the S-o-bs in this commit have given me permission to do this to the extent they may hold rights. git blame over multiple repos and branches suggests that only minimal other material is present (much of it likely not subject to copyright protection). The project's long and complex history as well as tooling limitations make it hard to be 100% sure. Any omissions are unintentional and I will correct them as they come to light. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Sean Bruno <sbruno@FreeBSD.org> Signed-off-by: Mikaël Urankar <mikael.urankar@gmail.com> Signed-off-by: Kyle Evans <kevans@FreeBSD.org> Signed-off-by: Guy Yur <guyyur@gmail.com> Signed-off-by: Alexander Kabaev <kan@FreeBSD.org> Signed-off-by: Michal Meloun <mmel@FreeBSD.org> Signed-off-by: Ed Schouten <ed@nuxi.nl> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Warner Losh <imp@bsdimp.com>
87 lines
2.2 KiB
C
87 lines
2.2 KiB
C
/*
|
|
* miscellaneous FreeBSD system call shims
|
|
*
|
|
* Copyright (c) 2013-2014 Stacey D. Son
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
#ifndef OS_MISC_H
|
|
#define OS_MISC_H
|
|
|
|
#include <sys/cpuset.h>
|
|
#include <sys/random.h>
|
|
#include <sched.h>
|
|
|
|
/*
|
|
* shm_open2 isn't exported, but the __sys_ alias is. We can use either for the
|
|
* static version, but to dynamically link we have to use the sys version.
|
|
*/
|
|
int __sys_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;
|
|
|
|
if (pathptr == (uintptr_t)SHM_ANON) {
|
|
upath = SHM_ANON;
|
|
} else {
|
|
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(__sys_shm_open2(upath,
|
|
target_to_host_bitmask(flags, fcntl_flags_tbl), mode,
|
|
target_to_host_bitmask(shmflags, shmflag_flags_tbl), uname));
|
|
|
|
if (upath != SHM_ANON) {
|
|
unlock_user(upath, pathptr, 0);
|
|
}
|
|
if (uname != NULL) {
|
|
unlock_user(uname, nameptr, 0);
|
|
}
|
|
return ret;
|
|
}
|
|
#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 */
|