184778508Sblueswir1 /* 2366c5c9fSWarner Losh * System call related declarations 384778508Sblueswir1 * 4366c5c9fSWarner Losh * Copyright (c) 2013-15 Stacey D. Son (sson at FreeBSD) 584778508Sblueswir1 * 6366c5c9fSWarner Losh * This program is free software; you can redistribute it and/or modify 7366c5c9fSWarner Losh * it under the terms of the GNU General Public License as published by 8366c5c9fSWarner Losh * the Free Software Foundation; either version 2 of the License, or 9366c5c9fSWarner Losh * (at your option) any later version. 1084778508Sblueswir1 * 11366c5c9fSWarner Losh * This program is distributed in the hope that it will be useful, 12366c5c9fSWarner Losh * but WITHOUT ANY WARRANTY; without even the implied warranty of 13366c5c9fSWarner Losh * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14366c5c9fSWarner Losh * GNU General Public License for more details. 15366c5c9fSWarner Losh * 16366c5c9fSWarner Losh * You should have received a copy of the GNU General Public License 17366c5c9fSWarner Losh * along with this program; if not, see <http://www.gnu.org/licenses/>. 1884778508Sblueswir1 */ 1984778508Sblueswir1 209c092804SMarkus Armbruster #ifndef SYSCALL_DEFS_H 219c092804SMarkus Armbruster #define SYSCALL_DEFS_H 2284778508Sblueswir1 23366c5c9fSWarner Losh #include <sys/syscall.h> 2437714547SWarner Losh #include <sys/resource.h> 2584778508Sblueswir1 2684778508Sblueswir1 #include "errno_defs.h" 2784778508Sblueswir1 2884778508Sblueswir1 #include "freebsd/syscall_nr.h" 2984778508Sblueswir1 #include "netbsd/syscall_nr.h" 3084778508Sblueswir1 #include "openbsd/syscall_nr.h" 3178cfb07fSJuergen Lock 32366c5c9fSWarner Losh /* 33366c5c9fSWarner Losh * machine/_types.h 34366c5c9fSWarner Losh * or x86/_types.h 35366c5c9fSWarner Losh */ 36366c5c9fSWarner Losh 37366c5c9fSWarner Losh /* 38366c5c9fSWarner Losh * time_t seems to be very inconsistly defined for the different *BSD's... 39366c5c9fSWarner Losh * 40366c5c9fSWarner Losh * FreeBSD uses a 64bits time_t except on i386 41366c5c9fSWarner Losh * so we have to add a special case here. 42366c5c9fSWarner Losh * 43366c5c9fSWarner Losh * On NetBSD time_t is always defined as an int64_t. On OpenBSD time_t 44366c5c9fSWarner Losh * is always defined as an int. 45366c5c9fSWarner Losh * 46366c5c9fSWarner Losh */ 47366c5c9fSWarner Losh #if (!defined(TARGET_I386)) 48a0c20b1bSWarner Losh typedef int64_t target_time_t; 49366c5c9fSWarner Losh #else 50a0c20b1bSWarner Losh typedef int32_t target_time_t; 51366c5c9fSWarner Losh #endif 52366c5c9fSWarner Losh 5378cfb07fSJuergen Lock struct target_iovec { 5478cfb07fSJuergen Lock abi_long iov_base; /* Starting address */ 5578cfb07fSJuergen Lock abi_long iov_len; /* Number of bytes */ 5678cfb07fSJuergen Lock }; 5778cfb07fSJuergen Lock 58366c5c9fSWarner Losh /* 5961a8f110SStacey Son * sys/ipc.h 6061a8f110SStacey Son */ 6161a8f110SStacey Son struct target_ipc_perm { 6261a8f110SStacey Son uint32_t cuid; /* creator user id */ 6361a8f110SStacey Son uint32_t cgid; /* creator group id */ 6461a8f110SStacey Son uint32_t uid; /* user id */ 6561a8f110SStacey Son uint32_t gid; /* group id */ 6661a8f110SStacey Son uint16_t mode; /* r/w permission */ 6761a8f110SStacey Son uint16_t seq; /* sequence # */ 6861a8f110SStacey Son abi_long key; /* user specified msg/sem/shm key */ 6961a8f110SStacey Son }; 7061a8f110SStacey Son 7161a8f110SStacey Son #define TARGET_IPC_RMID 0 /* remove identifier */ 7261a8f110SStacey Son #define TARGET_IPC_SET 1 /* set options */ 7361a8f110SStacey Son #define TARGET_IPC_STAT 2 /* get options */ 7461a8f110SStacey Son 7561a8f110SStacey Son /* 76695cb913SStacey Son * sys/shm.h 77695cb913SStacey Son */ 78695cb913SStacey Son struct target_shmid_ds { 79695cb913SStacey Son struct target_ipc_perm shm_perm; /* peration permission structure */ 80695cb913SStacey Son abi_ulong shm_segsz; /* size of segment in bytes */ 81695cb913SStacey Son int32_t shm_lpid; /* process ID of last shared memory op */ 82695cb913SStacey Son int32_t shm_cpid; /* process ID of creator */ 83695cb913SStacey Son int32_t shm_nattch; /* number of current attaches */ 84695cb913SStacey Son target_time_t shm_atime; /* time of last shmat() */ 85695cb913SStacey Son target_time_t shm_dtime; /* time of last shmdt() */ 86695cb913SStacey Son target_time_t shm_ctime; /* time of last change by shmctl() */ 87695cb913SStacey Son }; 88695cb913SStacey Son 89695cb913SStacey Son #define N_BSD_SHM_REGIONS 32 90695cb913SStacey Son struct bsd_shm_regions { 91695cb913SStacey Son abi_long start; 92695cb913SStacey Son abi_long size; 93695cb913SStacey Son }; 94695cb913SStacey Son 95695cb913SStacey Son /* 96366c5c9fSWarner Losh * sys/mman.h 97366c5c9fSWarner Losh */ 98*0c1ced42SKarim Taha #define TARGET_MADV_DONTNEED 4 /* dont need these pages */ 99*0c1ced42SKarim Taha 100366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_RESERVED0080 0x0080 /* previously misimplemented */ 101366c5c9fSWarner Losh /* MAP_INHERIT */ 102366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_RESERVED0100 0x0100 /* previously unimplemented */ 103366c5c9fSWarner Losh /* MAP_NOEXTEND */ 104366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_STACK 0x0400 /* region grows down, like a */ 105366c5c9fSWarner Losh /* stack */ 106366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_NOSYNC 0x0800 /* page to but do not sync */ 107366c5c9fSWarner Losh /* underlying file */ 108366c5c9fSWarner Losh 109366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_FLAGMASK 0x1ff7 110366c5c9fSWarner Losh 111366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_INHERIT 0x0080 /* region is retained after */ 112366c5c9fSWarner Losh /* exec */ 113366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_TRYFIXED 0x0400 /* attempt hint address, even */ 114366c5c9fSWarner Losh /* within break */ 115366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_WIRED 0x0800 /* mlock() mapping when it is */ 116366c5c9fSWarner Losh /* established */ 117366c5c9fSWarner Losh 118366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_STACK 0x2000 /* allocated from memory, */ 119366c5c9fSWarner Losh /* swap space (stack) */ 120366c5c9fSWarner Losh 121366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_FLAGMASK 0x3ff7 122366c5c9fSWarner Losh 123366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_INHERIT 0x0080 /* region is retained after */ 124366c5c9fSWarner Losh /* exec */ 125366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_NOEXTEND 0x0100 /* for MAP_FILE, don't change */ 126366c5c9fSWarner Losh /* file size */ 127366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_TRYFIXED 0x0400 /* attempt hint address, */ 128366c5c9fSWarner Losh /* even within heap */ 129366c5c9fSWarner Losh 130366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_FLAGMASK 0x17f7 131366c5c9fSWarner Losh 132366c5c9fSWarner Losh /* XXX */ 133366c5c9fSWarner Losh #define TARGET_BSD_MAP_FLAGMASK 0x3ff7 134366c5c9fSWarner Losh 135366c5c9fSWarner Losh /* 136366c5c9fSWarner Losh * sys/time.h 137366c5c9fSWarner Losh * sys/timex.h 138366c5c9fSWarner Losh */ 139366c5c9fSWarner Losh 140366c5c9fSWarner Losh typedef abi_long target_freebsd_suseconds_t; 141366c5c9fSWarner Losh 142366c5c9fSWarner Losh /* compare to sys/timespec.h */ 143366c5c9fSWarner Losh struct target_freebsd_timespec { 144a0c20b1bSWarner Losh target_time_t tv_sec; /* seconds */ 145366c5c9fSWarner Losh abi_long tv_nsec; /* and nanoseconds */ 146366c5c9fSWarner Losh #if !defined(TARGET_I386) && TARGET_ABI_BITS == 32 147366c5c9fSWarner Losh abi_long _pad; 148366c5c9fSWarner Losh #endif 149366c5c9fSWarner Losh }; 150366c5c9fSWarner Losh 151366c5c9fSWarner Losh #define TARGET_CPUCLOCK_WHICH_PID 0 152366c5c9fSWarner Losh #define TARGET_CPUCLOCK_WHICH_TID 1 153366c5c9fSWarner Losh 154366c5c9fSWarner Losh /* sys/umtx.h */ 155366c5c9fSWarner Losh struct target_freebsd__umtx_time { 156366c5c9fSWarner Losh struct target_freebsd_timespec _timeout; 157366c5c9fSWarner Losh uint32_t _flags; 158366c5c9fSWarner Losh uint32_t _clockid; 159366c5c9fSWarner Losh }; 160366c5c9fSWarner Losh 161366c5c9fSWarner Losh struct target_freebsd_timeval { 162a0c20b1bSWarner Losh target_time_t tv_sec; /* seconds */ 163366c5c9fSWarner Losh target_freebsd_suseconds_t tv_usec;/* and microseconds */ 164366c5c9fSWarner Losh #if !defined(TARGET_I386) && TARGET_ABI_BITS == 32 165366c5c9fSWarner Losh abi_long _pad; 166366c5c9fSWarner Losh #endif 167366c5c9fSWarner Losh }; 168366c5c9fSWarner Losh 169366c5c9fSWarner Losh /* 170366c5c9fSWarner Losh * sys/resource.h 171366c5c9fSWarner Losh */ 172366c5c9fSWarner Losh #define TARGET_RLIM_INFINITY RLIM_INFINITY 173366c5c9fSWarner Losh 174366c5c9fSWarner Losh #define TARGET_RLIMIT_CPU 0 175366c5c9fSWarner Losh #define TARGET_RLIMIT_FSIZE 1 176366c5c9fSWarner Losh #define TARGET_RLIMIT_DATA 2 177366c5c9fSWarner Losh #define TARGET_RLIMIT_STACK 3 178366c5c9fSWarner Losh #define TARGET_RLIMIT_CORE 4 179366c5c9fSWarner Losh #define TARGET_RLIMIT_RSS 5 180366c5c9fSWarner Losh #define TARGET_RLIMIT_MEMLOCK 6 181366c5c9fSWarner Losh #define TARGET_RLIMIT_NPROC 7 182366c5c9fSWarner Losh #define TARGET_RLIMIT_NOFILE 8 183366c5c9fSWarner Losh #define TARGET_RLIMIT_SBSIZE 9 184366c5c9fSWarner Losh #define TARGET_RLIMIT_AS 10 185366c5c9fSWarner Losh #define TARGET_RLIMIT_NPTS 11 186366c5c9fSWarner Losh #define TARGET_RLIMIT_SWAP 12 187366c5c9fSWarner Losh 188366c5c9fSWarner Losh struct target_rlimit { 189366c5c9fSWarner Losh uint64_t rlim_cur; 190366c5c9fSWarner Losh uint64_t rlim_max; 191366c5c9fSWarner Losh }; 192366c5c9fSWarner Losh 193366c5c9fSWarner Losh struct target_freebsd_rusage { 194366c5c9fSWarner Losh struct target_freebsd_timeval ru_utime; /* user time used */ 195366c5c9fSWarner Losh struct target_freebsd_timeval ru_stime; /* system time used */ 196366c5c9fSWarner Losh abi_long ru_maxrss; /* maximum resident set size */ 197366c5c9fSWarner Losh abi_long ru_ixrss; /* integral shared memory size */ 198366c5c9fSWarner Losh abi_long ru_idrss; /* integral unshared data size */ 199366c5c9fSWarner Losh abi_long ru_isrss; /* integral unshared stack size */ 200366c5c9fSWarner Losh abi_long ru_minflt; /* page reclaims */ 201366c5c9fSWarner Losh abi_long ru_majflt; /* page faults */ 202366c5c9fSWarner Losh abi_long ru_nswap; /* swaps */ 203366c5c9fSWarner Losh abi_long ru_inblock; /* block input operations */ 204366c5c9fSWarner Losh abi_long ru_oublock; /* block output operations */ 205366c5c9fSWarner Losh abi_long ru_msgsnd; /* messages sent */ 206366c5c9fSWarner Losh abi_long ru_msgrcv; /* messages received */ 207366c5c9fSWarner Losh abi_long ru_nsignals; /* signals received */ 208366c5c9fSWarner Losh abi_long ru_nvcsw; /* voluntary context switches */ 209366c5c9fSWarner Losh abi_long ru_nivcsw; /* involuntary context switches */ 210366c5c9fSWarner Losh }; 211366c5c9fSWarner Losh 212366c5c9fSWarner Losh struct target_freebsd__wrusage { 213366c5c9fSWarner Losh struct target_freebsd_rusage wru_self; 214366c5c9fSWarner Losh struct target_freebsd_rusage wru_children; 215366c5c9fSWarner Losh }; 216366c5c9fSWarner Losh 21740f5e298SStacey Son /* 21840f5e298SStacey Son * sys/stat.h 21940f5e298SStacey Son */ 22040f5e298SStacey Son struct target_freebsd11_stat { 22140f5e298SStacey Son uint32_t st_dev; /* inode's device */ 22240f5e298SStacey Son uint32_t st_ino; /* inode's number */ 22340f5e298SStacey Son int16_t st_mode; /* inode protection mode */ 22440f5e298SStacey Son int16_t st_nlink; /* number of hard links */ 22540f5e298SStacey Son uint32_t st_uid; /* user ID of the file's owner */ 22640f5e298SStacey Son uint32_t st_gid; /* group ID of the file's group */ 22740f5e298SStacey Son uint32_t st_rdev; /* device type */ 22840f5e298SStacey Son struct target_freebsd_timespec st_atim; /* time last accessed */ 22940f5e298SStacey Son struct target_freebsd_timespec st_mtim; /* time last data modification */ 23040f5e298SStacey Son struct target_freebsd_timespec st_ctim; /* time last file status change */ 23140f5e298SStacey Son int64_t st_size; /* file size, in bytes */ 23240f5e298SStacey Son int64_t st_blocks; /* blocks allocated for file */ 23340f5e298SStacey Son uint32_t st_blksize; /* optimal blocksize for I/O */ 23440f5e298SStacey Son uint32_t st_flags; /* user defined flags for file */ 23540f5e298SStacey Son uint32_t st_gen; /* file generation number */ 23640f5e298SStacey Son int32_t st_lspare; 23740f5e298SStacey Son struct target_freebsd_timespec st_birthtim; /* time of file creation */ 23840f5e298SStacey Son /* 23940f5e298SStacey Son * Explicitly pad st_birthtim to 16 bytes so that the size of 24040f5e298SStacey Son * struct stat is backwards compatible. We use bitfields instead 24140f5e298SStacey Son * of an array of chars so that this doesn't require a C99 compiler 24240f5e298SStacey Son * to compile if the size of the padding is 0. We use 2 bitfields 24340f5e298SStacey Son * to cover up to 64 bits on 32-bit machines. We assume that 24440f5e298SStacey Son * CHAR_BIT is 8... 24540f5e298SStacey Son */ 24640f5e298SStacey Son unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec)); 24740f5e298SStacey Son unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec)); 24840f5e298SStacey Son } __packed; 24940f5e298SStacey Son 250ad805a77SMichal Meloun #if defined(__i386__) 251ad805a77SMichal Meloun #define TARGET_HAS_STAT_TIME_T_EXT 1 252ad805a77SMichal Meloun #endif 253ad805a77SMichal Meloun 254ad805a77SMichal Meloun struct target_stat { 255ad805a77SMichal Meloun uint64_t st_dev; /* inode's device */ 256ad805a77SMichal Meloun uint64_t st_ino; /* inode's number */ 257ad805a77SMichal Meloun uint64_t st_nlink; /* number of hard links */ 258ad805a77SMichal Meloun int16_t st_mode; /* inode protection mode */ 259ad805a77SMichal Meloun int16_t st_padding0; 260ad805a77SMichal Meloun uint32_t st_uid; /* user ID of the file's owner */ 261ad805a77SMichal Meloun uint32_t st_gid; /* group ID of the file's group */ 262ad805a77SMichal Meloun int32_t st_padding1; 263ad805a77SMichal Meloun uint64_t st_rdev; /* device type */ 264ad805a77SMichal Meloun #ifdef TARGET_HAS_STAT_TIME_T_EXT 265ad805a77SMichal Meloun int32_t st_atim_ext; 266ad805a77SMichal Meloun #endif 267ad805a77SMichal Meloun struct target_freebsd_timespec st_atim; /* time of last access */ 268ad805a77SMichal Meloun #ifdef TARGET_HAS_STAT_TIME_T_EXT 269ad805a77SMichal Meloun int32_t st_mtim_ext; 270ad805a77SMichal Meloun #endif 271ad805a77SMichal Meloun struct target_freebsd_timespec st_mtim; /* time of last data modification */ 272ad805a77SMichal Meloun #ifdef TARGET_HAS_STAT_TIME_T_EXT 273ad805a77SMichal Meloun int32_t st_ctim_ext; 274ad805a77SMichal Meloun #endif 275ad805a77SMichal Meloun struct target_freebsd_timespec st_ctim;/* time of last file status change */ 276ad805a77SMichal Meloun #ifdef TARGET_HAS_STAT_TIME_T_EXT 277ad805a77SMichal Meloun int32_t st_btim_ext; 278ad805a77SMichal Meloun #endif 279ad805a77SMichal Meloun struct target_freebsd_timespec st_birthtim; /* time of file creation */ 280ad805a77SMichal Meloun int64_t st_size; /* file size, in bytes */ 281ad805a77SMichal Meloun int64_t st_blocks; /* blocks allocated for file */ 282ad805a77SMichal Meloun uint32_t st_blksize; /* optimal blocksize for I/O */ 283ad805a77SMichal Meloun uint32_t st_flags; /* user defined flags for file */ 284ad805a77SMichal Meloun uint64_t st_gen; /* file generation number */ 285ad805a77SMichal Meloun uint64_t st_spare[10]; 286ad805a77SMichal Meloun }; 287ad805a77SMichal Meloun 2881de075a0SStacey Son 2891de075a0SStacey Son /* struct nstat is the same as stat above but without the st_lspare field */ 2901de075a0SStacey Son struct target_freebsd11_nstat { 2911de075a0SStacey Son uint32_t st_dev; /* inode's device */ 2921de075a0SStacey Son uint32_t st_ino; /* inode's number */ 2931de075a0SStacey Son int16_t st_mode; /* inode protection mode */ 2941de075a0SStacey Son int16_t st_nlink; /* number of hard links */ 2951de075a0SStacey Son uint32_t st_uid; /* user ID of the file's owner */ 2961de075a0SStacey Son uint32_t st_gid; /* group ID of the file's group */ 2971de075a0SStacey Son uint32_t st_rdev; /* device type */ 2981de075a0SStacey Son struct target_freebsd_timespec st_atim; /* time last accessed */ 2991de075a0SStacey Son struct target_freebsd_timespec st_mtim; /* time last data modification */ 3001de075a0SStacey Son struct target_freebsd_timespec st_ctim; /* time last file status change */ 3011de075a0SStacey Son int64_t st_size; /* file size, in bytes */ 3021de075a0SStacey Son int64_t st_blocks; /* blocks allocated for file */ 3031de075a0SStacey Son uint32_t st_blksize; /* optimal blocksize for I/O */ 3041de075a0SStacey Son uint32_t st_flags; /* user defined flags for file */ 3051de075a0SStacey Son uint32_t st_gen; /* file generation number */ 3061de075a0SStacey Son struct target_freebsd_timespec st_birthtim; /* time of file creation */ 3071de075a0SStacey Son /* 3081de075a0SStacey Son * Explicitly pad st_birthtim to 16 bytes so that the size of 3091de075a0SStacey Son * struct stat is backwards compatible. We use bitfields instead 3101de075a0SStacey Son * of an array of chars so that this doesn't require a C99 compiler 3111de075a0SStacey Son * to compile if the size of the padding is 0. We use 2 bitfields 3121de075a0SStacey Son * to cover up to 64 bits on 32-bit machines. We assume that 3131de075a0SStacey Son * CHAR_BIT is 8... 3141de075a0SStacey Son */ 3151de075a0SStacey Son unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec)); 3161de075a0SStacey Son unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec)); 3171de075a0SStacey Son } __packed; 3181de075a0SStacey Son 3191de075a0SStacey Son /* 3201de075a0SStacey Son * sys/mount.h 3211de075a0SStacey Son */ 3221de075a0SStacey Son 3231de075a0SStacey Son /* filesystem id type */ 3241de075a0SStacey Son typedef struct target_freebsd_fsid { int32_t val[2]; } target_freebsd_fsid_t; 3251de075a0SStacey Son 3261de075a0SStacey Son /* filesystem statistics */ 3271de075a0SStacey Son struct target_freebsd11_statfs { 3281de075a0SStacey Son uint32_t f_version; /* structure version number */ 3291de075a0SStacey Son uint32_t f_type; /* type of filesystem */ 3301de075a0SStacey Son uint64_t f_flags; /* copy of mount exported flags */ 3311de075a0SStacey Son uint64_t f_bsize; /* filesystem fragment size */ 3321de075a0SStacey Son uint64_t f_iosize; /* optimal transfer block size */ 3331de075a0SStacey Son uint64_t f_blocks; /* total data blocks in filesystem */ 3341de075a0SStacey Son uint64_t f_bfree; /* free blocks in filesystem */ 3351de075a0SStacey Son int64_t f_bavail; /* free blocks avail to non-superuser */ 3361de075a0SStacey Son uint64_t f_files; /* total file nodes in filesystem */ 3371de075a0SStacey Son int64_t f_ffree; /* free nodes avail to non-superuser */ 3381de075a0SStacey Son uint64_t f_syncwrites; /* count of sync writes since mount */ 3391de075a0SStacey Son uint64_t f_asyncwrites; /* count of async writes since mount */ 3401de075a0SStacey Son uint64_t f_syncreads; /* count of sync reads since mount */ 3411de075a0SStacey Son uint64_t f_asyncreads; /* count of async reads since mount */ 3421de075a0SStacey Son uint64_t f_spare[10]; /* unused spare */ 3431de075a0SStacey Son uint32_t f_namemax; /* maximum filename length */ 3441de075a0SStacey Son uint32_t f_owner; /* user that mounted the filesystem */ 3451de075a0SStacey Son target_freebsd_fsid_t f_fsid; /* filesystem id */ 3461de075a0SStacey Son char f_charspare[80]; /* spare string space */ 3471de075a0SStacey Son char f_fstypename[16]; /* filesys type name */ 3481de075a0SStacey Son char f_mntfromname[88]; /* mount filesystem */ 3491de075a0SStacey Son char f_mntonname[88]; /* dir on which mounted*/ 3501de075a0SStacey Son }; 3511de075a0SStacey Son 35225efcda4SMichal Meloun struct target_statfs { 35325efcda4SMichal Meloun uint32_t f_version; /* structure version number */ 35425efcda4SMichal Meloun uint32_t f_type; /* type of filesystem */ 35525efcda4SMichal Meloun uint64_t f_flags; /* copy of mount exported flags */ 35625efcda4SMichal Meloun uint64_t f_bsize; /* filesystem fragment size */ 35725efcda4SMichal Meloun uint64_t f_iosize; /* optimal transfer block size */ 35825efcda4SMichal Meloun uint64_t f_blocks; /* total data blocks in filesystem */ 35925efcda4SMichal Meloun uint64_t f_bfree; /* free blocks in filesystem */ 36025efcda4SMichal Meloun int64_t f_bavail; /* free blocks avail to non-superuser */ 36125efcda4SMichal Meloun uint64_t f_files; /* total file nodes in filesystem */ 36225efcda4SMichal Meloun int64_t f_ffree; /* free nodes avail to non-superuser */ 36325efcda4SMichal Meloun uint64_t f_syncwrites; /* count of sync writes since mount */ 36425efcda4SMichal Meloun uint64_t f_asyncwrites; /* count of async writes since mount */ 36525efcda4SMichal Meloun uint64_t f_syncreads; /* count of sync reads since mount */ 36625efcda4SMichal Meloun uint64_t f_asyncreads; /* count of async reads since mount */ 36725efcda4SMichal Meloun uint64_t f_spare[10]; /* unused spare */ 36825efcda4SMichal Meloun uint32_t f_namemax; /* maximum filename length */ 36925efcda4SMichal Meloun uint32_t f_owner; /* user that mounted the filesystem */ 37025efcda4SMichal Meloun target_freebsd_fsid_t f_fsid; /* filesystem id */ 37125efcda4SMichal Meloun char f_charspare[80]; /* spare string space */ 37225efcda4SMichal Meloun char f_fstypename[16]; /* filesystem type name */ 37325efcda4SMichal Meloun char f_mntfromname[1024]; /* mounted filesystem */ 37425efcda4SMichal Meloun char f_mntonname[1024]; /* directory on which mounted */ 37525efcda4SMichal Meloun }; 37625efcda4SMichal Meloun 37754d07b44SStacey Son /* File identifier. These are unique per filesystem on a single machine. */ 37854d07b44SStacey Son #define TARGET_MAXFIDSZ 16 37954d07b44SStacey Son 38054d07b44SStacey Son struct target_freebsd_fid { 38154d07b44SStacey Son uint16_t fid_len; /* len of data in bytes */ 38254d07b44SStacey Son uint16_t fid_data0; /* force longword align */ 38354d07b44SStacey Son char fid_data[TARGET_MAXFIDSZ]; /* data (variable len) */ 38454d07b44SStacey Son }; 38554d07b44SStacey Son 38654d07b44SStacey Son /* Generic file handle */ 38754d07b44SStacey Son struct target_freebsd_fhandle { 38854d07b44SStacey Son target_freebsd_fsid_t fh_fsid; /* Filesystem id of mount point */ 38954d07b44SStacey Son struct target_freebsd_fid fh_fid; /* Filesys specific id */ 39054d07b44SStacey Son }; 39154d07b44SStacey Son typedef struct target_freebsd_fhandle target_freebsd_fhandle_t; 39254d07b44SStacey Son 39354d07b44SStacey Son /* 39454d07b44SStacey Son * sys/fcntl.h 39554d07b44SStacey Son */ 39654d07b44SStacey Son #define TARGET_F_DUPFD 0 39754d07b44SStacey Son #define TARGET_F_GETFD 1 39854d07b44SStacey Son #define TARGET_F_SETFD 2 39954d07b44SStacey Son #define TARGET_F_GETFL 3 40054d07b44SStacey Son #define TARGET_F_SETFL 4 40154d07b44SStacey Son #define TARGET_F_GETOWN 5 40254d07b44SStacey Son #define TARGET_F_SETOWN 6 40354d07b44SStacey Son #define TARGET_F_OGETLK 7 40454d07b44SStacey Son #define TARGET_F_OSETLK 8 40554d07b44SStacey Son #define TARGET_F_OSETLKW 9 40654d07b44SStacey Son #define TARGET_F_DUP2FD 10 40754d07b44SStacey Son #define TARGET_F_GETLK 11 40854d07b44SStacey Son #define TARGET_F_SETLK 12 40954d07b44SStacey Son #define TARGET_F_SETLKW 13 41054d07b44SStacey Son #define TARGET_F_SETLK_REMOTE 14 41154d07b44SStacey Son #define TARGET_F_READAHEAD 15 41254d07b44SStacey Son #define TARGET_F_RDAHEAD 16 41354d07b44SStacey Son #define TARGET_F_DUPFD_CLOEXEC 17 41454d07b44SStacey Son #define TARGET_F_DUP2FD_CLOEXEC 18 41554d07b44SStacey Son /* FreeBSD-specific */ 41654d07b44SStacey Son #define TARGET_F_ADD_SEALS 19 41754d07b44SStacey Son #define TARGET_F_GET_SEALS 20 41854d07b44SStacey Son 41954d07b44SStacey Son struct target_freebsd_flock { 42054d07b44SStacey Son int64_t l_start; 42154d07b44SStacey Son int64_t l_len; 42254d07b44SStacey Son int32_t l_pid; 42354d07b44SStacey Son int16_t l_type; 42454d07b44SStacey Son int16_t l_whence; 42554d07b44SStacey Son int32_t l_sysid; 42654d07b44SStacey Son } QEMU_PACKED; 42754d07b44SStacey Son 4285783a530SKarim Taha /* sys/unistd.h */ 4295783a530SKarim Taha /* user: vfork(2) semantics, clear signals */ 4305783a530SKarim Taha #define TARGET_RFSPAWN (1U << 31) 4315783a530SKarim Taha 432d314ae93SStacey Son /* 433d314ae93SStacey Son * from sys/procctl.h 434d314ae93SStacey Son */ 435d314ae93SStacey Son #define TARGET_PROC_SPROTECT 1 436d314ae93SStacey Son #define TARGET_PROC_REAP_ACQUIRE 2 437d314ae93SStacey Son #define TARGET_PROC_REAP_RELEASE 3 438d314ae93SStacey Son #define TARGET_PROC_REAP_STATUS 4 439d314ae93SStacey Son #define TARGET_PROC_REAP_GETPIDS 5 440d314ae93SStacey Son #define TARGET_PROC_REAP_KILL 6 441d314ae93SStacey Son 442d314ae93SStacey Son struct target_procctl_reaper_status { 443d314ae93SStacey Son uint32_t rs_flags; 444d314ae93SStacey Son uint32_t rs_children; 445d314ae93SStacey Son uint32_t rs_descendants; 446d314ae93SStacey Son uint32_t rs_reaper; 447d314ae93SStacey Son uint32_t rs_pid; 448d314ae93SStacey Son uint32_t rs_pad0[15]; 449d314ae93SStacey Son }; 450d314ae93SStacey Son 451d314ae93SStacey Son struct target_procctl_reaper_pidinfo { 452d314ae93SStacey Son uint32_t pi_pid; 453d314ae93SStacey Son uint32_t pi_subtree; 454d314ae93SStacey Son uint32_t pi_flags; 455d314ae93SStacey Son uint32_t pi_pad0[15]; 456d314ae93SStacey Son }; 457d314ae93SStacey Son 458d314ae93SStacey Son struct target_procctl_reaper_pids { 459d314ae93SStacey Son uint32_t rp_count; 460d314ae93SStacey Son uint32_t rp_pad0[15]; 461d314ae93SStacey Son abi_ulong rp_pids; 462d314ae93SStacey Son }; 463d314ae93SStacey Son 464d314ae93SStacey Son struct target_procctl_reaper_kill { 465d314ae93SStacey Son int32_t rk_sig; 466d314ae93SStacey Son uint32_t rk_flags; 467d314ae93SStacey Son uint32_t rk_subtree; 468d314ae93SStacey Son uint32_t rk_killed; 469d314ae93SStacey Son uint32_t rk_fpid; 470d314ae93SStacey Son uint32_t rk_pad0[15]; 471d314ae93SStacey Son }; 472d314ae93SStacey Son 473d314ae93SStacey Son 474a5b88166SWarner Losh #define safe_syscall0(type, name) \ 475a5b88166SWarner Losh type safe_##name(void) \ 476a5b88166SWarner Losh { \ 477a5b88166SWarner Losh return safe_syscall(SYS_##name); \ 478a5b88166SWarner Losh } 479a5b88166SWarner Losh 480a5b88166SWarner Losh #define safe_syscall1(type, name, type1, arg1) \ 481a5b88166SWarner Losh type safe_##name(type1 arg1) \ 482a5b88166SWarner Losh { \ 483a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1); \ 484a5b88166SWarner Losh } 485a5b88166SWarner Losh 486a5b88166SWarner Losh #define safe_syscall2(type, name, type1, arg1, type2, arg2) \ 487a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2) \ 488a5b88166SWarner Losh { \ 489a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2); \ 490a5b88166SWarner Losh } 491a5b88166SWarner Losh 492a5b88166SWarner Losh #define safe_syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ 493a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2, type3 arg3) \ 494a5b88166SWarner Losh { \ 495a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2, arg3); \ 496a5b88166SWarner Losh } 497a5b88166SWarner Losh 498a5b88166SWarner Losh #define safe_syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \ 499a5b88166SWarner Losh type4, arg4) \ 500a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ 501a5b88166SWarner Losh { \ 502a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4); \ 503a5b88166SWarner Losh } 504a5b88166SWarner Losh 505a5b88166SWarner Losh #define safe_syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \ 506a5b88166SWarner Losh type4, arg4, type5, arg5) \ 507a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 508a5b88166SWarner Losh type5 arg5) \ 509a5b88166SWarner Losh { \ 510a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5); \ 511a5b88166SWarner Losh } 512a5b88166SWarner Losh 513a5b88166SWarner Losh #define safe_syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \ 514a5b88166SWarner Losh type4, arg4, type5, arg5, type6, arg6) \ 515a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 516a5b88166SWarner Losh type5 arg5, type6 arg6) \ 517a5b88166SWarner Losh { \ 518a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5, arg6); \ 519a5b88166SWarner Losh } 520a5b88166SWarner Losh 521243c725fSKyle Evans #define safe_fcntl(...) safe_syscall(SYS_fcntl, __VA_ARGS__) 522243c725fSKyle Evans 52377d3522bSWarner Losh /* So far all target and host bitmasks are the same */ 524a05cee93SRichard Henderson #undef target_to_host_bitmask 52577d3522bSWarner Losh #define target_to_host_bitmask(x, tbl) (x) 526a05cee93SRichard Henderson #undef host_to_target_bitmask 52777d3522bSWarner Losh #define host_to_target_bitmask(x, tbl) (x) 52877d3522bSWarner Losh 5299c092804SMarkus Armbruster #endif /* SYSCALL_DEFS_H */ 530