1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 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 29 #ifndef _COMPAT_FREEBSD32_FREEBSD32_H_ 30 #define _COMPAT_FREEBSD32_FREEBSD32_H_ 31 32 #include <sys/abi_compat.h> 33 #include <sys/devicestat.h> 34 #include <sys/event.h> 35 #include <sys/mount.h> 36 #include <sys/procfs.h> 37 #include <sys/socket.h> 38 #include <sys/user.h> 39 #include <sys/_ffcounter.h> 40 41 struct timeval32 { 42 time32_t tv_sec; 43 int32_t tv_usec; 44 }; 45 46 struct timespec32 { 47 time32_t tv_sec; 48 int32_t tv_nsec; 49 }; 50 51 struct itimerspec32 { 52 struct timespec32 it_interval; 53 struct timespec32 it_value; 54 }; 55 56 struct bintime32 { 57 time32_t sec; 58 freebsd32_uint64_t frac; 59 }; 60 61 struct ffclock_estimate32 { 62 struct bintime32 update_time; 63 ffcounter update_ffcount; 64 ffcounter leapsec_next; 65 freebsd32_uint64_t period; 66 uint32_t errb_abs; 67 uint32_t errb_rate; 68 uint32_t status; 69 int16_t leapsec_total; 70 int8_t leapsec; 71 int8_t _pad; 72 } 73 #if defined(__amd64__) 74 __attribute__((packed)) 75 #endif 76 ; 77 #if defined(__amd64__) || defined(__i386__) 78 _Static_assert(sizeof(struct ffclock_estimate32) == 52, "ffclock_estimate32 size"); 79 #else 80 _Static_assert(sizeof(struct ffclock_estimate32) == 56, "ffclock_estimate32 size"); 81 #endif 82 83 struct rusage32 { 84 struct timeval32 ru_utime; 85 struct timeval32 ru_stime; 86 int32_t ru_maxrss; 87 int32_t ru_ixrss; 88 int32_t ru_idrss; 89 int32_t ru_isrss; 90 int32_t ru_minflt; 91 int32_t ru_majflt; 92 int32_t ru_nswap; 93 int32_t ru_inblock; 94 int32_t ru_oublock; 95 int32_t ru_msgsnd; 96 int32_t ru_msgrcv; 97 int32_t ru_nsignals; 98 int32_t ru_nvcsw; 99 int32_t ru_nivcsw; 100 }; 101 102 struct __wrusage32 { 103 struct rusage32 wru_self; 104 struct rusage32 wru_children; 105 }; 106 107 struct itimerval32 { 108 struct timeval32 it_interval; 109 struct timeval32 it_value; 110 }; 111 112 struct umtx_time32 { 113 struct timespec32 _timeout; 114 uint32_t _flags; 115 uint32_t _clockid; 116 }; 117 118 struct umtx_robust_lists_params_compat32 { 119 uint32_t robust_list_offset; 120 uint32_t robust_priv_list_offset; 121 uint32_t robust_inact_offset; 122 }; 123 124 struct umutex32 { 125 volatile __lwpid_t m_owner; /* Owner of the mutex */ 126 __uint32_t m_flags; /* Flags of the mutex */ 127 __uint32_t m_ceilings[2]; /* Priority protect ceiling */ 128 __uint32_t m_rb_lnk; /* Robust linkage */ 129 __uint32_t m_pad; 130 __uint32_t m_spare[2]; 131 }; 132 133 #define FREEBSD4_OMFSNAMELEN 16 134 #define FREEBSD4_OMNAMELEN (88 - 2 * sizeof(int32_t)) 135 136 /* 4.x version */ 137 struct ostatfs32 { 138 int32_t f_spare2; 139 int32_t f_bsize; 140 int32_t f_iosize; 141 int32_t f_blocks; 142 int32_t f_bfree; 143 int32_t f_bavail; 144 int32_t f_files; 145 int32_t f_ffree; 146 fsid_t f_fsid; 147 uid_t f_owner; 148 int32_t f_type; 149 int32_t f_flags; 150 int32_t f_syncwrites; 151 int32_t f_asyncwrites; 152 char f_fstypename[FREEBSD4_OMFSNAMELEN]; 153 char f_mntonname[FREEBSD4_OMNAMELEN]; 154 int32_t f_syncreads; 155 int32_t f_asyncreads; 156 int16_t f_spares1; 157 char f_mntfromname[FREEBSD4_OMNAMELEN]; 158 int16_t f_spares2 __packed; 159 int32_t f_spare[2]; 160 }; 161 162 struct nstat32 { 163 __uint32_t st_dev; /* inode's device */ 164 __uint32_t st_ino; /* inode's number */ 165 __uint32_t st_mode; /* inode protection mode */ 166 __uint32_t st_nlink; /* number of hard links */ 167 uid_t st_uid; /* user ID of the file's owner */ 168 gid_t st_gid; /* group ID of the file's group */ 169 __uint32_t st_rdev; /* device type */ 170 struct timespec32 st_atim; /* time of last access */ 171 struct timespec32 st_mtim; /* time of last data modification */ 172 struct timespec32 st_ctim; /* time of last file status change */ 173 off_t st_size; /* file size, in bytes */ 174 blkcnt_t st_blocks; /* blocks allocated for file */ 175 blksize_t st_blksize; /* optimal blocksize for I/O */ 176 fflags_t st_flags; /* user defined flags for file */ 177 __uint32_t st_gen; /* file generation number */ 178 struct timespec32 st_birthtim; /* time of file creation */ 179 /* 180 * See comment in the definition of struct freebsd11_stat 181 * in sys/stat.h about the following padding. 182 */ 183 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32)); 184 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32)); 185 }; 186 187 struct iovec32 { 188 uint32_t iov_base; 189 int iov_len; 190 }; 191 192 struct msghdr32 { 193 uint32_t msg_name; 194 socklen_t msg_namelen; 195 uint32_t msg_iov; 196 int msg_iovlen; 197 uint32_t msg_control; 198 socklen_t msg_controllen; 199 int msg_flags; 200 }; 201 202 #if defined(__amd64__) 203 #define __STAT32_TIME_T_EXT 1 204 #endif 205 206 struct stat32 { 207 dev_t st_dev; 208 ino_t st_ino; 209 nlink_t st_nlink; 210 mode_t st_mode; 211 uint16_t st_bsdflags; 212 uid_t st_uid; 213 gid_t st_gid; 214 uint32_t st_padding1; 215 dev_t st_rdev; 216 #ifdef __STAT32_TIME_T_EXT 217 __int32_t st_atim_ext; 218 #endif 219 struct timespec32 st_atim; 220 #ifdef __STAT32_TIME_T_EXT 221 __int32_t st_mtim_ext; 222 #endif 223 struct timespec32 st_mtim; 224 #ifdef __STAT32_TIME_T_EXT 225 __int32_t st_ctim_ext; 226 #endif 227 struct timespec32 st_ctim; 228 #ifdef __STAT32_TIME_T_EXT 229 __int32_t st_btim_ext; 230 #endif 231 struct timespec32 st_birthtim; 232 off_t st_size; 233 freebsd32_uint64_t st_blocks; 234 uint32_t st_blksize; 235 uint32_t st_flags; 236 freebsd32_uint64_t st_gen; 237 freebsd32_uint64_t st_filerev; 238 freebsd32_uint64_t st_spare[9]; 239 }; 240 struct freebsd11_stat32 { 241 uint32_t st_dev; 242 uint32_t st_ino; 243 mode_t st_mode; 244 uint16_t st_nlink; 245 uid_t st_uid; 246 gid_t st_gid; 247 uint32_t st_rdev; 248 struct timespec32 st_atim; 249 struct timespec32 st_mtim; 250 struct timespec32 st_ctim; 251 off_t st_size; 252 freebsd32_uint64_t st_blocks; 253 uint32_t st_blksize; 254 uint32_t st_flags; 255 uint32_t st_gen; 256 int32_t st_lspare; 257 struct timespec32 st_birthtim; 258 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32)); 259 unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32)); 260 }; 261 262 struct ostat32 { 263 __uint16_t st_dev; 264 __uint32_t st_ino; 265 mode_t st_mode; 266 __uint16_t st_nlink; 267 __uint16_t st_uid; 268 __uint16_t st_gid; 269 __uint16_t st_rdev; 270 __int32_t st_size; 271 struct timespec32 st_atim; 272 struct timespec32 st_mtim; 273 struct timespec32 st_ctim; 274 __int32_t st_blksize; 275 __int32_t st_blocks; 276 uint32_t st_flags; 277 __uint32_t st_gen; 278 }; 279 280 struct jail32_v0 { 281 uint32_t version; 282 uint32_t path; 283 uint32_t hostname; 284 uint32_t ip_number; 285 }; 286 287 struct jail32 { 288 uint32_t version; 289 uint32_t path; 290 uint32_t hostname; 291 uint32_t jailname; 292 uint32_t ip4s; 293 uint32_t ip6s; 294 uint32_t ip4; 295 uint32_t ip6; 296 }; 297 298 struct sigaction32 { 299 uint32_t sa_u; 300 int sa_flags; 301 sigset_t sa_mask; 302 }; 303 304 struct thr_param32 { 305 uint32_t start_func; 306 uint32_t arg; 307 uint32_t stack_base; 308 uint32_t stack_size; 309 uint32_t tls_base; 310 uint32_t tls_size; 311 uint32_t child_tid; 312 uint32_t parent_tid; 313 int32_t flags; 314 uint32_t rtp; 315 uint32_t spare[3]; 316 }; 317 318 struct i386_ldt_args32 { 319 uint32_t start; 320 uint32_t descs; 321 uint32_t num; 322 }; 323 324 struct mq_attr32 { 325 int mq_flags; 326 int mq_maxmsg; 327 int mq_msgsize; 328 int mq_curmsgs; 329 int __reserved[4]; 330 }; 331 332 struct kinfo_proc32 { 333 int ki_structsize; 334 int ki_layout; 335 uint32_t ki_args; 336 uint32_t ki_paddr; 337 uint32_t ki_addr; 338 uint32_t ki_tracep; 339 uint32_t ki_textvp; 340 uint32_t ki_fd; 341 uint32_t ki_vmspace; 342 uint32_t ki_wchan; 343 pid_t ki_pid; 344 pid_t ki_ppid; 345 pid_t ki_pgid; 346 pid_t ki_tpgid; 347 pid_t ki_sid; 348 pid_t ki_tsid; 349 short ki_jobc; 350 short ki_spare_short1; 351 uint32_t ki_tdev_freebsd11; 352 sigset_t ki_siglist; 353 sigset_t ki_sigmask; 354 sigset_t ki_sigignore; 355 sigset_t ki_sigcatch; 356 uid_t ki_uid; 357 uid_t ki_ruid; 358 uid_t ki_svuid; 359 gid_t ki_rgid; 360 gid_t ki_svgid; 361 short ki_ngroups; 362 short ki_spare_short2; 363 gid_t ki_groups[KI_NGROUPS]; 364 uint32_t ki_size; 365 int32_t ki_rssize; 366 int32_t ki_swrss; 367 int32_t ki_tsize; 368 int32_t ki_dsize; 369 int32_t ki_ssize; 370 u_short ki_xstat; 371 u_short ki_acflag; 372 fixpt_t ki_pctcpu; 373 u_int ki_estcpu; 374 u_int ki_slptime; 375 u_int ki_swtime; 376 u_int ki_cow; 377 freebsd32_uint64_t ki_runtime; 378 struct timeval32 ki_start; 379 struct timeval32 ki_childtime; 380 int ki_flag; 381 int ki_kiflag; 382 int ki_traceflag; 383 char ki_stat; 384 signed char ki_nice; 385 char ki_lock; 386 char ki_rqindex; 387 u_char ki_oncpu_old; 388 u_char ki_lastcpu_old; 389 char ki_tdname[TDNAMLEN+1]; 390 char ki_wmesg[WMESGLEN+1]; 391 char ki_login[LOGNAMELEN+1]; 392 char ki_lockname[LOCKNAMELEN+1]; 393 char ki_comm[COMMLEN+1]; 394 char ki_emul[KI_EMULNAMELEN+1]; 395 char ki_loginclass[LOGINCLASSLEN+1]; 396 char ki_moretdname[MAXCOMLEN-TDNAMLEN+1]; 397 char ki_sparestrings[46]; 398 int ki_spareints[KI_NSPARE_INT]; 399 freebsd32_uint64_t ki_tdev; 400 int ki_oncpu; 401 int ki_lastcpu; 402 int ki_tracer; 403 int ki_flag2; 404 int ki_fibnum; 405 u_int ki_cr_flags; 406 int ki_jid; 407 int ki_numthreads; 408 lwpid_t ki_tid; 409 struct priority ki_pri; 410 struct rusage32 ki_rusage; 411 struct rusage32 ki_rusage_ch; 412 uint32_t ki_pcb; 413 uint32_t ki_kstack; 414 uint32_t ki_udata; 415 uint32_t ki_tdaddr; 416 uint32_t ki_pd; 417 uint32_t ki_uerrmsg; 418 uint32_t ki_spareptrs[KI_NSPARE_PTR]; /* spare room for growth */ 419 int ki_sparelongs[KI_NSPARE_LONG]; 420 int ki_sflag; 421 int ki_tdflags; 422 }; 423 424 struct kinfo_sigtramp32 { 425 uint32_t ksigtramp_start; 426 uint32_t ksigtramp_end; 427 uint32_t ksigtramp_spare[4]; 428 }; 429 430 struct kinfo_vm_layout32 { 431 uint32_t kvm_min_user_addr; 432 uint32_t kvm_max_user_addr; 433 uint32_t kvm_text_addr; 434 uint32_t kvm_text_size; 435 uint32_t kvm_data_addr; 436 uint32_t kvm_data_size; 437 uint32_t kvm_stack_addr; 438 uint32_t kvm_stack_size; 439 int kvm_map_flags; 440 uint32_t kvm_shp_addr; 441 uint32_t kvm_shp_size; 442 uint32_t kvm_spare[12]; 443 }; 444 445 #if defined(_WANT_KEVENT32) || defined(_KERNEL) 446 struct kinfo_knote32 { 447 int knt_kq_fd; 448 struct kevent32 knt_event; 449 int knt_status; 450 int knt_extdata; 451 uint32_t knt_spare0[8]; 452 union { 453 struct { 454 int knt_vnode_type; 455 freebsd32_uint64_t knt_vnode_fsid; 456 freebsd32_uint64_t knt_vnode_fileid; 457 char knt_vnode_fullpath[PATH_MAX]; 458 } knt_vnode; 459 struct { 460 freebsd32_uint64_t knt_pipe_ino; 461 } knt_pipe; 462 }; 463 }; 464 #endif 465 466 struct kld_file_stat_1_32 { 467 int version; /* set to sizeof(struct kld_file_stat_1) */ 468 char name[MAXPATHLEN]; 469 int refs; 470 int id; 471 uint32_t address; /* load address */ 472 uint32_t size; /* size in bytes */ 473 }; 474 475 struct kld_file_stat32 { 476 int version; /* set to sizeof(struct kld_file_stat) */ 477 char name[MAXPATHLEN]; 478 int refs; 479 int id; 480 uint32_t address; /* load address */ 481 uint32_t size; /* size in bytes */ 482 char pathname[MAXPATHLEN]; 483 }; 484 485 struct procctl_reaper_pids32 { 486 u_int rp_count; 487 u_int rp_pad0[15]; 488 uint32_t rp_pids; 489 }; 490 491 struct timex32 { 492 unsigned int modes; 493 int32_t offset; 494 int32_t freq; 495 int32_t maxerror; 496 int32_t esterror; 497 int status; 498 int32_t constant; 499 int32_t precision; 500 int32_t tolerance; 501 int32_t ppsfreq; 502 int32_t jitter; 503 int shift; 504 int32_t stabil; 505 int32_t jitcnt; 506 int32_t calcnt; 507 int32_t errcnt; 508 int32_t stbcnt; 509 }; 510 511 struct ptrace_sc_ret32 { 512 uint32_t sr_retval[2]; 513 int sr_error; 514 }; 515 516 struct ptrace_coredump32 { 517 int pc_fd; 518 uint32_t pc_flags; 519 uint32_t pc_limit1, pc_limit2; 520 }; 521 522 struct ptrace_sc_remote32 { 523 struct ptrace_sc_ret32 pscr_ret; 524 u_int pscr_syscall; 525 u_int pscr_nargs; 526 uint32_t pscr_args; 527 }; 528 529 struct devstat32 { 530 u_int sequence0; 531 int allocated; 532 u_int start_count; 533 u_int end_count; 534 struct bintime32 busy_from; 535 struct { u_int32_t stqe_next; } dev_links; 536 u_int32_t device_number; 537 char device_name[DEVSTAT_NAME_LEN]; 538 int unit_number; 539 freebsd32_uint64_t bytes[DEVSTAT_N_TRANS_FLAGS]; 540 freebsd32_uint64_t operations[DEVSTAT_N_TRANS_FLAGS]; 541 struct bintime32 duration[DEVSTAT_N_TRANS_FLAGS]; 542 struct bintime32 busy_time; 543 struct bintime32 creation_time; 544 u_int32_t block_size; 545 freebsd32_uint64_t tag_types[3]; 546 devstat_support_flags flags; 547 devstat_type_flags device_type; 548 devstat_priority priority; 549 u_int32_t id; 550 u_int sequence1; 551 }; 552 553 #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */ 554