mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge tag '2023q3-bsd-user-pull-request' of https://gitlab.com/bsdimp/qemu into staging
Pull request for bsd-user 2023 Q3 (first batch) First batch of commits submitted by my GSoC student Karim Taha These implement the stat, statfs, statfh and dirents system calls. In addition, fix a missing break statment, and submit Richard Henderson's elf stat mmap cleansup. # -----BEGIN PGP SIGNATURE----- # Comment: GPGTools - https://gpgtools.org # # iQIzBAABCgAdFiEEIDX4lLAKo898zeG3bBzRKH2wEQAFAmTtL6EACgkQbBzRKH2w # EQALHQ//WOoHYxpNS1hy+oYIAvjW0JOqz9gCSFR0d56mDBShm7WO/9FZA6eGAzYQ # i5kBSVFwEBlM76K5vLTbRvCbCbAwlpAdMgI7HXValjspNhvu/66DNWmdil6GnXKu # 4QRaM/QGrobmYrNmf4SdgyjlMVH7wGyTrCTpXfvPfktZLAbQq7dCyNPTsOYXJP2V # LASk8j2gyW6fDi3z1AxTNVfS7BJX6DWMhPhlvC/aUOLVVGgj9Hw9uxPaKXC1t47D # bpZ+wJb4GMkcsmuiGJ40CXowjQ+M1lBrA4rN+lTMJNttZJ+TUYmizTFkYhX+B28h # Q2JZy5eLXlsxxRByOkOwFczfDT6jlG4BlK4jmDOvKlrTPLaWIHjezztTavWIZDlU # ce1oXQo3KEdWoa/QEsuxLeBbE+uZpu5+NqLeCk1cU4GPks8nbAcD7BGl6dDHKXM4 # 8vCcOMZLwO+xi5Etgcf/MtTPMpSO0rD9fTq2VSdYX0H197mkOdyCDAXjfKPsBUIE # VLAnCFfajMNRc5ITobEbz4GiMD/xy5s8eDZNeefG8lgySpl9XB2Lvw7SWDz1imsL # nBgQH6RHznU65wEvVGtnCGMj5kIMbohY2AGR75iGkRdgR+t2zMjUIiaU/qivD+6z # IEJ2jqDWqtQb81jFNrFzJlsim+GYRl0HcaEmyye2bgf5LHRSSNM= # =ORJ7 # -----END PGP SIGNATURE----- # gpg: Signature made Mon 28 Aug 2023 19:37:05 EDT # gpg: using RSA key 2035F894B00AA3CF7CCDE1B76C1CD1287DB01100 # gpg: Good signature from "Warner Losh <wlosh@netflix.com>" [unknown] # gpg: aka "Warner Losh <imp@bsdimp.com>" [unknown] # gpg: aka "Warner Losh <imp@freebsd.org>" [unknown] # gpg: aka "Warner Losh <imp@village.org>" [unknown] # gpg: aka "Warner Losh <wlosh@bsdimp.com>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 2035 F894 B00A A3CF 7CCD E1B7 6C1C D128 7DB0 1100 * tag '2023q3-bsd-user-pull-request' of https://gitlab.com/bsdimp/qemu: (36 commits) bsd-user: Add missing break after do_bsd_preadv bsd-user: Add getdents and fcntl related system calls bsd-user: Add glue for statfs related system calls bsd-user: Add glue for getfh and related syscalls bsd-user: Add glue for the freebsd11_stat syscalls bsd-user: Add os-stat.c to the build bsd-user: Implement do_freebsd_realpathat syscall bsd-user: Implement freebsd11 netbsd stat related syscalls bsd-user: Implement freebsd11 getdirents related syscalls bsd-user: Implement freebsd11 statfs related syscalls bsd-user: Implement freebsd11 fstat and fhstat related syscalls bsd-user: Implement freebsd11 stat related syscalls bsd-user: Implement stat related syscalls bsd-user: Implement getdents related syscalls bsd-user: Implement statfs related syscalls bsd-user: Implement statfh related syscalls bsd-user: Implement stat related syscalls bsd-uesr: Implement h2t_freebsd_stat and h2t_freebsd_statfs functions bsd-user: Implement target_to_host_fcntl_cmd bsd-user: Implement h2t_freebds11_statfs ... Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
#ifndef TARGET_ARCH_ELF_H
|
||||
#define TARGET_ARCH_ELF_H
|
||||
|
||||
#define ELF_START_MMAP 0x80000000
|
||||
#define ELF_ET_DYN_LOAD_ADDR 0x500000
|
||||
|
||||
#define elf_check_arch(x) ((x) == EM_ARM)
|
||||
|
||||
+1
-3
@@ -738,8 +738,6 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
|
||||
/* OK, This is the point of no return */
|
||||
info->end_data = 0;
|
||||
info->end_code = 0;
|
||||
info->start_mmap = (abi_ulong)ELF_START_MMAP;
|
||||
info->mmap = 0;
|
||||
elf_entry = (abi_ulong) elf_ex.e_entry;
|
||||
|
||||
/* XXX Join this with PT_INTERP search? */
|
||||
@@ -813,7 +811,7 @@ int load_elf_binary(struct bsd_binprm *bprm, struct target_pt_regs *regs,
|
||||
bprm->stringp, &elf_ex, load_addr,
|
||||
et_dyn_addr, interp_load_addr, info);
|
||||
info->load_addr = reloc_func_desc;
|
||||
info->start_brk = info->brk = elf_brk;
|
||||
info->brk = elf_brk;
|
||||
info->start_stack = bprm->p;
|
||||
info->load_bias = 0;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
bsd_user_ss.add(files(
|
||||
'os-stat.c',
|
||||
'os-sys.c',
|
||||
'os-syscall.c',
|
||||
))
|
||||
|
||||
@@ -0,0 +1,262 @@
|
||||
/*
|
||||
* FreeBSD stat related conversion routines
|
||||
*
|
||||
* Copyright (c) 2013 Stacey D. Son
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "qemu/osdep.h"
|
||||
|
||||
#include "qemu.h"
|
||||
|
||||
/*
|
||||
* stat conversion
|
||||
*/
|
||||
abi_long h2t_freebsd11_stat(abi_ulong target_addr,
|
||||
struct freebsd11_stat *host_st)
|
||||
{
|
||||
struct target_freebsd11_stat *target_st;
|
||||
|
||||
if (!lock_user_struct(VERIFY_WRITE, target_st, target_addr, 0)) {
|
||||
return -TARGET_EFAULT;
|
||||
}
|
||||
memset(target_st, 0, sizeof(*target_st));
|
||||
__put_user(host_st->st_dev, &target_st->st_dev);
|
||||
__put_user(host_st->st_ino, &target_st->st_ino);
|
||||
__put_user(host_st->st_mode, &target_st->st_mode);
|
||||
__put_user(host_st->st_nlink, &target_st->st_nlink);
|
||||
__put_user(host_st->st_uid, &target_st->st_uid);
|
||||
__put_user(host_st->st_gid, &target_st->st_gid);
|
||||
__put_user(host_st->st_rdev, &target_st->st_rdev);
|
||||
__put_user(host_st->st_atim.tv_sec, &target_st->st_atim.tv_sec);
|
||||
__put_user(host_st->st_atim.tv_nsec, &target_st->st_atim.tv_nsec);
|
||||
__put_user(host_st->st_mtim.tv_sec, &target_st->st_mtim.tv_sec);
|
||||
__put_user(host_st->st_mtim.tv_nsec, &target_st->st_mtim.tv_nsec);
|
||||
__put_user(host_st->st_ctim.tv_sec, &target_st->st_ctim.tv_sec);
|
||||
__put_user(host_st->st_ctim.tv_nsec, &target_st->st_ctim.tv_nsec);
|
||||
__put_user(host_st->st_size, &target_st->st_size);
|
||||
__put_user(host_st->st_blocks, &target_st->st_blocks);
|
||||
__put_user(host_st->st_blksize, &target_st->st_blksize);
|
||||
__put_user(host_st->st_flags, &target_st->st_flags);
|
||||
__put_user(host_st->st_gen, &target_st->st_gen);
|
||||
/* st_lspare not used */
|
||||
__put_user(host_st->st_birthtim.tv_sec, &target_st->st_birthtim.tv_sec);
|
||||
__put_user(host_st->st_birthtim.tv_nsec, &target_st->st_birthtim.tv_nsec);
|
||||
unlock_user_struct(target_st, target_addr, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
abi_long h2t_freebsd_stat(abi_ulong target_addr,
|
||||
struct stat *host_st)
|
||||
{
|
||||
struct target_stat *target_st;
|
||||
|
||||
if (!lock_user_struct(VERIFY_WRITE, target_st, target_addr, 0)) {
|
||||
return -TARGET_EFAULT;
|
||||
}
|
||||
memset(target_st, 0, sizeof(*target_st));
|
||||
__put_user(host_st->st_dev, &target_st->st_dev);
|
||||
__put_user(host_st->st_ino, &target_st->st_ino);
|
||||
__put_user(host_st->st_nlink, &target_st->st_nlink);
|
||||
__put_user(host_st->st_mode, &target_st->st_mode);
|
||||
__put_user(host_st->st_uid, &target_st->st_uid);
|
||||
__put_user(host_st->st_gid, &target_st->st_gid);
|
||||
__put_user(host_st->st_rdev, &target_st->st_rdev);
|
||||
__put_user(host_st->st_atim.tv_sec, &target_st->st_atim.tv_sec);
|
||||
__put_user(host_st->st_atim.tv_nsec, &target_st->st_atim.tv_nsec);
|
||||
#ifdef TARGET_HAS_STAT_TIME_T_EXT
|
||||
/* __put_user(host_st->st_mtim_ext, &target_st->st_mtim_ext); XXX */
|
||||
#endif
|
||||
__put_user(host_st->st_mtim.tv_sec, &target_st->st_mtim.tv_sec);
|
||||
__put_user(host_st->st_mtim.tv_nsec, &target_st->st_mtim.tv_nsec);
|
||||
#ifdef TARGET_HAS_STAT_TIME_T_EXT
|
||||
/* __put_user(host_st->st_ctim_ext, &target_st->st_ctim_ext); XXX */
|
||||
#endif
|
||||
__put_user(host_st->st_ctim.tv_sec, &target_st->st_ctim.tv_sec);
|
||||
__put_user(host_st->st_ctim.tv_nsec, &target_st->st_ctim.tv_nsec);
|
||||
#ifdef TARGET_HAS_STAT_TIME_T_EXT
|
||||
/* __put_user(host_st->st_birthtim_ext, &target_st->st_birthtim_ext); XXX */
|
||||
#endif
|
||||
__put_user(host_st->st_birthtim.tv_sec, &target_st->st_birthtim.tv_sec);
|
||||
__put_user(host_st->st_birthtim.tv_nsec, &target_st->st_birthtim.tv_nsec);
|
||||
|
||||
__put_user(host_st->st_size, &target_st->st_size);
|
||||
__put_user(host_st->st_blocks, &target_st->st_blocks);
|
||||
__put_user(host_st->st_blksize, &target_st->st_blksize);
|
||||
__put_user(host_st->st_flags, &target_st->st_flags);
|
||||
__put_user(host_st->st_gen, &target_st->st_gen);
|
||||
unlock_user_struct(target_st, target_addr, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
abi_long h2t_freebsd11_nstat(abi_ulong target_addr,
|
||||
struct freebsd11_stat *host_st)
|
||||
{
|
||||
struct target_freebsd11_nstat *target_st;
|
||||
|
||||
if (!lock_user_struct(VERIFY_WRITE, target_st, target_addr, 0)) {
|
||||
return -TARGET_EFAULT;
|
||||
}
|
||||
memset(target_st, 0, sizeof(*target_st));
|
||||
__put_user(host_st->st_dev, &target_st->st_dev);
|
||||
__put_user(host_st->st_ino, &target_st->st_ino);
|
||||
__put_user(host_st->st_mode, &target_st->st_mode);
|
||||
__put_user(host_st->st_nlink, &target_st->st_nlink);
|
||||
__put_user(host_st->st_uid, &target_st->st_uid);
|
||||
__put_user(host_st->st_gid, &target_st->st_gid);
|
||||
__put_user(host_st->st_rdev, &target_st->st_rdev);
|
||||
__put_user(host_st->st_atim.tv_sec, &target_st->st_atim.tv_sec);
|
||||
__put_user(host_st->st_atim.tv_nsec, &target_st->st_atim.tv_nsec);
|
||||
__put_user(host_st->st_mtim.tv_sec, &target_st->st_mtim.tv_sec);
|
||||
__put_user(host_st->st_mtim.tv_nsec, &target_st->st_mtim.tv_nsec);
|
||||
__put_user(host_st->st_ctim.tv_sec, &target_st->st_ctim.tv_sec);
|
||||
__put_user(host_st->st_ctim.tv_nsec, &target_st->st_ctim.tv_nsec);
|
||||
__put_user(host_st->st_size, &target_st->st_size);
|
||||
__put_user(host_st->st_blocks, &target_st->st_blocks);
|
||||
__put_user(host_st->st_blksize, &target_st->st_blksize);
|
||||
__put_user(host_st->st_flags, &target_st->st_flags);
|
||||
__put_user(host_st->st_gen, &target_st->st_gen);
|
||||
__put_user(host_st->st_birthtim.tv_sec, &target_st->st_birthtim.tv_sec);
|
||||
__put_user(host_st->st_birthtim.tv_nsec, &target_st->st_birthtim.tv_nsec);
|
||||
unlock_user_struct(target_st, target_addr, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* file handle conversion
|
||||
*/
|
||||
abi_long t2h_freebsd_fhandle(fhandle_t *host_fh, abi_ulong target_addr)
|
||||
{
|
||||
target_freebsd_fhandle_t *target_fh;
|
||||
|
||||
if (!lock_user_struct(VERIFY_READ, target_fh, target_addr, 1)) {
|
||||
return -TARGET_EFAULT;
|
||||
}
|
||||
__get_user(host_fh->fh_fsid.val[0], &target_fh->fh_fsid.val[0]);
|
||||
__get_user(host_fh->fh_fsid.val[1], &target_fh->fh_fsid.val[0]);
|
||||
__get_user(host_fh->fh_fid.fid_len, &target_fh->fh_fid.fid_len);
|
||||
/* u_short fid_data0; */
|
||||
memcpy(host_fh->fh_fid.fid_data, target_fh->fh_fid.fid_data,
|
||||
TARGET_MAXFIDSZ);
|
||||
unlock_user_struct(target_fh, target_addr, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
abi_long h2t_freebsd_fhandle(abi_ulong target_addr, fhandle_t *host_fh)
|
||||
{
|
||||
target_freebsd_fhandle_t *target_fh;
|
||||
|
||||
if (!lock_user_struct(VERIFY_WRITE, target_fh, target_addr, 0)) {
|
||||
return -TARGET_EFAULT;
|
||||
}
|
||||
__put_user(host_fh->fh_fsid.val[0], &target_fh->fh_fsid.val[0]);
|
||||
__put_user(host_fh->fh_fsid.val[1], &target_fh->fh_fsid.val[0]);
|
||||
__put_user(host_fh->fh_fid.fid_len, &target_fh->fh_fid.fid_len);
|
||||
/* u_short fid_data0; */
|
||||
memcpy(target_fh->fh_fid.fid_data, host_fh->fh_fid.fid_data,
|
||||
TARGET_MAXFIDSZ);
|
||||
unlock_user_struct(target_fh, target_addr, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* file system stat
|
||||
*/
|
||||
abi_long h2t_freebsd11_statfs(abi_ulong target_addr,
|
||||
struct freebsd11_statfs *host_statfs)
|
||||
{
|
||||
struct target_freebsd11_statfs *target_statfs;
|
||||
|
||||
if (!lock_user_struct(VERIFY_WRITE, target_statfs, target_addr, 0)) {
|
||||
return -TARGET_EFAULT;
|
||||
}
|
||||
__put_user(host_statfs->f_version, &target_statfs->f_version);
|
||||
__put_user(host_statfs->f_type, &target_statfs->f_type);
|
||||
__put_user(host_statfs->f_flags, &target_statfs->f_flags);
|
||||
__put_user(host_statfs->f_bsize, &target_statfs->f_bsize);
|
||||
__put_user(host_statfs->f_iosize, &target_statfs->f_iosize);
|
||||
__put_user(host_statfs->f_blocks, &target_statfs->f_blocks);
|
||||
__put_user(host_statfs->f_bfree, &target_statfs->f_bfree);
|
||||
__put_user(host_statfs->f_bavail, &target_statfs->f_bavail);
|
||||
__put_user(host_statfs->f_files, &target_statfs->f_files);
|
||||
__put_user(host_statfs->f_ffree, &target_statfs->f_ffree);
|
||||
__put_user(host_statfs->f_syncwrites, &target_statfs->f_syncwrites);
|
||||
__put_user(host_statfs->f_asyncwrites, &target_statfs->f_asyncwrites);
|
||||
__put_user(host_statfs->f_syncreads, &target_statfs->f_syncreads);
|
||||
__put_user(host_statfs->f_asyncreads, &target_statfs->f_asyncreads);
|
||||
/* uint64_t f_spare[10]; */
|
||||
__put_user(host_statfs->f_namemax, &target_statfs->f_namemax);
|
||||
__put_user(host_statfs->f_owner, &target_statfs->f_owner);
|
||||
__put_user(host_statfs->f_fsid.val[0], &target_statfs->f_fsid.val[0]);
|
||||
__put_user(host_statfs->f_fsid.val[1], &target_statfs->f_fsid.val[1]);
|
||||
/* char f_charspace[80]; */
|
||||
strncpy(target_statfs->f_fstypename, host_statfs->f_fstypename,
|
||||
sizeof(target_statfs->f_fstypename));
|
||||
strncpy(target_statfs->f_mntfromname, host_statfs->f_mntfromname,
|
||||
sizeof(target_statfs->f_mntfromname));
|
||||
strncpy(target_statfs->f_mntonname, host_statfs->f_mntonname,
|
||||
sizeof(target_statfs->f_mntonname));
|
||||
unlock_user_struct(target_statfs, target_addr, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
abi_long h2t_freebsd_statfs(abi_ulong target_addr,
|
||||
struct statfs *host_statfs)
|
||||
{
|
||||
struct target_statfs *target_statfs;
|
||||
|
||||
if (!lock_user_struct(VERIFY_WRITE, target_statfs, target_addr, 0)) {
|
||||
return -TARGET_EFAULT;
|
||||
}
|
||||
__put_user(host_statfs->f_version, &target_statfs->f_version);
|
||||
__put_user(host_statfs->f_type, &target_statfs->f_type);
|
||||
__put_user(host_statfs->f_flags, &target_statfs->f_flags);
|
||||
__put_user(host_statfs->f_bsize, &target_statfs->f_bsize);
|
||||
__put_user(host_statfs->f_iosize, &target_statfs->f_iosize);
|
||||
__put_user(host_statfs->f_blocks, &target_statfs->f_blocks);
|
||||
__put_user(host_statfs->f_bfree, &target_statfs->f_bfree);
|
||||
__put_user(host_statfs->f_bavail, &target_statfs->f_bavail);
|
||||
__put_user(host_statfs->f_files, &target_statfs->f_files);
|
||||
__put_user(host_statfs->f_ffree, &target_statfs->f_ffree);
|
||||
__put_user(host_statfs->f_syncwrites, &target_statfs->f_syncwrites);
|
||||
__put_user(host_statfs->f_asyncwrites, &target_statfs->f_asyncwrites);
|
||||
__put_user(host_statfs->f_syncreads, &target_statfs->f_syncreads);
|
||||
__put_user(host_statfs->f_asyncreads, &target_statfs->f_asyncreads);
|
||||
/* uint64_t f_spare[10]; */
|
||||
__put_user(host_statfs->f_namemax, &target_statfs->f_namemax);
|
||||
__put_user(host_statfs->f_owner, &target_statfs->f_owner);
|
||||
__put_user(host_statfs->f_fsid.val[0], &target_statfs->f_fsid.val[0]);
|
||||
__put_user(host_statfs->f_fsid.val[1], &target_statfs->f_fsid.val[1]);
|
||||
/* char f_charspace[80]; */
|
||||
strncpy(target_statfs->f_fstypename, host_statfs->f_fstypename,
|
||||
sizeof(target_statfs->f_fstypename));
|
||||
strncpy(target_statfs->f_mntfromname, host_statfs->f_mntfromname,
|
||||
sizeof(target_statfs->f_mntfromname));
|
||||
strncpy(target_statfs->f_mntonname, host_statfs->f_mntonname,
|
||||
sizeof(target_statfs->f_mntonname));
|
||||
unlock_user_struct(target_statfs, target_addr, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* fcntl cmd conversion
|
||||
*/
|
||||
abi_long target_to_host_fcntl_cmd(int cmd)
|
||||
{
|
||||
return cmd;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+111
-11
@@ -17,17 +17,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* We need the FreeBSD "legacy" definitions. Rust needs the FreeBSD 11 system
|
||||
* calls since it doesn't use libc at all, so we have to emulate that despite
|
||||
* FreeBSD 11 being EOL'd.
|
||||
*/
|
||||
#define _WANT_FREEBSD11_STAT
|
||||
#define _WANT_FREEBSD11_STATFS
|
||||
#define _WANT_FREEBSD11_DIRENT
|
||||
#define _WANT_KERNEL_ERRNO
|
||||
#define _WANT_SEMUN
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/cutils.h"
|
||||
#include "qemu/path.h"
|
||||
@@ -47,6 +36,9 @@
|
||||
#include "bsd-file.h"
|
||||
#include "bsd-proc.h"
|
||||
|
||||
/* *BSD dependent syscall shims */
|
||||
#include "os-stat.h"
|
||||
|
||||
/* I/O */
|
||||
safe_syscall3(int, open, const char *, path, int, flags, mode_t, mode);
|
||||
safe_syscall4(int, openat, int, fd, const char *, path, int, flags, mode_t,
|
||||
@@ -248,6 +240,7 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1,
|
||||
|
||||
case TARGET_FREEBSD_NR_preadv: /* preadv(2) */
|
||||
ret = do_bsd_preadv(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_write: /* write(2) */
|
||||
ret = do_bsd_write(arg1, arg2, arg3);
|
||||
@@ -493,6 +486,113 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1,
|
||||
ret = do_bsd_undelete(arg1);
|
||||
break;
|
||||
|
||||
/*
|
||||
* stat system calls
|
||||
*/
|
||||
case TARGET_FREEBSD_NR_freebsd11_stat: /* stat(2) */
|
||||
ret = do_freebsd11_stat(arg1, arg2);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_freebsd11_lstat: /* lstat(2) */
|
||||
ret = do_freebsd11_lstat(arg1, arg2);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_freebsd11_fstat: /* fstat(2) */
|
||||
ret = do_freebsd11_fstat(arg1, arg2);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_fstat: /* fstat(2) */
|
||||
ret = do_freebsd_fstat(arg1, arg2);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_freebsd11_fstatat: /* fstatat(2) */
|
||||
ret = do_freebsd11_fstatat(arg1, arg2, arg3, arg4);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_fstatat: /* fstatat(2) */
|
||||
ret = do_freebsd_fstatat(arg1, arg2, arg3, arg4);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_freebsd11_nstat: /* undocumented */
|
||||
ret = do_freebsd11_nstat(arg1, arg2);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_freebsd11_nfstat: /* undocumented */
|
||||
ret = do_freebsd11_nfstat(arg1, arg2);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_freebsd11_nlstat: /* undocumented */
|
||||
ret = do_freebsd11_nlstat(arg1, arg2);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_getfh: /* getfh(2) */
|
||||
ret = do_freebsd_getfh(arg1, arg2);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_lgetfh: /* lgetfh(2) */
|
||||
ret = do_freebsd_lgetfh(arg1, arg2);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_fhopen: /* fhopen(2) */
|
||||
ret = do_freebsd_fhopen(arg1, arg2);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_freebsd11_fhstat: /* fhstat(2) */
|
||||
ret = do_freebsd11_fhstat(arg1, arg2);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_fhstat: /* fhstat(2) */
|
||||
ret = do_freebsd_fhstat(arg1, arg2);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_freebsd11_fhstatfs: /* fhstatfs(2) */
|
||||
ret = do_freebsd11_fhstatfs(arg1, arg2);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_fhstatfs: /* fhstatfs(2) */
|
||||
ret = do_freebsd_fhstatfs(arg1, arg2);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_freebsd11_statfs: /* statfs(2) */
|
||||
ret = do_freebsd11_statfs(arg1, arg2);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_statfs: /* statfs(2) */
|
||||
ret = do_freebsd_statfs(arg1, arg2);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_freebsd11_fstatfs: /* fstatfs(2) */
|
||||
ret = do_freebsd11_fstatfs(arg1, arg2);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_fstatfs: /* fstatfs(2) */
|
||||
ret = do_freebsd_fstatfs(arg1, arg2);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_freebsd11_getfsstat: /* getfsstat(2) */
|
||||
ret = do_freebsd11_getfsstat(arg1, arg2, arg3);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_getfsstat: /* getfsstat(2) */
|
||||
ret = do_freebsd_getfsstat(arg1, arg2, arg3);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_freebsd11_getdents: /* getdents(2) */
|
||||
ret = do_freebsd11_getdents(arg1, arg2, arg3);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_getdirentries: /* getdirentries(2) */
|
||||
ret = do_freebsd_getdirentries(arg1, arg2, arg3, arg4);
|
||||
break;
|
||||
|
||||
case TARGET_FREEBSD_NR_freebsd11_getdirentries: /* getdirentries(2) */
|
||||
ret = do_freebsd11_getdirentries(arg1, arg2, arg3, arg4);
|
||||
break;
|
||||
case TARGET_FREEBSD_NR_fcntl: /* fcntl(2) */
|
||||
ret = do_freebsd_fcntl(arg1, arg2, arg3);
|
||||
break;
|
||||
|
||||
|
||||
/*
|
||||
* sys{ctl, arch, call}
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* FreeBSD conversion extern declarations
|
||||
*
|
||||
* Copyright (c) 2013 Stacey D. Son
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef QEMU_OS_H
|
||||
#define QEMU_OS_H
|
||||
|
||||
/* qemu/osdep.h pulls in the rest */
|
||||
|
||||
#include <sys/acl.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/timex.h>
|
||||
#include <sys/rtprio.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
struct freebsd11_stat;
|
||||
|
||||
/* os-stat.c */
|
||||
abi_long h2t_freebsd11_stat(abi_ulong target_addr,
|
||||
struct freebsd11_stat *host_st);
|
||||
abi_long h2t_freebsd11_nstat(abi_ulong target_addr,
|
||||
struct freebsd11_stat *host_st);
|
||||
abi_long t2h_freebsd_fhandle(fhandle_t *host_fh, abi_ulong target_addr);
|
||||
abi_long h2t_freebsd_fhandle(abi_ulong target_addr, fhandle_t *host_fh);
|
||||
abi_long h2t_freebsd11_statfs(abi_ulong target_addr,
|
||||
struct freebsd11_statfs *host_statfs);
|
||||
abi_long target_to_host_fcntl_cmd(int cmd);
|
||||
abi_long h2t_freebsd_stat(abi_ulong target_addr,
|
||||
struct stat *host_st);
|
||||
abi_long h2t_freebsd_statfs(abi_ulong target_addr,
|
||||
struct statfs *host_statfs);
|
||||
|
||||
#endif /* QEMU_OS_H */
|
||||
@@ -20,7 +20,6 @@
|
||||
#ifndef TARGET_ARCH_ELF_H
|
||||
#define TARGET_ARCH_ELF_H
|
||||
|
||||
#define ELF_START_MMAP 0x80000000
|
||||
#define ELF_ET_DYN_LOAD_ADDR 0x01001000
|
||||
#define elf_check_arch(x) (((x) == EM_386) || ((x) == EM_486))
|
||||
|
||||
|
||||
@@ -553,8 +553,6 @@ int main(int argc, char **argv)
|
||||
fprintf(f, "page layout changed following binary load\n");
|
||||
page_dump(f);
|
||||
|
||||
fprintf(f, "start_brk 0x" TARGET_ABI_FMT_lx "\n",
|
||||
info->start_brk);
|
||||
fprintf(f, "end_code 0x" TARGET_ABI_FMT_lx "\n",
|
||||
info->end_code);
|
||||
fprintf(f, "start_code 0x" TARGET_ABI_FMT_lx "\n",
|
||||
|
||||
+35
-50
@@ -38,6 +38,7 @@ extern char **environ;
|
||||
#include "exec/gdbstub.h"
|
||||
#include "qemu/clang-tsa.h"
|
||||
|
||||
#include "qemu-os.h"
|
||||
/*
|
||||
* This struct is used to hold certain information about the image. Basically,
|
||||
* it replicates in user space what would be certain task_struct fields in the
|
||||
@@ -50,10 +51,7 @@ struct image_info {
|
||||
abi_ulong end_code;
|
||||
abi_ulong start_data;
|
||||
abi_ulong end_data;
|
||||
abi_ulong start_brk;
|
||||
abi_ulong brk;
|
||||
abi_ulong start_mmap;
|
||||
abi_ulong mmap;
|
||||
abi_ulong rss;
|
||||
abi_ulong start_stack;
|
||||
abi_ulong entry;
|
||||
@@ -275,50 +273,37 @@ static inline bool access_ok(int type, abi_ulong addr, abi_ulong size)
|
||||
* These are usually used to access struct data members once the struct has been
|
||||
* locked - usually with lock_user_struct().
|
||||
*/
|
||||
#define __put_user(x, hptr)\
|
||||
({\
|
||||
int size = sizeof(*hptr);\
|
||||
switch (size) {\
|
||||
case 1:\
|
||||
*(uint8_t *)(hptr) = (uint8_t)(typeof(*hptr))(x);\
|
||||
break;\
|
||||
case 2:\
|
||||
*(uint16_t *)(hptr) = tswap16((typeof(*hptr))(x));\
|
||||
break;\
|
||||
case 4:\
|
||||
*(uint32_t *)(hptr) = tswap32((typeof(*hptr))(x));\
|
||||
break;\
|
||||
case 8:\
|
||||
*(uint64_t *)(hptr) = tswap64((typeof(*hptr))(x));\
|
||||
break;\
|
||||
default:\
|
||||
abort();\
|
||||
} \
|
||||
0;\
|
||||
})
|
||||
#define __put_user_e(x, hptr, e) \
|
||||
do { \
|
||||
PRAGMA_DISABLE_PACKED_WARNING; \
|
||||
(__builtin_choose_expr(sizeof(*(hptr)) == 1, stb_p, \
|
||||
__builtin_choose_expr(sizeof(*(hptr)) == 2, stw_##e##_p, \
|
||||
__builtin_choose_expr(sizeof(*(hptr)) == 4, stl_##e##_p, \
|
||||
__builtin_choose_expr(sizeof(*(hptr)) == 8, stq_##e##_p, abort)))) \
|
||||
((hptr), (x)), (void)0); \
|
||||
PRAGMA_REENABLE_PACKED_WARNING; \
|
||||
} while (0)
|
||||
|
||||
#define __get_user(x, hptr) \
|
||||
({\
|
||||
int size = sizeof(*hptr);\
|
||||
switch (size) {\
|
||||
case 1:\
|
||||
x = (typeof(*hptr))*(uint8_t *)(hptr);\
|
||||
break;\
|
||||
case 2:\
|
||||
x = (typeof(*hptr))tswap16(*(uint16_t *)(hptr));\
|
||||
break;\
|
||||
case 4:\
|
||||
x = (typeof(*hptr))tswap32(*(uint32_t *)(hptr));\
|
||||
break;\
|
||||
case 8:\
|
||||
x = (typeof(*hptr))tswap64(*(uint64_t *)(hptr));\
|
||||
break;\
|
||||
default:\
|
||||
x = 0;\
|
||||
abort();\
|
||||
} \
|
||||
0;\
|
||||
})
|
||||
#define __get_user_e(x, hptr, e) \
|
||||
do { \
|
||||
PRAGMA_DISABLE_PACKED_WARNING; \
|
||||
((x) = (typeof(*hptr))( \
|
||||
__builtin_choose_expr(sizeof(*(hptr)) == 1, ldub_p, \
|
||||
__builtin_choose_expr(sizeof(*(hptr)) == 2, lduw_##e##_p, \
|
||||
__builtin_choose_expr(sizeof(*(hptr)) == 4, ldl_##e##_p, \
|
||||
__builtin_choose_expr(sizeof(*(hptr)) == 8, ldq_##e##_p, abort)))) \
|
||||
(hptr)), (void)0); \
|
||||
PRAGMA_REENABLE_PACKED_WARNING; \
|
||||
} while (0)
|
||||
|
||||
|
||||
#if TARGET_BIG_ENDIAN
|
||||
# define __put_user(x, hptr) __put_user_e(x, hptr, be)
|
||||
# define __get_user(x, hptr) __get_user_e(x, hptr, be)
|
||||
#else
|
||||
# define __put_user(x, hptr) __put_user_e(x, hptr, le)
|
||||
# define __get_user(x, hptr) __get_user_e(x, hptr, le)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* put_user()/get_user() take a guest address and check access
|
||||
@@ -331,10 +316,10 @@ static inline bool access_ok(int type, abi_ulong addr, abi_ulong size)
|
||||
({ \
|
||||
abi_ulong __gaddr = (gaddr); \
|
||||
target_type *__hptr; \
|
||||
abi_long __ret; \
|
||||
abi_long __ret = 0; \
|
||||
__hptr = lock_user(VERIFY_WRITE, __gaddr, sizeof(target_type), 0); \
|
||||
if (__hptr) { \
|
||||
__ret = __put_user((x), __hptr); \
|
||||
__put_user((x), __hptr); \
|
||||
unlock_user(__hptr, __gaddr, sizeof(target_type)); \
|
||||
} else \
|
||||
__ret = -TARGET_EFAULT; \
|
||||
@@ -345,10 +330,10 @@ static inline bool access_ok(int type, abi_ulong addr, abi_ulong size)
|
||||
({ \
|
||||
abi_ulong __gaddr = (gaddr); \
|
||||
target_type *__hptr; \
|
||||
abi_long __ret; \
|
||||
abi_long __ret = 0; \
|
||||
__hptr = lock_user(VERIFY_READ, __gaddr, sizeof(target_type), 1); \
|
||||
if (__hptr) { \
|
||||
__ret = __get_user((x), __hptr); \
|
||||
__get_user((x), __hptr); \
|
||||
unlock_user(__hptr, __gaddr, 0); \
|
||||
} else { \
|
||||
(x) = 0; \
|
||||
|
||||
+1
-4
@@ -787,10 +787,7 @@ static int reset_signal_mask(target_ucontext_t *ucontext)
|
||||
TaskState *ts = (TaskState *)thread_cpu->opaque;
|
||||
|
||||
for (i = 0; i < TARGET_NSIG_WORDS; i++) {
|
||||
if (__get_user(target_set.__bits[i],
|
||||
&ucontext->uc_sigmask.__bits[i])) {
|
||||
return -TARGET_EFAULT;
|
||||
}
|
||||
__get_user(target_set.__bits[i], &ucontext->uc_sigmask.__bits[i]);
|
||||
}
|
||||
target_to_host_sigset_internal(&blocked, &target_set);
|
||||
ts->signal_mask = blocked;
|
||||
|
||||
+217
-4
@@ -45,9 +45,9 @@
|
||||
*
|
||||
*/
|
||||
#if (!defined(TARGET_I386))
|
||||
typedef int64_t target_freebsd_time_t;
|
||||
typedef int64_t target_time_t;
|
||||
#else
|
||||
typedef int32_t target_freebsd_time_t;
|
||||
typedef int32_t target_time_t;
|
||||
#endif
|
||||
|
||||
struct target_iovec {
|
||||
@@ -102,7 +102,7 @@ typedef abi_long target_freebsd_suseconds_t;
|
||||
|
||||
/* compare to sys/timespec.h */
|
||||
struct target_freebsd_timespec {
|
||||
target_freebsd_time_t tv_sec; /* seconds */
|
||||
target_time_t tv_sec; /* seconds */
|
||||
abi_long tv_nsec; /* and nanoseconds */
|
||||
#if !defined(TARGET_I386) && TARGET_ABI_BITS == 32
|
||||
abi_long _pad;
|
||||
@@ -120,7 +120,7 @@ struct target_freebsd__umtx_time {
|
||||
};
|
||||
|
||||
struct target_freebsd_timeval {
|
||||
target_freebsd_time_t tv_sec; /* seconds */
|
||||
target_time_t tv_sec; /* seconds */
|
||||
target_freebsd_suseconds_t tv_usec;/* and microseconds */
|
||||
#if !defined(TARGET_I386) && TARGET_ABI_BITS == 32
|
||||
abi_long _pad;
|
||||
@@ -179,6 +179,217 @@ struct target_freebsd__wrusage {
|
||||
struct target_freebsd_rusage wru_children;
|
||||
};
|
||||
|
||||
/*
|
||||
* sys/stat.h
|
||||
*/
|
||||
struct target_freebsd11_stat {
|
||||
uint32_t st_dev; /* inode's device */
|
||||
uint32_t st_ino; /* inode's number */
|
||||
int16_t st_mode; /* inode protection mode */
|
||||
int16_t st_nlink; /* number of hard links */
|
||||
uint32_t st_uid; /* user ID of the file's owner */
|
||||
uint32_t st_gid; /* group ID of the file's group */
|
||||
uint32_t st_rdev; /* device type */
|
||||
struct target_freebsd_timespec st_atim; /* time last accessed */
|
||||
struct target_freebsd_timespec st_mtim; /* time last data modification */
|
||||
struct target_freebsd_timespec st_ctim; /* time last file status change */
|
||||
int64_t st_size; /* file size, in bytes */
|
||||
int64_t st_blocks; /* blocks allocated for file */
|
||||
uint32_t st_blksize; /* optimal blocksize for I/O */
|
||||
uint32_t st_flags; /* user defined flags for file */
|
||||
uint32_t st_gen; /* file generation number */
|
||||
int32_t st_lspare;
|
||||
struct target_freebsd_timespec st_birthtim; /* time of file creation */
|
||||
/*
|
||||
* Explicitly pad st_birthtim to 16 bytes so that the size of
|
||||
* struct stat is backwards compatible. We use bitfields instead
|
||||
* of an array of chars so that this doesn't require a C99 compiler
|
||||
* to compile if the size of the padding is 0. We use 2 bitfields
|
||||
* to cover up to 64 bits on 32-bit machines. We assume that
|
||||
* CHAR_BIT is 8...
|
||||
*/
|
||||
unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec));
|
||||
unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec));
|
||||
} __packed;
|
||||
|
||||
#if defined(__i386__)
|
||||
#define TARGET_HAS_STAT_TIME_T_EXT 1
|
||||
#endif
|
||||
|
||||
struct target_stat {
|
||||
uint64_t st_dev; /* inode's device */
|
||||
uint64_t st_ino; /* inode's number */
|
||||
uint64_t st_nlink; /* number of hard links */
|
||||
int16_t st_mode; /* inode protection mode */
|
||||
int16_t st_padding0;
|
||||
uint32_t st_uid; /* user ID of the file's owner */
|
||||
uint32_t st_gid; /* group ID of the file's group */
|
||||
int32_t st_padding1;
|
||||
uint64_t st_rdev; /* device type */
|
||||
#ifdef TARGET_HAS_STAT_TIME_T_EXT
|
||||
int32_t st_atim_ext;
|
||||
#endif
|
||||
struct target_freebsd_timespec st_atim; /* time of last access */
|
||||
#ifdef TARGET_HAS_STAT_TIME_T_EXT
|
||||
int32_t st_mtim_ext;
|
||||
#endif
|
||||
struct target_freebsd_timespec st_mtim; /* time of last data modification */
|
||||
#ifdef TARGET_HAS_STAT_TIME_T_EXT
|
||||
int32_t st_ctim_ext;
|
||||
#endif
|
||||
struct target_freebsd_timespec st_ctim;/* time of last file status change */
|
||||
#ifdef TARGET_HAS_STAT_TIME_T_EXT
|
||||
int32_t st_btim_ext;
|
||||
#endif
|
||||
struct target_freebsd_timespec st_birthtim; /* time of file creation */
|
||||
int64_t st_size; /* file size, in bytes */
|
||||
int64_t st_blocks; /* blocks allocated for file */
|
||||
uint32_t st_blksize; /* optimal blocksize for I/O */
|
||||
uint32_t st_flags; /* user defined flags for file */
|
||||
uint64_t st_gen; /* file generation number */
|
||||
uint64_t st_spare[10];
|
||||
};
|
||||
|
||||
|
||||
/* struct nstat is the same as stat above but without the st_lspare field */
|
||||
struct target_freebsd11_nstat {
|
||||
uint32_t st_dev; /* inode's device */
|
||||
uint32_t st_ino; /* inode's number */
|
||||
int16_t st_mode; /* inode protection mode */
|
||||
int16_t st_nlink; /* number of hard links */
|
||||
uint32_t st_uid; /* user ID of the file's owner */
|
||||
uint32_t st_gid; /* group ID of the file's group */
|
||||
uint32_t st_rdev; /* device type */
|
||||
struct target_freebsd_timespec st_atim; /* time last accessed */
|
||||
struct target_freebsd_timespec st_mtim; /* time last data modification */
|
||||
struct target_freebsd_timespec st_ctim; /* time last file status change */
|
||||
int64_t st_size; /* file size, in bytes */
|
||||
int64_t st_blocks; /* blocks allocated for file */
|
||||
uint32_t st_blksize; /* optimal blocksize for I/O */
|
||||
uint32_t st_flags; /* user defined flags for file */
|
||||
uint32_t st_gen; /* file generation number */
|
||||
struct target_freebsd_timespec st_birthtim; /* time of file creation */
|
||||
/*
|
||||
* Explicitly pad st_birthtim to 16 bytes so that the size of
|
||||
* struct stat is backwards compatible. We use bitfields instead
|
||||
* of an array of chars so that this doesn't require a C99 compiler
|
||||
* to compile if the size of the padding is 0. We use 2 bitfields
|
||||
* to cover up to 64 bits on 32-bit machines. We assume that
|
||||
* CHAR_BIT is 8...
|
||||
*/
|
||||
unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec));
|
||||
unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec));
|
||||
} __packed;
|
||||
|
||||
/*
|
||||
* sys/mount.h
|
||||
*/
|
||||
|
||||
/* filesystem id type */
|
||||
typedef struct target_freebsd_fsid { int32_t val[2]; } target_freebsd_fsid_t;
|
||||
|
||||
/* filesystem statistics */
|
||||
struct target_freebsd11_statfs {
|
||||
uint32_t f_version; /* structure version number */
|
||||
uint32_t f_type; /* type of filesystem */
|
||||
uint64_t f_flags; /* copy of mount exported flags */
|
||||
uint64_t f_bsize; /* filesystem fragment size */
|
||||
uint64_t f_iosize; /* optimal transfer block size */
|
||||
uint64_t f_blocks; /* total data blocks in filesystem */
|
||||
uint64_t f_bfree; /* free blocks in filesystem */
|
||||
int64_t f_bavail; /* free blocks avail to non-superuser */
|
||||
uint64_t f_files; /* total file nodes in filesystem */
|
||||
int64_t f_ffree; /* free nodes avail to non-superuser */
|
||||
uint64_t f_syncwrites; /* count of sync writes since mount */
|
||||
uint64_t f_asyncwrites; /* count of async writes since mount */
|
||||
uint64_t f_syncreads; /* count of sync reads since mount */
|
||||
uint64_t f_asyncreads; /* count of async reads since mount */
|
||||
uint64_t f_spare[10]; /* unused spare */
|
||||
uint32_t f_namemax; /* maximum filename length */
|
||||
uint32_t f_owner; /* user that mounted the filesystem */
|
||||
target_freebsd_fsid_t f_fsid; /* filesystem id */
|
||||
char f_charspare[80]; /* spare string space */
|
||||
char f_fstypename[16]; /* filesys type name */
|
||||
char f_mntfromname[88]; /* mount filesystem */
|
||||
char f_mntonname[88]; /* dir on which mounted*/
|
||||
};
|
||||
|
||||
struct target_statfs {
|
||||
uint32_t f_version; /* structure version number */
|
||||
uint32_t f_type; /* type of filesystem */
|
||||
uint64_t f_flags; /* copy of mount exported flags */
|
||||
uint64_t f_bsize; /* filesystem fragment size */
|
||||
uint64_t f_iosize; /* optimal transfer block size */
|
||||
uint64_t f_blocks; /* total data blocks in filesystem */
|
||||
uint64_t f_bfree; /* free blocks in filesystem */
|
||||
int64_t f_bavail; /* free blocks avail to non-superuser */
|
||||
uint64_t f_files; /* total file nodes in filesystem */
|
||||
int64_t f_ffree; /* free nodes avail to non-superuser */
|
||||
uint64_t f_syncwrites; /* count of sync writes since mount */
|
||||
uint64_t f_asyncwrites; /* count of async writes since mount */
|
||||
uint64_t f_syncreads; /* count of sync reads since mount */
|
||||
uint64_t f_asyncreads; /* count of async reads since mount */
|
||||
uint64_t f_spare[10]; /* unused spare */
|
||||
uint32_t f_namemax; /* maximum filename length */
|
||||
uint32_t f_owner; /* user that mounted the filesystem */
|
||||
target_freebsd_fsid_t f_fsid; /* filesystem id */
|
||||
char f_charspare[80]; /* spare string space */
|
||||
char f_fstypename[16]; /* filesystem type name */
|
||||
char f_mntfromname[1024]; /* mounted filesystem */
|
||||
char f_mntonname[1024]; /* directory on which mounted */
|
||||
};
|
||||
|
||||
/* File identifier. These are unique per filesystem on a single machine. */
|
||||
#define TARGET_MAXFIDSZ 16
|
||||
|
||||
struct target_freebsd_fid {
|
||||
uint16_t fid_len; /* len of data in bytes */
|
||||
uint16_t fid_data0; /* force longword align */
|
||||
char fid_data[TARGET_MAXFIDSZ]; /* data (variable len) */
|
||||
};
|
||||
|
||||
/* Generic file handle */
|
||||
struct target_freebsd_fhandle {
|
||||
target_freebsd_fsid_t fh_fsid; /* Filesystem id of mount point */
|
||||
struct target_freebsd_fid fh_fid; /* Filesys specific id */
|
||||
};
|
||||
typedef struct target_freebsd_fhandle target_freebsd_fhandle_t;
|
||||
|
||||
/*
|
||||
* sys/fcntl.h
|
||||
*/
|
||||
#define TARGET_F_DUPFD 0
|
||||
#define TARGET_F_GETFD 1
|
||||
#define TARGET_F_SETFD 2
|
||||
#define TARGET_F_GETFL 3
|
||||
#define TARGET_F_SETFL 4
|
||||
#define TARGET_F_GETOWN 5
|
||||
#define TARGET_F_SETOWN 6
|
||||
#define TARGET_F_OGETLK 7
|
||||
#define TARGET_F_OSETLK 8
|
||||
#define TARGET_F_OSETLKW 9
|
||||
#define TARGET_F_DUP2FD 10
|
||||
#define TARGET_F_GETLK 11
|
||||
#define TARGET_F_SETLK 12
|
||||
#define TARGET_F_SETLKW 13
|
||||
#define TARGET_F_SETLK_REMOTE 14
|
||||
#define TARGET_F_READAHEAD 15
|
||||
#define TARGET_F_RDAHEAD 16
|
||||
#define TARGET_F_DUPFD_CLOEXEC 17
|
||||
#define TARGET_F_DUP2FD_CLOEXEC 18
|
||||
/* FreeBSD-specific */
|
||||
#define TARGET_F_ADD_SEALS 19
|
||||
#define TARGET_F_GET_SEALS 20
|
||||
|
||||
struct target_freebsd_flock {
|
||||
int64_t l_start;
|
||||
int64_t l_len;
|
||||
int32_t l_pid;
|
||||
int16_t l_type;
|
||||
int16_t l_whence;
|
||||
int32_t l_sysid;
|
||||
} QEMU_PACKED;
|
||||
|
||||
#define safe_syscall0(type, name) \
|
||||
type safe_##name(void) \
|
||||
{ \
|
||||
@@ -226,6 +437,8 @@ type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
|
||||
return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5, arg6); \
|
||||
}
|
||||
|
||||
#define safe_fcntl(...) safe_syscall(SYS_fcntl, __VA_ARGS__)
|
||||
|
||||
/* So far all target and host bitmasks are the same */
|
||||
#undef target_to_host_bitmask
|
||||
#define target_to_host_bitmask(x, tbl) (x)
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#ifndef TARGET_ARCH_ELF_H
|
||||
#define TARGET_ARCH_ELF_H
|
||||
|
||||
#define ELF_START_MMAP 0x2aaaaab000ULL
|
||||
#define ELF_ET_DYN_LOAD_ADDR 0x01021000
|
||||
#define elf_check_arch(x) (((x) == ELF_ARCH))
|
||||
|
||||
|
||||
@@ -22,6 +22,36 @@
|
||||
#define QEMU_EXTERN_C extern
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Tricky points:
|
||||
* - Use __builtin_choose_expr to avoid type promotion from ?:,
|
||||
* - Invalid sizes result in a compile time error stemming from
|
||||
* the fact that abort has no parameters.
|
||||
* - It's easier to use the endian-specific unaligned load/store
|
||||
* functions than host-endian unaligned load/store plus tswapN.
|
||||
* - The pragmas are necessary only to silence a clang false-positive
|
||||
* warning: see https://bugs.llvm.org/show_bug.cgi?id=39113 .
|
||||
* - We have to disable -Wpragmas warnings to avoid a complaint about
|
||||
* an unknown warning type from older compilers that don't know about
|
||||
* -Waddress-of-packed-member.
|
||||
* - gcc has bugs in its _Pragma() support in some versions, eg
|
||||
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83256 -- so we only
|
||||
* include the warning-suppression pragmas for clang
|
||||
*/
|
||||
#ifdef __clang__
|
||||
#define PRAGMA_DISABLE_PACKED_WARNING \
|
||||
_Pragma("GCC diagnostic push"); \
|
||||
_Pragma("GCC diagnostic ignored \"-Wpragmas\""); \
|
||||
_Pragma("GCC diagnostic ignored \"-Waddress-of-packed-member\"")
|
||||
|
||||
#define PRAGMA_REENABLE_PACKED_WARNING \
|
||||
_Pragma("GCC diagnostic pop")
|
||||
|
||||
#else
|
||||
#define PRAGMA_DISABLE_PACKED_WARNING
|
||||
#define PRAGMA_REENABLE_PACKED_WARNING
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
|
||||
# define QEMU_PACKED __attribute__((gcc_struct, packed))
|
||||
#else
|
||||
|
||||
@@ -88,6 +88,19 @@ QEMU_EXTERN_C int daemon(int, int);
|
||||
#define __USE_MINGW_ANSI_STDIO 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We need the FreeBSD "legacy" definitions. Rust needs the FreeBSD 11 system
|
||||
* calls since it doesn't use libc at all, so we have to emulate that despite
|
||||
* FreeBSD 11 being EOL'd.
|
||||
*/
|
||||
#ifdef __FreeBSD__
|
||||
#define _WANT_FREEBSD11_STAT
|
||||
#define _WANT_FREEBSD11_STATFS
|
||||
#define _WANT_FREEBSD11_DIRENT
|
||||
#define _WANT_KERNEL_ERRNO
|
||||
#define _WANT_SEMUN
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
Reference in New Issue
Block a user