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 /* 59*61a8f110SStacey Son * sys/ipc.h 60*61a8f110SStacey Son */ 61*61a8f110SStacey Son struct target_ipc_perm { 62*61a8f110SStacey Son uint32_t cuid; /* creator user id */ 63*61a8f110SStacey Son uint32_t cgid; /* creator group id */ 64*61a8f110SStacey Son uint32_t uid; /* user id */ 65*61a8f110SStacey Son uint32_t gid; /* group id */ 66*61a8f110SStacey Son uint16_t mode; /* r/w permission */ 67*61a8f110SStacey Son uint16_t seq; /* sequence # */ 68*61a8f110SStacey Son abi_long key; /* user specified msg/sem/shm key */ 69*61a8f110SStacey Son }; 70*61a8f110SStacey Son 71*61a8f110SStacey Son #define TARGET_IPC_RMID 0 /* remove identifier */ 72*61a8f110SStacey Son #define TARGET_IPC_SET 1 /* set options */ 73*61a8f110SStacey Son #define TARGET_IPC_STAT 2 /* get options */ 74*61a8f110SStacey Son 75*61a8f110SStacey Son /* 76366c5c9fSWarner Losh * sys/mman.h 77366c5c9fSWarner Losh */ 78366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_RESERVED0080 0x0080 /* previously misimplemented */ 79366c5c9fSWarner Losh /* MAP_INHERIT */ 80366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_RESERVED0100 0x0100 /* previously unimplemented */ 81366c5c9fSWarner Losh /* MAP_NOEXTEND */ 82366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_STACK 0x0400 /* region grows down, like a */ 83366c5c9fSWarner Losh /* stack */ 84366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_NOSYNC 0x0800 /* page to but do not sync */ 85366c5c9fSWarner Losh /* underlying file */ 86366c5c9fSWarner Losh 87366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_FLAGMASK 0x1ff7 88366c5c9fSWarner Losh 89366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_INHERIT 0x0080 /* region is retained after */ 90366c5c9fSWarner Losh /* exec */ 91366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_TRYFIXED 0x0400 /* attempt hint address, even */ 92366c5c9fSWarner Losh /* within break */ 93366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_WIRED 0x0800 /* mlock() mapping when it is */ 94366c5c9fSWarner Losh /* established */ 95366c5c9fSWarner Losh 96366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_STACK 0x2000 /* allocated from memory, */ 97366c5c9fSWarner Losh /* swap space (stack) */ 98366c5c9fSWarner Losh 99366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_FLAGMASK 0x3ff7 100366c5c9fSWarner Losh 101366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_INHERIT 0x0080 /* region is retained after */ 102366c5c9fSWarner Losh /* exec */ 103366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_NOEXTEND 0x0100 /* for MAP_FILE, don't change */ 104366c5c9fSWarner Losh /* file size */ 105366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_TRYFIXED 0x0400 /* attempt hint address, */ 106366c5c9fSWarner Losh /* even within heap */ 107366c5c9fSWarner Losh 108366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_FLAGMASK 0x17f7 109366c5c9fSWarner Losh 110366c5c9fSWarner Losh /* XXX */ 111366c5c9fSWarner Losh #define TARGET_BSD_MAP_FLAGMASK 0x3ff7 112366c5c9fSWarner Losh 113366c5c9fSWarner Losh /* 114366c5c9fSWarner Losh * sys/time.h 115366c5c9fSWarner Losh * sys/timex.h 116366c5c9fSWarner Losh */ 117366c5c9fSWarner Losh 118366c5c9fSWarner Losh typedef abi_long target_freebsd_suseconds_t; 119366c5c9fSWarner Losh 120366c5c9fSWarner Losh /* compare to sys/timespec.h */ 121366c5c9fSWarner Losh struct target_freebsd_timespec { 122a0c20b1bSWarner Losh target_time_t tv_sec; /* seconds */ 123366c5c9fSWarner Losh abi_long tv_nsec; /* and nanoseconds */ 124366c5c9fSWarner Losh #if !defined(TARGET_I386) && TARGET_ABI_BITS == 32 125366c5c9fSWarner Losh abi_long _pad; 126366c5c9fSWarner Losh #endif 127366c5c9fSWarner Losh }; 128366c5c9fSWarner Losh 129366c5c9fSWarner Losh #define TARGET_CPUCLOCK_WHICH_PID 0 130366c5c9fSWarner Losh #define TARGET_CPUCLOCK_WHICH_TID 1 131366c5c9fSWarner Losh 132366c5c9fSWarner Losh /* sys/umtx.h */ 133366c5c9fSWarner Losh struct target_freebsd__umtx_time { 134366c5c9fSWarner Losh struct target_freebsd_timespec _timeout; 135366c5c9fSWarner Losh uint32_t _flags; 136366c5c9fSWarner Losh uint32_t _clockid; 137366c5c9fSWarner Losh }; 138366c5c9fSWarner Losh 139366c5c9fSWarner Losh struct target_freebsd_timeval { 140a0c20b1bSWarner Losh target_time_t tv_sec; /* seconds */ 141366c5c9fSWarner Losh target_freebsd_suseconds_t tv_usec;/* and microseconds */ 142366c5c9fSWarner Losh #if !defined(TARGET_I386) && TARGET_ABI_BITS == 32 143366c5c9fSWarner Losh abi_long _pad; 144366c5c9fSWarner Losh #endif 145366c5c9fSWarner Losh }; 146366c5c9fSWarner Losh 147366c5c9fSWarner Losh /* 148366c5c9fSWarner Losh * sys/resource.h 149366c5c9fSWarner Losh */ 150366c5c9fSWarner Losh #define TARGET_RLIM_INFINITY RLIM_INFINITY 151366c5c9fSWarner Losh 152366c5c9fSWarner Losh #define TARGET_RLIMIT_CPU 0 153366c5c9fSWarner Losh #define TARGET_RLIMIT_FSIZE 1 154366c5c9fSWarner Losh #define TARGET_RLIMIT_DATA 2 155366c5c9fSWarner Losh #define TARGET_RLIMIT_STACK 3 156366c5c9fSWarner Losh #define TARGET_RLIMIT_CORE 4 157366c5c9fSWarner Losh #define TARGET_RLIMIT_RSS 5 158366c5c9fSWarner Losh #define TARGET_RLIMIT_MEMLOCK 6 159366c5c9fSWarner Losh #define TARGET_RLIMIT_NPROC 7 160366c5c9fSWarner Losh #define TARGET_RLIMIT_NOFILE 8 161366c5c9fSWarner Losh #define TARGET_RLIMIT_SBSIZE 9 162366c5c9fSWarner Losh #define TARGET_RLIMIT_AS 10 163366c5c9fSWarner Losh #define TARGET_RLIMIT_NPTS 11 164366c5c9fSWarner Losh #define TARGET_RLIMIT_SWAP 12 165366c5c9fSWarner Losh 166366c5c9fSWarner Losh struct target_rlimit { 167366c5c9fSWarner Losh uint64_t rlim_cur; 168366c5c9fSWarner Losh uint64_t rlim_max; 169366c5c9fSWarner Losh }; 170366c5c9fSWarner Losh 171366c5c9fSWarner Losh struct target_freebsd_rusage { 172366c5c9fSWarner Losh struct target_freebsd_timeval ru_utime; /* user time used */ 173366c5c9fSWarner Losh struct target_freebsd_timeval ru_stime; /* system time used */ 174366c5c9fSWarner Losh abi_long ru_maxrss; /* maximum resident set size */ 175366c5c9fSWarner Losh abi_long ru_ixrss; /* integral shared memory size */ 176366c5c9fSWarner Losh abi_long ru_idrss; /* integral unshared data size */ 177366c5c9fSWarner Losh abi_long ru_isrss; /* integral unshared stack size */ 178366c5c9fSWarner Losh abi_long ru_minflt; /* page reclaims */ 179366c5c9fSWarner Losh abi_long ru_majflt; /* page faults */ 180366c5c9fSWarner Losh abi_long ru_nswap; /* swaps */ 181366c5c9fSWarner Losh abi_long ru_inblock; /* block input operations */ 182366c5c9fSWarner Losh abi_long ru_oublock; /* block output operations */ 183366c5c9fSWarner Losh abi_long ru_msgsnd; /* messages sent */ 184366c5c9fSWarner Losh abi_long ru_msgrcv; /* messages received */ 185366c5c9fSWarner Losh abi_long ru_nsignals; /* signals received */ 186366c5c9fSWarner Losh abi_long ru_nvcsw; /* voluntary context switches */ 187366c5c9fSWarner Losh abi_long ru_nivcsw; /* involuntary context switches */ 188366c5c9fSWarner Losh }; 189366c5c9fSWarner Losh 190366c5c9fSWarner Losh struct target_freebsd__wrusage { 191366c5c9fSWarner Losh struct target_freebsd_rusage wru_self; 192366c5c9fSWarner Losh struct target_freebsd_rusage wru_children; 193366c5c9fSWarner Losh }; 194366c5c9fSWarner Losh 19540f5e298SStacey Son /* 19640f5e298SStacey Son * sys/stat.h 19740f5e298SStacey Son */ 19840f5e298SStacey Son struct target_freebsd11_stat { 19940f5e298SStacey Son uint32_t st_dev; /* inode's device */ 20040f5e298SStacey Son uint32_t st_ino; /* inode's number */ 20140f5e298SStacey Son int16_t st_mode; /* inode protection mode */ 20240f5e298SStacey Son int16_t st_nlink; /* number of hard links */ 20340f5e298SStacey Son uint32_t st_uid; /* user ID of the file's owner */ 20440f5e298SStacey Son uint32_t st_gid; /* group ID of the file's group */ 20540f5e298SStacey Son uint32_t st_rdev; /* device type */ 20640f5e298SStacey Son struct target_freebsd_timespec st_atim; /* time last accessed */ 20740f5e298SStacey Son struct target_freebsd_timespec st_mtim; /* time last data modification */ 20840f5e298SStacey Son struct target_freebsd_timespec st_ctim; /* time last file status change */ 20940f5e298SStacey Son int64_t st_size; /* file size, in bytes */ 21040f5e298SStacey Son int64_t st_blocks; /* blocks allocated for file */ 21140f5e298SStacey Son uint32_t st_blksize; /* optimal blocksize for I/O */ 21240f5e298SStacey Son uint32_t st_flags; /* user defined flags for file */ 21340f5e298SStacey Son uint32_t st_gen; /* file generation number */ 21440f5e298SStacey Son int32_t st_lspare; 21540f5e298SStacey Son struct target_freebsd_timespec st_birthtim; /* time of file creation */ 21640f5e298SStacey Son /* 21740f5e298SStacey Son * Explicitly pad st_birthtim to 16 bytes so that the size of 21840f5e298SStacey Son * struct stat is backwards compatible. We use bitfields instead 21940f5e298SStacey Son * of an array of chars so that this doesn't require a C99 compiler 22040f5e298SStacey Son * to compile if the size of the padding is 0. We use 2 bitfields 22140f5e298SStacey Son * to cover up to 64 bits on 32-bit machines. We assume that 22240f5e298SStacey Son * CHAR_BIT is 8... 22340f5e298SStacey Son */ 22440f5e298SStacey Son unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec)); 22540f5e298SStacey Son unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec)); 22640f5e298SStacey Son } __packed; 22740f5e298SStacey Son 228ad805a77SMichal Meloun #if defined(__i386__) 229ad805a77SMichal Meloun #define TARGET_HAS_STAT_TIME_T_EXT 1 230ad805a77SMichal Meloun #endif 231ad805a77SMichal Meloun 232ad805a77SMichal Meloun struct target_stat { 233ad805a77SMichal Meloun uint64_t st_dev; /* inode's device */ 234ad805a77SMichal Meloun uint64_t st_ino; /* inode's number */ 235ad805a77SMichal Meloun uint64_t st_nlink; /* number of hard links */ 236ad805a77SMichal Meloun int16_t st_mode; /* inode protection mode */ 237ad805a77SMichal Meloun int16_t st_padding0; 238ad805a77SMichal Meloun uint32_t st_uid; /* user ID of the file's owner */ 239ad805a77SMichal Meloun uint32_t st_gid; /* group ID of the file's group */ 240ad805a77SMichal Meloun int32_t st_padding1; 241ad805a77SMichal Meloun uint64_t st_rdev; /* device type */ 242ad805a77SMichal Meloun #ifdef TARGET_HAS_STAT_TIME_T_EXT 243ad805a77SMichal Meloun int32_t st_atim_ext; 244ad805a77SMichal Meloun #endif 245ad805a77SMichal Meloun struct target_freebsd_timespec st_atim; /* time of last access */ 246ad805a77SMichal Meloun #ifdef TARGET_HAS_STAT_TIME_T_EXT 247ad805a77SMichal Meloun int32_t st_mtim_ext; 248ad805a77SMichal Meloun #endif 249ad805a77SMichal Meloun struct target_freebsd_timespec st_mtim; /* time of last data modification */ 250ad805a77SMichal Meloun #ifdef TARGET_HAS_STAT_TIME_T_EXT 251ad805a77SMichal Meloun int32_t st_ctim_ext; 252ad805a77SMichal Meloun #endif 253ad805a77SMichal Meloun struct target_freebsd_timespec st_ctim;/* time of last file status change */ 254ad805a77SMichal Meloun #ifdef TARGET_HAS_STAT_TIME_T_EXT 255ad805a77SMichal Meloun int32_t st_btim_ext; 256ad805a77SMichal Meloun #endif 257ad805a77SMichal Meloun struct target_freebsd_timespec st_birthtim; /* time of file creation */ 258ad805a77SMichal Meloun int64_t st_size; /* file size, in bytes */ 259ad805a77SMichal Meloun int64_t st_blocks; /* blocks allocated for file */ 260ad805a77SMichal Meloun uint32_t st_blksize; /* optimal blocksize for I/O */ 261ad805a77SMichal Meloun uint32_t st_flags; /* user defined flags for file */ 262ad805a77SMichal Meloun uint64_t st_gen; /* file generation number */ 263ad805a77SMichal Meloun uint64_t st_spare[10]; 264ad805a77SMichal Meloun }; 265ad805a77SMichal Meloun 2661de075a0SStacey Son 2671de075a0SStacey Son /* struct nstat is the same as stat above but without the st_lspare field */ 2681de075a0SStacey Son struct target_freebsd11_nstat { 2691de075a0SStacey Son uint32_t st_dev; /* inode's device */ 2701de075a0SStacey Son uint32_t st_ino; /* inode's number */ 2711de075a0SStacey Son int16_t st_mode; /* inode protection mode */ 2721de075a0SStacey Son int16_t st_nlink; /* number of hard links */ 2731de075a0SStacey Son uint32_t st_uid; /* user ID of the file's owner */ 2741de075a0SStacey Son uint32_t st_gid; /* group ID of the file's group */ 2751de075a0SStacey Son uint32_t st_rdev; /* device type */ 2761de075a0SStacey Son struct target_freebsd_timespec st_atim; /* time last accessed */ 2771de075a0SStacey Son struct target_freebsd_timespec st_mtim; /* time last data modification */ 2781de075a0SStacey Son struct target_freebsd_timespec st_ctim; /* time last file status change */ 2791de075a0SStacey Son int64_t st_size; /* file size, in bytes */ 2801de075a0SStacey Son int64_t st_blocks; /* blocks allocated for file */ 2811de075a0SStacey Son uint32_t st_blksize; /* optimal blocksize for I/O */ 2821de075a0SStacey Son uint32_t st_flags; /* user defined flags for file */ 2831de075a0SStacey Son uint32_t st_gen; /* file generation number */ 2841de075a0SStacey Son struct target_freebsd_timespec st_birthtim; /* time of file creation */ 2851de075a0SStacey Son /* 2861de075a0SStacey Son * Explicitly pad st_birthtim to 16 bytes so that the size of 2871de075a0SStacey Son * struct stat is backwards compatible. We use bitfields instead 2881de075a0SStacey Son * of an array of chars so that this doesn't require a C99 compiler 2891de075a0SStacey Son * to compile if the size of the padding is 0. We use 2 bitfields 2901de075a0SStacey Son * to cover up to 64 bits on 32-bit machines. We assume that 2911de075a0SStacey Son * CHAR_BIT is 8... 2921de075a0SStacey Son */ 2931de075a0SStacey Son unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec)); 2941de075a0SStacey Son unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec)); 2951de075a0SStacey Son } __packed; 2961de075a0SStacey Son 2971de075a0SStacey Son /* 2981de075a0SStacey Son * sys/mount.h 2991de075a0SStacey Son */ 3001de075a0SStacey Son 3011de075a0SStacey Son /* filesystem id type */ 3021de075a0SStacey Son typedef struct target_freebsd_fsid { int32_t val[2]; } target_freebsd_fsid_t; 3031de075a0SStacey Son 3041de075a0SStacey Son /* filesystem statistics */ 3051de075a0SStacey Son struct target_freebsd11_statfs { 3061de075a0SStacey Son uint32_t f_version; /* structure version number */ 3071de075a0SStacey Son uint32_t f_type; /* type of filesystem */ 3081de075a0SStacey Son uint64_t f_flags; /* copy of mount exported flags */ 3091de075a0SStacey Son uint64_t f_bsize; /* filesystem fragment size */ 3101de075a0SStacey Son uint64_t f_iosize; /* optimal transfer block size */ 3111de075a0SStacey Son uint64_t f_blocks; /* total data blocks in filesystem */ 3121de075a0SStacey Son uint64_t f_bfree; /* free blocks in filesystem */ 3131de075a0SStacey Son int64_t f_bavail; /* free blocks avail to non-superuser */ 3141de075a0SStacey Son uint64_t f_files; /* total file nodes in filesystem */ 3151de075a0SStacey Son int64_t f_ffree; /* free nodes avail to non-superuser */ 3161de075a0SStacey Son uint64_t f_syncwrites; /* count of sync writes since mount */ 3171de075a0SStacey Son uint64_t f_asyncwrites; /* count of async writes since mount */ 3181de075a0SStacey Son uint64_t f_syncreads; /* count of sync reads since mount */ 3191de075a0SStacey Son uint64_t f_asyncreads; /* count of async reads since mount */ 3201de075a0SStacey Son uint64_t f_spare[10]; /* unused spare */ 3211de075a0SStacey Son uint32_t f_namemax; /* maximum filename length */ 3221de075a0SStacey Son uint32_t f_owner; /* user that mounted the filesystem */ 3231de075a0SStacey Son target_freebsd_fsid_t f_fsid; /* filesystem id */ 3241de075a0SStacey Son char f_charspare[80]; /* spare string space */ 3251de075a0SStacey Son char f_fstypename[16]; /* filesys type name */ 3261de075a0SStacey Son char f_mntfromname[88]; /* mount filesystem */ 3271de075a0SStacey Son char f_mntonname[88]; /* dir on which mounted*/ 3281de075a0SStacey Son }; 3291de075a0SStacey Son 33025efcda4SMichal Meloun struct target_statfs { 33125efcda4SMichal Meloun uint32_t f_version; /* structure version number */ 33225efcda4SMichal Meloun uint32_t f_type; /* type of filesystem */ 33325efcda4SMichal Meloun uint64_t f_flags; /* copy of mount exported flags */ 33425efcda4SMichal Meloun uint64_t f_bsize; /* filesystem fragment size */ 33525efcda4SMichal Meloun uint64_t f_iosize; /* optimal transfer block size */ 33625efcda4SMichal Meloun uint64_t f_blocks; /* total data blocks in filesystem */ 33725efcda4SMichal Meloun uint64_t f_bfree; /* free blocks in filesystem */ 33825efcda4SMichal Meloun int64_t f_bavail; /* free blocks avail to non-superuser */ 33925efcda4SMichal Meloun uint64_t f_files; /* total file nodes in filesystem */ 34025efcda4SMichal Meloun int64_t f_ffree; /* free nodes avail to non-superuser */ 34125efcda4SMichal Meloun uint64_t f_syncwrites; /* count of sync writes since mount */ 34225efcda4SMichal Meloun uint64_t f_asyncwrites; /* count of async writes since mount */ 34325efcda4SMichal Meloun uint64_t f_syncreads; /* count of sync reads since mount */ 34425efcda4SMichal Meloun uint64_t f_asyncreads; /* count of async reads since mount */ 34525efcda4SMichal Meloun uint64_t f_spare[10]; /* unused spare */ 34625efcda4SMichal Meloun uint32_t f_namemax; /* maximum filename length */ 34725efcda4SMichal Meloun uint32_t f_owner; /* user that mounted the filesystem */ 34825efcda4SMichal Meloun target_freebsd_fsid_t f_fsid; /* filesystem id */ 34925efcda4SMichal Meloun char f_charspare[80]; /* spare string space */ 35025efcda4SMichal Meloun char f_fstypename[16]; /* filesystem type name */ 35125efcda4SMichal Meloun char f_mntfromname[1024]; /* mounted filesystem */ 35225efcda4SMichal Meloun char f_mntonname[1024]; /* directory on which mounted */ 35325efcda4SMichal Meloun }; 35425efcda4SMichal Meloun 35554d07b44SStacey Son /* File identifier. These are unique per filesystem on a single machine. */ 35654d07b44SStacey Son #define TARGET_MAXFIDSZ 16 35754d07b44SStacey Son 35854d07b44SStacey Son struct target_freebsd_fid { 35954d07b44SStacey Son uint16_t fid_len; /* len of data in bytes */ 36054d07b44SStacey Son uint16_t fid_data0; /* force longword align */ 36154d07b44SStacey Son char fid_data[TARGET_MAXFIDSZ]; /* data (variable len) */ 36254d07b44SStacey Son }; 36354d07b44SStacey Son 36454d07b44SStacey Son /* Generic file handle */ 36554d07b44SStacey Son struct target_freebsd_fhandle { 36654d07b44SStacey Son target_freebsd_fsid_t fh_fsid; /* Filesystem id of mount point */ 36754d07b44SStacey Son struct target_freebsd_fid fh_fid; /* Filesys specific id */ 36854d07b44SStacey Son }; 36954d07b44SStacey Son typedef struct target_freebsd_fhandle target_freebsd_fhandle_t; 37054d07b44SStacey Son 37154d07b44SStacey Son /* 37254d07b44SStacey Son * sys/fcntl.h 37354d07b44SStacey Son */ 37454d07b44SStacey Son #define TARGET_F_DUPFD 0 37554d07b44SStacey Son #define TARGET_F_GETFD 1 37654d07b44SStacey Son #define TARGET_F_SETFD 2 37754d07b44SStacey Son #define TARGET_F_GETFL 3 37854d07b44SStacey Son #define TARGET_F_SETFL 4 37954d07b44SStacey Son #define TARGET_F_GETOWN 5 38054d07b44SStacey Son #define TARGET_F_SETOWN 6 38154d07b44SStacey Son #define TARGET_F_OGETLK 7 38254d07b44SStacey Son #define TARGET_F_OSETLK 8 38354d07b44SStacey Son #define TARGET_F_OSETLKW 9 38454d07b44SStacey Son #define TARGET_F_DUP2FD 10 38554d07b44SStacey Son #define TARGET_F_GETLK 11 38654d07b44SStacey Son #define TARGET_F_SETLK 12 38754d07b44SStacey Son #define TARGET_F_SETLKW 13 38854d07b44SStacey Son #define TARGET_F_SETLK_REMOTE 14 38954d07b44SStacey Son #define TARGET_F_READAHEAD 15 39054d07b44SStacey Son #define TARGET_F_RDAHEAD 16 39154d07b44SStacey Son #define TARGET_F_DUPFD_CLOEXEC 17 39254d07b44SStacey Son #define TARGET_F_DUP2FD_CLOEXEC 18 39354d07b44SStacey Son /* FreeBSD-specific */ 39454d07b44SStacey Son #define TARGET_F_ADD_SEALS 19 39554d07b44SStacey Son #define TARGET_F_GET_SEALS 20 39654d07b44SStacey Son 39754d07b44SStacey Son struct target_freebsd_flock { 39854d07b44SStacey Son int64_t l_start; 39954d07b44SStacey Son int64_t l_len; 40054d07b44SStacey Son int32_t l_pid; 40154d07b44SStacey Son int16_t l_type; 40254d07b44SStacey Son int16_t l_whence; 40354d07b44SStacey Son int32_t l_sysid; 40454d07b44SStacey Son } QEMU_PACKED; 40554d07b44SStacey Son 4065783a530SKarim Taha /* sys/unistd.h */ 4075783a530SKarim Taha /* user: vfork(2) semantics, clear signals */ 4085783a530SKarim Taha #define TARGET_RFSPAWN (1U << 31) 4095783a530SKarim Taha 410d314ae93SStacey Son /* 411d314ae93SStacey Son * from sys/procctl.h 412d314ae93SStacey Son */ 413d314ae93SStacey Son #define TARGET_PROC_SPROTECT 1 414d314ae93SStacey Son #define TARGET_PROC_REAP_ACQUIRE 2 415d314ae93SStacey Son #define TARGET_PROC_REAP_RELEASE 3 416d314ae93SStacey Son #define TARGET_PROC_REAP_STATUS 4 417d314ae93SStacey Son #define TARGET_PROC_REAP_GETPIDS 5 418d314ae93SStacey Son #define TARGET_PROC_REAP_KILL 6 419d314ae93SStacey Son 420d314ae93SStacey Son struct target_procctl_reaper_status { 421d314ae93SStacey Son uint32_t rs_flags; 422d314ae93SStacey Son uint32_t rs_children; 423d314ae93SStacey Son uint32_t rs_descendants; 424d314ae93SStacey Son uint32_t rs_reaper; 425d314ae93SStacey Son uint32_t rs_pid; 426d314ae93SStacey Son uint32_t rs_pad0[15]; 427d314ae93SStacey Son }; 428d314ae93SStacey Son 429d314ae93SStacey Son struct target_procctl_reaper_pidinfo { 430d314ae93SStacey Son uint32_t pi_pid; 431d314ae93SStacey Son uint32_t pi_subtree; 432d314ae93SStacey Son uint32_t pi_flags; 433d314ae93SStacey Son uint32_t pi_pad0[15]; 434d314ae93SStacey Son }; 435d314ae93SStacey Son 436d314ae93SStacey Son struct target_procctl_reaper_pids { 437d314ae93SStacey Son uint32_t rp_count; 438d314ae93SStacey Son uint32_t rp_pad0[15]; 439d314ae93SStacey Son abi_ulong rp_pids; 440d314ae93SStacey Son }; 441d314ae93SStacey Son 442d314ae93SStacey Son struct target_procctl_reaper_kill { 443d314ae93SStacey Son int32_t rk_sig; 444d314ae93SStacey Son uint32_t rk_flags; 445d314ae93SStacey Son uint32_t rk_subtree; 446d314ae93SStacey Son uint32_t rk_killed; 447d314ae93SStacey Son uint32_t rk_fpid; 448d314ae93SStacey Son uint32_t rk_pad0[15]; 449d314ae93SStacey Son }; 450d314ae93SStacey Son 451d314ae93SStacey Son 452a5b88166SWarner Losh #define safe_syscall0(type, name) \ 453a5b88166SWarner Losh type safe_##name(void) \ 454a5b88166SWarner Losh { \ 455a5b88166SWarner Losh return safe_syscall(SYS_##name); \ 456a5b88166SWarner Losh } 457a5b88166SWarner Losh 458a5b88166SWarner Losh #define safe_syscall1(type, name, type1, arg1) \ 459a5b88166SWarner Losh type safe_##name(type1 arg1) \ 460a5b88166SWarner Losh { \ 461a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1); \ 462a5b88166SWarner Losh } 463a5b88166SWarner Losh 464a5b88166SWarner Losh #define safe_syscall2(type, name, type1, arg1, type2, arg2) \ 465a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2) \ 466a5b88166SWarner Losh { \ 467a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2); \ 468a5b88166SWarner Losh } 469a5b88166SWarner Losh 470a5b88166SWarner Losh #define safe_syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ 471a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2, type3 arg3) \ 472a5b88166SWarner Losh { \ 473a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2, arg3); \ 474a5b88166SWarner Losh } 475a5b88166SWarner Losh 476a5b88166SWarner Losh #define safe_syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \ 477a5b88166SWarner Losh type4, arg4) \ 478a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ 479a5b88166SWarner Losh { \ 480a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4); \ 481a5b88166SWarner Losh } 482a5b88166SWarner Losh 483a5b88166SWarner Losh #define safe_syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \ 484a5b88166SWarner Losh type4, arg4, type5, arg5) \ 485a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 486a5b88166SWarner Losh type5 arg5) \ 487a5b88166SWarner Losh { \ 488a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5); \ 489a5b88166SWarner Losh } 490a5b88166SWarner Losh 491a5b88166SWarner Losh #define safe_syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \ 492a5b88166SWarner Losh type4, arg4, type5, arg5, type6, arg6) \ 493a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 494a5b88166SWarner Losh type5 arg5, type6 arg6) \ 495a5b88166SWarner Losh { \ 496a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5, arg6); \ 497a5b88166SWarner Losh } 498a5b88166SWarner Losh 499243c725fSKyle Evans #define safe_fcntl(...) safe_syscall(SYS_fcntl, __VA_ARGS__) 500243c725fSKyle Evans 50177d3522bSWarner Losh /* So far all target and host bitmasks are the same */ 502a05cee93SRichard Henderson #undef target_to_host_bitmask 50377d3522bSWarner Losh #define target_to_host_bitmask(x, tbl) (x) 504a05cee93SRichard Henderson #undef host_to_target_bitmask 50577d3522bSWarner Losh #define host_to_target_bitmask(x, tbl) (x) 50677d3522bSWarner Losh 5079c092804SMarkus Armbruster #endif /* SYSCALL_DEFS_H */ 508