1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2001 Doug Rabson 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $FreeBSD$ 29 */ 30 31 #ifndef _COMPAT_FREEBSD32_FREEBSD32_H_ 32 #define _COMPAT_FREEBSD32_FREEBSD32_H_ 33 34 #include <sys/abi_compat.h> 35 #include <sys/procfs.h> 36 #include <sys/socket.h> 37 #include <sys/user.h> 38 #include <sys/_ffcounter.h> 39 40 /* 41 * i386 is the only arch with a 32-bit time_t 42 */ 43 #ifdef __amd64__ 44 typedef int32_t time32_t; 45 #else 46 typedef int64_t time32_t; 47 #endif 48 49 struct timeval32 { 50 time32_t tv_sec; 51 int32_t tv_usec; 52 }; 53 54 struct timespec32 { 55 time32_t tv_sec; 56 int32_t tv_nsec; 57 }; 58 59 struct itimerspec32 { 60 struct timespec32 it_interval; 61 struct timespec32 it_value; 62 }; 63 64 struct bintime32 { 65 time32_t sec; 66 uint32_t frac[2]; 67 }; 68 69 struct ffclock_estimate32 { 70 struct bintime32 update_time; 71 ffcounter update_ffcount; 72 ffcounter leapsec_next; 73 uint64_t period; 74 uint32_t errb_abs; 75 uint32_t errb_rate; 76 uint32_t status; 77 int16_t leapsec_total; 78 int8_t leapsec; 79 int8_t _pad; 80 } 81 #if defined(__amd64__) 82 __attribute__((packed)) 83 #endif 84 ; 85 #if defined(__amd64__) 86 _Static_assert(sizeof(struct ffclock_estimate32) == 52, "ffclock_estimate32 size"); 87 #else 88 _Static_assert(sizeof(struct ffclock_estimate32) == 56, "ffclock_estimate32 size"); 89 #endif 90 91 struct rusage32 { 92 struct timeval32 ru_utime; 93 struct timeval32 ru_stime; 94 int32_t ru_maxrss; 95 int32_t ru_ixrss; 96 int32_t ru_idrss; 97 int32_t ru_isrss; 98 int32_t ru_minflt; 99 int32_t ru_majflt; 100 int32_t ru_nswap; 101 int32_t ru_inblock; 102 int32_t ru_oublock; 103 int32_t ru_msgsnd; 104 int32_t ru_msgrcv; 105 int32_t ru_nsignals; 106 int32_t ru_nvcsw; 107 int32_t ru_nivcsw; 108 }; 109 110 struct __wrusage32 { 111 struct rusage32 wru_self; 112 struct rusage32 wru_children; 113 }; 114 115 struct itimerval32 { 116 struct timeval32 it_interval; 117 struct timeval32 it_value; 118 }; 119 120 struct umtx_time32 { 121 struct timespec32 _timeout; 122 uint32_t _flags; 123 uint32_t _clockid; 124 }; 125 126 struct umtx_robust_lists_params_compat32 { 127 uint32_t robust_list_offset; 128 uint32_t robust_priv_list_offset; 129 uint32_t robust_inact_offset; 130 }; 131 132 struct umutex32 { 133 volatile __lwpid_t m_owner; /* Owner of the mutex */ 134 __uint32_t m_flags; /* Flags of the mutex */ 135 __uint32_t m_ceilings[2]; /* Priority protect ceiling */ 136 __uint32_t m_rb_lnk; /* Robust linkage */ 137 __uint32_t m_pad; 138 __uint32_t m_spare[2]; 139 }; 140 141 #define FREEBSD4_OMFSNAMELEN 16 142 #define FREEBSD4_OMNAMELEN (88 - 2 * sizeof(int32_t)) 143 144 /* 4.x version */ 145 struct ostatfs32 { 146 int32_t f_spare2; 147 int32_t f_bsize; 148 int32_t f_iosize; 149 int32_t f_blocks; 150 int32_t f_bfree; 151 int32_t f_bavail; 152 int32_t f_files; 153 int32_t f_ffree; 154 fsid_t f_fsid; 155 uid_t f_owner; 156 int32_t f_type; 157 int32_t f_flags; 158 int32_t f_syncwrites; 159 int32_t f_asyncwrites; 160 char f_fstypename[FREEBSD4_OMFSNAMELEN]; 161 char f_mntonname[FREEBSD4_OMNAMELEN]; 162 int32_t f_syncreads; 163 int32_t f_asyncreads; 164 int16_t f_spares1; 165 char f_mntfromname[FREEBSD4_OMNAMELEN]; 166 int16_t f_spares2 __packed; 167 int32_t f_spare[2]; 168 }; 169 170 struct iovec32 { 171 u_int32_t iov_base; 172 int iov_len; 173 }; 174 175 struct msghdr32 { 176 u_int32_t msg_name; 177 socklen_t msg_namelen; 178 u_int32_t msg_iov; 179 int msg_iovlen; 180 u_int32_t msg_control; 181 socklen_t msg_controllen; 182 int msg_flags; 183 }; 184 185 #if defined(__amd64__) 186 #define __STAT32_TIME_T_EXT 1 187 #endif 188 189 struct stat32 { 190 dev_t st_dev; 191 ino_t st_ino; 192 nlink_t st_nlink; 193 mode_t st_mode; 194 u_int16_t st_padding0; 195 uid_t st_uid; 196 gid_t st_gid; 197 u_int32_t st_padding1; 198 dev_t st_rdev; 199 #ifdef __STAT32_TIME_T_EXT 200 __int32_t st_atim_ext; 201 #endif 202 struct timespec32 st_atim; 203 #ifdef __STAT32_TIME_T_EXT 204 __int32_t st_mtim_ext; 205 #endif 206 struct timespec32 st_mtim; 207 #ifdef __STAT32_TIME_T_EXT 208 __int32_t st_ctim_ext; 209 #endif 210 struct timespec32 st_ctim; 211 #ifdef __STAT32_TIME_T_EXT 212 __int32_t st_btim_ext; 213 #endif 214 struct timespec32 st_birthtim; 215 off_t st_size; 216 int64_t st_blocks; 217 u_int32_t st_blksize; 218 u_int32_t st_flags; 219 u_int64_t st_gen; 220 u_int64_t st_spare[10]; 221 }; 222 struct freebsd11_stat32 { 223 u_int32_t st_dev; 224 u_int32_t st_ino; 225 mode_t st_mode; 226 u_int16_t st_nlink; 227 uid_t st_uid; 228 gid_t st_gid; 229 u_int32_t st_rdev; 230 struct timespec32 st_atim; 231 struct timespec32 st_mtim; 232 struct timespec32 st_ctim; 233 off_t st_size; 234 int64_t st_blocks; 235 u_int32_t st_blksize; 236 u_int32_t st_flags; 237 u_int32_t st_gen; 238 int32_t st_lspare; 239 struct timespec32 st_birthtim; 240 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32)); 241 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32)); 242 }; 243 244 struct ostat32 { 245 __uint16_t st_dev; 246 __uint32_t st_ino; 247 mode_t st_mode; 248 __uint16_t st_nlink; 249 __uint16_t st_uid; 250 __uint16_t st_gid; 251 __uint16_t st_rdev; 252 __int32_t st_size; 253 struct timespec32 st_atim; 254 struct timespec32 st_mtim; 255 struct timespec32 st_ctim; 256 __int32_t st_blksize; 257 __int32_t st_blocks; 258 u_int32_t st_flags; 259 __uint32_t st_gen; 260 }; 261 262 struct jail32_v0 { 263 u_int32_t version; 264 uint32_t path; 265 uint32_t hostname; 266 u_int32_t ip_number; 267 }; 268 269 struct jail32 { 270 uint32_t version; 271 uint32_t path; 272 uint32_t hostname; 273 uint32_t jailname; 274 uint32_t ip4s; 275 uint32_t ip6s; 276 uint32_t ip4; 277 uint32_t ip6; 278 }; 279 280 struct sigaction32 { 281 u_int32_t sa_u; 282 int sa_flags; 283 sigset_t sa_mask; 284 }; 285 286 struct thr_param32 { 287 uint32_t start_func; 288 uint32_t arg; 289 uint32_t stack_base; 290 uint32_t stack_size; 291 uint32_t tls_base; 292 uint32_t tls_size; 293 uint32_t child_tid; 294 uint32_t parent_tid; 295 int32_t flags; 296 uint32_t rtp; 297 uint32_t spare[3]; 298 }; 299 300 struct i386_ldt_args32 { 301 uint32_t start; 302 uint32_t descs; 303 uint32_t num; 304 }; 305 306 struct mq_attr32 { 307 int mq_flags; 308 int mq_maxmsg; 309 int mq_msgsize; 310 int mq_curmsgs; 311 int __reserved[4]; 312 }; 313 314 struct kinfo_proc32 { 315 int ki_structsize; 316 int ki_layout; 317 uint32_t ki_args; 318 uint32_t ki_paddr; 319 uint32_t ki_addr; 320 uint32_t ki_tracep; 321 uint32_t ki_textvp; 322 uint32_t ki_fd; 323 uint32_t ki_vmspace; 324 uint32_t ki_wchan; 325 pid_t ki_pid; 326 pid_t ki_ppid; 327 pid_t ki_pgid; 328 pid_t ki_tpgid; 329 pid_t ki_sid; 330 pid_t ki_tsid; 331 short ki_jobc; 332 short ki_spare_short1; 333 uint32_t ki_tdev_freebsd11; 334 sigset_t ki_siglist; 335 sigset_t ki_sigmask; 336 sigset_t ki_sigignore; 337 sigset_t ki_sigcatch; 338 uid_t ki_uid; 339 uid_t ki_ruid; 340 uid_t ki_svuid; 341 gid_t ki_rgid; 342 gid_t ki_svgid; 343 short ki_ngroups; 344 short ki_spare_short2; 345 gid_t ki_groups[KI_NGROUPS]; 346 uint32_t ki_size; 347 int32_t ki_rssize; 348 int32_t ki_swrss; 349 int32_t ki_tsize; 350 int32_t ki_dsize; 351 int32_t ki_ssize; 352 u_short ki_xstat; 353 u_short ki_acflag; 354 fixpt_t ki_pctcpu; 355 u_int ki_estcpu; 356 u_int ki_slptime; 357 u_int ki_swtime; 358 u_int ki_cow; 359 u_int64_t ki_runtime; 360 struct timeval32 ki_start; 361 struct timeval32 ki_childtime; 362 int ki_flag; 363 int ki_kiflag; 364 int ki_traceflag; 365 char ki_stat; 366 signed char ki_nice; 367 char ki_lock; 368 char ki_rqindex; 369 u_char ki_oncpu_old; 370 u_char ki_lastcpu_old; 371 char ki_tdname[TDNAMLEN+1]; 372 char ki_wmesg[WMESGLEN+1]; 373 char ki_login[LOGNAMELEN+1]; 374 char ki_lockname[LOCKNAMELEN+1]; 375 char ki_comm[COMMLEN+1]; 376 char ki_emul[KI_EMULNAMELEN+1]; 377 char ki_loginclass[LOGINCLASSLEN+1]; 378 char ki_moretdname[MAXCOMLEN-TDNAMLEN+1]; 379 char ki_sparestrings[46]; 380 int ki_spareints[KI_NSPARE_INT]; 381 uint64_t ki_tdev; 382 int ki_oncpu; 383 int ki_lastcpu; 384 int ki_tracer; 385 int ki_flag2; 386 int ki_fibnum; 387 u_int ki_cr_flags; 388 int ki_jid; 389 int ki_numthreads; 390 lwpid_t ki_tid; 391 struct priority ki_pri; 392 struct rusage32 ki_rusage; 393 struct rusage32 ki_rusage_ch; 394 uint32_t ki_pcb; 395 uint32_t ki_kstack; 396 uint32_t ki_udata; 397 uint32_t ki_tdaddr; 398 uint32_t ki_spareptrs[KI_NSPARE_PTR]; /* spare room for growth */ 399 int ki_sparelongs[KI_NSPARE_LONG]; 400 int ki_sflag; 401 int ki_tdflags; 402 }; 403 404 struct kinfo_sigtramp32 { 405 uint32_t ksigtramp_start; 406 uint32_t ksigtramp_end; 407 uint32_t ksigtramp_spare[4]; 408 }; 409 410 struct kld_file_stat_1_32 { 411 int version; /* set to sizeof(struct kld_file_stat_1) */ 412 char name[MAXPATHLEN]; 413 int refs; 414 int id; 415 uint32_t address; /* load address */ 416 uint32_t size; /* size in bytes */ 417 }; 418 419 struct kld_file_stat32 { 420 int version; /* set to sizeof(struct kld_file_stat) */ 421 char name[MAXPATHLEN]; 422 int refs; 423 int id; 424 uint32_t address; /* load address */ 425 uint32_t size; /* size in bytes */ 426 char pathname[MAXPATHLEN]; 427 }; 428 429 struct procctl_reaper_pids32 { 430 u_int rp_count; 431 u_int rp_pad0[15]; 432 uint32_t rp_pids; 433 }; 434 435 struct timex32 { 436 unsigned int modes; 437 int32_t offset; 438 int32_t freq; 439 int32_t maxerror; 440 int32_t esterror; 441 int status; 442 int32_t constant; 443 int32_t precision; 444 int32_t tolerance; 445 int32_t ppsfreq; 446 int32_t jitter; 447 int shift; 448 int32_t stabil; 449 int32_t jitcnt; 450 int32_t calcnt; 451 int32_t errcnt; 452 int32_t stbcnt; 453 }; 454 455 struct ptrace_coredump32 { 456 int pc_fd; 457 uint32_t pc_flags; 458 uint32_t pc_limit1, pc_limit2; 459 }; 460 461 #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */ 462