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)) 48*a0c20b1bSWarner Losh typedef int64_t target_time_t; 49366c5c9fSWarner Losh #else 50*a0c20b1bSWarner 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 /* 59366c5c9fSWarner Losh * sys/mman.h 60366c5c9fSWarner Losh */ 61366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_RESERVED0080 0x0080 /* previously misimplemented */ 62366c5c9fSWarner Losh /* MAP_INHERIT */ 63366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_RESERVED0100 0x0100 /* previously unimplemented */ 64366c5c9fSWarner Losh /* MAP_NOEXTEND */ 65366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_STACK 0x0400 /* region grows down, like a */ 66366c5c9fSWarner Losh /* stack */ 67366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_NOSYNC 0x0800 /* page to but do not sync */ 68366c5c9fSWarner Losh /* underlying file */ 69366c5c9fSWarner Losh 70366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_FLAGMASK 0x1ff7 71366c5c9fSWarner Losh 72366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_INHERIT 0x0080 /* region is retained after */ 73366c5c9fSWarner Losh /* exec */ 74366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_TRYFIXED 0x0400 /* attempt hint address, even */ 75366c5c9fSWarner Losh /* within break */ 76366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_WIRED 0x0800 /* mlock() mapping when it is */ 77366c5c9fSWarner Losh /* established */ 78366c5c9fSWarner Losh 79366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_STACK 0x2000 /* allocated from memory, */ 80366c5c9fSWarner Losh /* swap space (stack) */ 81366c5c9fSWarner Losh 82366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_FLAGMASK 0x3ff7 83366c5c9fSWarner Losh 84366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_INHERIT 0x0080 /* region is retained after */ 85366c5c9fSWarner Losh /* exec */ 86366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_NOEXTEND 0x0100 /* for MAP_FILE, don't change */ 87366c5c9fSWarner Losh /* file size */ 88366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_TRYFIXED 0x0400 /* attempt hint address, */ 89366c5c9fSWarner Losh /* even within heap */ 90366c5c9fSWarner Losh 91366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_FLAGMASK 0x17f7 92366c5c9fSWarner Losh 93366c5c9fSWarner Losh /* XXX */ 94366c5c9fSWarner Losh #define TARGET_BSD_MAP_FLAGMASK 0x3ff7 95366c5c9fSWarner Losh 96366c5c9fSWarner Losh /* 97366c5c9fSWarner Losh * sys/time.h 98366c5c9fSWarner Losh * sys/timex.h 99366c5c9fSWarner Losh */ 100366c5c9fSWarner Losh 101366c5c9fSWarner Losh typedef abi_long target_freebsd_suseconds_t; 102366c5c9fSWarner Losh 103366c5c9fSWarner Losh /* compare to sys/timespec.h */ 104366c5c9fSWarner Losh struct target_freebsd_timespec { 105*a0c20b1bSWarner Losh target_time_t tv_sec; /* seconds */ 106366c5c9fSWarner Losh abi_long tv_nsec; /* and nanoseconds */ 107366c5c9fSWarner Losh #if !defined(TARGET_I386) && TARGET_ABI_BITS == 32 108366c5c9fSWarner Losh abi_long _pad; 109366c5c9fSWarner Losh #endif 110366c5c9fSWarner Losh }; 111366c5c9fSWarner Losh 112366c5c9fSWarner Losh #define TARGET_CPUCLOCK_WHICH_PID 0 113366c5c9fSWarner Losh #define TARGET_CPUCLOCK_WHICH_TID 1 114366c5c9fSWarner Losh 115366c5c9fSWarner Losh /* sys/umtx.h */ 116366c5c9fSWarner Losh struct target_freebsd__umtx_time { 117366c5c9fSWarner Losh struct target_freebsd_timespec _timeout; 118366c5c9fSWarner Losh uint32_t _flags; 119366c5c9fSWarner Losh uint32_t _clockid; 120366c5c9fSWarner Losh }; 121366c5c9fSWarner Losh 122366c5c9fSWarner Losh struct target_freebsd_timeval { 123*a0c20b1bSWarner Losh target_time_t tv_sec; /* seconds */ 124366c5c9fSWarner Losh target_freebsd_suseconds_t tv_usec;/* and microseconds */ 125366c5c9fSWarner Losh #if !defined(TARGET_I386) && TARGET_ABI_BITS == 32 126366c5c9fSWarner Losh abi_long _pad; 127366c5c9fSWarner Losh #endif 128366c5c9fSWarner Losh }; 129366c5c9fSWarner Losh 130366c5c9fSWarner Losh /* 131366c5c9fSWarner Losh * sys/resource.h 132366c5c9fSWarner Losh */ 133366c5c9fSWarner Losh #if defined(__FreeBSD__) 134366c5c9fSWarner Losh #define TARGET_RLIM_INFINITY RLIM_INFINITY 135366c5c9fSWarner Losh #else 136366c5c9fSWarner Losh #define TARGET_RLIM_INFINITY ((abi_ulong)-1) 137366c5c9fSWarner Losh #endif 138366c5c9fSWarner Losh 139366c5c9fSWarner Losh #define TARGET_RLIMIT_CPU 0 140366c5c9fSWarner Losh #define TARGET_RLIMIT_FSIZE 1 141366c5c9fSWarner Losh #define TARGET_RLIMIT_DATA 2 142366c5c9fSWarner Losh #define TARGET_RLIMIT_STACK 3 143366c5c9fSWarner Losh #define TARGET_RLIMIT_CORE 4 144366c5c9fSWarner Losh #define TARGET_RLIMIT_RSS 5 145366c5c9fSWarner Losh #define TARGET_RLIMIT_MEMLOCK 6 146366c5c9fSWarner Losh #define TARGET_RLIMIT_NPROC 7 147366c5c9fSWarner Losh #define TARGET_RLIMIT_NOFILE 8 148366c5c9fSWarner Losh #define TARGET_RLIMIT_SBSIZE 9 149366c5c9fSWarner Losh #define TARGET_RLIMIT_AS 10 150366c5c9fSWarner Losh #define TARGET_RLIMIT_NPTS 11 151366c5c9fSWarner Losh #define TARGET_RLIMIT_SWAP 12 152366c5c9fSWarner Losh 153366c5c9fSWarner Losh struct target_rlimit { 154366c5c9fSWarner Losh uint64_t rlim_cur; 155366c5c9fSWarner Losh uint64_t rlim_max; 156366c5c9fSWarner Losh }; 157366c5c9fSWarner Losh 158366c5c9fSWarner Losh struct target_freebsd_rusage { 159366c5c9fSWarner Losh struct target_freebsd_timeval ru_utime; /* user time used */ 160366c5c9fSWarner Losh struct target_freebsd_timeval ru_stime; /* system time used */ 161366c5c9fSWarner Losh abi_long ru_maxrss; /* maximum resident set size */ 162366c5c9fSWarner Losh abi_long ru_ixrss; /* integral shared memory size */ 163366c5c9fSWarner Losh abi_long ru_idrss; /* integral unshared data size */ 164366c5c9fSWarner Losh abi_long ru_isrss; /* integral unshared stack size */ 165366c5c9fSWarner Losh abi_long ru_minflt; /* page reclaims */ 166366c5c9fSWarner Losh abi_long ru_majflt; /* page faults */ 167366c5c9fSWarner Losh abi_long ru_nswap; /* swaps */ 168366c5c9fSWarner Losh abi_long ru_inblock; /* block input operations */ 169366c5c9fSWarner Losh abi_long ru_oublock; /* block output operations */ 170366c5c9fSWarner Losh abi_long ru_msgsnd; /* messages sent */ 171366c5c9fSWarner Losh abi_long ru_msgrcv; /* messages received */ 172366c5c9fSWarner Losh abi_long ru_nsignals; /* signals received */ 173366c5c9fSWarner Losh abi_long ru_nvcsw; /* voluntary context switches */ 174366c5c9fSWarner Losh abi_long ru_nivcsw; /* involuntary context switches */ 175366c5c9fSWarner Losh }; 176366c5c9fSWarner Losh 177366c5c9fSWarner Losh struct target_freebsd__wrusage { 178366c5c9fSWarner Losh struct target_freebsd_rusage wru_self; 179366c5c9fSWarner Losh struct target_freebsd_rusage wru_children; 180366c5c9fSWarner Losh }; 181366c5c9fSWarner Losh 18240f5e298SStacey Son /* 18340f5e298SStacey Son * sys/stat.h 18440f5e298SStacey Son */ 18540f5e298SStacey Son struct target_freebsd11_stat { 18640f5e298SStacey Son uint32_t st_dev; /* inode's device */ 18740f5e298SStacey Son uint32_t st_ino; /* inode's number */ 18840f5e298SStacey Son int16_t st_mode; /* inode protection mode */ 18940f5e298SStacey Son int16_t st_nlink; /* number of hard links */ 19040f5e298SStacey Son uint32_t st_uid; /* user ID of the file's owner */ 19140f5e298SStacey Son uint32_t st_gid; /* group ID of the file's group */ 19240f5e298SStacey Son uint32_t st_rdev; /* device type */ 19340f5e298SStacey Son struct target_freebsd_timespec st_atim; /* time last accessed */ 19440f5e298SStacey Son struct target_freebsd_timespec st_mtim; /* time last data modification */ 19540f5e298SStacey Son struct target_freebsd_timespec st_ctim; /* time last file status change */ 19640f5e298SStacey Son int64_t st_size; /* file size, in bytes */ 19740f5e298SStacey Son int64_t st_blocks; /* blocks allocated for file */ 19840f5e298SStacey Son uint32_t st_blksize; /* optimal blocksize for I/O */ 19940f5e298SStacey Son uint32_t st_flags; /* user defined flags for file */ 20040f5e298SStacey Son uint32_t st_gen; /* file generation number */ 20140f5e298SStacey Son int32_t st_lspare; 20240f5e298SStacey Son struct target_freebsd_timespec st_birthtim; /* time of file creation */ 20340f5e298SStacey Son /* 20440f5e298SStacey Son * Explicitly pad st_birthtim to 16 bytes so that the size of 20540f5e298SStacey Son * struct stat is backwards compatible. We use bitfields instead 20640f5e298SStacey Son * of an array of chars so that this doesn't require a C99 compiler 20740f5e298SStacey Son * to compile if the size of the padding is 0. We use 2 bitfields 20840f5e298SStacey Son * to cover up to 64 bits on 32-bit machines. We assume that 20940f5e298SStacey Son * CHAR_BIT is 8... 21040f5e298SStacey Son */ 21140f5e298SStacey Son unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec)); 21240f5e298SStacey Son unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec)); 21340f5e298SStacey Son } __packed; 21440f5e298SStacey Son 215ad805a77SMichal Meloun #if defined(__i386__) 216ad805a77SMichal Meloun #define TARGET_HAS_STAT_TIME_T_EXT 1 217ad805a77SMichal Meloun #endif 218ad805a77SMichal Meloun 219ad805a77SMichal Meloun struct target_stat { 220ad805a77SMichal Meloun uint64_t st_dev; /* inode's device */ 221ad805a77SMichal Meloun uint64_t st_ino; /* inode's number */ 222ad805a77SMichal Meloun uint64_t st_nlink; /* number of hard links */ 223ad805a77SMichal Meloun int16_t st_mode; /* inode protection mode */ 224ad805a77SMichal Meloun int16_t st_padding0; 225ad805a77SMichal Meloun uint32_t st_uid; /* user ID of the file's owner */ 226ad805a77SMichal Meloun uint32_t st_gid; /* group ID of the file's group */ 227ad805a77SMichal Meloun int32_t st_padding1; 228ad805a77SMichal Meloun uint64_t st_rdev; /* device type */ 229ad805a77SMichal Meloun #ifdef TARGET_HAS_STAT_TIME_T_EXT 230ad805a77SMichal Meloun int32_t st_atim_ext; 231ad805a77SMichal Meloun #endif 232ad805a77SMichal Meloun struct target_freebsd_timespec st_atim; /* time of last access */ 233ad805a77SMichal Meloun #ifdef TARGET_HAS_STAT_TIME_T_EXT 234ad805a77SMichal Meloun int32_t st_mtim_ext; 235ad805a77SMichal Meloun #endif 236ad805a77SMichal Meloun struct target_freebsd_timespec st_mtim; /* time of last data modification */ 237ad805a77SMichal Meloun #ifdef TARGET_HAS_STAT_TIME_T_EXT 238ad805a77SMichal Meloun int32_t st_ctim_ext; 239ad805a77SMichal Meloun #endif 240ad805a77SMichal Meloun struct target_freebsd_timespec st_ctim;/* time of last file status change */ 241ad805a77SMichal Meloun #ifdef TARGET_HAS_STAT_TIME_T_EXT 242ad805a77SMichal Meloun int32_t st_btim_ext; 243ad805a77SMichal Meloun #endif 244ad805a77SMichal Meloun struct target_freebsd_timespec st_birthtim; /* time of file creation */ 245ad805a77SMichal Meloun int64_t st_size; /* file size, in bytes */ 246ad805a77SMichal Meloun int64_t st_blocks; /* blocks allocated for file */ 247ad805a77SMichal Meloun uint32_t st_blksize; /* optimal blocksize for I/O */ 248ad805a77SMichal Meloun uint32_t st_flags; /* user defined flags for file */ 249ad805a77SMichal Meloun uint64_t st_gen; /* file generation number */ 250ad805a77SMichal Meloun uint64_t st_spare[10]; 251ad805a77SMichal Meloun }; 252ad805a77SMichal Meloun 2531de075a0SStacey Son 2541de075a0SStacey Son /* struct nstat is the same as stat above but without the st_lspare field */ 2551de075a0SStacey Son struct target_freebsd11_nstat { 2561de075a0SStacey Son uint32_t st_dev; /* inode's device */ 2571de075a0SStacey Son uint32_t st_ino; /* inode's number */ 2581de075a0SStacey Son int16_t st_mode; /* inode protection mode */ 2591de075a0SStacey Son int16_t st_nlink; /* number of hard links */ 2601de075a0SStacey Son uint32_t st_uid; /* user ID of the file's owner */ 2611de075a0SStacey Son uint32_t st_gid; /* group ID of the file's group */ 2621de075a0SStacey Son uint32_t st_rdev; /* device type */ 2631de075a0SStacey Son struct target_freebsd_timespec st_atim; /* time last accessed */ 2641de075a0SStacey Son struct target_freebsd_timespec st_mtim; /* time last data modification */ 2651de075a0SStacey Son struct target_freebsd_timespec st_ctim; /* time last file status change */ 2661de075a0SStacey Son int64_t st_size; /* file size, in bytes */ 2671de075a0SStacey Son int64_t st_blocks; /* blocks allocated for file */ 2681de075a0SStacey Son uint32_t st_blksize; /* optimal blocksize for I/O */ 2691de075a0SStacey Son uint32_t st_flags; /* user defined flags for file */ 2701de075a0SStacey Son uint32_t st_gen; /* file generation number */ 2711de075a0SStacey Son struct target_freebsd_timespec st_birthtim; /* time of file creation */ 2721de075a0SStacey Son /* 2731de075a0SStacey Son * Explicitly pad st_birthtim to 16 bytes so that the size of 2741de075a0SStacey Son * struct stat is backwards compatible. We use bitfields instead 2751de075a0SStacey Son * of an array of chars so that this doesn't require a C99 compiler 2761de075a0SStacey Son * to compile if the size of the padding is 0. We use 2 bitfields 2771de075a0SStacey Son * to cover up to 64 bits on 32-bit machines. We assume that 2781de075a0SStacey Son * CHAR_BIT is 8... 2791de075a0SStacey Son */ 2801de075a0SStacey Son unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec)); 2811de075a0SStacey Son unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec)); 2821de075a0SStacey Son } __packed; 2831de075a0SStacey Son 2841de075a0SStacey Son /* 2851de075a0SStacey Son * sys/mount.h 2861de075a0SStacey Son */ 2871de075a0SStacey Son 2881de075a0SStacey Son /* filesystem id type */ 2891de075a0SStacey Son typedef struct target_freebsd_fsid { int32_t val[2]; } target_freebsd_fsid_t; 2901de075a0SStacey Son 2911de075a0SStacey Son /* filesystem statistics */ 2921de075a0SStacey Son struct target_freebsd11_statfs { 2931de075a0SStacey Son uint32_t f_version; /* structure version number */ 2941de075a0SStacey Son uint32_t f_type; /* type of filesystem */ 2951de075a0SStacey Son uint64_t f_flags; /* copy of mount exported flags */ 2961de075a0SStacey Son uint64_t f_bsize; /* filesystem fragment size */ 2971de075a0SStacey Son uint64_t f_iosize; /* optimal transfer block size */ 2981de075a0SStacey Son uint64_t f_blocks; /* total data blocks in filesystem */ 2991de075a0SStacey Son uint64_t f_bfree; /* free blocks in filesystem */ 3001de075a0SStacey Son int64_t f_bavail; /* free blocks avail to non-superuser */ 3011de075a0SStacey Son uint64_t f_files; /* total file nodes in filesystem */ 3021de075a0SStacey Son int64_t f_ffree; /* free nodes avail to non-superuser */ 3031de075a0SStacey Son uint64_t f_syncwrites; /* count of sync writes since mount */ 3041de075a0SStacey Son uint64_t f_asyncwrites; /* count of async writes since mount */ 3051de075a0SStacey Son uint64_t f_syncreads; /* count of sync reads since mount */ 3061de075a0SStacey Son uint64_t f_asyncreads; /* count of async reads since mount */ 3071de075a0SStacey Son uint64_t f_spare[10]; /* unused spare */ 3081de075a0SStacey Son uint32_t f_namemax; /* maximum filename length */ 3091de075a0SStacey Son uint32_t f_owner; /* user that mounted the filesystem */ 3101de075a0SStacey Son target_freebsd_fsid_t f_fsid; /* filesystem id */ 3111de075a0SStacey Son char f_charspare[80]; /* spare string space */ 3121de075a0SStacey Son char f_fstypename[16]; /* filesys type name */ 3131de075a0SStacey Son char f_mntfromname[88]; /* mount filesystem */ 3141de075a0SStacey Son char f_mntonname[88]; /* dir on which mounted*/ 3151de075a0SStacey Son }; 3161de075a0SStacey Son 31725efcda4SMichal Meloun struct target_statfs { 31825efcda4SMichal Meloun uint32_t f_version; /* structure version number */ 31925efcda4SMichal Meloun uint32_t f_type; /* type of filesystem */ 32025efcda4SMichal Meloun uint64_t f_flags; /* copy of mount exported flags */ 32125efcda4SMichal Meloun uint64_t f_bsize; /* filesystem fragment size */ 32225efcda4SMichal Meloun uint64_t f_iosize; /* optimal transfer block size */ 32325efcda4SMichal Meloun uint64_t f_blocks; /* total data blocks in filesystem */ 32425efcda4SMichal Meloun uint64_t f_bfree; /* free blocks in filesystem */ 32525efcda4SMichal Meloun int64_t f_bavail; /* free blocks avail to non-superuser */ 32625efcda4SMichal Meloun uint64_t f_files; /* total file nodes in filesystem */ 32725efcda4SMichal Meloun int64_t f_ffree; /* free nodes avail to non-superuser */ 32825efcda4SMichal Meloun uint64_t f_syncwrites; /* count of sync writes since mount */ 32925efcda4SMichal Meloun uint64_t f_asyncwrites; /* count of async writes since mount */ 33025efcda4SMichal Meloun uint64_t f_syncreads; /* count of sync reads since mount */ 33125efcda4SMichal Meloun uint64_t f_asyncreads; /* count of async reads since mount */ 33225efcda4SMichal Meloun uint64_t f_spare[10]; /* unused spare */ 33325efcda4SMichal Meloun uint32_t f_namemax; /* maximum filename length */ 33425efcda4SMichal Meloun uint32_t f_owner; /* user that mounted the filesystem */ 33525efcda4SMichal Meloun target_freebsd_fsid_t f_fsid; /* filesystem id */ 33625efcda4SMichal Meloun char f_charspare[80]; /* spare string space */ 33725efcda4SMichal Meloun char f_fstypename[16]; /* filesystem type name */ 33825efcda4SMichal Meloun char f_mntfromname[1024]; /* mounted filesystem */ 33925efcda4SMichal Meloun char f_mntonname[1024]; /* directory on which mounted */ 34025efcda4SMichal Meloun }; 34125efcda4SMichal Meloun 34254d07b44SStacey Son /* File identifier. These are unique per filesystem on a single machine. */ 34354d07b44SStacey Son #define TARGET_MAXFIDSZ 16 34454d07b44SStacey Son 34554d07b44SStacey Son struct target_freebsd_fid { 34654d07b44SStacey Son uint16_t fid_len; /* len of data in bytes */ 34754d07b44SStacey Son uint16_t fid_data0; /* force longword align */ 34854d07b44SStacey Son char fid_data[TARGET_MAXFIDSZ]; /* data (variable len) */ 34954d07b44SStacey Son }; 35054d07b44SStacey Son 35154d07b44SStacey Son /* Generic file handle */ 35254d07b44SStacey Son struct target_freebsd_fhandle { 35354d07b44SStacey Son target_freebsd_fsid_t fh_fsid; /* Filesystem id of mount point */ 35454d07b44SStacey Son struct target_freebsd_fid fh_fid; /* Filesys specific id */ 35554d07b44SStacey Son }; 35654d07b44SStacey Son typedef struct target_freebsd_fhandle target_freebsd_fhandle_t; 35754d07b44SStacey Son 35854d07b44SStacey Son /* 35954d07b44SStacey Son * sys/fcntl.h 36054d07b44SStacey Son */ 36154d07b44SStacey Son #define TARGET_F_DUPFD 0 36254d07b44SStacey Son #define TARGET_F_GETFD 1 36354d07b44SStacey Son #define TARGET_F_SETFD 2 36454d07b44SStacey Son #define TARGET_F_GETFL 3 36554d07b44SStacey Son #define TARGET_F_SETFL 4 36654d07b44SStacey Son #define TARGET_F_GETOWN 5 36754d07b44SStacey Son #define TARGET_F_SETOWN 6 36854d07b44SStacey Son #define TARGET_F_OGETLK 7 36954d07b44SStacey Son #define TARGET_F_OSETLK 8 37054d07b44SStacey Son #define TARGET_F_OSETLKW 9 37154d07b44SStacey Son #define TARGET_F_DUP2FD 10 37254d07b44SStacey Son #define TARGET_F_GETLK 11 37354d07b44SStacey Son #define TARGET_F_SETLK 12 37454d07b44SStacey Son #define TARGET_F_SETLKW 13 37554d07b44SStacey Son #define TARGET_F_SETLK_REMOTE 14 37654d07b44SStacey Son #define TARGET_F_READAHEAD 15 37754d07b44SStacey Son #define TARGET_F_RDAHEAD 16 37854d07b44SStacey Son #define TARGET_F_DUPFD_CLOEXEC 17 37954d07b44SStacey Son #define TARGET_F_DUP2FD_CLOEXEC 18 38054d07b44SStacey Son /* FreeBSD-specific */ 38154d07b44SStacey Son #define TARGET_F_ADD_SEALS 19 38254d07b44SStacey Son #define TARGET_F_GET_SEALS 20 38354d07b44SStacey Son 38454d07b44SStacey Son struct target_freebsd_flock { 38554d07b44SStacey Son int64_t l_start; 38654d07b44SStacey Son int64_t l_len; 38754d07b44SStacey Son int32_t l_pid; 38854d07b44SStacey Son int16_t l_type; 38954d07b44SStacey Son int16_t l_whence; 39054d07b44SStacey Son int32_t l_sysid; 39154d07b44SStacey Son } QEMU_PACKED; 39254d07b44SStacey Son 393a5b88166SWarner Losh #define safe_syscall0(type, name) \ 394a5b88166SWarner Losh type safe_##name(void) \ 395a5b88166SWarner Losh { \ 396a5b88166SWarner Losh return safe_syscall(SYS_##name); \ 397a5b88166SWarner Losh } 398a5b88166SWarner Losh 399a5b88166SWarner Losh #define safe_syscall1(type, name, type1, arg1) \ 400a5b88166SWarner Losh type safe_##name(type1 arg1) \ 401a5b88166SWarner Losh { \ 402a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1); \ 403a5b88166SWarner Losh } 404a5b88166SWarner Losh 405a5b88166SWarner Losh #define safe_syscall2(type, name, type1, arg1, type2, arg2) \ 406a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2) \ 407a5b88166SWarner Losh { \ 408a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2); \ 409a5b88166SWarner Losh } 410a5b88166SWarner Losh 411a5b88166SWarner Losh #define safe_syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \ 412a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2, type3 arg3) \ 413a5b88166SWarner Losh { \ 414a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2, arg3); \ 415a5b88166SWarner Losh } 416a5b88166SWarner Losh 417a5b88166SWarner Losh #define safe_syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \ 418a5b88166SWarner Losh type4, arg4) \ 419a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ 420a5b88166SWarner Losh { \ 421a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4); \ 422a5b88166SWarner Losh } 423a5b88166SWarner Losh 424a5b88166SWarner Losh #define safe_syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \ 425a5b88166SWarner Losh type4, arg4, type5, arg5) \ 426a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 427a5b88166SWarner Losh type5 arg5) \ 428a5b88166SWarner Losh { \ 429a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5); \ 430a5b88166SWarner Losh } 431a5b88166SWarner Losh 432a5b88166SWarner Losh #define safe_syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \ 433a5b88166SWarner Losh type4, arg4, type5, arg5, type6, arg6) \ 434a5b88166SWarner Losh type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ 435a5b88166SWarner Losh type5 arg5, type6 arg6) \ 436a5b88166SWarner Losh { \ 437a5b88166SWarner Losh return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5, arg6); \ 438a5b88166SWarner Losh } 439a5b88166SWarner Losh 440243c725fSKyle Evans #define safe_fcntl(...) safe_syscall(SYS_fcntl, __VA_ARGS__) 441243c725fSKyle Evans 44277d3522bSWarner Losh /* So far all target and host bitmasks are the same */ 443a05cee93SRichard Henderson #undef target_to_host_bitmask 44477d3522bSWarner Losh #define target_to_host_bitmask(x, tbl) (x) 445a05cee93SRichard Henderson #undef host_to_target_bitmask 44677d3522bSWarner Losh #define host_to_target_bitmask(x, tbl) (x) 44777d3522bSWarner Losh 4489c092804SMarkus Armbruster #endif /* SYSCALL_DEFS_H */ 449