1 /**	$MirOS: src/sys/sys/sysctl.h,v 1.7 2010/09/12 18:20:06 tg Exp $ */
2 /*	$NetBSD: sysctl.h,v 1.99 2003/09/28 13:02:19 dsl Exp $	*/
3 /*	$OpenBSD: sysctl.h,v 1.77 2004/04/19 22:52:33 tedu Exp $	*/
4 /*	$NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $	*/
5 
6 /*
7  * Copyright (c) 1989, 1993
8  *	The Regents of the University of California.  All rights reserved.
9  *
10  * This code is derived from software contributed to Berkeley by
11  * Mike Karels at Berkeley Software Design, Inc.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  * 3. Neither the name of the University nor the names of its contributors
22  *    may be used to endorse or promote products derived from this software
23  *    without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  *
37  *	@(#)sysctl.h	8.2 (Berkeley) 3/30/95
38  */
39 
40 #ifndef _SYS_SYSCTL_H_
41 #define	_SYS_SYSCTL_H_
42 
43 /*
44  * These are for the eproc structure defined below.
45  */
46 #ifndef _KERNEL
47 #include <sys/time.h>
48 #include <sys/ucred.h>
49 #include <sys/proc.h>
50 #include <sys/resource.h>
51 #endif
52 
53 #include <sys/resourcevar.h>	/* XXX */
54 
55 #include <uvm/uvm_extern.h>
56 
57 /*
58  * Definitions for sysctl call.  The sysctl call uses a hierarchical name
59  * for objects that can be examined or modified.  The name is expressed as
60  * a sequence of integers.  Like a file path name, the meaning of each
61  * component depends on its place in the hierarchy.  The top-level and kern
62  * identifiers are defined here, and other identifiers are defined in the
63  * respective subsystem header files.
64  */
65 
66 #define	CTL_MAXNAME	12	/* largest number of components supported */
67 
68 /*
69  * Each subsystem defined by sysctl defines a list of variables
70  * for that subsystem. Each name is either a node with further
71  * levels defined below it, or it is a leaf of some particular
72  * type given below. Each sysctl level defines a set of name/type
73  * pairs to be used by sysctl(1) in manipulating the subsystem.
74  */
75 struct ctlname {
76 	char	*ctl_name;	/* subsystem name */
77 	int	ctl_type;	/* type of name */
78 };
79 #define	CTLTYPE_NODE	1	/* name is a node */
80 #define	CTLTYPE_INT	2	/* name describes an integer */
81 #define	CTLTYPE_STRING	3	/* name describes a string */
82 #define	CTLTYPE_QUAD	4	/* name describes a 64-bit number */
83 #define	CTLTYPE_STRUCT	5	/* name describes a structure */
84 
85 /*
86  * Top-level identifiers
87  */
88 #define	CTL_UNSPEC	0		/* unused */
89 #define	CTL_KERN	1		/* "high kernel": proc, limits */
90 #define	CTL_VM		2		/* virtual memory */
91 #define	CTL_FS		3		/* file system, mount type is next */
92 #define	CTL_NET		4		/* network, see socket.h */
93 #define	CTL_DEBUG	5		/* debugging parameters */
94 #define	CTL_HW		6		/* generic cpu/io */
95 #define	CTL_MACHDEP	7		/* machine dependent */
96 #define	CTL_USER	8		/* user-level */
97 #define	CTL_DDB		9		/* DDB user interface, see db_var.h */
98 #define	CTL_VFS		10		/* VFS sysctl's */
99 #define	CTL_MAXID	11		/* number of valid top-level ids */
100 
101 #define	CTL_NAMES { \
102 	{ 0, 0 }, \
103 	{ "kern", CTLTYPE_NODE }, \
104 	{ "vm", CTLTYPE_NODE }, \
105 	{ "fs", CTLTYPE_NODE }, \
106 	{ "net", CTLTYPE_NODE }, \
107 	{ "debug", CTLTYPE_NODE }, \
108 	{ "hw", CTLTYPE_NODE }, \
109 	{ "machdep", CTLTYPE_NODE }, \
110 	{ "user", CTLTYPE_NODE }, \
111 	{ "ddb", CTLTYPE_NODE }, \
112 	{ "vfs", CTLTYPE_NODE }, \
113 }
114 
115 /*
116  * CTL_KERN identifiers
117  */
118 #define	KERN_OSTYPE	 	 1	/* string: system version */
119 #define	KERN_OSRELEASE	 	 2	/* string: system release */
120 #define	KERN_OSREV	 	 3	/* int: system revision */
121 #define	KERN_VERSION	 	 4	/* string: compile time info */
122 #define	KERN_MAXVNODES	 	 5	/* int: max vnodes */
123 #define	KERN_MAXPROC	 	 6	/* int: max processes */
124 #define	KERN_MAXFILES	 	 7	/* int: max open files */
125 #define	KERN_ARGMAX	 	 8	/* int: max arguments to exec */
126 #define	KERN_SECURELVL	 	 9	/* int: system security level */
127 #define	KERN_HOSTNAME		10	/* string: hostname */
128 #define	KERN_HOSTID		11	/* int: host identifier */
129 #define	KERN_CLOCKRATE		12	/* struct: struct clockinfo */
130 #define	KERN_VNODE		13	/* struct: vnode structures */
131 #define	KERN_PROC		14	/* struct: process entries */
132 #define	KERN_FILE		15	/* struct: file entries */
133 /*define gap			16	*/
134 #define	KERN_POSIX1		17	/* int: POSIX.1 version */
135 #define	KERN_NGROUPS		18	/* int: # of supplemental group ids */
136 #define	KERN_JOB_CONTROL	19	/* int: is job control available */
137 #define	KERN_SAVED_IDS		20	/* int: saved set-user/group-ID */
138 #define	KERN_BOOTTIME		21	/* struct: time kernel was booted */
139 #define	KERN_DOMAINNAME		22	/* string: (YP) domainname */
140 #define	KERN_MAXPARTITIONS	23	/* int: number of partitions/disk */
141 #define	KERN_RAWPARTITION	24	/* int: raw partition number */
142 /*define gap			25	*/
143 /*define gap			26	*/
144 #define	KERN_OSVERSION		27	/* string: kernel build version */
145 #define	KERN_SOMAXCONN		28	/* int: listen queue maximum */
146 #define	KERN_SOMINCONN		29	/* int: half-open controllable param */
147 #define	KERN_USERMOUNT		30	/* int: users may mount filesystems */
148 #define	KERN_RND		31	/* struct: rnd(4) statistics */
149 #define	KERN_NOSUIDCOREDUMP	32	/* int: no setuid coredumps ever */
150 #define	KERN_FSYNC		33	/* int: file synchronization support */
151 #define	KERN_SYSVMSG		34	/* int: SysV message queue suppoprt */
152 #define	KERN_SYSVSEM		35	/* int: SysV semaphore support */
153 #define	KERN_SYSVSHM		36	/* int: SysV shared memory support */
154 #define	KERN_ARND		37	/* int: random integer from arc4rnd */
155 #define	KERN_MSGBUFSIZE		38	/* int: size of message buffer */
156 #define KERN_MALLOCSTATS	39	/* node: malloc statistics */
157 #define KERN_CPTIME		40	/* array: cp_time */
158 #define KERN_NCHSTATS		41	/* struct: vfs cache statistics */
159 #define KERN_FORKSTAT		42	/* struct: fork statistics */
160 #define KERN_NSELCOLL		43	/* int: select(2) collisions */
161 #define KERN_TTY		44	/* node: tty information */
162 #define	KERN_CCPU		45	/* int: ccpu */
163 #define	KERN_FSCALE		46	/* int: fscale */
164 #define	KERN_NPROCS		47	/* int: number of processes */
165 #define	KERN_MSGBUF		48	/* message buffer, KERN_MSGBUFSIZE */
166 #define	KERN_POOL		49	/* struct: pool information */
167 #define	KERN_STACKGAPRANDOM	50	/* int: stackgap_random */
168 #define	KERN_SYSVIPC_INFO	51	/* struct: SysV sem/shm/msg info */
169 #define KERN_USERCRYPTO		52	/* int: usercrypto */
170 #define KERN_CRYPTODEVALLOWSOFT	53	/* int: cryptodevallowsoft */
171 #define KERN_SPLASSERT		54	/* int: splassert */
172 #define KERN_PROC_ARGS		55	/* node: proc args and env */
173 #define	KERN_NFILES		56	/* int: number of open files */
174 #define	KERN_TTYCOUNT		57	/* int: number of tty devices */
175 #define KERN_NUMVNODES		58	/* int: number of vnodes in use */
176 #define	KERN_MBSTAT		59	/* struct: mbuf statistics */
177 #define KERN_USERASYMCRYPTO	60	/* int: usercrypto */
178 #define	KERN_SEMINFO		61	/* struct: SysV struct seminfo */
179 #define	KERN_SHMINFO		62	/* struct: SysV struct shminfo */
180 #define KERN_INTRCNT		63	/* node: interrupt counters */
181 #define	KERN_WATCHDOG		64	/* node: watchdog */
182 #define	KERN_ALLOWPSA		65	/* int: allow user "ps a" */
183 #define	KERN_ALLOWPSE		66	/* int: allow user "ps e" */
184 #define	KERN_EMUL		67	/* node: emuls */
185 #define	KERN_ROOT_DEVICE	68	/* string: root device */
186 #define	KERN_ROOT_PARTITION	69	/* int: root partition */
187 #define	KERN_PROC2		70	/* struct: process entries */
188 /*define gap			71	*/
189 #define	KERN_MAXCLUSTERS	72	/* number of mclusters */
190 #define	KERN_EMULUNAME		73	/* uname for the linuxulator */
191 #define	KERN_OSPATCHLEVEL	74	/* string: system patchlevel */
192 #define	KERN_MAXID		75	/* number of valid kern ids */
193 
194 #define	CTL_KERN_NAMES { \
195 	{ 0, 0 }, \
196 	{ "ostype", CTLTYPE_STRING }, \
197 	{ "osrelease", CTLTYPE_STRING }, \
198 	{ "osrevision", CTLTYPE_INT }, \
199 	{ "version", CTLTYPE_STRING }, \
200 	{ "maxvnodes", CTLTYPE_INT }, \
201 	{ "maxproc", CTLTYPE_INT }, \
202 	{ "maxfiles", CTLTYPE_INT }, \
203 	{ "argmax", CTLTYPE_INT }, \
204 	{ "securelevel", CTLTYPE_INT }, \
205 	{ "hostname", CTLTYPE_STRING }, \
206 	{ "hostid", CTLTYPE_INT }, \
207 	{ "clockrate", CTLTYPE_STRUCT }, \
208 	{ "vnode", CTLTYPE_STRUCT }, \
209 	{ "proc", CTLTYPE_STRUCT }, \
210 	{ "file", CTLTYPE_STRUCT }, \
211 	{ "gap", 0 }, \
212 	{ "posix1version", CTLTYPE_INT }, \
213 	{ "ngroups", CTLTYPE_INT }, \
214 	{ "job_control", CTLTYPE_INT }, \
215 	{ "saved_ids", CTLTYPE_INT }, \
216 	{ "boottime", CTLTYPE_STRUCT }, \
217 	{ "domainname", CTLTYPE_STRING }, \
218 	{ "maxpartitions", CTLTYPE_INT }, \
219 	{ "rawpartition", CTLTYPE_INT }, \
220 	{ "gap", 0 }, \
221 	{ "gap", 0 }, \
222 	{ "osversion", CTLTYPE_STRING }, \
223 	{ "somaxconn", CTLTYPE_INT }, \
224 	{ "sominconn", CTLTYPE_INT }, \
225 	{ "usermount", CTLTYPE_INT }, \
226 	{ "random", CTLTYPE_STRUCT }, \
227 	{ "nosuidcoredump", CTLTYPE_INT }, \
228 	{ "fsync", CTLTYPE_INT }, \
229 	{ "sysvmsg", CTLTYPE_INT }, \
230 	{ "sysvsem", CTLTYPE_INT }, \
231 	{ "sysvshm", CTLTYPE_INT }, \
232 	{ "arandom", CTLTYPE_INT }, \
233 	{ "msgbufsize", CTLTYPE_INT }, \
234 	{ "malloc", CTLTYPE_NODE }, \
235 	{ "cp_time", CTLTYPE_STRUCT }, \
236 	{ "nchstats", CTLTYPE_STRUCT }, \
237 	{ "forkstat", CTLTYPE_STRUCT }, \
238 	{ "nselcoll", CTLTYPE_INT }, \
239 	{ "tty", CTLTYPE_NODE }, \
240 	{ "ccpu", CTLTYPE_INT }, \
241 	{ "fscale", CTLTYPE_INT }, \
242 	{ "nprocs", CTLTYPE_INT }, \
243 	{ "msgbuf", CTLTYPE_STRUCT }, \
244 	{ "pool", CTLTYPE_NODE }, \
245 	{ "stackgap_random", CTLTYPE_INT }, \
246 	{ "sysvipc_info", CTLTYPE_INT }, \
247 	{ "usercrypto", CTLTYPE_INT }, \
248 	{ "cryptodevallowsoft", CTLTYPE_INT }, \
249 	{ "splassert", CTLTYPE_INT }, \
250 	{ "procargs", CTLTYPE_NODE }, \
251 	{ "nfiles", CTLTYPE_INT }, \
252 	{ "ttycount", CTLTYPE_INT }, \
253 	{ "numvnodes", CTLTYPE_INT }, \
254 	{ "mbstat", CTLTYPE_STRUCT }, \
255 	{ "userasymcrypto", CTLTYPE_INT }, \
256 	{ "seminfo", CTLTYPE_STRUCT }, \
257 	{ "shminfo", CTLTYPE_STRUCT }, \
258 	{ "intrcnt", CTLTYPE_NODE }, \
259  	{ "watchdog", CTLTYPE_NODE }, \
260 	{ "allowpsa", CTLTYPE_INT }, \
261 	{ "allowpse", CTLTYPE_INT }, \
262  	{ "emul", CTLTYPE_NODE }, \
263 	{ "root_device", CTLTYPE_STRING }, \
264 	{ "root_partition", CTLTYPE_INT }, \
265  	{ "proc2", CTLTYPE_STRUCT }, \
266 	{ "gap", 0 }, \
267  	{ "maxclusters", CTLTYPE_INT }, \
268 	{ "emul_uname", CTLTYPE_STRING }, \
269 	{ "ospatchlevel", CTLTYPE_STRING }, \
270 }
271 
272 /*
273  * KERN_EMUL subtypes.
274  */
275 #define	KERN_EMUL_NUM		0
276 /* Fourth level sysctl names */
277 #define KERN_EMUL_NAME		0
278 #define KERN_EMUL_ENABLED	1
279 
280 
281 /*
282  * KERN_PROC subtypes
283  */
284 #define	KERN_PROC_ALL		0	/* everything but kernel threads */
285 #define	KERN_PROC_PID		1	/* by process id */
286 #define	KERN_PROC_PGRP		2	/* by process group id */
287 #define	KERN_PROC_SESSION	3	/* by session of pid */
288 #define	KERN_PROC_TTY		4	/* by controlling tty */
289 #define	KERN_PROC_UID		5	/* by effective uid */
290 #define	KERN_PROC_RUID		6	/* by real uid */
291 #define	KERN_PROC_KTHREAD	7	/* also return kernel threads */
292 
293 /*
294  * KERN_SYSVIPC_INFO subtypes
295  */
296 #define KERN_SYSVIPC_MSG_INFO	1	/* msginfo and msqid_ds */
297 #define KERN_SYSVIPC_SEM_INFO	2	/* seminfo and semid_ds */
298 #define KERN_SYSVIPC_SHM_INFO	3	/* shminfo and shmid_ds */
299 
300 /*
301  * KERN_PROC_ARGS subtypes
302  */
303 #define KERN_PROC_ARGV		1
304 #define KERN_PROC_NARGV		2
305 #define KERN_PROC_ENV		3
306 #define KERN_PROC_NENV		4
307 
308 /*
309  * KERN_PROC subtype ops return arrays of augmented proc structures:
310  */
311 struct kinfo_proc {
312 	struct	proc kp_proc;			/* proc structure */
313 	struct	eproc {
314 		struct	proc *e_paddr;		/* address of proc */
315 		struct	session *e_sess;	/* session pointer */
316 		struct	pcred e_pcred;		/* process credentials */
317 		struct	ucred e_ucred;		/* current credentials */
318 		struct	vmspace e_vm;		/* address space */
319 		struct  pstats e_pstats;	/* process stats */
320 		int	e_pstats_valid;		/* pstats valid? */
321 		pid_t	e_ppid;			/* parent process id */
322 		pid_t	e_pgid;			/* process group id */
323 		short	e_jobc;			/* job control counter */
324 		dev_t	e_tdev;			/* controlling tty dev */
325 		pid_t	e_tpgid;		/* tty process group id */
326 		struct	session *e_tsess;	/* tty session pointer */
327 #define	WMESGLEN	7
328 		char	e_wmesg[WMESGLEN+1];	/* wchan message */
329 		segsz_t e_xsize;		/* text size */
330 		short	e_xrssize;		/* text rss */
331 		short	e_xccount;		/* text references */
332 		short	e_xswrss;
333 		long	e_flag;
334 #define	EPROC_CTTY	0x01	/* controlling tty vnode active */
335 #define	EPROC_SLEADER	0x02	/* session leader */
336 		char	e_login[MAXLOGNAME];	/* setlogin() name */
337 #define	EMULNAMELEN	7
338 		char	e_emul[EMULNAMELEN+1];	/* syscall emulation name */
339 	        rlim_t	e_maxrss;
340 	} kp_eproc;
341 };
342 
343 /*
344  * KERN_PROC2 subtype ops return arrays of relatively fixed size
345  * structures of process info.   Use 8 byte alignment, and new
346  * elements should only be added to the end of this structure so
347  * binary compatibility can be preserved.
348  */
349 #define	KI_NGROUPS	16
350 #define	KI_MAXCOMLEN	24	/* extra for 8 byte alignment */
351 #define	KI_WMESGLEN	8
352 #define	KI_MAXLOGNAME	32
353 #define	KI_EMULNAMELEN	8
354 
355 struct kinfo_proc2 {
356 	u_int64_t p_forw;		/* PTR: linked run/sleep queue. */
357 	u_int64_t p_back;
358 	u_int64_t p_paddr;		/* PTR: address of proc */
359 
360 	u_int64_t p_addr;		/* PTR: Kernel virtual addr of u-area */
361 	u_int64_t p_fd;			/* PTR: Ptr to open files structure. */
362 	u_int64_t p_stats;		/* PTR: Accounting/statistics */
363 	u_int64_t p_limit;		/* PTR: Process limits. */
364 	u_int64_t p_vmspace;		/* PTR: Address space. */
365 	u_int64_t p_sigacts;		/* PTR: Signal actions, state */
366 	u_int64_t p_sess;		/* PTR: session pointer */
367 	u_int64_t p_tsess;		/* PTR: tty session pointer */
368 	u_int64_t p_ru;			/* PTR: Exit information. XXX */
369 
370 	int32_t	p_eflag;		/* LONG: extra kinfo_proc2 flags */
371 	int32_t	p_exitsig;		/* INT: signal to sent to parent on exit */
372 	int32_t	p_flag;			/* INT: P_* flags. */
373 
374 	int32_t	p_pid;			/* PID_T: Process identifier. */
375 	int32_t	p_ppid;			/* PID_T: Parent process id */
376 	int32_t	p_sid;			/* PID_T: session id */
377 	int32_t	p__pgid;		/* PID_T: process group id */
378 					/* XXX: <sys/proc.h> hijacks p_pgid */
379 	int32_t	p_tpgid;		/* PID_T: tty process group id */
380 
381 	u_int32_t p_uid;		/* UID_T: effective user id */
382 	u_int32_t p_ruid;		/* UID_T: real user id */
383 	u_int32_t p_gid;		/* GID_T: effective group id */
384 	u_int32_t p_rgid;		/* GID_T: real group id */
385 
386 	u_int32_t p_groups[KI_NGROUPS];	/* GID_T: groups */
387 	int16_t	p_ngroups;		/* SHORT: number of groups */
388 
389 	int16_t	p_jobc;			/* SHORT: job control counter */
390 	u_int32_t p_tdev;		/* DEV_T: controlling tty dev */
391 
392 	u_int32_t p_estcpu;		/* U_INT: Time averaged value of p_cpticks. */
393 	u_int64_t p_rtime_sec_32;	/* dummy (unused) */
394 	int32_t	p_cpticks;		/* INT: Ticks of cpu time. */
395 	u_int32_t p_pctcpu;		/* FIXPT_T: %cpu for this process during p_swtime */
396 	u_int32_t p_swtime;		/* U_INT: Time swapped in or out. */
397 	u_int32_t p_slptime;		/* U_INT: Time since last blocked. */
398 	int32_t	p_schedflags;		/* INT: PSCHED_* flags */
399 
400 	u_int64_t p_uticks;		/* U_QUAD_T: Statclock hits in user mode. */
401 	u_int64_t p_sticks;		/* U_QUAD_T: Statclock hits in system mode. */
402 	u_int64_t p_iticks;		/* U_QUAD_T: Statclock hits processing intr. */
403 
404 	u_int64_t p_tracep;		/* PTR: Trace to vnode or file */
405 	int32_t	p_traceflag;		/* INT: Kernel trace points. */
406 
407 	int32_t p_holdcnt;		/* INT: If non-zero, don't swap. */
408 
409 	int32_t p_siglist;		/* INT: Signals arrived but not delivered. */
410 	u_int32_t p_sigmask;		/* SIGSET_T: Current signal mask. */
411 	u_int32_t p_sigignore;		/* SIGSET_T: Signals being ignored. */
412 	u_int32_t p_sigcatch;		/* SIGSET_T: Signals being caught by user. */
413 
414 	int8_t	p_stat;			/* CHAR: S* process status (from LWP). */
415 	u_int8_t p_priority;		/* U_CHAR: Process priority. */
416 	u_int8_t p_usrpri;		/* U_CHAR: User-priority based on p_cpu and p_nice. */
417 	u_int8_t p_nice;		/* U_CHAR: Process "nice" value. */
418 
419 	u_int16_t p_xstat;		/* U_SHORT: Exit status for wait; also stop signal. */
420 	u_int16_t p_acflag;		/* U_SHORT: Accounting flags. */
421 
422 	char	p_comm[KI_MAXCOMLEN];
423 
424 	char	p_wmesg[KI_WMESGLEN];	/* wchan message */
425 	u_int64_t p_wchan;		/* PTR: sleep address. */
426 
427 	char	p_login[KI_MAXLOGNAME];	/* setlogin() name */
428 
429 	int32_t	p_vm_rssize;		/* SEGSZ_T: current resident set size in pages */
430 	int32_t	p_vm_tsize;		/* SEGSZ_T: text size (pages) */
431 	int32_t	p_vm_dsize;		/* SEGSZ_T: data size (pages) */
432 	int32_t	p_vm_ssize;		/* SEGSZ_T: stack size (pages) */
433 
434 	int64_t	p_uvalid;		/* CHAR: following p_u* members from struct user are valid */
435 					/* XXX 64 bits for alignment */
436 	u_int32_t p_ustart_sec;		/* STRUCT TIMEVAL: starting time. */
437 	u_int32_t p_ustart_usec;	/* STRUCT TIMEVAL: starting time. */
438 
439 	u_int32_t p_uutime_sec;		/* STRUCT TIMEVAL: user time. */
440 	u_int32_t p_uutime_usec;	/* STRUCT TIMEVAL: user time. */
441 	u_int32_t p_ustime_sec;		/* STRUCT TIMEVAL: system time. */
442 	u_int32_t p_ustime_usec;	/* STRUCT TIMEVAL: system time. */
443 
444 	u_int64_t p_uru_maxrss;		/* LONG: max resident set size. */
445 	u_int64_t p_uru_ixrss;		/* LONG: integral shared memory size. */
446 	u_int64_t p_uru_idrss;		/* LONG: integral unshared data ". */
447 	u_int64_t p_uru_isrss;		/* LONG: integral unshared stack ". */
448 	u_int64_t p_uru_minflt;		/* LONG: page reclaims. */
449 	u_int64_t p_uru_majflt;		/* LONG: page faults. */
450 	u_int64_t p_uru_nswap;		/* LONG: swaps. */
451 	u_int64_t p_uru_inblock;	/* LONG: block input operations. */
452 	u_int64_t p_uru_oublock;	/* LONG: block output operations. */
453 	u_int64_t p_uru_msgsnd;		/* LONG: messages sent. */
454 	u_int64_t p_uru_msgrcv;		/* LONG: messages received. */
455 	u_int64_t p_uru_nsignals;	/* LONG: signals received. */
456 	u_int64_t p_uru_nvcsw;		/* LONG: voluntary context switches. */
457 	u_int64_t p_uru_nivcsw;		/* LONG: involuntary ". */
458 
459 	u_int32_t p_uctime_sec;		/* STRUCT TIMEVAL: child u+s time. */
460 	u_int32_t p_uctime_usec;	/* STRUCT TIMEVAL: child u+s time. */
461 	u_int64_t p_realflag;		/* INT: P_* flags (not including LWPs). */
462 	u_int32_t p_svuid;		/* UID_T: saved user id */
463 	u_int32_t p_svgid;		/* GID_T: saved group id */
464 	char    p_emul[KI_EMULNAMELEN];	/* syscall emulation name */
465 	u_int64_t p_rlim_rss_cur;	/* RLIM_T: soft limit for rss */
466 	time_t p_rtime_sec;		/* STRUCT TIMEVAL: Real time. */
467 	u_int32_t p_rtime_usec;		/* STRUCT TIMEVAL: Real time. */
468 };
469 
470 /*
471  * KERN_INTR_CNT
472  */
473 #define KERN_INTRCNT_NUM	1	/* int: # intrcnt */
474 #define KERN_INTRCNT_CNT	2	/* node: intrcnt */
475 #define KERN_INTRCNT_NAME	3	/* node: names */
476 #define KERN_INTRCNT_MAXID	4
477 
478 #define CTL_KERN_INTRCNT_NAMES { \
479 	{ 0, 0 }, \
480 	{ "nintrcnt", CTLTYPE_INT }, \
481 	{ "intrcnt", CTLTYPE_NODE }, \
482 	{ "intrname", CTLTYPE_NODE }, \
483 }
484 
485 /*
486  * KERN_WATCHDOG
487  */
488 #define KERN_WATCHDOG_PERIOD	1	/* int: watchdog period */
489 #define KERN_WATCHDOG_AUTO	2	/* int: automatic tickle */
490 #define KERN_WATCHDOG_MAXID	3
491 
492 #define CTL_KERN_WATCHDOG_NAMES { \
493 	{ 0, 0 }, \
494 	{ "period", CTLTYPE_INT }, \
495 	{ "auto", CTLTYPE_INT }, \
496 }
497 
498 /*
499  * CTL_FS identifiers
500  */
501 #define	FS_POSIX	1		/* POSIX flags */
502 #define	FS_MAXID	2
503 
504 #define	CTL_FS_NAMES { \
505 	{ 0, 0 }, \
506 	{ "posix", CTLTYPE_NODE }, \
507 }
508 
509 /*
510  * CTL_FS identifiers
511  */
512 #define	FS_POSIX_SETUID	1		/* int: always clear SGID/SUID bit when owner change */
513 #define	FS_POSIX_MAXID	2
514 
515 #define	CTL_FS_POSIX_NAMES { \
516 	{ 0, 0 }, \
517 	{ "setuid", CTLTYPE_INT }, \
518 }
519 
520 /*
521  * CTL_HW identifiers
522  */
523 #define	HW_MACHINE	 1		/* string: machine class */
524 #define	HW_MODEL	 2		/* string: specific machine model */
525 #define	HW_NCPU		 3		/* int: number of cpus */
526 #define	HW_BYTEORDER	 4		/* int: machine byte order */
527 #define	HW_PHYSMEM	 5		/* int: total memory */
528 #define	HW_USERMEM	 6		/* int: non-kernel memory */
529 #define	HW_PAGESIZE	 7		/* int: software page size */
530 #define	HW_DISKNAMES	 8		/* strings: disk drive names */
531 #define	HW_DISKSTATS	 9		/* struct: diskstats[] */
532 #define	HW_DISKCOUNT	10		/* int: number of disks */
533 #define	HW_SENSORS	11		/* node: hardware monitors */
534 #define	HW_CPUSPEED	12		/* get CPU frequency */
535 #define	HW_SETPERF	13		/* set CPU performance % */
536 #define	HW_MACHINE_ARCH	14		/* string: machine architecture */
537 #define	HW_MAXID	15		/* number of valid hw ids */
538 
539 #define	CTL_HW_NAMES { \
540 	{ 0, 0 }, \
541 	{ "machine", CTLTYPE_STRING }, \
542 	{ "model", CTLTYPE_STRING }, \
543 	{ "ncpu", CTLTYPE_INT }, \
544 	{ "byteorder", CTLTYPE_INT }, \
545 	{ "physmem", CTLTYPE_INT }, \
546 	{ "usermem", CTLTYPE_INT }, \
547 	{ "pagesize", CTLTYPE_INT }, \
548 	{ "disknames", CTLTYPE_STRING }, \
549 	{ "diskstats", CTLTYPE_STRUCT }, \
550 	{ "diskcount", CTLTYPE_INT }, \
551 	{ "sensors", CTLTYPE_NODE}, \
552 	{ "cpuspeed", CTLTYPE_INT }, \
553 	{ "setperf", CTLTYPE_INT }, \
554 	{ "machine_arch", CTLTYPE_STRING }, \
555 }
556 
557 /*
558  * CTL_USER definitions
559  */
560 #define	USER_CS_PATH		 1	/* string: _CS_PATH */
561 #define	USER_BC_BASE_MAX	 2	/* int: BC_BASE_MAX */
562 #define	USER_BC_DIM_MAX		 3	/* int: BC_DIM_MAX */
563 #define	USER_BC_SCALE_MAX	 4	/* int: BC_SCALE_MAX */
564 #define	USER_BC_STRING_MAX	 5	/* int: BC_STRING_MAX */
565 #define	USER_COLL_WEIGHTS_MAX	 6	/* int: COLL_WEIGHTS_MAX */
566 #define	USER_EXPR_NEST_MAX	 7	/* int: EXPR_NEST_MAX */
567 #define	USER_LINE_MAX		 8	/* int: LINE_MAX */
568 #define	USER_RE_DUP_MAX		 9	/* int: RE_DUP_MAX */
569 #define	USER_POSIX2_VERSION	10	/* int: POSIX2_VERSION */
570 #define	USER_POSIX2_C_BIND	11	/* int: POSIX2_C_BIND */
571 #define	USER_POSIX2_C_DEV	12	/* int: POSIX2_C_DEV */
572 #define	USER_POSIX2_CHAR_TERM	13	/* int: POSIX2_CHAR_TERM */
573 #define	USER_POSIX2_FORT_DEV	14	/* int: POSIX2_FORT_DEV */
574 #define	USER_POSIX2_FORT_RUN	15	/* int: POSIX2_FORT_RUN */
575 #define	USER_POSIX2_LOCALEDEF	16	/* int: POSIX2_LOCALEDEF */
576 #define	USER_POSIX2_SW_DEV	17	/* int: POSIX2_SW_DEV */
577 #define	USER_POSIX2_UPE		18	/* int: POSIX2_UPE */
578 #define	USER_STREAM_MAX		19	/* int: POSIX2_STREAM_MAX */
579 #define	USER_TZNAME_MAX		20	/* int: POSIX2_TZNAME_MAX */
580 #define	USER_MAXID		21	/* number of valid user ids */
581 
582 #define	CTL_USER_NAMES { \
583 	{ 0, 0 }, \
584 	{ "cs_path", CTLTYPE_STRING }, \
585 	{ "bc_base_max", CTLTYPE_INT }, \
586 	{ "bc_dim_max", CTLTYPE_INT }, \
587 	{ "bc_scale_max", CTLTYPE_INT }, \
588 	{ "bc_string_max", CTLTYPE_INT }, \
589 	{ "coll_weights_max", CTLTYPE_INT }, \
590 	{ "expr_nest_max", CTLTYPE_INT }, \
591 	{ "line_max", CTLTYPE_INT }, \
592 	{ "re_dup_max", CTLTYPE_INT }, \
593 	{ "posix2_version", CTLTYPE_INT }, \
594 	{ "posix2_c_bind", CTLTYPE_INT }, \
595 	{ "posix2_c_dev", CTLTYPE_INT }, \
596 	{ "posix2_char_term", CTLTYPE_INT }, \
597 	{ "posix2_fort_dev", CTLTYPE_INT }, \
598 	{ "posix2_fort_run", CTLTYPE_INT }, \
599 	{ "posix2_localedef", CTLTYPE_INT }, \
600 	{ "posix2_sw_dev", CTLTYPE_INT }, \
601 	{ "posix2_upe", CTLTYPE_INT }, \
602 	{ "stream_max", CTLTYPE_INT }, \
603 	{ "tzname_max", CTLTYPE_INT }, \
604 }
605 
606 /*
607  * CTL_DEBUG definitions
608  *
609  * Second level identifier specifies which debug variable.
610  * Third level identifier specifies which stucture component.
611  */
612 #define	CTL_DEBUG_NAME		0	/* string: variable name */
613 #define	CTL_DEBUG_VALUE		1	/* int: variable value */
614 #define	CTL_DEBUG_MAXID		20
615 
616 #ifdef	_KERNEL
617 #ifdef	DEBUG
618 /*
619  * CTL_DEBUG variables.
620  *
621  * These are declared as separate variables so that they can be
622  * individually initialized at the location of their associated
623  * variable. The loader prevents multiple use by issuing errors
624  * if a variable is initialized in more than one place. They are
625  * aggregated into an array in debug_sysctl(), so that it can
626  * conveniently locate them when querried. If more debugging
627  * variables are added, they must also be declared here and also
628  * entered into the array.
629  */
630 struct ctldebug {
631 	char	*debugname;	/* name of debugging variable */
632 	int	*debugvar;	/* pointer to debugging variable */
633 };
634 extern struct ctldebug debug0, debug1, debug2, debug3, debug4;
635 extern struct ctldebug debug5, debug6, debug7, debug8, debug9;
636 extern struct ctldebug debug10, debug11, debug12, debug13, debug14;
637 extern struct ctldebug debug15, debug16, debug17, debug18, debug19;
638 #endif	/* DEBUG */
639 
640 /*
641  * Internal sysctl function calling convention:
642  *
643  *	(*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen);
644  *
645  * The name parameter points at the next component of the name to be
646  * interpreted.  The namelen parameter is the number of integers in
647  * the name.
648  */
649 typedef int (sysctlfn)(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
650 
651 int sysctl_int(void *, size_t *, void *, size_t, int *);
652 int sysctl_rdint(void *, size_t *, void *, int);
653 int sysctl_int_arr(int **, int *, u_int, void *, size_t *, void *, size_t);
654 int sysctl_quad(void *, size_t *, void *, size_t, int64_t *);
655 int sysctl_rdquad(void *, size_t *, void *, int64_t);
656 int sysctl_string(void *, size_t *, void *, size_t, char *, int);
657 int sysctl_tstring(void *, size_t *, void *, size_t, char *, int);
658 int sysctl__string(void *, size_t *, void *, size_t, char *, int, int);
659 int sysctl_rdstring(void *, size_t *, void *, const char *);
660 int sysctl_rdstruct(void *, size_t *, void *, const void *, int);
661 int sysctl_struct(void *, size_t *, void *, size_t, void *, int);
662 int sysctl_file(char *, size_t *);
663 int sysctl_doproc(int *, u_int, char *, size_t *);
664 struct radix_node;
665 struct walkarg;
666 int sysctl_dumpentry(struct radix_node *, void *);
667 int sysctl_iflist(int, struct walkarg *);
668 int sysctl_rtable(int *, u_int, void *, size_t *, void *, size_t);
669 int sysctl_clockrate(char *, size_t *);
670 int sysctl_vnode(char *, size_t *, struct proc *);
671 int sysctl_dopool(int *, u_int, char *, size_t *);
672 
673 void fill_eproc(struct proc *, struct eproc *);
674 void fill_kproc2(struct proc *, struct kinfo_proc2 *);
675 
676 int kern_sysctl(int *, u_int, void *, size_t *, void *, size_t,
677 		     struct proc *);
678 int hw_sysctl(int *, u_int, void *, size_t *, void *, size_t,
679 		   struct proc *);
680 #ifdef DEBUG
681 int debug_sysctl(int *, u_int, void *, size_t *, void *, size_t,
682 		      struct proc *);
683 #endif
684 int vm_sysctl(int *, u_int, void *, size_t *, void *, size_t,
685 		   struct proc *);
686 int fs_sysctl(int *, u_int, void *, size_t *, void *, size_t,
687 		   struct proc *);
688 int fs_posix_sysctl(int *, u_int, void *, size_t *, void *, size_t,
689 			 struct proc *);
690 int net_sysctl(int *, u_int, void *, size_t *, void *, size_t,
691 		    struct proc *);
692 int cpu_sysctl(int *, u_int, void *, size_t *, void *, size_t,
693 		    struct proc *);
694 int vfs_sysctl(int *, u_int, void *, size_t *, void *, size_t,
695 		    struct proc *);
696 int sysctl_sysvipc(int *, u_int, void *, size_t *);
697 int sysctl_wdog(int *, u_int, void *, size_t *, void *, size_t);
698 
699 extern int (*cpu_cpuspeed)(int *);
700 extern int (*cpu_setperf)(int);
701 
702 int bpf_sysctl(int *, u_int, void *, size_t *, void *, size_t);
703 
704 void sysctl_init(void);
705 
706 #else	/* !_KERNEL */
707 #include <sys/cdefs.h>
708 
709 __BEGIN_DECLS
710 int	sysctl(int *, u_int, void *, size_t *, void *, size_t);
711 __END_DECLS
712 #endif	/* _KERNEL */
713 #endif	/* !_SYS_SYSCTL_H_ */
714