xref: /netbsd/sys/sys/sysctl.h (revision c4a72b64)
1 /*	$NetBSD: sysctl.h,v 1.81 2002/11/17 19:54:59 manu Exp $	*/
2 
3 /*
4  * Copyright (c) 1989, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * Mike Karels at Berkeley Software Design, Inc.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *	This product includes software developed by the University of
21  *	California, Berkeley and its contributors.
22  * 4. Neither the name of the University nor the names of its contributors
23  *    may be used to endorse or promote products derived from this software
24  *    without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  *
38  *	@(#)sysctl.h	8.1 (Berkeley) 6/2/93
39  */
40 
41 #ifndef _SYS_SYSCTL_H_
42 #define	_SYS_SYSCTL_H_
43 
44 /*
45  * These are for the eproc structure defined below.
46  */
47 #include <sys/time.h>
48 #include <sys/ucred.h>
49 #include <sys/proc.h>
50 #include <uvm/uvm_extern.h>
51 
52 /*
53  * Definitions for sysctl call.  The sysctl call uses a hierarchical name
54  * for objects that can be examined or modified.  The name is expressed as
55  * a sequence of integers.  Like a file path name, the meaning of each
56  * component depends on its place in the hierarchy.  The top-level and kern
57  * identifiers are defined here, and other identifiers are defined in the
58  * respective subsystem header files.
59  */
60 
61 #define	CTL_MAXNAME	12	/* largest number of components supported */
62 
63 /*
64  * Each subsystem defined by sysctl defines a list of variables
65  * for that subsystem. Each name is either a node with further
66  * levels defined below it, or it is a leaf of some particular
67  * type given below. Each sysctl level defines a set of name/type
68  * pairs to be used by sysctl(1) in manipulating the subsystem.
69  */
70 struct ctlname {
71 	const char *ctl_name;	/* subsystem name */
72 	int	ctl_type;	/* type of name */
73 };
74 #define	CTLTYPE_NODE	1	/* name is a node */
75 #define	CTLTYPE_INT	2	/* name describes an integer */
76 #define	CTLTYPE_STRING	3	/* name describes a string */
77 #define	CTLTYPE_QUAD	4	/* name describes a 64-bit number */
78 #define	CTLTYPE_STRUCT	5	/* name describes a structure */
79 
80 /*
81  * Top-level identifiers
82  */
83 #define	CTL_UNSPEC	0		/* unused */
84 #define	CTL_KERN	1		/* "high kernel": proc, limits */
85 #define	CTL_VM		2		/* virtual memory */
86 #define	CTL_VFS		3		/* file system, mount type is next */
87 #define	CTL_NET		4		/* network, see socket.h */
88 #define	CTL_DEBUG	5		/* debugging parameters */
89 #define	CTL_HW		6		/* generic cpu/io */
90 #define	CTL_MACHDEP	7		/* machine dependent */
91 #define	CTL_USER	8		/* user-level */
92 #define	CTL_DDB		9		/* in-kernel debugger */
93 #define	CTL_PROC	10		/* per-proc attr */
94 #define	CTL_VENDOR	11		/* vendor-specific data */
95 #define	CTL_EMUL	12		/* emulation-specific data */
96 #define	CTL_MAXID	13		/* number of valid top-level ids */
97 
98 #define	CTL_NAMES { \
99 	{ 0, 0 }, \
100 	{ "kern", CTLTYPE_NODE }, \
101 	{ "vm", CTLTYPE_NODE }, \
102 	{ "vfs", CTLTYPE_NODE }, \
103 	{ "net", CTLTYPE_NODE }, \
104 	{ "debug", CTLTYPE_NODE }, \
105 	{ "hw", CTLTYPE_NODE }, \
106 	{ "machdep", CTLTYPE_NODE }, \
107 	{ "user", CTLTYPE_NODE }, \
108 	{ "ddb", CTLTYPE_NODE }, \
109 	{ "proc", CTLTYPE_NODE }, \
110 	{ "vendor", CTLTYPE_NODE }, \
111 	{ "emul", CTLTYPE_NODE }, \
112 }
113 
114 /*
115  * The "vendor" toplevel name is to be used by vendors who wish to
116  * have their own private MIB tree. If you do that, please use
117  * vendor.<yourname>.*
118  */
119 
120 /*
121  * CTL_KERN identifiers
122  */
123 #define	KERN_OSTYPE	 	 1	/* string: system version */
124 #define	KERN_OSRELEASE	 	 2	/* string: system release */
125 #define	KERN_OSREV	 	 3	/* int: system revision */
126 #define	KERN_VERSION	 	 4	/* string: compile time info */
127 #define	KERN_MAXVNODES	 	 5	/* int: max vnodes */
128 #define	KERN_MAXPROC	 	 6	/* int: max processes */
129 #define	KERN_MAXFILES	 	 7	/* int: max open files */
130 #define	KERN_ARGMAX	 	 8	/* int: max arguments to exec */
131 #define	KERN_SECURELVL	 	 9	/* int: system security level */
132 #define	KERN_HOSTNAME		10	/* string: hostname */
133 #define	KERN_HOSTID		11	/* int: host identifier */
134 #define	KERN_CLOCKRATE		12	/* struct: struct clockrate */
135 #define	KERN_VNODE		13	/* struct: vnode structures */
136 #define	KERN_PROC		14	/* struct: process entries */
137 #define	KERN_FILE		15	/* struct: file entries */
138 #define	KERN_PROF		16	/* node: kernel profiling info */
139 #define	KERN_POSIX1		17	/* int: POSIX.1 version */
140 #define	KERN_NGROUPS		18	/* int: # of supplemental group ids */
141 #define	KERN_JOB_CONTROL	19	/* int: is job control available */
142 #define	KERN_SAVED_IDS		20	/* int: saved set-user/group-ID */
143 #define	KERN_BOOTTIME		21	/* struct: time kernel was booted */
144 #define	KERN_DOMAINNAME		22	/* string: (YP) domainname */
145 #define	KERN_MAXPARTITIONS	23	/* int: number of partitions/disk */
146 #define	KERN_RAWPARTITION	24	/* int: raw partition number */
147 #define	KERN_NTPTIME		25	/* struct: extended-precision time */
148 #define	KERN_TIMEX		26	/* struct: ntp timekeeping state */
149 #define	KERN_AUTONICETIME	27	/* int: proc time before autonice */
150 #define	KERN_AUTONICEVAL	28	/* int: auto nice value */
151 #define	KERN_RTC_OFFSET		29	/* int: offset of rtc from gmt */
152 #define	KERN_ROOT_DEVICE	30	/* string: root device */
153 #define	KERN_MSGBUFSIZE		31	/* int: max # of chars in msg buffer */
154 #define	KERN_FSYNC		32	/* int: file synchronization support */
155 #define	KERN_SYSVMSG		33	/* int: SysV message queue suppoprt */
156 #define	KERN_SYSVSEM		34	/* int: SysV semaphore support */
157 #define	KERN_SYSVSHM		35	/* int: SysV shared memory support */
158 #define	KERN_OLDSHORTCORENAME	36	/* old, unimplemented */
159 #define	KERN_SYNCHRONIZED_IO	37	/* int: POSIX synchronized I/O */
160 #define	KERN_IOV_MAX		38	/* int: max iovec's for readv(2) etc. */
161 #define	KERN_MBUF		39	/* node: mbuf parameters */
162 #define	KERN_MAPPED_FILES	40	/* int: POSIX memory mapped files */
163 #define	KERN_MEMLOCK		41	/* int: POSIX memory locking */
164 #define	KERN_MEMLOCK_RANGE	42	/* int: POSIX memory range locking */
165 #define	KERN_MEMORY_PROTECTION	43	/* int: POSIX memory protections */
166 #define	KERN_LOGIN_NAME_MAX	44	/* int: max length login name + NUL */
167 #define	KERN_DEFCORENAME	45	/* old: sort core name format */
168 #define	KERN_LOGSIGEXIT		46	/* int: log signalled processes */
169 #define	KERN_PROC2		47	/* struct: process entries */
170 #define	KERN_PROC_ARGS		48	/* struct: process argv/env */
171 #define	KERN_FSCALE		49	/* int: fixpt FSCALE */
172 #define	KERN_CCPU		50	/* int: fixpt ccpu */
173 #define	KERN_CP_TIME		51	/* struct: cpu time counters */
174 #define	KERN_SYSVIPC_INFO	52	/* number of valid kern ids */
175 #define	KERN_MSGBUF		53	/* kernel message buffer */
176 #define	KERN_CONSDEV		54	/* dev_t: console terminal device */
177 #define	KERN_MAXPTYS		55	/* int: maximum number of ptys */
178 #define	KERN_PIPE		56	/* node: pipe limits */
179 #define	KERN_MAXPHYS		57	/* int: kernel value of MAXPHYS */
180 #define	KERN_SBMAX		58	/* int: max socket buffer size */
181 #define	KERN_TKSTAT		59	/* tty in/out counters */
182 #define	KERN_MONOTONIC_CLOCK	60	/* int: POSIX monotonic clock */
183 #define	KERN_URND		61	/* int: random integer from urandom */
184 #ifndef _KERNEL
185 #define	KERN_ARND		KERN_URND	/* compat w/ openbsd */
186 #endif
187 #define	KERN_MAXID		62	/* number of valid kern ids */
188 
189 #define	CTL_KERN_NAMES { \
190 	{ 0, 0 }, \
191 	{ "ostype", CTLTYPE_STRING }, \
192 	{ "osrelease", CTLTYPE_STRING }, \
193 	{ "osrevision", CTLTYPE_INT }, \
194 	{ "version", CTLTYPE_STRING }, \
195 	{ "maxvnodes", CTLTYPE_INT }, \
196 	{ "maxproc", CTLTYPE_INT }, \
197 	{ "maxfiles", CTLTYPE_INT }, \
198 	{ "argmax", CTLTYPE_INT }, \
199 	{ "securelevel", CTLTYPE_INT }, \
200 	{ "hostname", CTLTYPE_STRING }, \
201 	{ "hostid", CTLTYPE_INT }, \
202 	{ "clockrate", CTLTYPE_STRUCT }, \
203 	{ "vnode", CTLTYPE_STRUCT }, \
204 	{ "proc", CTLTYPE_STRUCT }, \
205 	{ "file", CTLTYPE_STRUCT }, \
206 	{ "profiling", CTLTYPE_NODE }, \
207 	{ "posix1version", CTLTYPE_INT }, \
208 	{ "ngroups", CTLTYPE_INT }, \
209 	{ "job_control", CTLTYPE_INT }, \
210 	{ "saved_ids", CTLTYPE_INT }, \
211 	{ "boottime", CTLTYPE_STRUCT }, \
212 	{ "domainname", CTLTYPE_STRING }, \
213 	{ "maxpartitions", CTLTYPE_INT }, \
214 	{ "rawpartition", CTLTYPE_INT }, \
215 	{ "ntptime", CTLTYPE_STRUCT }, \
216 	{ "timex", CTLTYPE_STRUCT }, \
217 	{ "autonicetime", CTLTYPE_INT }, \
218 	{ "autoniceval", CTLTYPE_INT }, \
219 	{ "rtc_offset", CTLTYPE_INT }, \
220 	{ "root_device", CTLTYPE_STRING }, \
221 	{ "msgbufsize", CTLTYPE_INT }, \
222 	{ "fsync", CTLTYPE_INT }, \
223 	{ "sysvmsg", CTLTYPE_INT }, \
224 	{ "sysvsem", CTLTYPE_INT }, \
225 	{ "sysvshm", CTLTYPE_INT }, \
226 	{ 0, 0 }, \
227 	{ "synchronized_io", CTLTYPE_INT }, \
228 	{ "iov_max", CTLTYPE_INT }, \
229 	{ "mbuf", CTLTYPE_NODE }, \
230 	{ "mapped_files", CTLTYPE_INT }, \
231 	{ "memlock", CTLTYPE_INT }, \
232 	{ "memlock_range", CTLTYPE_INT }, \
233 	{ "memory_protection", CTLTYPE_INT }, \
234 	{ "login_name_max", CTLTYPE_INT }, \
235 	{ "defcorename", CTLTYPE_STRING }, \
236 	{ "logsigexit", CTLTYPE_INT }, \
237 	{ "proc2", CTLTYPE_STRUCT }, \
238 	{ "proc_args", CTLTYPE_STRING }, \
239 	{ "fscale", CTLTYPE_INT }, \
240 	{ "ccpu", CTLTYPE_INT }, \
241 	{ "cp_time", CTLTYPE_STRUCT }, \
242 	{ "sysvipc_info", CTLTYPE_STRUCT }, \
243 	{ "msgbuf", CTLTYPE_STRUCT }, \
244 	{ "consdev", CTLTYPE_STRUCT }, \
245 	{ "maxptys", CTLTYPE_INT }, \
246 	{ "pipe", CTLTYPE_NODE }, \
247 	{ "maxphys", CTLTYPE_INT }, \
248 	{ "sbmax", CTLTYPE_INT }, \
249 	{ "tkstat", CTLTYPE_NODE }, \
250 	{ "monotonic_clock", CTLTYPE_INT }, \
251 	{ "urandom", CTLTYPE_INT }, \
252 }
253 
254 /*
255  * KERN_PROC subtypes
256  */
257 #define	KERN_PROC_ALL		 0	/* everything */
258 #define	KERN_PROC_PID		 1	/* by process id */
259 #define	KERN_PROC_PGRP		 2	/* by process group id */
260 #define	KERN_PROC_SESSION	 3	/* by session of pid */
261 #define	KERN_PROC_TTY		 4	/* by controlling tty */
262 #define	KERN_PROC_UID		 5	/* by effective uid */
263 #define	KERN_PROC_RUID		 6	/* by real uid */
264 #define	KERN_PROC_GID		 7	/* by effective gid */
265 #define	KERN_PROC_RGID		 8	/* by real gid */
266 
267 /*
268  * KERN_PROC_TTY sub-subtypes
269  */
270 #define	KERN_PROC_TTY_NODEV	NODEV		/* no controlling tty */
271 #define	KERN_PROC_TTY_REVOKE	((dev_t)-2)	/* revoked tty */
272 
273 /*
274  * KERN_PROC subtype ops return arrays of augmented proc structures:
275  */
276 struct kinfo_proc {
277 	struct	proc kp_proc;			/* proc structure */
278 	struct	eproc {
279 		struct	proc *e_paddr;		/* address of proc */
280 		struct	session *e_sess;	/* session pointer */
281 		struct	pcred e_pcred;		/* process credentials */
282 		struct	ucred e_ucred;		/* current credentials */
283 		struct	vmspace e_vm;		/* address space */
284 		pid_t	e_ppid;			/* parent process id */
285 		pid_t	e_pgid;			/* process group id */
286 		short	e_jobc;			/* job control counter */
287 		dev_t	e_tdev;			/* controlling tty dev */
288 		pid_t	e_tpgid;		/* tty process group id */
289 		struct	session *e_tsess;	/* tty session pointer */
290 #define	WMESGLEN	8
291 		char	e_wmesg[WMESGLEN];	/* wchan message */
292 		segsz_t e_xsize;		/* text size */
293 		short	e_xrssize;		/* text rss */
294 		short	e_xccount;		/* text references */
295 		short	e_xswrss;
296 		long	e_flag;
297 #define	EPROC_CTTY	0x01	/* controlling tty vnode active */
298 #define	EPROC_SLEADER	0x02	/* session leader */
299 		char	e_login[MAXLOGNAME];	/* setlogin() name */
300 		pid_t	e_sid;			/* session id */
301 		long	e_spare[3];
302 	} kp_eproc;
303 };
304 
305 /*
306  * KERN_PROC2 subtype ops return arrays of relatively fixed size
307  * structures of process info.   Use 8 byte alignment, and new
308  * elements should only be added to the end of this structure so
309  * binary compatibility can be preserved.
310  */
311 #define	KI_NGROUPS	16
312 #define	KI_MAXCOMLEN	24	/* extra for 8 byte alignment */
313 #define	KI_WMESGLEN	8
314 #define	KI_MAXLOGNAME	24	/* extra for 8 byte alignment */
315 
316 #define KI_NOCPU	(~(u_int64_t)0)
317 
318 typedef struct {
319 	u_int32_t	__bits[4];
320 } ki_sigset_t;
321 
322 struct kinfo_proc2 {
323 	u_int64_t p_forw;		/* PTR: linked run/sleep queue. */
324 	u_int64_t p_back;
325 	u_int64_t p_paddr;		/* PTR: address of proc */
326 
327 	u_int64_t p_addr;		/* PTR: Kernel virtual addr of u-area */
328 	u_int64_t p_fd;			/* PTR: Ptr to open files structure. */
329 	u_int64_t p_cwdi;		/* PTR: cdir/rdir/cmask info */
330 	u_int64_t p_stats;		/* PTR: Accounting/statistics */
331 	u_int64_t p_limit;		/* PTR: Process limits. */
332 	u_int64_t p_vmspace;		/* PTR: Address space. */
333 	u_int64_t p_sigacts;		/* PTR: Signal actions, state */
334 	u_int64_t p_sess;		/* PTR: session pointer */
335 	u_int64_t p_tsess;		/* PTR: tty session pointer */
336 	u_int64_t p_ru;			/* PTR: Exit information. XXX */
337 
338 	int32_t	p_eflag;		/* LONG: extra kinfo_proc2 flags */
339 	int32_t	p_exitsig;		/* INT: signal to sent to parent on exit */
340 	int32_t	p_flag;			/* INT: P_* flags. */
341 
342 	int32_t	p_pid;			/* PID_T: Process identifier. */
343 	int32_t	p_ppid;			/* PID_T: Parent process id */
344 	int32_t	p_sid;			/* PID_T: session id */
345 	int32_t	p__pgid;		/* PID_T: process group id */
346 					/* XXX: <sys/proc.h> hijacks p_pgid */
347 	int32_t	p_tpgid;		/* PID_T: tty process group id */
348 
349 	u_int32_t p_uid;		/* UID_T: effective user id */
350 	u_int32_t p_ruid;		/* UID_T: real user id */
351 	u_int32_t p_gid;		/* GID_T: effective group id */
352 	u_int32_t p_rgid;		/* GID_T: real group id */
353 
354 	u_int32_t p_groups[KI_NGROUPS];	/* GID_T: groups */
355 	int16_t	p_ngroups;		/* SHORT: number of groups */
356 
357 	int16_t	p_jobc;			/* SHORT: job control counter */
358 	u_int32_t p_tdev;		/* DEV_T: controlling tty dev */
359 
360 	u_int32_t p_estcpu;		/* U_INT: Time averaged value of p_cpticks. */
361 	u_int32_t p_rtime_sec;		/* STRUCT TIMEVAL: Real time. */
362 	u_int32_t p_rtime_usec;		/* STRUCT TIMEVAL: Real time. */
363 	int32_t	p_cpticks;		/* INT: Ticks of cpu time. */
364 	u_int32_t p_pctcpu;		/* FIXPT_T: %cpu for this process during p_swtime */
365 	u_int32_t p_swtime;		/* U_INT: Time swapped in or out. */
366 	u_int32_t p_slptime;		/* U_INT: Time since last blocked. */
367 	int32_t	p_schedflags;		/* INT: PSCHED_* flags */
368 
369 	u_int64_t p_uticks;		/* U_QUAD_T: Statclock hits in user mode. */
370 	u_int64_t p_sticks;		/* U_QUAD_T: Statclock hits in system mode. */
371 	u_int64_t p_iticks;		/* U_QUAD_T: Statclock hits processing intr. */
372 
373 	u_int64_t p_tracep;		/* PTR: Trace to vnode or file */
374 	int32_t	p_traceflag;		/* INT: Kernel trace points. */
375 
376 	int32_t	p_holdcnt;              /* INT: If non-zero, don't swap. */
377 
378 	ki_sigset_t p_siglist;		/* SIGSET_T: Signals arrived but not delivered. */
379 	ki_sigset_t p_sigmask;		/* SIGSET_T: Current signal mask. */
380 	ki_sigset_t p_sigignore;	/* SIGSET_T: Signals being ignored. */
381 	ki_sigset_t p_sigcatch;		/* SIGSET_T: Signals being caught by user. */
382 
383 	int8_t	p_stat;			/* CHAR: S* process status. */
384 	u_int8_t p_priority;		/* U_CHAR: Process priority. */
385 	u_int8_t p_usrpri;		/* U_CHAR: User-priority based on p_cpu and p_nice. */
386 	u_int8_t p_nice;		/* U_CHAR: Process "nice" value. */
387 
388 	u_int16_t p_xstat;		/* U_SHORT: Exit status for wait; also stop signal. */
389 	u_int16_t p_acflag;		/* U_SHORT: Accounting flags. */
390 
391 	char	p_comm[KI_MAXCOMLEN];
392 
393 	char	p_wmesg[KI_WMESGLEN];	/* wchan message */
394 	u_int64_t p_wchan;		/* PTR: sleep address. */
395 
396 	char	p_login[KI_MAXLOGNAME];	/* setlogin() name */
397 
398 	int32_t	p_vm_rssize;		/* SEGSZ_T: current resident set size in pages */
399 	int32_t	p_vm_tsize;		/* SEGSZ_T: text size (pages) */
400 	int32_t	p_vm_dsize;		/* SEGSZ_T: data size (pages) */
401 	int32_t	p_vm_ssize;		/* SEGSZ_T: stack size (pages) */
402 
403 	int64_t	p_uvalid;		/* CHAR: following p_u* members from struct user are valid */
404 					/* XXX 64 bits for alignment */
405 	u_int32_t p_ustart_sec;		/* STRUCT TIMEVAL: starting time. */
406 	u_int32_t p_ustart_usec;	/* STRUCT TIMEVAL: starting time. */
407 
408 	u_int32_t p_uutime_sec;		/* STRUCT TIMEVAL: user time. */
409 	u_int32_t p_uutime_usec;	/* STRUCT TIMEVAL: user time. */
410 	u_int32_t p_ustime_sec;		/* STRUCT TIMEVAL: system time. */
411 	u_int32_t p_ustime_usec;	/* STRUCT TIMEVAL: system time. */
412 
413 	u_int64_t p_uru_maxrss;		/* LONG: max resident set size. */
414 	u_int64_t p_uru_ixrss;		/* LONG: integral shared memory size. */
415 	u_int64_t p_uru_idrss;		/* LONG: integral unshared data ". */
416 	u_int64_t p_uru_isrss;		/* LONG: integral unshared stack ". */
417 	u_int64_t p_uru_minflt;		/* LONG: page reclaims. */
418 	u_int64_t p_uru_majflt;		/* LONG: page faults. */
419 	u_int64_t p_uru_nswap;		/* LONG: swaps. */
420 	u_int64_t p_uru_inblock;	/* LONG: block input operations. */
421 	u_int64_t p_uru_oublock;	/* LONG: block output operations. */
422 	u_int64_t p_uru_msgsnd;		/* LONG: messages sent. */
423 	u_int64_t p_uru_msgrcv;		/* LONG: messages received. */
424 	u_int64_t p_uru_nsignals;	/* LONG: signals received. */
425 	u_int64_t p_uru_nvcsw;		/* LONG: voluntary context switches. */
426 	u_int64_t p_uru_nivcsw;		/* LONG: involuntary ". */
427 
428 	u_int32_t p_uctime_sec;		/* STRUCT TIMEVAL: child u+s time. */
429 	u_int32_t p_uctime_usec;	/* STRUCT TIMEVAL: child u+s time. */
430 	u_int64_t p_cpuid;		/* LONG: cpu id */
431 };
432 
433 /*
434  * KERN_PROC_ARGS subtypes
435  */
436 #define	KERN_PROC_ARGV		1	/* argv */
437 #define	KERN_PROC_NARGV		2	/* number of strings in above */
438 #define	KERN_PROC_ENV		3	/* environ */
439 #define	KERN_PROC_NENV		4	/* number of strings in above */
440 
441 /*
442  * KERN_SYSVIPC_INFO subtypes
443  */
444 #define	KERN_SYSVIPC_MSG_INFO		1	/* msginfo and msqid_ds */
445 #define	KERN_SYSVIPC_SEM_INFO		2	/* seminfo and semid_ds */
446 #define	KERN_SYSVIPC_SHM_INFO		3	/* shminfo and shmid_ds */
447 
448 /*
449  * tty counter sysctl variables
450  */
451 #define	KERN_TKSTAT_NIN			1	/* total input character */
452 #define	KERN_TKSTAT_NOUT		2	/* total output character */
453 #define	KERN_TKSTAT_CANCC		3	/* canonical input character */
454 #define	KERN_TKSTAT_RAWCC		4	/* raw input character */
455 #define	KERN_TKSTAT_MAXID		5	/* number of valid TKSTAT ids */
456 
457 #define	KERN_TKSTAT_NAMES { \
458 	{ 0, 0 }, \
459 	{ "nin", CTLTYPE_QUAD }, \
460 	{ "nout", CTLTYPE_QUAD }, \
461 	{ "cancc", CTLTYPE_QUAD }, \
462 	{ "rawcc", CTLTYPE_QUAD }, \
463 }
464 
465 
466 /*
467  * CTL_HW identifiers
468  */
469 #define	HW_MACHINE	 1		/* string: machine class */
470 #define	HW_MODEL	 2		/* string: specific machine model */
471 #define	HW_NCPU		 3		/* int: number of cpus */
472 #define	HW_BYTEORDER	 4		/* int: machine byte order */
473 #define	HW_PHYSMEM	 5		/* int: total memory */
474 #define	HW_USERMEM	 6		/* int: non-kernel memory */
475 #define	HW_PAGESIZE	 7		/* int: software page size */
476 #define	HW_DISKNAMES	 8		/* string: disk drive names */
477 #define	HW_DISKSTATS	 9		/* struct: diskstats[] */
478 #define	HW_MACHINE_ARCH	10		/* string: machine architecture */
479 #define	HW_ALIGNBYTES	11		/* int: ALIGNBYTES for the kernel */
480 #define	HW_CNMAGIC	12		/* string: console magic sequence(s) */
481 #define	HW_MAXID	13		/* number of valid hw ids */
482 
483 #define	CTL_HW_NAMES { \
484 	{ 0, 0 }, \
485 	{ "machine", CTLTYPE_STRING }, \
486 	{ "model", CTLTYPE_STRING }, \
487 	{ "ncpu", CTLTYPE_INT }, \
488 	{ "byteorder", CTLTYPE_INT }, \
489 	{ "physmem", CTLTYPE_INT }, \
490 	{ "usermem", CTLTYPE_INT }, \
491 	{ "pagesize", CTLTYPE_INT }, \
492 	{ "disknames", CTLTYPE_STRING }, \
493 	{ "diskstats", CTLTYPE_STRUCT }, \
494 	{ "machine_arch", CTLTYPE_STRING }, \
495 	{ "alignbytes", CTLTYPE_INT }, \
496 	{ "cnmagic", CTLTYPE_STRING }, \
497 }
498 
499 /*
500  * CTL_USER definitions
501  */
502 #define	USER_CS_PATH		 1	/* string: _CS_PATH */
503 #define	USER_BC_BASE_MAX	 2	/* int: BC_BASE_MAX */
504 #define	USER_BC_DIM_MAX		 3	/* int: BC_DIM_MAX */
505 #define	USER_BC_SCALE_MAX	 4	/* int: BC_SCALE_MAX */
506 #define	USER_BC_STRING_MAX	 5	/* int: BC_STRING_MAX */
507 #define	USER_COLL_WEIGHTS_MAX	 6	/* int: COLL_WEIGHTS_MAX */
508 #define	USER_EXPR_NEST_MAX	 7	/* int: EXPR_NEST_MAX */
509 #define	USER_LINE_MAX		 8	/* int: LINE_MAX */
510 #define	USER_RE_DUP_MAX		 9	/* int: RE_DUP_MAX */
511 #define	USER_POSIX2_VERSION	10	/* int: POSIX2_VERSION */
512 #define	USER_POSIX2_C_BIND	11	/* int: POSIX2_C_BIND */
513 #define	USER_POSIX2_C_DEV	12	/* int: POSIX2_C_DEV */
514 #define	USER_POSIX2_CHAR_TERM	13	/* int: POSIX2_CHAR_TERM */
515 #define	USER_POSIX2_FORT_DEV	14	/* int: POSIX2_FORT_DEV */
516 #define	USER_POSIX2_FORT_RUN	15	/* int: POSIX2_FORT_RUN */
517 #define	USER_POSIX2_LOCALEDEF	16	/* int: POSIX2_LOCALEDEF */
518 #define	USER_POSIX2_SW_DEV	17	/* int: POSIX2_SW_DEV */
519 #define	USER_POSIX2_UPE		18	/* int: POSIX2_UPE */
520 #define	USER_STREAM_MAX		19	/* int: POSIX2_STREAM_MAX */
521 #define	USER_TZNAME_MAX		20	/* int: POSIX2_TZNAME_MAX */
522 #define	USER_MAXID		21	/* number of valid user ids */
523 
524 #define	CTL_USER_NAMES { \
525 	{ 0, 0 }, \
526 	{ "cs_path", CTLTYPE_STRING }, \
527 	{ "bc_base_max", CTLTYPE_INT }, \
528 	{ "bc_dim_max", CTLTYPE_INT }, \
529 	{ "bc_scale_max", CTLTYPE_INT }, \
530 	{ "bc_string_max", CTLTYPE_INT }, \
531 	{ "coll_weights_max", CTLTYPE_INT }, \
532 	{ "expr_nest_max", CTLTYPE_INT }, \
533 	{ "line_max", CTLTYPE_INT }, \
534 	{ "re_dup_max", CTLTYPE_INT }, \
535 	{ "posix2_version", CTLTYPE_INT }, \
536 	{ "posix2_c_bind", CTLTYPE_INT }, \
537 	{ "posix2_c_dev", CTLTYPE_INT }, \
538 	{ "posix2_char_term", CTLTYPE_INT }, \
539 	{ "posix2_fort_dev", CTLTYPE_INT }, \
540 	{ "posix2_fort_run", CTLTYPE_INT }, \
541 	{ "posix2_localedef", CTLTYPE_INT }, \
542 	{ "posix2_sw_dev", CTLTYPE_INT }, \
543 	{ "posix2_upe", CTLTYPE_INT }, \
544 	{ "stream_max", CTLTYPE_INT }, \
545 	{ "tzname_max", CTLTYPE_INT }, \
546 }
547 
548 /*
549  * CTL_DDB definitions
550  */
551 #define	DDBCTL_RADIX		1	/* int: Input and output radix */
552 #define	DDBCTL_MAXOFF		2	/* int: max symbol offset */
553 #define	DDBCTL_MAXWIDTH		3	/* int: width of the display line */
554 #define	DDBCTL_LINES		4	/* int: number of display lines */
555 #define	DDBCTL_TABSTOPS		5	/* int: tab width */
556 #define	DDBCTL_ONPANIC		6	/* int: DDB on panic if non-zero */
557 #define	DDBCTL_FROMCONSOLE	7	/* int: DDB via console if non-zero */
558 #define	DDBCTL_MAXID		8	/* number of valid DDB ids */
559 
560 #define	CTL_DDB_NAMES { \
561 	{ 0, 0 }, \
562 	{ "radix", CTLTYPE_INT }, \
563 	{ "maxoff", CTLTYPE_INT }, \
564 	{ "maxwidth", CTLTYPE_INT }, \
565 	{ "lines", CTLTYPE_INT }, \
566 	{ "tabstops", CTLTYPE_INT }, \
567 	{ "onpanic", CTLTYPE_INT }, \
568 	{ "fromconsole", CTLTYPE_INT }, \
569 }
570 
571 /*
572  * CTL_DEBUG definitions
573  *
574  * Second level identifier specifies which debug variable.
575  * Third level identifier specifies which stucture component.
576  */
577 #define	CTL_DEBUG_NAME		0	/* string: variable name */
578 #define	CTL_DEBUG_VALUE		1	/* int: variable value */
579 #define	CTL_DEBUG_MAXID		20
580 
581 /*
582  * CTL_PROC subtype. Either a PID, or a magic value for the current proc.
583  */
584 
585 #define	PROC_CURPROC	(~((u_int)1 << 31))
586 
587 /*
588  * CTL_PROC tree: either corename (string), or a limit
589  * (rlimit.<type>.{hard,soft}, int).
590  */
591 #define	PROC_PID_CORENAME	1
592 #define	PROC_PID_LIMIT		2
593 #define	PROC_PID_STOPFORK	3
594 #define	PROC_PID_STOPEXEC	4
595 #define	PROC_PID_MAXID		5
596 
597 #define	PROC_PID_NAMES { \
598 	{ 0, 0 }, \
599 	{ "corename", CTLTYPE_STRING }, \
600 	{ "rlimit", CTLTYPE_NODE }, \
601 	{ "stopfork", CTLTYPE_INT }, \
602 	{ "stopexec", CTLTYPE_INT }, \
603 }
604 
605 /* Limit types from <sys/resources.h> */
606 #define	PROC_PID_LIMIT_CPU	(RLIMIT_CPU+1)
607 #define	PROC_PID_LIMIT_FSIZE	(RLIMIT_FSIZE+1)
608 #define	PROC_PID_LIMIT_DATA	(RLIMIT_DATA+1)
609 #define	PROC_PID_LIMIT_STACK	(RLIMIT_STACK+1)
610 #define	PROC_PID_LIMIT_CORE	(RLIMIT_CORE+1)
611 #define	PROC_PID_LIMIT_RSS	(RLIMIT_RSS+1)
612 #define	PROC_PID_LIMIT_MEMLOCK	(RLIMIT_MEMLOCK+1)
613 #define PROC_PID_LIMIT_NPROC	(RLIMIT_NPROC+1)
614 #define	PROC_PID_LIMIT_NOFILE	(RLIMIT_NOFILE+1)
615 #define	PROC_PID_LIMIT_MAXID 	10
616 
617 #define	PROC_PID_LIMIT_NAMES { \
618 	{ 0, 0 }, \
619 	{ "cputime", CTLTYPE_NODE }, \
620 	{ "filesize", CTLTYPE_NODE }, \
621 	{ "datasize", CTLTYPE_NODE }, \
622 	{ "stacksize", CTLTYPE_NODE }, \
623 	{ "coredumpsize", CTLTYPE_NODE }, \
624 	{ "memoryuse", CTLTYPE_NODE }, \
625 	{ "memorylocked", CTLTYPE_NODE }, \
626 	{ "maxproc", CTLTYPE_NODE }, \
627 	{ "descriptors", CTLTYPE_NODE }, \
628 }
629 /* for each type, either hard or soft value */
630 #define	PROC_PID_LIMIT_TYPE_SOFT	1
631 #define	PROC_PID_LIMIT_TYPE_HARD	2
632 #define	PROC_PID_LIMIT_TYPE_MAXID	3
633 
634 #define	PROC_PID_LIMIT_TYPE_NAMES { \
635 	{0, 0}, \
636 	{ "soft", CTLTYPE_QUAD }, \
637 	{ "hard", CTLTYPE_QUAD }, \
638 }
639 
640 /*
641  * CTL_EMUL definitions
642  *
643  * Second level identifier specifies which emulation variable.
644  * Subsequent levels are specified in the emulations themselves.
645  */
646 #define	EMUL_LINUX	1
647 #define	EMUL_IRIX	2
648 
649 #define	EMUL_MAXID	3
650 #define	CTL_EMUL_NAMES { \
651 	{ 0, 0 }, \
652 	{ "linux", CTLTYPE_NODE }, \
653 	{ "irix", CTLTYPE_NODE }, \
654 }
655 
656 #ifdef	_KERNEL
657 /*
658  * CTL_DEBUG variables.
659  *
660  * These are declared as separate variables so that they can be
661  * individually initialized at the location of their associated
662  * variable. The loader prevents multiple use by issuing errors
663  * if a variable is initialized in more than one place. They are
664  * aggregated into an array in debug_sysctl(), so that it can
665  * conveniently locate them when querried. If more debugging
666  * variables are added, they must also be declared here and also
667  * entered into the array.
668  */
669 struct ctldebug {
670 	char	*debugname;	/* name of debugging variable */
671 	int	*debugvar;	/* pointer to debugging variable */
672 };
673 #ifdef	DEBUG
674 extern struct ctldebug debug0, debug1, debug2, debug3, debug4;
675 extern struct ctldebug debug5, debug6, debug7, debug8, debug9;
676 extern struct ctldebug debug10, debug11, debug12, debug13, debug14;
677 extern struct ctldebug debug15, debug16, debug17, debug18, debug19;
678 #endif	/* DEBUG */
679 
680 /*
681  * Internal sysctl function calling convention:
682  *
683  *	(*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen);
684  *
685  * The name parameter points at the next component of the name to be
686  * interpreted.  The namelen parameter is the number of integers in
687  * the name.
688  */
689 typedef int (sysctlfn)
690     (int *, u_int, void *, size_t *, void *, size_t, struct proc *);
691 
692 int sysctl_int(void *, size_t *, void *, size_t, int *);
693 int sysctl_rdint(void *, size_t *, void *, int);
694 int sysctl_quad(void *, size_t *, void *, size_t, quad_t *);
695 int sysctl_rdquad(void *, size_t *, void *, quad_t);
696 int sysctl_string(void *, size_t *, void *, size_t, char *, size_t);
697 int sysctl_rdstring(void *, size_t *, void *, const char *);
698 int sysctl_struct(void *, size_t *, void *, size_t, void *, size_t);
699 int sysctl_rdstruct(void *, size_t *, void *, const void *, size_t);
700 int sysctl_rdminstruct(void *, size_t *, void *, const void *, size_t);
701 int sysctl_clockrate(void *, size_t *);
702 int sysctl_disknames(void *, size_t *);
703 int sysctl_diskstats(int *, u_int, void *, size_t *);
704 int sysctl_vnode(char *, size_t *, struct proc *);
705 int sysctl_ntptime(void *, size_t *);
706 #ifdef GPROF
707 int sysctl_doprof(int *, u_int, void *, size_t *, void *, size_t);
708 #endif
709 int sysctl_dombuf(int *, u_int, void *, size_t *, void *, size_t);
710 
711 void fill_eproc(struct proc *, struct eproc *);
712 
713 int kern_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
714 int hw_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
715 int proc_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
716 #ifdef DEBUG
717 int debug_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
718 #endif
719 int net_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
720 int cpu_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
721 int emul_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
722 
723 /* ddb_sysctl() declared in ddb_var.h */
724 
725 void	sysctl_init(void);
726 
727 #ifdef __SYSCTL_PRIVATE
728 extern struct lock sysctl_memlock;
729 #endif
730 
731 #else	/* !_KERNEL */
732 #include <sys/cdefs.h>
733 
734 __BEGIN_DECLS
735 int	sysctl __P((int *, u_int, void *, size_t *, const void *, size_t));
736 __END_DECLS
737 #endif	/* _KERNEL */
738 #endif	/* !_SYS_SYSCTL_H_ */
739