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 /* 76*695cb913SStacey Son * sys/shm.h 77*695cb913SStacey Son */ 78*695cb913SStacey Son struct target_shmid_ds { 79*695cb913SStacey Son struct target_ipc_perm shm_perm; /* peration permission structure */ 80*695cb913SStacey Son abi_ulong shm_segsz; /* size of segment in bytes */ 81*695cb913SStacey Son int32_t shm_lpid; /* process ID of last shared memory op */ 82*695cb913SStacey Son int32_t shm_cpid; /* process ID of creator */ 83*695cb913SStacey Son int32_t shm_nattch; /* number of current attaches */ 84*695cb913SStacey Son target_time_t shm_atime; /* time of last shmat() */ 85*695cb913SStacey Son target_time_t shm_dtime; /* time of last shmdt() */ 86*695cb913SStacey Son target_time_t shm_ctime; /* time of last change by shmctl() */ 87*695cb913SStacey Son }; 88*695cb913SStacey Son 89*695cb913SStacey Son #define N_BSD_SHM_REGIONS 32 90*695cb913SStacey Son struct bsd_shm_regions { 91*695cb913SStacey Son abi_long start; 92*695cb913SStacey Son abi_long size; 93*695cb913SStacey Son }; 94*695cb913SStacey Son 95*695cb913SStacey Son /* 96366c5c9fSWarner Losh * sys/mman.h 97366c5c9fSWarner Losh */ 98366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_RESERVED0080 0x0080 /* previously misimplemented */ 99366c5c9fSWarner Losh /* MAP_INHERIT */ 100366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_RESERVED0100 0x0100 /* previously unimplemented */ 101366c5c9fSWarner Losh /* MAP_NOEXTEND */ 102366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_STACK 0x0400 /* region grows down, like a */ 103366c5c9fSWarner Losh /* stack */ 104366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_NOSYNC 0x0800 /* page to but do not sync */ 105366c5c9fSWarner Losh /* underlying file */ 106366c5c9fSWarner Losh 107366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_FLAGMASK 0x1ff7 108366c5c9fSWarner Losh 109366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_INHERIT 0x0080 /* region is retained after */ 110366c5c9fSWarner Losh /* exec */ 111366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_TRYFIXED 0x0400 /* attempt hint address, even */ 112366c5c9fSWarner Losh /* within break */ 113366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_WIRED 0x0800 /* mlock() mapping when it is */ 114366c5c9fSWarner Losh /* established */ 115366c5c9fSWarner Losh 116366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_STACK 0x2000 /* allocated from memory, */ 117366c5c9fSWarner Losh /* swap space (stack) */ 118366c5c9fSWarner Losh 119366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_FLAGMASK 0x3ff7 120366c5c9fSWarner Losh 121366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_INHERIT 0x0080 /* region is retained after */ 122366c5c9fSWarner Losh /* exec */ 123366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_NOEXTEND 0x0100 /* for MAP_FILE, don't change */ 124366c5c9fSWarner Losh /* file size */ 125366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_TRYFIXED 0x0400 /* attempt hint address, */ 126366c5c9fSWarner Losh /* even within heap */ 127366c5c9fSWarner Losh 128366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_FLAGMASK 0x17f7 129366c5c9fSWarner Losh 130366c5c9fSWarner Losh /* XXX */ 131366c5c9fSWarner Losh #define TARGET_BSD_MAP_FLAGMASK 0x3ff7 132366c5c9fSWarner Losh 133366c5c9fSWarner Losh /* 134366c5c9fSWarner Losh * sys/time.h 135366c5c9fSWarner Losh * sys/timex.h 136366c5c9fSWarner Losh */ 137366c5c9fSWarner Losh 138366c5c9fSWarner Losh typedef abi_long target_freebsd_suseconds_t; 139366c5c9fSWarner Losh 140366c5c9fSWarner Losh /* compare to sys/timespec.h */ 141366c5c9fSWarner Losh struct target_freebsd_timespec { 142a0c20b1bSWarner Losh target_time_t tv_sec; /* seconds */ 143366c5c9fSWarner Losh abi_long tv_nsec; /* and nanoseconds */ 144366c5c9fSWarner Losh #if !defined(TARGET_I386) && TARGET_ABI_BITS == 32 145366c5c9fSWarner Losh abi_long _pad; 146366c5c9fSWarner Losh #endif 147366c5c9fSWarner Losh }; 148366c5c9fSWarner Losh 149366c5c9fSWarner Losh #define TARGET_CPUCLOCK_WHICH_PID 0 150366c5c9fSWarner Losh #define TARGET_CPUCLOCK_WHICH_TID 1 151366c5c9fSWarner Losh 152366c5c9fSWarner Losh /* sys/umtx.h */ 153366c5c9fSWarner Losh struct target_freebsd__umtx_time { 154366c5c9fSWarner Losh struct target_freebsd_timespec _timeout; 155366c5c9fSWarner Losh uint32_t _flags; 156366c5c9fSWarner Losh uint32_t _clockid; 157366c5c9fSWarner Losh }; 158366c5c9fSWarner Losh 159366c5c9fSWarner Losh struct target_freebsd_timeval { 160a0c20b1bSWarner Losh target_time_t tv_sec; /* seconds */ 161366c5c9fSWarner Losh target_freebsd_suseconds_t tv_usec;/* and microseconds */ 162366c5c9fSWarner Losh #if !defined(TARGET_I386) && TARGET_ABI_BITS == 32 163366c5c9fSWarner Losh abi_long _pad; 164366c5c9fSWarner Losh #endif 165366c5c9fSWarner Losh }; 166366c5c9fSWarner Losh 167366c5c9fSWarner Losh /* 168366c5c9fSWarner Losh * sys/resource.h 169366c5c9fSWarner Losh */ 170366c5c9fSWarner Losh #define TARGET_RLIM_INFINITY RLIM_INFINITY 171366c5c9fSWarner Losh 172366c5c9fSWarner Losh #define TARGET_RLIMIT_CPU 0 173366c5c9fSWarner Losh #define TARGET_RLIMIT_FSIZE 1 174366c5c9fSWarner Losh #define TARGET_RLIMIT_DATA 2 175366c5c9fSWarner Losh #define TARGET_RLIMIT_STACK 3 176366c5c9fSWarner Losh #define TARGET_RLIMIT_CORE 4 177366c5c9fSWarner Losh #define TARGET_RLIMIT_RSS 5 178366c5c9fSWarner Losh #define TARGET_RLIMIT_MEMLOCK 6 179366c5c9fSWarner Losh #define TARGET_RLIMIT_NPROC 7 180366c5c9fSWarner Losh #define TARGET_RLIMIT_NOFILE 8 181366c5c9fSWarner Losh #define TARGET_RLIMIT_SBSIZE 9 182366c5c9fSWarner Losh #define TARGET_RLIMIT_AS 10 183366c5c9fSWarner Losh #define TARGET_RLIMIT_NPTS 11 184366c5c9fSWarner Losh #define TARGET_RLIMIT_SWAP 12 185366c5c9fSWarner Losh 186366c5c9fSWarner Losh struct target_rlimit { 187366c5c9fSWarner Losh uint64_t rlim_cur; 188366c5c9fSWarner Losh uint64_t rlim_max; 189366c5c9fSWarner Losh }; 190366c5c9fSWarner Losh 191366c5c9fSWarner Losh struct target_freebsd_rusage { 192366c5c9fSWarner Losh struct target_freebsd_timeval ru_utime; /* user time used */ 193366c5c9fSWarner Losh struct target_freebsd_timeval ru_stime; /* system time used */ 194366c5c9fSWarner Losh abi_long ru_maxrss; /* maximum resident set size */ 195366c5c9fSWarner Losh abi_long ru_ixrss; /* integral shared memory size */ 196366c5c9fSWarner Losh abi_long ru_idrss; /* integral unshared data size */ 197366c5c9fSWarner Losh abi_long ru_isrss; /* integral unshared stack size */ 198366c5c9fSWarner Losh abi_long ru_minflt; /* page reclaims */ 199366c5c9fSWarner Losh abi_long ru_majflt; /* page faults */ 200366c5c9fSWarner Losh abi_long ru_nswap; /* swaps */ 201366c5c9fSWarner Losh abi_long ru_inblock; /* block input operations */ 202366c5c9fSWarner Losh abi_long ru_oublock; /* block output operations */ 203366c5c9fSWarner Losh abi_long ru_msgsnd; /* messages sent */ 204366c5c9fSWarner Losh abi_long ru_msgrcv; /* messages received */ 205366c5c9fSWarner Losh abi_long ru_nsignals; /* signals received */ 206366c5c9fSWarner Losh abi_long ru_nvcsw; /* voluntary context switches */ 207366c5c9fSWarner Losh abi_long ru_nivcsw; /* involuntary context switches */ 208366c5c9fSWarner Losh }; 209366c5c9fSWarner Losh 210366c5c9fSWarner Losh struct target_freebsd__wrusage { 211366c5c9fSWarner Losh struct target_freebsd_rusage wru_self; 212366c5c9fSWarner Losh struct target_freebsd_rusage wru_children; 213366c5c9fSWarner Losh }; 214366c5c9fSWarner Losh 21540f5e298SStacey Son /* 21640f5e298SStacey Son * sys/stat.h 21740f5e298SStacey Son */ 21840f5e298SStacey Son struct target_freebsd11_stat { 21940f5e298SStacey Son uint32_t st_dev; /* inode's device */ 22040f5e298SStacey Son uint32_t st_ino; /* inode's number */ 22140f5e298SStacey Son int16_t st_mode; /* inode protection mode */ 22240f5e298SStacey Son int16_t st_nlink; /* number of hard links */ 22340f5e298SStacey Son uint32_t st_uid; /* user ID of the file's owner */ 22440f5e298SStacey Son uint32_t st_gid; /* group ID of the file's group */ 22540f5e298SStacey Son uint32_t st_rdev; /* device type */ 22640f5e298SStacey Son struct target_freebsd_timespec st_atim; /* time last accessed */ 22740f5e298SStacey Son struct target_freebsd_timespec st_mtim; /* time last data modification */ 22840f5e298SStacey Son struct target_freebsd_timespec st_ctim; /* time last file status change */ 22940f5e298SStacey Son int64_t st_size; /* file size, in bytes */ 23040f5e298SStacey Son int64_t st_blocks; /* blocks allocated for file */ 23140f5e298SStacey Son uint32_t st_blksize; /* optimal blocksize for I/O */ 23240f5e298SStacey Son uint32_t st_flags; /* user defined flags for file */ 23340f5e298SStacey Son uint32_t st_gen; /* file generation number */ 23440f5e298SStacey Son int32_t st_lspare; 23540f5e298SStacey Son struct target_freebsd_timespec st_birthtim; /* time of file creation */ 23640f5e298SStacey Son /* 23740f5e298SStacey Son * Explicitly pad st_birthtim to 16 bytes so that the size of 23840f5e298SStacey Son * struct stat is backwards compatible. We use bitfields instead 23940f5e298SStacey Son * of an array of chars so that this doesn't require a C99 compiler 24040f5e298SStacey Son * to compile if the size of the padding is 0. We use 2 bitfields 24140f5e298SStacey Son * to cover up to 64 bits on 32-bit machines. We assume that 24240f5e298SStacey Son * CHAR_BIT is 8... 24340f5e298SStacey Son */ 24440f5e298SStacey Son unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec)); 24540f5e298SStacey Son unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec)); 24640f5e298SStacey Son } __packed; 24740f5e298SStacey Son 248ad805a77SMichal Meloun #if defined(__i386__) 249ad805a77SMichal Meloun #define TARGET_HAS_STAT_TIME_T_EXT 1 250ad805a77SMichal Meloun #endif 251ad805a77SMichal Meloun 252ad805a77SMichal Meloun struct target_stat { 253ad805a77SMichal Meloun uint64_t st_dev; /* inode's device */ 254ad805a77SMichal Meloun uint64_t st_ino; /* inode's number */ 255ad805a77SMichal Meloun uint64_t st_nlink; /* number of hard links */ 256ad805a77SMichal Meloun int16_t st_mode; /* inode protection mode */ 257ad805a77SMichal Meloun int16_t st_padding0; 258ad805a77SMichal Meloun uint32_t st_uid; /* user ID of the file's owner */ 259ad805a77SMichal Meloun uint32_t st_gid; /* group ID of the file's group */ 260ad805a77SMichal Meloun int32_t st_padding1; 261ad805a77SMichal Meloun uint64_t st_rdev; /* device type */ 262ad805a77SMichal Meloun #ifdef TARGET_HAS_STAT_TIME_T_EXT 263ad805a77SMichal Meloun int32_t st_atim_ext; 264ad805a77SMichal Meloun #endif 265ad805a77SMichal Meloun struct target_freebsd_timespec st_atim; /* time of last access */ 266ad805a77SMichal Meloun #ifdef TARGET_HAS_STAT_TIME_T_EXT 267ad805a77SMichal Meloun int32_t st_mtim_ext; 268ad805a77SMichal Meloun #endif 269ad805a77SMichal Meloun struct target_freebsd_timespec st_mtim; /* time of last data modification */ 270ad805a77SMichal Meloun #ifdef TARGET_HAS_STAT_TIME_T_EXT 271ad805a77SMichal Meloun int32_t st_ctim_ext; 272ad805a77SMichal Meloun #endif 273ad805a77SMichal Meloun struct target_freebsd_timespec st_ctim;/* time of last file status change */ 274ad805a77SMichal Meloun #ifdef TARGET_HAS_STAT_TIME_T_EXT 275ad805a77SMichal Meloun int32_t st_btim_ext; 276ad805a77SMichal Meloun #endif 277ad805a77SMichal Meloun struct target_freebsd_timespec st_birthtim; /* time of file creation */ 278ad805a77SMichal Meloun int64_t st_size; /* file size, in bytes */ 279ad805a77SMichal Meloun int64_t st_blocks; /* blocks allocated for file */ 280ad805a77SMichal Meloun uint32_t st_blksize; /* optimal blocksize for I/O */ 281ad805a77SMichal Meloun uint32_t st_flags; /* user defined flags for file */ 282ad805a77SMichal Meloun uint64_t st_gen; /* file generation number */ 283ad805a77SMichal Meloun uint64_t st_spare[10]; 284ad805a77SMichal Meloun }; 285ad805a77SMichal Meloun 2861de075a0SStacey Son 2871de075a0SStacey Son /* struct nstat is the same as stat above but without the st_lspare field */ 2881de075a0SStacey Son struct target_freebsd11_nstat { 2891de075a0SStacey Son uint32_t st_dev; /* inode's device */ 2901de075a0SStacey Son uint32_t st_ino; /* inode's number */ 2911de075a0SStacey Son int16_t st_mode; /* inode protection mode */ 2921de075a0SStacey Son int16_t st_nlink; /* number of hard links */ 2931de075a0SStacey Son uint32_t st_uid; /* user ID of the file's owner */ 2941de075a0SStacey Son uint32_t st_gid; /* group ID of the file's group */ 2951de075a0SStacey Son uint32_t st_rdev; /* device type */ 2961de075a0SStacey Son struct target_freebsd_timespec st_atim; /* time last accessed */ 2971de075a0SStacey Son struct target_freebsd_timespec st_mtim; /* time last data modification */ 2981de075a0SStacey Son struct target_freebsd_timespec st_ctim; /* time last file status change */ 2991de075a0SStacey Son int64_t st_size; /* file size, in bytes */ 3001de075a0SStacey Son int64_t st_blocks; /* blocks allocated for file */ 3011de075a0SStacey Son uint32_t st_blksize; /* optimal blocksize for I/O */ 3021de075a0SStacey Son uint32_t st_flags; /* user defined flags for file */ 3031de075a0SStacey Son uint32_t st_gen; /* file generation number */ 3041de075a0SStacey Son struct target_freebsd_timespec st_birthtim; /* time of file creation */ 3051de075a0SStacey Son /* 3061de075a0SStacey Son * Explicitly pad st_birthtim to 16 bytes so that the size of 3071de075a0SStacey Son * struct stat is backwards compatible. We use bitfields instead 3081de075a0SStacey Son * of an array of chars so that this doesn't require a C99 compiler 3091de075a0SStacey Son * to compile if the size of the padding is 0. We use 2 bitfields 3101de075a0SStacey Son * to cover up to 64 bits on 32-bit machines. We assume that 3111de075a0SStacey Son * CHAR_BIT is 8... 3121de075a0SStacey Son */ 3131de075a0SStacey Son unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec)); 3141de075a0SStacey Son unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec)); 3151de075a0SStacey Son } __packed; 3161de075a0SStacey Son 3171de075a0SStacey Son /* 3181de075a0SStacey Son * sys/mount.h 3191de075a0SStacey Son */ 3201de075a0SStacey Son 3211de075a0SStacey Son /* filesystem id type */ 3221de075a0SStacey Son typedef struct target_freebsd_fsid { int32_t val[2]; } target_freebsd_fsid_t; 3231de075a0SStacey Son 3241de075a0SStacey Son /* filesystem statistics */ 3251de075a0SStacey Son struct target_freebsd11_statfs { 3261de075a0SStacey Son uint32_t f_version; /* structure version number */ 3271de075a0SStacey Son uint32_t f_type; /* type of filesystem */ 3281de075a0SStacey Son uint64_t f_flags; /* copy of mount exported flags */ 3291de075a0SStacey Son uint64_t f_bsize; /* filesystem fragment size */ 3301de075a0SStacey Son uint64_t f_iosize; /* optimal transfer block size */ 3311de075a0SStacey Son uint64_t f_blocks; /* total data blocks in filesystem */ 3321de075a0SStacey Son uint64_t f_bfree; /* free blocks in filesystem */ 3331de075a0SStacey Son int64_t f_bavail; /* free blocks avail to non-superuser */ 3341de075a0SStacey Son uint64_t f_files; /* total file nodes in filesystem */ 3351de075a0SStacey Son int64_t f_ffree; /* free nodes avail to non-superuser */ 3361de075a0SStacey Son uint64_t f_syncwrites; /* count of sync writes since mount */ 3371de075a0SStacey Son uint64_t f_asyncwrites; /* count of async writes since mount */ 3381de075a0SStacey Son uint64_t f_syncreads; /* count of sync reads since mount */ 3391de075a0SStacey Son uint64_t f_asyncreads; /* count of async reads since mount */ 3401de075a0SStacey Son uint64_t f_spare[10]; /* unused spare */ 3411de075a0SStacey Son uint32_t f_namemax; /* maximum filename length */ 3421de075a0SStacey Son uint32_t f_owner; /* user that mounted the filesystem */ 3431de075a0SStacey Son target_freebsd_fsid_t f_fsid; /* filesystem id */ 3441de075a0SStacey Son char f_charspare[80]; /* spare string space */ 3451de075a0SStacey Son char f_fstypename[16]; /* filesys type name */ 3461de075a0SStacey Son char f_mntfromname[88]; /* mount filesystem */ 3471de075a0SStacey Son char f_mntonname[88]; /* dir on which mounted*/ 3481de075a0SStacey Son }; 3491de075a0SStacey Son 35025efcda4SMichal Meloun struct target_statfs { 35125efcda4SMichal Meloun uint32_t f_version; /* structure version number */ 35225efcda4SMichal Meloun uint32_t f_type; /* type of filesystem */ 35325efcda4SMichal Meloun uint64_t f_flags; /* copy of mount exported flags */ 35425efcda4SMichal Meloun uint64_t f_bsize; /* filesystem fragment size */ 35525efcda4SMichal Meloun uint64_t f_iosize; /* optimal transfer block size */ 35625efcda4SMichal Meloun uint64_t f_blocks; /* total data blocks in filesystem */ 35725efcda4SMichal Meloun uint64_t f_bfree; /* free blocks in filesystem */ 35825efcda4SMichal Meloun int64_t f_bavail; /* free blocks avail to non-superuser */ 35925efcda4SMichal Meloun uint64_t f_files; /* total file nodes in filesystem */ 36025efcda4SMichal Meloun int64_t f_ffree; /* free nodes avail to non-superuser */ 36125efcda4SMichal Meloun uint64_t f_syncwrites; /* count of sync writes since mount */ 36225efcda4SMichal Meloun uint64_t f_asyncwrites; /* count of async writes since mount */ 36325efcda4SMichal Meloun uint64_t f_syncreads; /* count of sync reads since mount */ 36425efcda4SMichal Meloun uint64_t f_asyncreads; /* count of async reads since mount */ 36525efcda4SMichal Meloun uint64_t f_spare[10]; /* unused spare */ 36625efcda4SMichal Meloun uint32_t f_namemax; /* maximum filename length */ 36725efcda4SMichal Meloun uint32_t f_owner; /* user that mounted the filesystem */ 36825efcda4SMichal Meloun target_freebsd_fsid_t f_fsid; /* filesystem id */ 36925efcda4SMichal Meloun char f_charspare[80]; /* spare string space */ 37025efcda4SMichal Meloun char f_fstypename[16]; /* filesystem type name */ 37125efcda4SMichal Meloun char f_mntfromname[1024]; /* mounted filesystem */ 37225efcda4SMichal Meloun char f_mntonname[1024]; /* directory on which mounted */ 37325efcda4SMichal Meloun }; 37425efcda4SMichal Meloun 37554d07b44SStacey Son /* File identifier. These are unique per filesystem on a single machine. */ 37654d07b44SStacey Son #define TARGET_MAXFIDSZ 16 37754d07b44SStacey Son 37854d07b44SStacey Son struct target_freebsd_fid { 37954d07b44SStacey Son uint16_t fid_len; /* len of data in bytes */ 38054d07b44SStacey Son uint16_t fid_data0; /* force longword align */ 38154d07b44SStacey Son char fid_data[TARGET_MAXFIDSZ]; /* data (variable len) */ 38254d07b44SStacey Son }; 38354d07b44SStacey Son 38454d07b44SStacey Son /* Generic file handle */ 38554d07b44SStacey Son struct target_freebsd_fhandle { 38654d07b44SStacey Son target_freebsd_fsid_t fh_fsid; /* Filesystem id of mount point */ 38754d07b44SStacey Son struct target_freebsd_fid fh_fid; /* Filesys specific id */ 38854d07b44SStacey Son }; 38954d07b44SStacey Son typedef struct target_freebsd_fhandle target_freebsd_fhandle_t; 39054d07b44SStacey Son 39154d07b44SStacey Son /* 39254d07b44SStacey Son * sys/fcntl.h 39354d07b44SStacey Son */ 39454d07b44SStacey Son #define TARGET_F_DUPFD 0 39554d07b44SStacey Son #define TARGET_F_GETFD 1 39654d07b44SStacey Son #define TARGET_F_SETFD 2 39754d07b44SStacey Son #define TARGET_F_GETFL 3 39854d07b44SStacey Son #define TARGET_F_SETFL 4 39954d07b44SStacey Son #define TARGET_F_GETOWN 5 40054d07b44SStacey Son #define TARGET_F_SETOWN 6 40154d07b44SStacey Son #define TARGET_F_OGETLK 7 40254d07b44SStacey Son #define TARGET_F_OSETLK 8 40354d07b44SStacey Son #define TARGET_F_OSETLKW 9 40454d07b44SStacey Son #define TARGET_F_DUP2FD 10 40554d07b44SStacey Son #define TARGET_F_GETLK 11 40654d07b44SStacey Son #define TARGET_F_SETLK 12 40754d07b44SStacey Son #define TARGET_F_SETLKW 13 40854d07b44SStacey Son #define TARGET_F_SETLK_REMOTE 14 40954d07b44SStacey Son #define TARGET_F_READAHEAD 15 41054d07b44SStacey Son #define TARGET_F_RDAHEAD 16 41154d07b44SStacey Son #define TARGET_F_DUPFD_CLOEXEC 17 41254d07b44SStacey Son #define TARGET_F_DUP2FD_CLOEXEC 18 41354d07b44SStacey Son /* FreeBSD-specific */ 41454d07b44SStacey Son #define TARGET_F_ADD_SEALS 19 41554d07b44SStacey Son #define TARGET_F_GET_SEALS 20 41654d07b44SStacey Son 41754d07b44SStacey Son struct target_freebsd_flock { 41854d07b44SStacey Son int64_t l_start; 41954d07b44SStacey Son int64_t l_len; 42054d07b44SStacey Son int32_t l_pid; 42154d07b44SStacey Son int16_t l_type; 42254d07b44SStacey Son int16_t l_whence; 42354d07b44SStacey Son int32_t l_sysid; 42454d07b44SStacey Son } QEMU_PACKED; 42554d07b44SStacey Son 4265783a530SKarim Taha /* sys/unistd.h */ 4275783a530SKarim Taha /* user: vfork(2) semantics, clear signals */ 4285783a530SKarim Taha #define TARGET_RFSPAWN (1U << 31) 4295783a530SKarim Taha 430d314ae93SStacey Son /* 431d314ae93SStacey Son * from sys/procctl.h 432d314ae93SStacey Son */ 433d314ae93SStacey Son #define TARGET_PROC_SPROTECT 1 434d314ae93SStacey Son #define TARGET_PROC_REAP_ACQUIRE 2 435d314ae93SStacey Son #define TARGET_PROC_REAP_RELEASE 3 436d314ae93SStacey Son #define TARGET_PROC_REAP_STATUS 4 437d314ae93SStacey Son #define TARGET_PROC_REAP_GETPIDS 5 438d314ae93SStacey Son #define TARGET_PROC_REAP_KILL 6 439d314ae93SStacey Son 440d314ae93SStacey Son struct target_procctl_reaper_status { 441d314ae93SStacey Son uint32_t rs_flags; 442d314ae93SStacey Son uint32_t rs_children; 443d314ae93SStacey Son uint32_t rs_descendants; 444d314ae93SStacey Son uint32_t rs_reaper; 445d314ae93SStacey Son uint32_t rs_pid; 446d314ae93SStacey Son uint32_t rs_pad0[15]; 447d314ae93SStacey Son }; 448d314ae93SStacey Son 449d314ae93SStacey Son struct target_procctl_reaper_pidinfo { 450d314ae93SStacey Son uint32_t pi_pid; 451d314ae93SStacey Son uint32_t pi_subtree; 452d314ae93SStacey Son uint32_t pi_flags; 453d314ae93SStacey Son uint32_t pi_pad0[15]; 454d314ae93SStacey Son }; 455d314ae93SStacey Son 456d314ae93SStacey Son struct target_procctl_reaper_pids { 457d314ae93SStacey Son uint32_t rp_count; 458d314ae93SStacey Son uint32_t rp_pad0[15]; 459d314ae93SStacey Son abi_ulong rp_pids; 460d314ae93SStacey Son }; 461d314ae93SStacey Son 462d314ae93SStacey Son struct target_procctl_reaper_kill { 463d314ae93SStacey Son int32_t rk_sig; 464d314ae93SStacey Son uint32_t rk_flags; 465d314ae93SStacey Son uint32_t rk_subtree; 466d314ae93SStacey Son uint32_t rk_killed; 467d314ae93SStacey Son uint32_t rk_fpid; 468d314ae93SStacey Son uint32_t rk_pad0[15]; 469d314ae93SStacey Son }; 470d314ae93SStacey Son 471d314ae93SStacey Son 472a5b88166SWarner Losh #define safe_syscall0(type, name) \ 473a5b88166SWarner Losh type safe_##name(void) \ 474a5b88166SWarner Losh { \ 475a5b88166SWarner Losh return safe_syscall(SYS_##name); \ 476a5b88166SWarner Losh } 477a5b88166SWarner Losh 478a5b88166SWarner Losh #define safe_syscall1(type, name, type1, arg1) \ 479a5b88166SWarner Losh type safe_##name(type1 arg1) \ 480a5b88166SWarner Losh { \ 481a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1); \ 482a5b88166SWarner Losh } 483a5b88166SWarner Losh 484a5b88166SWarner Losh #define safe_syscall2(type, name, type1, arg1, type2, arg2) \ 485a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2) \ 486a5b88166SWarner Losh { \ 487a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2); \ 488a5b88166SWarner Losh } 489a5b88166SWarner Losh 490a5b88166SWarner Losh #define safe_syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ 491a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2, type3 arg3) \ 492a5b88166SWarner Losh { \ 493a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2, arg3); \ 494a5b88166SWarner Losh } 495a5b88166SWarner Losh 496a5b88166SWarner Losh #define safe_syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \ 497a5b88166SWarner Losh type4, arg4) \ 498a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ 499a5b88166SWarner Losh { \ 500a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4); \ 501a5b88166SWarner Losh } 502a5b88166SWarner Losh 503a5b88166SWarner Losh #define safe_syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \ 504a5b88166SWarner Losh type4, arg4, type5, arg5) \ 505a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 506a5b88166SWarner Losh type5 arg5) \ 507a5b88166SWarner Losh { \ 508a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5); \ 509a5b88166SWarner Losh } 510a5b88166SWarner Losh 511a5b88166SWarner Losh #define safe_syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \ 512a5b88166SWarner Losh type4, arg4, type5, arg5, type6, arg6) \ 513a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 514a5b88166SWarner Losh type5 arg5, type6 arg6) \ 515a5b88166SWarner Losh { \ 516a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5, arg6); \ 517a5b88166SWarner Losh } 518a5b88166SWarner Losh 519243c725fSKyle Evans #define safe_fcntl(...) safe_syscall(SYS_fcntl, __VA_ARGS__) 520243c725fSKyle Evans 52177d3522bSWarner Losh /* So far all target and host bitmasks are the same */ 522a05cee93SRichard Henderson #undef target_to_host_bitmask 52377d3522bSWarner Losh #define target_to_host_bitmask(x, tbl) (x) 524a05cee93SRichard Henderson #undef host_to_target_bitmask 52577d3522bSWarner Losh #define host_to_target_bitmask(x, tbl) (x) 52677d3522bSWarner Losh 5279c092804SMarkus Armbruster #endif /* SYSCALL_DEFS_H */ 528