1 /*- 2 * Copyright (c) 2001 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD$ 27 */ 28 29 #ifndef _COMPAT_FREEBSD32_FREEBSD32_H_ 30 #define _COMPAT_FREEBSD32_FREEBSD32_H_ 31 32 #include <sys/procfs.h> 33 #include <sys/socket.h> 34 #include <sys/user.h> 35 36 #define PTRIN(v) (void *)(uintptr_t) (v) 37 #define PTROUT(v) (u_int32_t)(uintptr_t) (v) 38 39 #define CP(src,dst,fld) do { (dst).fld = (src).fld; } while (0) 40 #define PTRIN_CP(src,dst,fld) \ 41 do { (dst).fld = PTRIN((src).fld); } while (0) 42 #define PTROUT_CP(src,dst,fld) \ 43 do { (dst).fld = PTROUT((src).fld); } while (0) 44 45 struct timeval32 { 46 int32_t tv_sec; 47 int32_t tv_usec; 48 }; 49 #define TV_CP(src,dst,fld) do { \ 50 CP((src).fld,(dst).fld,tv_sec); \ 51 CP((src).fld,(dst).fld,tv_usec); \ 52 } while (0) 53 54 struct timespec32 { 55 u_int32_t tv_sec; 56 u_int32_t tv_nsec; 57 }; 58 #define TS_CP(src,dst,fld) do { \ 59 CP((src).fld,(dst).fld,tv_sec); \ 60 CP((src).fld,(dst).fld,tv_nsec); \ 61 } while (0); 62 63 struct rusage32 { 64 struct timeval32 ru_utime; 65 struct timeval32 ru_stime; 66 int32_t ru_maxrss; 67 int32_t ru_ixrss; 68 int32_t ru_idrss; 69 int32_t ru_isrss; 70 int32_t ru_minflt; 71 int32_t ru_majflt; 72 int32_t ru_nswap; 73 int32_t ru_inblock; 74 int32_t ru_oublock; 75 int32_t ru_msgsnd; 76 int32_t ru_msgrcv; 77 int32_t ru_nsignals; 78 int32_t ru_nvcsw; 79 int32_t ru_nivcsw; 80 }; 81 82 struct itimerval32 { 83 struct timeval32 it_interval; 84 struct timeval32 it_value; 85 }; 86 87 #define FREEBSD4_MNAMELEN (88 - 2 * sizeof(int32_t)) /* size of on/from name bufs */ 88 89 /* 4.x version */ 90 struct statfs32 { 91 int32_t f_spare2; 92 int32_t f_bsize; 93 int32_t f_iosize; 94 int32_t f_blocks; 95 int32_t f_bfree; 96 int32_t f_bavail; 97 int32_t f_files; 98 int32_t f_ffree; 99 fsid_t f_fsid; 100 uid_t f_owner; 101 int32_t f_type; 102 int32_t f_flags; 103 int32_t f_syncwrites; 104 int32_t f_asyncwrites; 105 char f_fstypename[MFSNAMELEN]; 106 char f_mntonname[FREEBSD4_MNAMELEN]; 107 int32_t f_syncreads; 108 int32_t f_asyncreads; 109 int16_t f_spares1; 110 char f_mntfromname[FREEBSD4_MNAMELEN]; 111 int16_t f_spares2 __packed; 112 int32_t f_spare[2]; 113 }; 114 115 struct kevent32 { 116 u_int32_t ident; /* identifier for this event */ 117 short filter; /* filter for event */ 118 u_short flags; 119 u_int fflags; 120 int32_t data; 121 u_int32_t udata; /* opaque user data identifier */ 122 }; 123 124 struct iovec32 { 125 u_int32_t iov_base; 126 int iov_len; 127 }; 128 129 struct msghdr32 { 130 u_int32_t msg_name; 131 socklen_t msg_namelen; 132 u_int32_t msg_iov; 133 int msg_iovlen; 134 u_int32_t msg_control; 135 socklen_t msg_controllen; 136 int msg_flags; 137 }; 138 139 struct stat32 { 140 dev_t st_dev; 141 ino_t st_ino; 142 mode_t st_mode; 143 nlink_t st_nlink; 144 uid_t st_uid; 145 gid_t st_gid; 146 dev_t st_rdev; 147 struct timespec32 st_atim; 148 struct timespec32 st_mtim; 149 struct timespec32 st_ctim; 150 off_t st_size; 151 int64_t st_blocks; 152 u_int32_t st_blksize; 153 u_int32_t st_flags; 154 u_int32_t st_gen; 155 struct timespec32 st_birthtim; 156 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32)); 157 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32)); 158 }; 159 160 struct ostat32 { 161 __uint16_t st_dev; 162 ino_t st_ino; 163 mode_t st_mode; 164 nlink_t st_nlink; 165 __uint16_t st_uid; 166 __uint16_t st_gid; 167 __uint16_t st_rdev; 168 __int32_t st_size; 169 struct timespec32 st_atim; 170 struct timespec32 st_mtim; 171 struct timespec32 st_ctim; 172 __int32_t st_blksize; 173 __int32_t st_blocks; 174 u_int32_t st_flags; 175 __uint32_t st_gen; 176 }; 177 178 struct jail32_v0 { 179 u_int32_t version; 180 uint32_t path; 181 uint32_t hostname; 182 u_int32_t ip_number; 183 }; 184 185 struct jail32 { 186 uint32_t version; 187 uint32_t path; 188 uint32_t hostname; 189 uint32_t jailname; 190 uint32_t ip4s; 191 uint32_t ip6s; 192 uint32_t ip4; 193 uint32_t ip6; 194 }; 195 196 struct sigaction32 { 197 u_int32_t sa_u; 198 int sa_flags; 199 sigset_t sa_mask; 200 }; 201 202 struct thr_param32 { 203 uint32_t start_func; 204 uint32_t arg; 205 uint32_t stack_base; 206 uint32_t stack_size; 207 uint32_t tls_base; 208 uint32_t tls_size; 209 uint32_t child_tid; 210 uint32_t parent_tid; 211 int32_t flags; 212 uint32_t rtp; 213 uint32_t spare[3]; 214 }; 215 216 struct i386_ldt_args32 { 217 uint32_t start; 218 uint32_t descs; 219 uint32_t num; 220 }; 221 222 /* 223 * Alternative layouts for <sys/procfs.h> 224 */ 225 struct prstatus32 { 226 int pr_version; 227 u_int pr_statussz; 228 u_int pr_gregsetsz; 229 u_int pr_fpregsetsz; 230 int pr_osreldate; 231 int pr_cursig; 232 pid_t pr_pid; 233 struct reg32 pr_reg; 234 }; 235 236 struct prpsinfo32 { 237 int pr_version; 238 u_int pr_psinfosz; 239 char pr_fname[PRFNAMESZ+1]; 240 char pr_psargs[PRARGSZ+1]; 241 }; 242 243 struct mq_attr32 { 244 int mq_flags; 245 int mq_maxmsg; 246 int mq_msgsize; 247 int mq_curmsgs; 248 int __reserved[4]; 249 }; 250 251 struct kinfo_proc32 { 252 int ki_structsize; 253 int ki_layout; 254 uint32_t ki_args; 255 uint32_t ki_paddr; 256 uint32_t ki_addr; 257 uint32_t ki_tracep; 258 uint32_t ki_textvp; 259 uint32_t ki_fd; 260 uint32_t ki_vmspace; 261 uint32_t ki_wchan; 262 pid_t ki_pid; 263 pid_t ki_ppid; 264 pid_t ki_pgid; 265 pid_t ki_tpgid; 266 pid_t ki_sid; 267 pid_t ki_tsid; 268 short ki_jobc; 269 short ki_spare_short1; 270 dev_t ki_tdev; 271 sigset_t ki_siglist; 272 sigset_t ki_sigmask; 273 sigset_t ki_sigignore; 274 sigset_t ki_sigcatch; 275 uid_t ki_uid; 276 uid_t ki_ruid; 277 uid_t ki_svuid; 278 gid_t ki_rgid; 279 gid_t ki_svgid; 280 short ki_ngroups; 281 short ki_spare_short2; 282 gid_t ki_groups[KI_NGROUPS]; 283 uint32_t ki_size; 284 int32_t ki_rssize; 285 int32_t ki_swrss; 286 int32_t ki_tsize; 287 int32_t ki_dsize; 288 int32_t ki_ssize; 289 u_short ki_xstat; 290 u_short ki_acflag; 291 fixpt_t ki_pctcpu; 292 u_int ki_estcpu; 293 u_int ki_slptime; 294 u_int ki_swtime; 295 int ki_spareint1; 296 u_int64_t ki_runtime; 297 struct timeval32 ki_start; 298 struct timeval32 ki_childtime; 299 int ki_flag; 300 int ki_kiflag; 301 int ki_traceflag; 302 char ki_stat; 303 signed char ki_nice; 304 char ki_lock; 305 char ki_rqindex; 306 u_char ki_oncpu; 307 u_char ki_lastcpu; 308 char ki_ocomm[OCOMMLEN+1]; 309 char ki_wmesg[WMESGLEN+1]; 310 char ki_login[LOGNAMELEN+1]; 311 char ki_lockname[LOCKNAMELEN+1]; 312 char ki_comm[COMMLEN+1]; 313 char ki_emul[KI_EMULNAMELEN+1]; 314 char ki_sparestrings[68]; 315 int ki_spareints[KI_NSPARE_INT]; 316 u_int ki_cr_flags; 317 int ki_jid; 318 int ki_numthreads; 319 lwpid_t ki_tid; 320 struct priority ki_pri; 321 struct rusage32 ki_rusage; 322 struct rusage32 ki_rusage_ch; 323 uint32_t ki_pcb; 324 uint32_t ki_kstack; 325 uint32_t ki_udata; 326 uint32_t ki_spareptrs[KI_NSPARE_PTR]; /* spare room for growth */ 327 int ki_sparelongs[KI_NSPARE_LONG]; 328 int ki_sflag; 329 int ki_tdflags; 330 }; 331 332 #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */ 333