xref: /netbsd/sys/sys/sysctl.h (revision bf9ec67e)
1 /*	$NetBSD: sysctl.h,v 1.74 2002/03/20 00:23:46 christos 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_MAXID		61	/* number of valid kern ids */
184 
185 #define	CTL_KERN_NAMES { \
186 	{ 0, 0 }, \
187 	{ "ostype", CTLTYPE_STRING }, \
188 	{ "osrelease", CTLTYPE_STRING }, \
189 	{ "osrevision", CTLTYPE_INT }, \
190 	{ "version", CTLTYPE_STRING }, \
191 	{ "maxvnodes", CTLTYPE_INT }, \
192 	{ "maxproc", CTLTYPE_INT }, \
193 	{ "maxfiles", CTLTYPE_INT }, \
194 	{ "argmax", CTLTYPE_INT }, \
195 	{ "securelevel", CTLTYPE_INT }, \
196 	{ "hostname", CTLTYPE_STRING }, \
197 	{ "hostid", CTLTYPE_INT }, \
198 	{ "clockrate", CTLTYPE_STRUCT }, \
199 	{ "vnode", CTLTYPE_STRUCT }, \
200 	{ "proc", CTLTYPE_STRUCT }, \
201 	{ "file", CTLTYPE_STRUCT }, \
202 	{ "profiling", CTLTYPE_NODE }, \
203 	{ "posix1version", CTLTYPE_INT }, \
204 	{ "ngroups", CTLTYPE_INT }, \
205 	{ "job_control", CTLTYPE_INT }, \
206 	{ "saved_ids", CTLTYPE_INT }, \
207 	{ "boottime", CTLTYPE_STRUCT }, \
208 	{ "domainname", CTLTYPE_STRING }, \
209 	{ "maxpartitions", CTLTYPE_INT }, \
210 	{ "rawpartition", CTLTYPE_INT }, \
211 	{ "ntptime", CTLTYPE_STRUCT }, \
212 	{ "timex", CTLTYPE_STRUCT }, \
213 	{ "autonicetime", CTLTYPE_INT }, \
214 	{ "autoniceval", CTLTYPE_INT }, \
215 	{ "rtc_offset", CTLTYPE_INT }, \
216 	{ "root_device", CTLTYPE_STRING }, \
217 	{ "msgbufsize", CTLTYPE_INT }, \
218 	{ "fsync", CTLTYPE_INT }, \
219 	{ "sysvmsg", CTLTYPE_INT }, \
220 	{ "sysvsem", CTLTYPE_INT }, \
221 	{ "sysvshm", CTLTYPE_INT }, \
222 	{ 0, 0 }, \
223 	{ "synchronized_io", CTLTYPE_INT }, \
224 	{ "iov_max", CTLTYPE_INT }, \
225 	{ "mbuf", CTLTYPE_NODE }, \
226 	{ "mapped_files", CTLTYPE_INT }, \
227 	{ "memlock", CTLTYPE_INT }, \
228 	{ "memlock_range", CTLTYPE_INT }, \
229 	{ "memory_protection", CTLTYPE_INT }, \
230 	{ "login_name_max", CTLTYPE_INT }, \
231 	{ "defcorename", CTLTYPE_STRING }, \
232 	{ "logsigexit", CTLTYPE_INT }, \
233 	{ "proc2", CTLTYPE_STRUCT }, \
234 	{ "proc_args", CTLTYPE_STRING }, \
235 	{ "fscale", CTLTYPE_INT }, \
236 	{ "ccpu", CTLTYPE_INT }, \
237 	{ "cp_time", CTLTYPE_STRUCT }, \
238 	{ "sysvipc_info", CTLTYPE_STRUCT }, \
239 	{ "msgbuf", CTLTYPE_STRUCT }, \
240 	{ "consdev", CTLTYPE_STRUCT }, \
241 	{ "maxptys", CTLTYPE_INT }, \
242 	{ "pipe", CTLTYPE_NODE }, \
243 	{ "maxphys", CTLTYPE_INT }, \
244 	{ "sbmax", CTLTYPE_INT }, \
245 	{ "tkstat", CTLTYPE_NODE }, \
246 	{ "monotonic_clock", CTLTYPE_INT }, \
247 }
248 
249 /*
250  * KERN_PROC subtypes
251  */
252 #define	KERN_PROC_ALL		 0	/* everything */
253 #define	KERN_PROC_PID		 1	/* by process id */
254 #define	KERN_PROC_PGRP		 2	/* by process group id */
255 #define	KERN_PROC_SESSION	 3	/* by session of pid */
256 #define	KERN_PROC_TTY		 4	/* by controlling tty */
257 #define	KERN_PROC_UID		 5	/* by effective uid */
258 #define	KERN_PROC_RUID		 6	/* by real uid */
259 #define	KERN_PROC_GID		 7	/* by effective gid */
260 #define	KERN_PROC_RGID		 8	/* by real gid */
261 
262 /*
263  * KERN_PROC_TTY sub-subtypes
264  */
265 #define	KERN_PROC_TTY_NODEV	NODEV		/* no controlling tty */
266 #define	KERN_PROC_TTY_REVOKE	((dev_t)-2)	/* revoked tty */
267 
268 /*
269  * KERN_PROC subtype ops return arrays of augmented proc structures:
270  */
271 struct kinfo_proc {
272 	struct	proc kp_proc;			/* proc structure */
273 	struct	eproc {
274 		struct	proc *e_paddr;		/* address of proc */
275 		struct	session *e_sess;	/* session pointer */
276 		struct	pcred e_pcred;		/* process credentials */
277 		struct	ucred e_ucred;		/* current credentials */
278 		struct	vmspace e_vm;		/* address space */
279 		pid_t	e_ppid;			/* parent process id */
280 		pid_t	e_pgid;			/* process group id */
281 		short	e_jobc;			/* job control counter */
282 		dev_t	e_tdev;			/* controlling tty dev */
283 		pid_t	e_tpgid;		/* tty process group id */
284 		struct	session *e_tsess;	/* tty session pointer */
285 #define	WMESGLEN	8
286 		char	e_wmesg[WMESGLEN];	/* wchan message */
287 		segsz_t e_xsize;		/* text size */
288 		short	e_xrssize;		/* text rss */
289 		short	e_xccount;		/* text references */
290 		short	e_xswrss;
291 		long	e_flag;
292 #define	EPROC_CTTY	0x01	/* controlling tty vnode active */
293 #define	EPROC_SLEADER	0x02	/* session leader */
294 		char	e_login[MAXLOGNAME];	/* setlogin() name */
295 		pid_t	e_sid;			/* session id */
296 		long	e_spare[3];
297 	} kp_eproc;
298 };
299 
300 /*
301  * KERN_PROC2 subtype ops return arrays of relatively fixed size
302  * structures of process info.   Use 8 byte alignment, and new
303  * elements should only be added to the end of this structure so
304  * binary compatibility can be preserved.
305  */
306 #define	KI_NGROUPS	16
307 #define	KI_MAXCOMLEN	24	/* extra for 8 byte alignment */
308 #define	KI_WMESGLEN	8
309 #define	KI_MAXLOGNAME	24	/* extra for 8 byte alignment */
310 
311 #define KI_NOCPU	(~(u_int64_t)0)
312 
313 typedef struct {
314 	u_int32_t	__bits[4];
315 } ki_sigset_t;
316 
317 struct kinfo_proc2 {
318 	u_int64_t p_forw;		/* PTR: linked run/sleep queue. */
319 	u_int64_t p_back;
320 	u_int64_t p_paddr;		/* PTR: address of proc */
321 
322 	u_int64_t p_addr;		/* PTR: Kernel virtual addr of u-area */
323 	u_int64_t p_fd;			/* PTR: Ptr to open files structure. */
324 	u_int64_t p_cwdi;		/* PTR: cdir/rdir/cmask info */
325 	u_int64_t p_stats;		/* PTR: Accounting/statistics */
326 	u_int64_t p_limit;		/* PTR: Process limits. */
327 	u_int64_t p_vmspace;		/* PTR: Address space. */
328 	u_int64_t p_sigacts;		/* PTR: Signal actions, state */
329 	u_int64_t p_sess;		/* PTR: session pointer */
330 	u_int64_t p_tsess;		/* PTR: tty session pointer */
331 	u_int64_t p_ru;			/* PTR: Exit information. XXX */
332 
333 	int32_t	p_eflag;		/* LONG: extra kinfo_proc2 flags */
334 	int32_t	p_exitsig;		/* INT: signal to sent to parent on exit */
335 	int32_t	p_flag;			/* INT: P_* flags. */
336 
337 	int32_t	p_pid;			/* PID_T: Process identifier. */
338 	int32_t	p_ppid;			/* PID_T: Parent process id */
339 	int32_t	p_sid;			/* PID_T: session id */
340 	int32_t	p__pgid;		/* PID_T: process group id */
341 					/* XXX: <sys/proc.h> hijacks p_pgid */
342 	int32_t	p_tpgid;		/* PID_T: tty process group id */
343 
344 	u_int32_t p_uid;		/* UID_T: effective user id */
345 	u_int32_t p_ruid;		/* UID_T: real user id */
346 	u_int32_t p_gid;		/* GID_T: effective group id */
347 	u_int32_t p_rgid;		/* GID_T: real group id */
348 
349 	u_int32_t p_groups[KI_NGROUPS];	/* GID_T: groups */
350 	int16_t	p_ngroups;		/* SHORT: number of groups */
351 
352 	int16_t	p_jobc;			/* SHORT: job control counter */
353 	u_int32_t p_tdev;		/* DEV_T: controlling tty dev */
354 
355 	u_int32_t p_estcpu;		/* U_INT: Time averaged value of p_cpticks. */
356 	u_int32_t p_rtime_sec;		/* STRUCT TIMEVAL: Real time. */
357 	u_int32_t p_rtime_usec;		/* STRUCT TIMEVAL: Real time. */
358 	int32_t	p_cpticks;		/* INT: Ticks of cpu time. */
359 	u_int32_t p_pctcpu;		/* FIXPT_T: %cpu for this process during p_swtime */
360 	u_int32_t p_swtime;		/* U_INT: Time swapped in or out. */
361 	u_int32_t p_slptime;		/* U_INT: Time since last blocked. */
362 	int32_t	p_schedflags;		/* INT: PSCHED_* flags */
363 
364 	u_int64_t p_uticks;		/* U_QUAD_T: Statclock hits in user mode. */
365 	u_int64_t p_sticks;		/* U_QUAD_T: Statclock hits in system mode. */
366 	u_int64_t p_iticks;		/* U_QUAD_T: Statclock hits processing intr. */
367 
368 	u_int64_t p_tracep;		/* PTR: Trace to vnode or file */
369 	int32_t	p_traceflag;		/* INT: Kernel trace points. */
370 
371 	int32_t	p_holdcnt;              /* INT: If non-zero, don't swap. */
372 
373 	ki_sigset_t p_siglist;		/* SIGSET_T: Signals arrived but not delivered. */
374 	ki_sigset_t p_sigmask;		/* SIGSET_T: Current signal mask. */
375 	ki_sigset_t p_sigignore;	/* SIGSET_T: Signals being ignored. */
376 	ki_sigset_t p_sigcatch;		/* SIGSET_T: Signals being caught by user. */
377 
378 	int8_t	p_stat;			/* CHAR: S* process status. */
379 	u_int8_t p_priority;		/* U_CHAR: Process priority. */
380 	u_int8_t p_usrpri;		/* U_CHAR: User-priority based on p_cpu and p_nice. */
381 	u_int8_t p_nice;		/* U_CHAR: Process "nice" value. */
382 
383 	u_int16_t p_xstat;		/* U_SHORT: Exit status for wait; also stop signal. */
384 	u_int16_t p_acflag;		/* U_SHORT: Accounting flags. */
385 
386 	char	p_comm[KI_MAXCOMLEN];
387 
388 	char	p_wmesg[KI_WMESGLEN];	/* wchan message */
389 	u_int64_t p_wchan;		/* PTR: sleep address. */
390 
391 	char	p_login[KI_MAXLOGNAME];	/* setlogin() name */
392 
393 	int32_t	p_vm_rssize;		/* SEGSZ_T: current resident set size in pages */
394 	int32_t	p_vm_tsize;		/* SEGSZ_T: text size (pages) */
395 	int32_t	p_vm_dsize;		/* SEGSZ_T: data size (pages) */
396 	int32_t	p_vm_ssize;		/* SEGSZ_T: stack size (pages) */
397 
398 	int64_t	p_uvalid;		/* CHAR: following p_u* members from struct user are valid */
399 					/* XXX 64 bits for alignment */
400 	u_int32_t p_ustart_sec;		/* STRUCT TIMEVAL: starting time. */
401 	u_int32_t p_ustart_usec;	/* STRUCT TIMEVAL: starting time. */
402 
403 	u_int32_t p_uutime_sec;		/* STRUCT TIMEVAL: user time. */
404 	u_int32_t p_uutime_usec;	/* STRUCT TIMEVAL: user time. */
405 	u_int32_t p_ustime_sec;		/* STRUCT TIMEVAL: system time. */
406 	u_int32_t p_ustime_usec;	/* STRUCT TIMEVAL: system time. */
407 
408 	u_int64_t p_uru_maxrss;		/* LONG: max resident set size. */
409 	u_int64_t p_uru_ixrss;		/* LONG: integral shared memory size. */
410 	u_int64_t p_uru_idrss;		/* LONG: integral unshared data ". */
411 	u_int64_t p_uru_isrss;		/* LONG: integral unshared stack ". */
412 	u_int64_t p_uru_minflt;		/* LONG: page reclaims. */
413 	u_int64_t p_uru_majflt;		/* LONG: page faults. */
414 	u_int64_t p_uru_nswap;		/* LONG: swaps. */
415 	u_int64_t p_uru_inblock;	/* LONG: block input operations. */
416 	u_int64_t p_uru_oublock;	/* LONG: block output operations. */
417 	u_int64_t p_uru_msgsnd;		/* LONG: messages sent. */
418 	u_int64_t p_uru_msgrcv;		/* LONG: messages received. */
419 	u_int64_t p_uru_nsignals;	/* LONG: signals received. */
420 	u_int64_t p_uru_nvcsw;		/* LONG: voluntary context switches. */
421 	u_int64_t p_uru_nivcsw;		/* LONG: involuntary ". */
422 
423 	u_int32_t p_uctime_sec;		/* STRUCT TIMEVAL: child u+s time. */
424 	u_int32_t p_uctime_usec;	/* STRUCT TIMEVAL: child u+s time. */
425 	u_int64_t p_cpuid;		/* LONG: cpu id */
426 };
427 
428 /*
429  * KERN_PROC_ARGS subtypes
430  */
431 #define	KERN_PROC_ARGV		1	/* argv */
432 #define	KERN_PROC_NARGV		2	/* number of strings in above */
433 #define	KERN_PROC_ENV		3	/* environ */
434 #define	KERN_PROC_NENV		4	/* number of strings in above */
435 
436 /*
437  * KERN_SYSVIPC_INFO subtypes
438  */
439 #define	KERN_SYSVIPC_MSG_INFO		1	/* msginfo and msqid_ds */
440 #define	KERN_SYSVIPC_SEM_INFO		2	/* seminfo and semid_ds */
441 #define	KERN_SYSVIPC_SHM_INFO		3	/* shminfo and shmid_ds */
442 
443 /*
444  * tty counter sysctl variables
445  */
446 #define	KERN_TKSTAT_NIN			1	/* total input character */
447 #define	KERN_TKSTAT_NOUT		2	/* total output character */
448 #define	KERN_TKSTAT_CANCC		3	/* canonical input character */
449 #define	KERN_TKSTAT_RAWCC		4	/* raw input character */
450 #define	KERN_TKSTAT_MAXID		5	/* number of valid TKSTAT ids */
451 
452 #define	KERN_TKSTAT_NAMES { \
453 	{ 0, 0 }, \
454 	{ "nin", CTLTYPE_QUAD }, \
455 	{ "nout", CTLTYPE_QUAD }, \
456 	{ "cancc", CTLTYPE_QUAD }, \
457 	{ "rawcc", CTLTYPE_QUAD }, \
458 }
459 
460 
461 /*
462  * CTL_HW identifiers
463  */
464 #define	HW_MACHINE	 1		/* string: machine class */
465 #define	HW_MODEL	 2		/* string: specific machine model */
466 #define	HW_NCPU		 3		/* int: number of cpus */
467 #define	HW_BYTEORDER	 4		/* int: machine byte order */
468 #define	HW_PHYSMEM	 5		/* int: total memory */
469 #define	HW_USERMEM	 6		/* int: non-kernel memory */
470 #define	HW_PAGESIZE	 7		/* int: software page size */
471 #define	HW_DISKNAMES	 8		/* string: disk drive names */
472 #define	HW_DISKSTATS	 9		/* struct: diskstats[] */
473 #define	HW_MACHINE_ARCH	10		/* string: machine architecture */
474 #define	HW_ALIGNBYTES	11		/* int: ALIGNBYTES for the kernel */
475 #define	HW_CNMAGIC	12		/* string: console magic sequence(s) */
476 #define	HW_MAXID	13		/* number of valid hw ids */
477 
478 #define	CTL_HW_NAMES { \
479 	{ 0, 0 }, \
480 	{ "machine", CTLTYPE_STRING }, \
481 	{ "model", CTLTYPE_STRING }, \
482 	{ "ncpu", CTLTYPE_INT }, \
483 	{ "byteorder", CTLTYPE_INT }, \
484 	{ "physmem", CTLTYPE_INT }, \
485 	{ "usermem", CTLTYPE_INT }, \
486 	{ "pagesize", CTLTYPE_INT }, \
487 	{ "disknames", CTLTYPE_STRING }, \
488 	{ "diskstats", CTLTYPE_STRUCT }, \
489 	{ "machine_arch", CTLTYPE_STRING }, \
490 	{ "alignbytes", CTLTYPE_INT }, \
491 	{ "cnmagic", CTLTYPE_STRING }, \
492 }
493 
494 /*
495  * CTL_USER definitions
496  */
497 #define	USER_CS_PATH		 1	/* string: _CS_PATH */
498 #define	USER_BC_BASE_MAX	 2	/* int: BC_BASE_MAX */
499 #define	USER_BC_DIM_MAX		 3	/* int: BC_DIM_MAX */
500 #define	USER_BC_SCALE_MAX	 4	/* int: BC_SCALE_MAX */
501 #define	USER_BC_STRING_MAX	 5	/* int: BC_STRING_MAX */
502 #define	USER_COLL_WEIGHTS_MAX	 6	/* int: COLL_WEIGHTS_MAX */
503 #define	USER_EXPR_NEST_MAX	 7	/* int: EXPR_NEST_MAX */
504 #define	USER_LINE_MAX		 8	/* int: LINE_MAX */
505 #define	USER_RE_DUP_MAX		 9	/* int: RE_DUP_MAX */
506 #define	USER_POSIX2_VERSION	10	/* int: POSIX2_VERSION */
507 #define	USER_POSIX2_C_BIND	11	/* int: POSIX2_C_BIND */
508 #define	USER_POSIX2_C_DEV	12	/* int: POSIX2_C_DEV */
509 #define	USER_POSIX2_CHAR_TERM	13	/* int: POSIX2_CHAR_TERM */
510 #define	USER_POSIX2_FORT_DEV	14	/* int: POSIX2_FORT_DEV */
511 #define	USER_POSIX2_FORT_RUN	15	/* int: POSIX2_FORT_RUN */
512 #define	USER_POSIX2_LOCALEDEF	16	/* int: POSIX2_LOCALEDEF */
513 #define	USER_POSIX2_SW_DEV	17	/* int: POSIX2_SW_DEV */
514 #define	USER_POSIX2_UPE		18	/* int: POSIX2_UPE */
515 #define	USER_STREAM_MAX		19	/* int: POSIX2_STREAM_MAX */
516 #define	USER_TZNAME_MAX		20	/* int: POSIX2_TZNAME_MAX */
517 #define	USER_MAXID		21	/* number of valid user ids */
518 
519 #define	CTL_USER_NAMES { \
520 	{ 0, 0 }, \
521 	{ "cs_path", CTLTYPE_STRING }, \
522 	{ "bc_base_max", CTLTYPE_INT }, \
523 	{ "bc_dim_max", CTLTYPE_INT }, \
524 	{ "bc_scale_max", CTLTYPE_INT }, \
525 	{ "bc_string_max", CTLTYPE_INT }, \
526 	{ "coll_weights_max", CTLTYPE_INT }, \
527 	{ "expr_nest_max", CTLTYPE_INT }, \
528 	{ "line_max", CTLTYPE_INT }, \
529 	{ "re_dup_max", CTLTYPE_INT }, \
530 	{ "posix2_version", CTLTYPE_INT }, \
531 	{ "posix2_c_bind", CTLTYPE_INT }, \
532 	{ "posix2_c_dev", CTLTYPE_INT }, \
533 	{ "posix2_char_term", CTLTYPE_INT }, \
534 	{ "posix2_fort_dev", CTLTYPE_INT }, \
535 	{ "posix2_fort_run", CTLTYPE_INT }, \
536 	{ "posix2_localedef", CTLTYPE_INT }, \
537 	{ "posix2_sw_dev", CTLTYPE_INT }, \
538 	{ "posix2_upe", CTLTYPE_INT }, \
539 	{ "stream_max", CTLTYPE_INT }, \
540 	{ "tzname_max", CTLTYPE_INT }, \
541 }
542 
543 /*
544  * CTL_DDB definitions
545  */
546 #define	DDBCTL_RADIX		1	/* int: Input and output radix */
547 #define	DDBCTL_MAXOFF		2	/* int: max symbol offset */
548 #define	DDBCTL_MAXWIDTH		3	/* int: width of the display line */
549 #define	DDBCTL_LINES		4	/* int: number of display lines */
550 #define	DDBCTL_TABSTOPS		5	/* int: tab width */
551 #define	DDBCTL_ONPANIC		6	/* int: DDB on panic if non-zero */
552 #define	DDBCTL_FROMCONSOLE	7	/* int: DDB via console if non-zero */
553 #define	DDBCTL_MAXID		8	/* number of valid DDB ids */
554 
555 #define	CTL_DDB_NAMES { \
556 	{ 0, 0 }, \
557 	{ "radix", CTLTYPE_INT }, \
558 	{ "maxoff", CTLTYPE_INT }, \
559 	{ "maxwidth", CTLTYPE_INT }, \
560 	{ "lines", CTLTYPE_INT }, \
561 	{ "tabstops", CTLTYPE_INT }, \
562 	{ "onpanic", CTLTYPE_INT }, \
563 	{ "fromconsole", CTLTYPE_INT }, \
564 }
565 
566 /*
567  * CTL_DEBUG definitions
568  *
569  * Second level identifier specifies which debug variable.
570  * Third level identifier specifies which stucture component.
571  */
572 #define	CTL_DEBUG_NAME		0	/* string: variable name */
573 #define	CTL_DEBUG_VALUE		1	/* int: variable value */
574 #define	CTL_DEBUG_MAXID		20
575 
576 /*
577  * CTL_PROC subtype. Either a PID, or a magic value for the current proc.
578  */
579 
580 #define	PROC_CURPROC	(~((u_int)1 << 31))
581 
582 /*
583  * CTL_PROC tree: either corename (string), or a limit
584  * (rlimit.<type>.{hard,soft}, int).
585  */
586 #define	PROC_PID_CORENAME	1
587 #define	PROC_PID_LIMIT		2
588 #define	PROC_PID_MAXID		3
589 
590 #define	PROC_PID_NAMES { \
591 	{ 0, 0 }, \
592 	{ "corename", CTLTYPE_STRING }, \
593 	{ "rlimit", CTLTYPE_NODE }, \
594 }
595 
596 /* Limit types from <sys/resources.h> */
597 #define	PROC_PID_LIMIT_CPU	(RLIMIT_CPU+1)
598 #define	PROC_PID_LIMIT_FSIZE	(RLIMIT_FSIZE+1)
599 #define	PROC_PID_LIMIT_DATA	(RLIMIT_DATA+1)
600 #define	PROC_PID_LIMIT_STACK	(RLIMIT_STACK+1)
601 #define	PROC_PID_LIMIT_CORE	(RLIMIT_CORE+1)
602 #define	PROC_PID_LIMIT_RSS	(RLIMIT_RSS+1)
603 #define	PROC_PID_LIMIT_MEMLOCK	(RLIMIT_MEMLOCK+1)
604 #define PROC_PID_LIMIT_NPROC	(RLIMIT_NPROC+1)
605 #define	PROC_PID_LIMIT_NOFILE	(RLIMIT_NOFILE+1)
606 #define	PROC_PID_LIMIT_MAXID 	10
607 
608 #define	PROC_PID_LIMIT_NAMES { \
609 	{ 0, 0 }, \
610 	{ "cputime", CTLTYPE_NODE }, \
611 	{ "filesize", CTLTYPE_NODE }, \
612 	{ "datasize", CTLTYPE_NODE }, \
613 	{ "stacksize", CTLTYPE_NODE }, \
614 	{ "coredumpsize", CTLTYPE_NODE }, \
615 	{ "memoryuse", CTLTYPE_NODE }, \
616 	{ "memorylocked", CTLTYPE_NODE }, \
617 	{ "maxproc", CTLTYPE_NODE }, \
618 	{ "descriptors", CTLTYPE_NODE }, \
619 }
620 /* for each type, either hard or soft value */
621 #define	PROC_PID_LIMIT_TYPE_SOFT	1
622 #define	PROC_PID_LIMIT_TYPE_HARD	2
623 #define	PROC_PID_LIMIT_TYPE_MAXID	3
624 
625 #define	PROC_PID_LIMIT_TYPE_NAMES { \
626 	{0, 0}, \
627 	{ "soft", CTLTYPE_QUAD }, \
628 	{ "hard", CTLTYPE_QUAD }, \
629 }
630 
631 /*
632  * CTL_EMUL definitions
633  *
634  * Second level identifier specifies which emulation variable.
635  * Subsequent levels are specified in the emulations themselves.
636  */
637 #define	EMUL_LINUX	1
638 
639 #define	EMUL_MAXID	2
640 #define	CTL_EMUL_NAMES { \
641 	{ 0, 0 }, \
642 	{ "linux", CTLTYPE_NODE }, \
643 }
644 
645 #ifdef	_KERNEL
646 /*
647  * CTL_DEBUG variables.
648  *
649  * These are declared as separate variables so that they can be
650  * individually initialized at the location of their associated
651  * variable. The loader prevents multiple use by issuing errors
652  * if a variable is initialized in more than one place. They are
653  * aggregated into an array in debug_sysctl(), so that it can
654  * conveniently locate them when querried. If more debugging
655  * variables are added, they must also be declared here and also
656  * entered into the array.
657  */
658 struct ctldebug {
659 	char	*debugname;	/* name of debugging variable */
660 	int	*debugvar;	/* pointer to debugging variable */
661 };
662 #ifdef	DEBUG
663 extern struct ctldebug debug0, debug1, debug2, debug3, debug4;
664 extern struct ctldebug debug5, debug6, debug7, debug8, debug9;
665 extern struct ctldebug debug10, debug11, debug12, debug13, debug14;
666 extern struct ctldebug debug15, debug16, debug17, debug18, debug19;
667 #endif	/* DEBUG */
668 
669 /*
670  * Internal sysctl function calling convention:
671  *
672  *	(*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen);
673  *
674  * The name parameter points at the next component of the name to be
675  * interpreted.  The namelen parameter is the number of integers in
676  * the name.
677  */
678 typedef int (sysctlfn)
679     (int *, u_int, void *, size_t *, void *, size_t, struct proc *);
680 
681 int sysctl_int(void *, size_t *, void *, size_t, int *);
682 int sysctl_rdint(void *, size_t *, void *, int);
683 int sysctl_quad(void *, size_t *, void *, size_t, quad_t *);
684 int sysctl_rdquad(void *, size_t *, void *, quad_t);
685 int sysctl_string(void *, size_t *, void *, size_t, char *, int);
686 int sysctl_rdstring(void *, size_t *, void *, const char *);
687 int sysctl_struct(void *, size_t *, void *, size_t, void *, int);
688 int sysctl_rdstruct(void *, size_t *, void *, const void *, int);
689 int sysctl_rdminstruct(void *, size_t *, void *, const void *, int);
690 int sysctl_clockrate(void *, size_t *);
691 int sysctl_disknames(void *, size_t *);
692 int sysctl_diskstats(int *, u_int, void *, size_t *);
693 int sysctl_vnode(char *, size_t *, struct proc *);
694 int sysctl_ntptime(void *, size_t *);
695 #ifdef GPROF
696 int sysctl_doprof(int *, u_int, void *, size_t *, void *, size_t);
697 #endif
698 int sysctl_dombuf(int *, u_int, void *, size_t *, void *, size_t);
699 
700 void fill_eproc(struct proc *, struct eproc *);
701 
702 int kern_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
703 int hw_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
704 int proc_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
705 #ifdef DEBUG
706 int debug_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
707 #endif
708 int net_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
709 int cpu_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
710 int emul_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
711 
712 /* ddb_sysctl() declared in ddb_var.h */
713 
714 void	sysctl_init(void);
715 
716 #ifdef __SYSCTL_PRIVATE
717 extern struct lock sysctl_memlock;
718 #endif
719 
720 #else	/* !_KERNEL */
721 #include <sys/cdefs.h>
722 
723 __BEGIN_DECLS
724 int	sysctl __P((int *, u_int, void *, size_t *, const void *, size_t));
725 __END_DECLS
726 #endif	/* _KERNEL */
727 #endif	/* !_SYS_SYSCTL_H_ */
728