xref: /freebsd/sys/compat/freebsd32/freebsd32.h (revision e17f5b1d)
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 
39 /*
40  * i386 is the only arch with a 32-bit time_t
41  */
42 #ifdef __amd64__
43 typedef	int32_t	time32_t;
44 #else
45 typedef	int64_t	time32_t;
46 #endif
47 
48 struct timeval32 {
49 	time32_t tv_sec;
50 	int32_t tv_usec;
51 };
52 
53 struct timespec32 {
54 	time32_t tv_sec;
55 	int32_t tv_nsec;
56 };
57 
58 struct itimerspec32 {
59 	struct timespec32  it_interval;
60 	struct timespec32  it_value;
61 };
62 
63 struct bintime32 {
64 	time32_t sec;
65 	uint32_t frac[2];
66 };
67 
68 struct rusage32 {
69 	struct timeval32 ru_utime;
70 	struct timeval32 ru_stime;
71 	int32_t	ru_maxrss;
72 	int32_t	ru_ixrss;
73 	int32_t	ru_idrss;
74 	int32_t	ru_isrss;
75 	int32_t	ru_minflt;
76 	int32_t	ru_majflt;
77 	int32_t	ru_nswap;
78 	int32_t	ru_inblock;
79 	int32_t	ru_oublock;
80 	int32_t	ru_msgsnd;
81 	int32_t	ru_msgrcv;
82 	int32_t	ru_nsignals;
83 	int32_t	ru_nvcsw;
84 	int32_t	ru_nivcsw;
85 };
86 
87 struct wrusage32 {
88 	struct rusage32	wru_self;
89 	struct rusage32 wru_children;
90 };
91 
92 struct itimerval32 {
93 	struct timeval32 it_interval;
94 	struct timeval32 it_value;
95 };
96 
97 #define FREEBSD4_MFSNAMELEN	16
98 #define FREEBSD4_MNAMELEN	(88 - 2 * sizeof(int32_t))
99 
100 /* 4.x version */
101 struct statfs32 {
102 	int32_t	f_spare2;
103 	int32_t	f_bsize;
104 	int32_t	f_iosize;
105 	int32_t	f_blocks;
106 	int32_t	f_bfree;
107 	int32_t	f_bavail;
108 	int32_t	f_files;
109 	int32_t	f_ffree;
110 	fsid_t	f_fsid;
111 	uid_t	f_owner;
112 	int32_t	f_type;
113 	int32_t	f_flags;
114 	int32_t	f_syncwrites;
115 	int32_t	f_asyncwrites;
116 	char	f_fstypename[FREEBSD4_MFSNAMELEN];
117 	char	f_mntonname[FREEBSD4_MNAMELEN];
118 	int32_t	f_syncreads;
119 	int32_t	f_asyncreads;
120 	int16_t	f_spares1;
121 	char	f_mntfromname[FREEBSD4_MNAMELEN];
122 	int16_t	f_spares2 __packed;
123 	int32_t f_spare[2];
124 };
125 
126 struct iovec32 {
127 	u_int32_t iov_base;
128 	int	iov_len;
129 };
130 
131 struct msghdr32 {
132 	u_int32_t	 msg_name;
133 	socklen_t	 msg_namelen;
134 	u_int32_t	 msg_iov;
135 	int		 msg_iovlen;
136 	u_int32_t	 msg_control;
137 	socklen_t	 msg_controllen;
138 	int		 msg_flags;
139 };
140 
141 #if defined(__amd64__)
142 #define	__STAT32_TIME_T_EXT	1
143 #endif
144 
145 struct stat32 {
146 	dev_t st_dev;
147 	ino_t st_ino;
148 	nlink_t st_nlink;
149 	mode_t	st_mode;
150 	u_int16_t st_padding0;
151 	uid_t	st_uid;
152 	gid_t	st_gid;
153 	u_int32_t st_padding1;
154 	dev_t st_rdev;
155 #ifdef	__STAT32_TIME_T_EXT
156 	__int32_t st_atim_ext;
157 #endif
158 	struct timespec32 st_atim;
159 #ifdef	__STAT32_TIME_T_EXT
160 	__int32_t st_mtim_ext;
161 #endif
162 	struct timespec32 st_mtim;
163 #ifdef	__STAT32_TIME_T_EXT
164 	__int32_t st_ctim_ext;
165 #endif
166 	struct timespec32 st_ctim;
167 #ifdef	__STAT32_TIME_T_EXT
168 	__int32_t st_btim_ext;
169 #endif
170 	struct timespec32 st_birthtim;
171 	off_t	st_size;
172 	int64_t	st_blocks;
173 	u_int32_t st_blksize;
174 	u_int32_t st_flags;
175 	u_int64_t st_gen;
176 	u_int64_t st_spare[10];
177 };
178 struct freebsd11_stat32 {
179 	u_int32_t st_dev;
180 	u_int32_t st_ino;
181 	mode_t	st_mode;
182 	u_int16_t st_nlink;
183 	uid_t	st_uid;
184 	gid_t	st_gid;
185 	u_int32_t st_rdev;
186 	struct timespec32 st_atim;
187 	struct timespec32 st_mtim;
188 	struct timespec32 st_ctim;
189 	off_t	st_size;
190 	int64_t	st_blocks;
191 	u_int32_t st_blksize;
192 	u_int32_t st_flags;
193 	u_int32_t st_gen;
194 	int32_t	st_lspare;
195 	struct timespec32 st_birthtim;
196 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
197 	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
198 };
199 
200 struct ostat32 {
201 	__uint16_t st_dev;
202 	__uint32_t st_ino;
203 	mode_t	st_mode;
204 	__uint16_t st_nlink;
205 	__uint16_t st_uid;
206 	__uint16_t st_gid;
207 	__uint16_t st_rdev;
208 	__int32_t st_size;
209 	struct timespec32 st_atim;
210 	struct timespec32 st_mtim;
211 	struct timespec32 st_ctim;
212 	__int32_t st_blksize;
213 	__int32_t st_blocks;
214 	u_int32_t st_flags;
215 	__uint32_t st_gen;
216 };
217 
218 struct jail32_v0 {
219 	u_int32_t	version;
220 	uint32_t	path;
221 	uint32_t	hostname;
222 	u_int32_t	ip_number;
223 };
224 
225 struct jail32 {
226 	uint32_t	version;
227 	uint32_t	path;
228 	uint32_t	hostname;
229 	uint32_t	jailname;
230 	uint32_t	ip4s;
231 	uint32_t	ip6s;
232 	uint32_t	ip4;
233 	uint32_t	ip6;
234 };
235 
236 struct sigaction32 {
237 	u_int32_t	sa_u;
238 	int		sa_flags;
239 	sigset_t	sa_mask;
240 };
241 
242 struct thr_param32 {
243 	uint32_t start_func;
244 	uint32_t arg;
245 	uint32_t stack_base;
246 	uint32_t stack_size;
247 	uint32_t tls_base;
248 	uint32_t tls_size;
249 	uint32_t child_tid;
250 	uint32_t parent_tid;
251 	int32_t	 flags;
252 	uint32_t rtp;
253 	uint32_t spare[3];
254 };
255 
256 struct i386_ldt_args32 {
257 	uint32_t start;
258 	uint32_t descs;
259 	uint32_t num;
260 };
261 
262 struct mq_attr32 {
263 	int	mq_flags;
264 	int	mq_maxmsg;
265 	int	mq_msgsize;
266 	int	mq_curmsgs;
267 	int	__reserved[4];
268 };
269 
270 struct kinfo_proc32 {
271 	int	ki_structsize;
272 	int	ki_layout;
273 	uint32_t ki_args;
274 	uint32_t ki_paddr;
275 	uint32_t ki_addr;
276 	uint32_t ki_tracep;
277 	uint32_t ki_textvp;
278 	uint32_t ki_fd;
279 	uint32_t ki_vmspace;
280 	uint32_t ki_wchan;
281 	pid_t	ki_pid;
282 	pid_t	ki_ppid;
283 	pid_t	ki_pgid;
284 	pid_t	ki_tpgid;
285 	pid_t	ki_sid;
286 	pid_t	ki_tsid;
287 	short	ki_jobc;
288 	short	ki_spare_short1;
289 	uint32_t ki_tdev_freebsd11;
290 	sigset_t ki_siglist;
291 	sigset_t ki_sigmask;
292 	sigset_t ki_sigignore;
293 	sigset_t ki_sigcatch;
294 	uid_t	ki_uid;
295 	uid_t	ki_ruid;
296 	uid_t	ki_svuid;
297 	gid_t	ki_rgid;
298 	gid_t	ki_svgid;
299 	short	ki_ngroups;
300 	short	ki_spare_short2;
301 	gid_t 	ki_groups[KI_NGROUPS];
302 	uint32_t ki_size;
303 	int32_t ki_rssize;
304 	int32_t ki_swrss;
305 	int32_t ki_tsize;
306 	int32_t ki_dsize;
307 	int32_t ki_ssize;
308 	u_short	ki_xstat;
309 	u_short	ki_acflag;
310 	fixpt_t	ki_pctcpu;
311 	u_int	ki_estcpu;
312 	u_int	ki_slptime;
313 	u_int	ki_swtime;
314 	u_int	ki_cow;
315 	u_int64_t ki_runtime;
316 	struct	timeval32 ki_start;
317 	struct	timeval32 ki_childtime;
318 	int	ki_flag;
319 	int	ki_kiflag;
320 	int	ki_traceflag;
321 	char	ki_stat;
322 	signed char ki_nice;
323 	char	ki_lock;
324 	char	ki_rqindex;
325 	u_char	ki_oncpu_old;
326 	u_char	ki_lastcpu_old;
327 	char	ki_tdname[TDNAMLEN+1];
328 	char	ki_wmesg[WMESGLEN+1];
329 	char	ki_login[LOGNAMELEN+1];
330 	char	ki_lockname[LOCKNAMELEN+1];
331 	char	ki_comm[COMMLEN+1];
332 	char	ki_emul[KI_EMULNAMELEN+1];
333 	char	ki_loginclass[LOGINCLASSLEN+1];
334 	char	ki_moretdname[MAXCOMLEN-TDNAMLEN+1];
335 	char	ki_sparestrings[46];
336 	int	ki_spareints[KI_NSPARE_INT];
337 	uint64_t ki_tdev;
338 	int	ki_oncpu;
339 	int	ki_lastcpu;
340 	int	ki_tracer;
341 	int	ki_flag2;
342 	int	ki_fibnum;
343 	u_int	ki_cr_flags;
344 	int	ki_jid;
345 	int	ki_numthreads;
346 	lwpid_t	ki_tid;
347 	struct	priority ki_pri;
348 	struct	rusage32 ki_rusage;
349 	struct	rusage32 ki_rusage_ch;
350 	uint32_t ki_pcb;
351 	uint32_t ki_kstack;
352 	uint32_t ki_udata;
353 	uint32_t ki_tdaddr;
354 	uint32_t ki_spareptrs[KI_NSPARE_PTR];	/* spare room for growth */
355 	int	ki_sparelongs[KI_NSPARE_LONG];
356 	int	ki_sflag;
357 	int	ki_tdflags;
358 };
359 
360 struct kinfo_sigtramp32 {
361 	uint32_t ksigtramp_start;
362 	uint32_t ksigtramp_end;
363 	uint32_t ksigtramp_spare[4];
364 };
365 
366 struct kld32_file_stat_1 {
367 	int	version;	/* set to sizeof(struct kld_file_stat_1) */
368 	char	name[MAXPATHLEN];
369 	int	refs;
370 	int	id;
371 	uint32_t address;	/* load address */
372 	uint32_t size;		/* size in bytes */
373 };
374 
375 struct kld32_file_stat {
376 	int	version;	/* set to sizeof(struct kld_file_stat) */
377 	char	name[MAXPATHLEN];
378 	int	refs;
379 	int	id;
380 	uint32_t address;	/* load address */
381 	uint32_t size;		/* size in bytes */
382 	char	pathname[MAXPATHLEN];
383 };
384 
385 struct procctl_reaper_pids32 {
386 	u_int	rp_count;
387 	u_int	rp_pad0[15];
388 	uint32_t rp_pids;
389 };
390 
391 #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */
392