| @@ -1,1338 +1,1333 @@ | | | @@ -1,1338 +1,1333 @@ |
1 | /* $NetBSD: sysctl.h,v 1.194 2011/04/26 16:36:43 joerg Exp $ */ | | 1 | /* $NetBSD: sysctl.h,v 1.195 2011/04/26 21:27:44 joerg Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1989, 1993 | | 4 | * Copyright (c) 1989, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Mike Karels at Berkeley Software Design, Inc. | | 8 | * Mike Karels at Berkeley Software Design, Inc. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
15 | * 2. Redistributions in binary form must reproduce the above copyright | | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in the | | 16 | * notice, this list of conditions and the following disclaimer in the |
17 | * documentation and/or other materials provided with the distribution. | | 17 | * documentation and/or other materials provided with the distribution. |
18 | * 3. Neither the name of the University nor the names of its contributors | | 18 | * 3. Neither the name of the University nor the names of its contributors |
19 | * may be used to endorse or promote products derived from this software | | 19 | * may be used to endorse or promote products derived from this software |
20 | * without specific prior written permission. | | 20 | * without specific prior written permission. |
21 | * | | 21 | * |
22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
32 | * SUCH DAMAGE. | | 32 | * SUCH DAMAGE. |
33 | * | | 33 | * |
34 | * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 | | 34 | * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 |
35 | */ | | 35 | */ |
36 | | | 36 | |
37 | #ifndef _SYS_SYSCTL_H_ | | 37 | #ifndef _SYS_SYSCTL_H_ |
38 | #define _SYS_SYSCTL_H_ | | 38 | #define _SYS_SYSCTL_H_ |
39 | | | 39 | |
40 | /* | | 40 | /* |
41 | * These are for the eproc structure defined below. | | 41 | * These are for the eproc structure defined below. |
42 | */ | | 42 | */ |
43 | #include <sys/time.h> | | 43 | #include <sys/time.h> |
44 | #include <sys/ucred.h> | | 44 | #include <sys/ucred.h> |
45 | #include <sys/ucontext.h> | | 45 | #include <sys/ucontext.h> |
46 | #include <sys/proc.h> | | 46 | #include <sys/proc.h> |
47 | #include <uvm/uvm_extern.h> | | 47 | #include <uvm/uvm_extern.h> |
48 | | | 48 | |
49 | | | 49 | |
50 | /* For offsetof() */ | | 50 | /* For offsetof() */ |
51 | #if defined(_KERNEL) || defined(_STANDALONE) | | 51 | #if defined(_KERNEL) || defined(_STANDALONE) |
52 | #include <sys/systm.h> | | 52 | #include <sys/systm.h> |
53 | #else | | 53 | #else |
54 | #include <stddef.h> | | 54 | #include <stddef.h> |
55 | #include <stdbool.h> | | 55 | #include <stdbool.h> |
56 | #endif | | 56 | #endif |
57 | | | 57 | |
58 | /* | | 58 | /* |
59 | * Definitions for sysctl call. The sysctl call uses a hierarchical name | | 59 | * Definitions for sysctl call. The sysctl call uses a hierarchical name |
60 | * for objects that can be examined or modified. The name is expressed as | | 60 | * for objects that can be examined or modified. The name is expressed as |
61 | * a sequence of integers. Like a file path name, the meaning of each | | 61 | * a sequence of integers. Like a file path name, the meaning of each |
62 | * component depends on its place in the hierarchy. The top-level and kern | | 62 | * component depends on its place in the hierarchy. The top-level and kern |
63 | * identifiers are defined here, and other identifiers are defined in the | | 63 | * identifiers are defined here, and other identifiers are defined in the |
64 | * respective subsystem header files. | | 64 | * respective subsystem header files. |
65 | */ | | 65 | */ |
66 | | | 66 | |
67 | #define CTL_MAXNAME 12 /* largest number of components supported */ | | 67 | #define CTL_MAXNAME 12 /* largest number of components supported */ |
68 | #define SYSCTL_NAMELEN 32 /* longest name allowed for a node */ | | 68 | #define SYSCTL_NAMELEN 32 /* longest name allowed for a node */ |
69 | | | 69 | |
70 | #define CREATE_BASE (1024) /* start of dynamic mib allocation */ | | 70 | #define CREATE_BASE (1024) /* start of dynamic mib allocation */ |
71 | #define SYSCTL_DEFSIZE 8 /* initial size of a child set */ | | 71 | #define SYSCTL_DEFSIZE 8 /* initial size of a child set */ |
72 | | | 72 | |
73 | /* | | 73 | /* |
74 | * Each subsystem defined by sysctl defines a list of variables | | 74 | * Each subsystem defined by sysctl defines a list of variables |
75 | * for that subsystem. Each name is either a node with further | | 75 | * for that subsystem. Each name is either a node with further |
76 | * levels defined below it, or it is a leaf of some particular | | 76 | * levels defined below it, or it is a leaf of some particular |
77 | * type given below. Each sysctl level defines a set of name/type | | 77 | * type given below. Each sysctl level defines a set of name/type |
78 | * pairs to be used by sysctl(1) in manipulating the subsystem. | | 78 | * pairs to be used by sysctl(1) in manipulating the subsystem. |
79 | */ | | 79 | */ |
80 | struct ctlname { | | 80 | struct ctlname { |
81 | const char *ctl_name; /* subsystem name */ | | 81 | const char *ctl_name; /* subsystem name */ |
82 | int ctl_type; /* type of name */ | | 82 | int ctl_type; /* type of name */ |
83 | }; | | 83 | }; |
84 | #define CTLTYPE_NODE 1 /* name is a node */ | | 84 | #define CTLTYPE_NODE 1 /* name is a node */ |
85 | #define CTLTYPE_INT 2 /* name describes an integer */ | | 85 | #define CTLTYPE_INT 2 /* name describes an integer */ |
86 | #define CTLTYPE_STRING 3 /* name describes a string */ | | 86 | #define CTLTYPE_STRING 3 /* name describes a string */ |
87 | #define CTLTYPE_QUAD 4 /* name describes a 64-bit number */ | | 87 | #define CTLTYPE_QUAD 4 /* name describes a 64-bit number */ |
88 | #define CTLTYPE_STRUCT 5 /* name describes a structure */ | | 88 | #define CTLTYPE_STRUCT 5 /* name describes a structure */ |
89 | #define CTLTYPE_BOOL 6 /* name describes a bool */ | | 89 | #define CTLTYPE_BOOL 6 /* name describes a bool */ |
90 | | | 90 | |
91 | /* | | 91 | /* |
92 | * Flags that apply to each node, governing access and other features | | 92 | * Flags that apply to each node, governing access and other features |
93 | */ | | 93 | */ |
94 | #define CTLFLAG_READONLY 0x00000000 | | 94 | #define CTLFLAG_READONLY 0x00000000 |
95 | /* #define CTLFLAG_UNUSED1 0x00000010 */ | | 95 | /* #define CTLFLAG_UNUSED1 0x00000010 */ |
96 | /* #define CTLFLAG_UNUSED2 0x00000020 */ | | 96 | /* #define CTLFLAG_UNUSED2 0x00000020 */ |
97 | /* #define CTLFLAG_READ* 0x00000040 */ | | 97 | /* #define CTLFLAG_READ* 0x00000040 */ |
98 | #define CTLFLAG_READWRITE 0x00000070 | | 98 | #define CTLFLAG_READWRITE 0x00000070 |
99 | #define CTLFLAG_ANYWRITE 0x00000080 | | 99 | #define CTLFLAG_ANYWRITE 0x00000080 |
100 | #define CTLFLAG_PRIVATE 0x00000100 | | 100 | #define CTLFLAG_PRIVATE 0x00000100 |
101 | #define CTLFLAG_PERMANENT 0x00000200 | | 101 | #define CTLFLAG_PERMANENT 0x00000200 |
102 | #define CTLFLAG_OWNDATA 0x00000400 | | 102 | #define CTLFLAG_OWNDATA 0x00000400 |
103 | #define CTLFLAG_IMMEDIATE 0x00000800 | | 103 | #define CTLFLAG_IMMEDIATE 0x00000800 |
104 | #define CTLFLAG_HEX 0x00001000 | | 104 | #define CTLFLAG_HEX 0x00001000 |
105 | #define CTLFLAG_ROOT 0x00002000 | | 105 | #define CTLFLAG_ROOT 0x00002000 |
106 | #define CTLFLAG_ANYNUMBER 0x00004000 | | 106 | #define CTLFLAG_ANYNUMBER 0x00004000 |
107 | #define CTLFLAG_HIDDEN 0x00008000 | | 107 | #define CTLFLAG_HIDDEN 0x00008000 |
108 | #define CTLFLAG_ALIAS 0x00010000 | | 108 | #define CTLFLAG_ALIAS 0x00010000 |
109 | #define CTLFLAG_MMAP 0x00020000 | | 109 | #define CTLFLAG_MMAP 0x00020000 |
110 | #define CTLFLAG_OWNDESC 0x00040000 | | 110 | #define CTLFLAG_OWNDESC 0x00040000 |
111 | | | 111 | |
112 | /* | | 112 | /* |
113 | * sysctl API version | | 113 | * sysctl API version |
114 | */ | | 114 | */ |
115 | #define SYSCTL_VERS_MASK 0xff000000 | | 115 | #define SYSCTL_VERS_MASK 0xff000000 |
116 | #define SYSCTL_VERS_0 0x00000000 | | 116 | #define SYSCTL_VERS_0 0x00000000 |
117 | #define SYSCTL_VERS_1 0x01000000 | | 117 | #define SYSCTL_VERS_1 0x01000000 |
118 | #define SYSCTL_VERSION SYSCTL_VERS_1 | | 118 | #define SYSCTL_VERSION SYSCTL_VERS_1 |
119 | #define SYSCTL_VERS(f) ((f) & SYSCTL_VERS_MASK) | | 119 | #define SYSCTL_VERS(f) ((f) & SYSCTL_VERS_MASK) |
120 | | | 120 | |
121 | /* | | 121 | /* |
122 | * Flags that can be set by a create request from user-space | | 122 | * Flags that can be set by a create request from user-space |
123 | */ | | 123 | */ |
124 | #define SYSCTL_USERFLAGS (CTLFLAG_READWRITE|\ | | 124 | #define SYSCTL_USERFLAGS (CTLFLAG_READWRITE|\ |
125 | CTLFLAG_ANYWRITE|\ | | 125 | CTLFLAG_ANYWRITE|\ |
126 | CTLFLAG_PRIVATE|\ | | 126 | CTLFLAG_PRIVATE|\ |
127 | CTLFLAG_OWNDATA|\ | | 127 | CTLFLAG_OWNDATA|\ |
128 | CTLFLAG_IMMEDIATE|\ | | 128 | CTLFLAG_IMMEDIATE|\ |
129 | CTLFLAG_HEX|\ | | 129 | CTLFLAG_HEX|\ |
130 | CTLFLAG_HIDDEN) | | 130 | CTLFLAG_HIDDEN) |
131 | | | 131 | |
132 | /* | | 132 | /* |
133 | * Accessor macros | | 133 | * Accessor macros |
134 | */ | | 134 | */ |
135 | #define SYSCTL_TYPEMASK 0x0000000f | | 135 | #define SYSCTL_TYPEMASK 0x0000000f |
136 | #define SYSCTL_TYPE(x) ((x) & SYSCTL_TYPEMASK) | | 136 | #define SYSCTL_TYPE(x) ((x) & SYSCTL_TYPEMASK) |
137 | #define SYSCTL_FLAGMASK 0x00fffff0 | | 137 | #define SYSCTL_FLAGMASK 0x00fffff0 |
138 | #define SYSCTL_FLAGS(x) ((x) & SYSCTL_FLAGMASK) | | 138 | #define SYSCTL_FLAGS(x) ((x) & SYSCTL_FLAGMASK) |
139 | | | 139 | |
140 | /* | | 140 | /* |
141 | * Meta-identifiers | | 141 | * Meta-identifiers |
142 | */ | | 142 | */ |
143 | #define CTL_EOL -1 /* end of createv/destroyv list */ | | 143 | #define CTL_EOL -1 /* end of createv/destroyv list */ |
144 | #define CTL_QUERY -2 /* enumerates children of a node */ | | 144 | #define CTL_QUERY -2 /* enumerates children of a node */ |
145 | #define CTL_CREATE -3 /* node create request */ | | 145 | #define CTL_CREATE -3 /* node create request */ |
146 | #define CTL_CREATESYM -4 /* node create request with symbol */ | | 146 | #define CTL_CREATESYM -4 /* node create request with symbol */ |
147 | #define CTL_DESTROY -5 /* node destroy request */ | | 147 | #define CTL_DESTROY -5 /* node destroy request */ |
148 | #define CTL_MMAP -6 /* mmap request */ | | 148 | #define CTL_MMAP -6 /* mmap request */ |
149 | #define CTL_DESCRIBE -7 /* get node descriptions */ | | 149 | #define CTL_DESCRIBE -7 /* get node descriptions */ |
150 | | | 150 | |
151 | /* | | 151 | /* |
152 | * Top-level identifiers | | 152 | * Top-level identifiers |
153 | */ | | 153 | */ |
154 | #define CTL_UNSPEC 0 /* unused */ | | 154 | #define CTL_UNSPEC 0 /* unused */ |
155 | #define CTL_KERN 1 /* "high kernel": proc, limits */ | | 155 | #define CTL_KERN 1 /* "high kernel": proc, limits */ |
156 | #define CTL_VM 2 /* virtual memory */ | | 156 | #define CTL_VM 2 /* virtual memory */ |
157 | #define CTL_VFS 3 /* file system, mount type is next */ | | 157 | #define CTL_VFS 3 /* file system, mount type is next */ |
158 | #define CTL_NET 4 /* network, see socket.h */ | | 158 | #define CTL_NET 4 /* network, see socket.h */ |
159 | #define CTL_DEBUG 5 /* debugging parameters */ | | 159 | #define CTL_DEBUG 5 /* debugging parameters */ |
160 | #define CTL_HW 6 /* generic CPU/io */ | | 160 | #define CTL_HW 6 /* generic CPU/io */ |
161 | #define CTL_MACHDEP 7 /* machine dependent */ | | 161 | #define CTL_MACHDEP 7 /* machine dependent */ |
162 | #define CTL_USER 8 /* user-level */ | | 162 | #define CTL_USER 8 /* user-level */ |
163 | #define CTL_DDB 9 /* in-kernel debugger */ | | 163 | #define CTL_DDB 9 /* in-kernel debugger */ |
164 | #define CTL_PROC 10 /* per-proc attr */ | | 164 | #define CTL_PROC 10 /* per-proc attr */ |
165 | #define CTL_VENDOR 11 /* vendor-specific data */ | | 165 | #define CTL_VENDOR 11 /* vendor-specific data */ |
166 | #define CTL_EMUL 12 /* emulation-specific data */ | | 166 | #define CTL_EMUL 12 /* emulation-specific data */ |
167 | #define CTL_SECURITY 13 /* security */ | | 167 | #define CTL_SECURITY 13 /* security */ |
168 | #define CTL_MAXID 14 /* number of valid top-level ids */ | | 168 | #define CTL_MAXID 14 /* number of valid top-level ids */ |
169 | | | 169 | |
170 | /* | | 170 | /* |
171 | * The "vendor" toplevel name is to be used by vendors who wish to | | 171 | * The "vendor" toplevel name is to be used by vendors who wish to |
172 | * have their own private MIB tree. If you do that, please use | | 172 | * have their own private MIB tree. If you do that, please use |
173 | * vendor.<yourname>.* | | 173 | * vendor.<yourname>.* |
174 | */ | | 174 | */ |
175 | | | 175 | |
176 | /* | | 176 | /* |
177 | * CTL_KERN identifiers | | 177 | * CTL_KERN identifiers |
178 | */ | | 178 | */ |
179 | #define KERN_OSTYPE 1 /* string: system version */ | | 179 | #define KERN_OSTYPE 1 /* string: system version */ |
180 | #define KERN_OSRELEASE 2 /* string: system release */ | | 180 | #define KERN_OSRELEASE 2 /* string: system release */ |
181 | #define KERN_OSREV 3 /* int: system revision */ | | 181 | #define KERN_OSREV 3 /* int: system revision */ |
182 | #define KERN_VERSION 4 /* string: compile time info */ | | 182 | #define KERN_VERSION 4 /* string: compile time info */ |
183 | #define KERN_MAXVNODES 5 /* int: max vnodes */ | | 183 | #define KERN_MAXVNODES 5 /* int: max vnodes */ |
184 | #define KERN_MAXPROC 6 /* int: max processes */ | | 184 | #define KERN_MAXPROC 6 /* int: max processes */ |
185 | #define KERN_MAXFILES 7 /* int: max open files */ | | 185 | #define KERN_MAXFILES 7 /* int: max open files */ |
186 | #define KERN_ARGMAX 8 /* int: max arguments to exec */ | | 186 | #define KERN_ARGMAX 8 /* int: max arguments to exec */ |
187 | #define KERN_SECURELVL 9 /* int: system security level */ | | 187 | #define KERN_SECURELVL 9 /* int: system security level */ |
188 | #define KERN_HOSTNAME 10 /* string: hostname */ | | 188 | #define KERN_HOSTNAME 10 /* string: hostname */ |
189 | #define KERN_HOSTID 11 /* int: host identifier */ | | 189 | #define KERN_HOSTID 11 /* int: host identifier */ |
190 | #define KERN_CLOCKRATE 12 /* struct: struct clockinfo */ | | 190 | #define KERN_CLOCKRATE 12 /* struct: struct clockinfo */ |
191 | #define KERN_VNODE 13 /* struct: vnode structures */ | | 191 | #define KERN_VNODE 13 /* struct: vnode structures */ |
192 | #define KERN_PROC 14 /* struct: process entries */ | | 192 | #define KERN_PROC 14 /* struct: process entries */ |
193 | #define KERN_FILE 15 /* struct: file entries */ | | 193 | #define KERN_FILE 15 /* struct: file entries */ |
194 | #define KERN_PROF 16 /* node: kernel profiling info */ | | 194 | #define KERN_PROF 16 /* node: kernel profiling info */ |
195 | #define KERN_POSIX1 17 /* int: POSIX.1 version */ | | 195 | #define KERN_POSIX1 17 /* int: POSIX.1 version */ |
196 | #define KERN_NGROUPS 18 /* int: # of supplemental group ids */ | | 196 | #define KERN_NGROUPS 18 /* int: # of supplemental group ids */ |
197 | #define KERN_JOB_CONTROL 19 /* int: is job control available */ | | 197 | #define KERN_JOB_CONTROL 19 /* int: is job control available */ |
198 | #define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */ | | 198 | #define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */ |
199 | #define KERN_OBOOTTIME 21 /* struct: time kernel was booted */ | | 199 | #define KERN_OBOOTTIME 21 /* struct: time kernel was booted */ |
200 | #define KERN_DOMAINNAME 22 /* string: (YP) domainname */ | | 200 | #define KERN_DOMAINNAME 22 /* string: (YP) domainname */ |
201 | #define KERN_MAXPARTITIONS 23 /* int: number of partitions/disk */ | | 201 | #define KERN_MAXPARTITIONS 23 /* int: number of partitions/disk */ |
202 | #define KERN_RAWPARTITION 24 /* int: raw partition number */ | | 202 | #define KERN_RAWPARTITION 24 /* int: raw partition number */ |
203 | #define KERN_NTPTIME 25 /* struct: extended-precision time */ | | 203 | #define KERN_NTPTIME 25 /* struct: extended-precision time */ |
204 | #define KERN_TIMEX 26 /* struct: ntp timekeeping state */ | | 204 | #define KERN_TIMEX 26 /* struct: ntp timekeeping state */ |
205 | #define KERN_AUTONICETIME 27 /* int: proc time before autonice */ | | 205 | #define KERN_AUTONICETIME 27 /* int: proc time before autonice */ |
206 | #define KERN_AUTONICEVAL 28 /* int: auto nice value */ | | 206 | #define KERN_AUTONICEVAL 28 /* int: auto nice value */ |
207 | #define KERN_RTC_OFFSET 29 /* int: offset of rtc from gmt */ | | 207 | #define KERN_RTC_OFFSET 29 /* int: offset of rtc from gmt */ |
208 | #define KERN_ROOT_DEVICE 30 /* string: root device */ | | 208 | #define KERN_ROOT_DEVICE 30 /* string: root device */ |
209 | #define KERN_MSGBUFSIZE 31 /* int: max # of chars in msg buffer */ | | 209 | #define KERN_MSGBUFSIZE 31 /* int: max # of chars in msg buffer */ |
210 | #define KERN_FSYNC 32 /* int: file synchronization support */ | | 210 | #define KERN_FSYNC 32 /* int: file synchronization support */ |
211 | #define KERN_OLDSYSVMSG 33 /* old: SysV message queue suppoprt */ | | 211 | #define KERN_OLDSYSVMSG 33 /* old: SysV message queue suppoprt */ |
212 | #define KERN_OLDSYSVSEM 34 /* old: SysV semaphore support */ | | 212 | #define KERN_OLDSYSVSEM 34 /* old: SysV semaphore support */ |
213 | #define KERN_OLDSYSVSHM 35 /* old: SysV shared memory support */ | | 213 | #define KERN_OLDSYSVSHM 35 /* old: SysV shared memory support */ |
214 | #define KERN_OLDSHORTCORENAME 36 /* old, unimplemented */ | | 214 | #define KERN_OLDSHORTCORENAME 36 /* old, unimplemented */ |
215 | #define KERN_SYNCHRONIZED_IO 37 /* int: POSIX synchronized I/O */ | | 215 | #define KERN_SYNCHRONIZED_IO 37 /* int: POSIX synchronized I/O */ |
216 | #define KERN_IOV_MAX 38 /* int: max iovec's for readv(2) etc. */ | | 216 | #define KERN_IOV_MAX 38 /* int: max iovec's for readv(2) etc. */ |
217 | #define KERN_MBUF 39 /* node: mbuf parameters */ | | 217 | #define KERN_MBUF 39 /* node: mbuf parameters */ |
218 | #define KERN_MAPPED_FILES 40 /* int: POSIX memory mapped files */ | | 218 | #define KERN_MAPPED_FILES 40 /* int: POSIX memory mapped files */ |
219 | #define KERN_MEMLOCK 41 /* int: POSIX memory locking */ | | 219 | #define KERN_MEMLOCK 41 /* int: POSIX memory locking */ |
220 | #define KERN_MEMLOCK_RANGE 42 /* int: POSIX memory range locking */ | | 220 | #define KERN_MEMLOCK_RANGE 42 /* int: POSIX memory range locking */ |
221 | #define KERN_MEMORY_PROTECTION 43 /* int: POSIX memory protections */ | | 221 | #define KERN_MEMORY_PROTECTION 43 /* int: POSIX memory protections */ |
222 | #define KERN_LOGIN_NAME_MAX 44 /* int: max length login name + NUL */ | | 222 | #define KERN_LOGIN_NAME_MAX 44 /* int: max length login name + NUL */ |
223 | #define KERN_DEFCORENAME 45 /* old: sort core name format */ | | 223 | #define KERN_DEFCORENAME 45 /* old: sort core name format */ |
224 | #define KERN_LOGSIGEXIT 46 /* int: log signalled processes */ | | 224 | #define KERN_LOGSIGEXIT 46 /* int: log signalled processes */ |
225 | #define KERN_PROC2 47 /* struct: process entries */ | | 225 | #define KERN_PROC2 47 /* struct: process entries */ |
226 | #define KERN_PROC_ARGS 48 /* struct: process argv/env */ | | 226 | #define KERN_PROC_ARGS 48 /* struct: process argv/env */ |
227 | #define KERN_FSCALE 49 /* int: fixpt FSCALE */ | | 227 | #define KERN_FSCALE 49 /* int: fixpt FSCALE */ |
228 | #define KERN_CCPU 50 /* old: fixpt ccpu */ | | 228 | #define KERN_CCPU 50 /* old: fixpt ccpu */ |
229 | #define KERN_CP_TIME 51 /* struct: CPU time counters */ | | 229 | #define KERN_CP_TIME 51 /* struct: CPU time counters */ |
230 | #define KERN_OLDSYSVIPC_INFO 52 /* old: number of valid kern ids */ | | 230 | #define KERN_OLDSYSVIPC_INFO 52 /* old: number of valid kern ids */ |
231 | #define KERN_MSGBUF 53 /* kernel message buffer */ | | 231 | #define KERN_MSGBUF 53 /* kernel message buffer */ |
232 | #define KERN_CONSDEV 54 /* dev_t: console terminal device */ | | 232 | #define KERN_CONSDEV 54 /* dev_t: console terminal device */ |
233 | #define KERN_MAXPTYS 55 /* int: maximum number of ptys */ | | 233 | #define KERN_MAXPTYS 55 /* int: maximum number of ptys */ |
234 | #define KERN_PIPE 56 /* node: pipe limits */ | | 234 | #define KERN_PIPE 56 /* node: pipe limits */ |
235 | #define KERN_MAXPHYS 57 /* int: kernel value of MAXPHYS */ | | 235 | #define KERN_MAXPHYS 57 /* int: kernel value of MAXPHYS */ |
236 | #define KERN_SBMAX 58 /* int: max socket buffer size */ | | 236 | #define KERN_SBMAX 58 /* int: max socket buffer size */ |
237 | #define KERN_TKSTAT 59 /* tty in/out counters */ | | 237 | #define KERN_TKSTAT 59 /* tty in/out counters */ |
238 | #define KERN_MONOTONIC_CLOCK 60 /* int: POSIX monotonic clock */ | | 238 | #define KERN_MONOTONIC_CLOCK 60 /* int: POSIX monotonic clock */ |
239 | #define KERN_URND 61 /* int: random integer from urandom */ | | 239 | #define KERN_URND 61 /* int: random integer from urandom */ |
240 | #define KERN_LABELSECTOR 62 /* int: disklabel sector */ | | 240 | #define KERN_LABELSECTOR 62 /* int: disklabel sector */ |
241 | #define KERN_LABELOFFSET 63 /* int: offset of label within sector */ | | 241 | #define KERN_LABELOFFSET 63 /* int: offset of label within sector */ |
242 | #define KERN_LWP 64 /* struct: lwp entries */ | | 242 | #define KERN_LWP 64 /* struct: lwp entries */ |
243 | #define KERN_FORKFSLEEP 65 /* int: sleep length on failed fork */ | | 243 | #define KERN_FORKFSLEEP 65 /* int: sleep length on failed fork */ |
244 | #define KERN_POSIX_THREADS 66 /* int: POSIX Threads option */ | | 244 | #define KERN_POSIX_THREADS 66 /* int: POSIX Threads option */ |
245 | #define KERN_POSIX_SEMAPHORES 67 /* int: POSIX Semaphores option */ | | 245 | #define KERN_POSIX_SEMAPHORES 67 /* int: POSIX Semaphores option */ |
246 | #define KERN_POSIX_BARRIERS 68 /* int: POSIX Barriers option */ | | 246 | #define KERN_POSIX_BARRIERS 68 /* int: POSIX Barriers option */ |
247 | #define KERN_POSIX_TIMERS 69 /* int: POSIX Timers option */ | | 247 | #define KERN_POSIX_TIMERS 69 /* int: POSIX Timers option */ |
248 | #define KERN_POSIX_SPIN_LOCKS 70 /* int: POSIX Spin Locks option */ | | 248 | #define KERN_POSIX_SPIN_LOCKS 70 /* int: POSIX Spin Locks option */ |
249 | #define KERN_POSIX_READER_WRITER_LOCKS 71 /* int: POSIX R/W Locks option */ | | 249 | #define KERN_POSIX_READER_WRITER_LOCKS 71 /* int: POSIX R/W Locks option */ |
250 | #define KERN_DUMP_ON_PANIC 72 /* int: dump on panic */ | | 250 | #define KERN_DUMP_ON_PANIC 72 /* int: dump on panic */ |
251 | #define KERN_SOMAXKVA 73 /* int: max socket kernel virtual mem */ | | 251 | #define KERN_SOMAXKVA 73 /* int: max socket kernel virtual mem */ |
252 | #define KERN_ROOT_PARTITION 74 /* int: root partition */ | | 252 | #define KERN_ROOT_PARTITION 74 /* int: root partition */ |
253 | #define KERN_DRIVERS 75 /* struct: driver names and majors #s */ | | 253 | #define KERN_DRIVERS 75 /* struct: driver names and majors #s */ |
254 | #define KERN_BUF 76 /* struct: buffers */ | | 254 | #define KERN_BUF 76 /* struct: buffers */ |
255 | #define KERN_FILE2 77 /* struct: file entries */ | | 255 | #define KERN_FILE2 77 /* struct: file entries */ |
256 | #define KERN_VERIEXEC 78 /* node: verified exec */ | | 256 | #define KERN_VERIEXEC 78 /* node: verified exec */ |
257 | #define KERN_CP_ID 79 /* struct: cpu id numbers */ | | 257 | #define KERN_CP_ID 79 /* struct: cpu id numbers */ |
258 | #define KERN_HARDCLOCK_TICKS 80 /* int: number of hardclock ticks */ | | 258 | #define KERN_HARDCLOCK_TICKS 80 /* int: number of hardclock ticks */ |
259 | #define KERN_ARND 81 /* void *buf, size_t siz random */ | | 259 | #define KERN_ARND 81 /* void *buf, size_t siz random */ |
260 | #define KERN_SYSVIPC 82 /* node: SysV IPC parameters */ | | 260 | #define KERN_SYSVIPC 82 /* node: SysV IPC parameters */ |
261 | #define KERN_BOOTTIME 83 /* struct: time kernel was booted */ | | 261 | #define KERN_BOOTTIME 83 /* struct: time kernel was booted */ |
262 | #define KERN_EVCNT 84 /* struct: evcnts */ | | 262 | #define KERN_EVCNT 84 /* struct: evcnts */ |
263 | #define KERN_MAXID 85 /* number of valid kern ids */ | | 263 | #define KERN_MAXID 85 /* number of valid kern ids */ |
264 | | | 264 | |
265 | | | 265 | |
266 | #define CTL_KERN_NAMES { \ | | 266 | #define CTL_KERN_NAMES { \ |
267 | { 0, 0 }, \ | | 267 | { 0, 0 }, \ |
268 | { "ostype", CTLTYPE_STRING }, \ | | 268 | { "ostype", CTLTYPE_STRING }, \ |
269 | { "osrelease", CTLTYPE_STRING }, \ | | 269 | { "osrelease", CTLTYPE_STRING }, \ |
270 | { "osrevision", CTLTYPE_INT }, \ | | 270 | { "osrevision", CTLTYPE_INT }, \ |
271 | { "version", CTLTYPE_STRING }, \ | | 271 | { "version", CTLTYPE_STRING }, \ |
272 | { "maxvnodes", CTLTYPE_INT }, \ | | 272 | { "maxvnodes", CTLTYPE_INT }, \ |
273 | { "maxproc", CTLTYPE_INT }, \ | | 273 | { "maxproc", CTLTYPE_INT }, \ |
274 | { "maxfiles", CTLTYPE_INT }, \ | | 274 | { "maxfiles", CTLTYPE_INT }, \ |
275 | { "argmax", CTLTYPE_INT }, \ | | 275 | { "argmax", CTLTYPE_INT }, \ |
276 | { "securelevel", CTLTYPE_INT }, \ | | 276 | { "securelevel", CTLTYPE_INT }, \ |
277 | { "hostname", CTLTYPE_STRING }, \ | | 277 | { "hostname", CTLTYPE_STRING }, \ |
278 | { "hostid", CTLTYPE_INT }, \ | | 278 | { "hostid", CTLTYPE_INT }, \ |
279 | { "clockrate", CTLTYPE_STRUCT }, \ | | 279 | { "clockrate", CTLTYPE_STRUCT }, \ |
280 | { "vnode", CTLTYPE_STRUCT }, \ | | 280 | { "vnode", CTLTYPE_STRUCT }, \ |
281 | { "proc", CTLTYPE_STRUCT }, \ | | 281 | { "proc", CTLTYPE_STRUCT }, \ |
282 | { "file", CTLTYPE_STRUCT }, \ | | 282 | { "file", CTLTYPE_STRUCT }, \ |
283 | { "profiling", CTLTYPE_NODE }, \ | | 283 | { "profiling", CTLTYPE_NODE }, \ |
284 | { "posix1version", CTLTYPE_INT }, \ | | 284 | { "posix1version", CTLTYPE_INT }, \ |
285 | { "ngroups", CTLTYPE_INT }, \ | | 285 | { "ngroups", CTLTYPE_INT }, \ |
286 | { "job_control", CTLTYPE_INT }, \ | | 286 | { "job_control", CTLTYPE_INT }, \ |
287 | { "saved_ids", CTLTYPE_INT }, \ | | 287 | { "saved_ids", CTLTYPE_INT }, \ |
288 | { 0, 0 }, \ | | 288 | { 0, 0 }, \ |
289 | { "domainname", CTLTYPE_STRING }, \ | | 289 | { "domainname", CTLTYPE_STRING }, \ |
290 | { "maxpartitions", CTLTYPE_INT }, \ | | 290 | { "maxpartitions", CTLTYPE_INT }, \ |
291 | { "rawpartition", CTLTYPE_INT }, \ | | 291 | { "rawpartition", CTLTYPE_INT }, \ |
292 | { "ntptime", CTLTYPE_STRUCT }, \ | | 292 | { "ntptime", CTLTYPE_STRUCT }, \ |
293 | { "timex", CTLTYPE_STRUCT }, \ | | 293 | { "timex", CTLTYPE_STRUCT }, \ |
294 | { "autonicetime", CTLTYPE_INT }, \ | | 294 | { "autonicetime", CTLTYPE_INT }, \ |
295 | { "autoniceval", CTLTYPE_INT }, \ | | 295 | { "autoniceval", CTLTYPE_INT }, \ |
296 | { "rtc_offset", CTLTYPE_INT }, \ | | 296 | { "rtc_offset", CTLTYPE_INT }, \ |
297 | { "root_device", CTLTYPE_STRING }, \ | | 297 | { "root_device", CTLTYPE_STRING }, \ |
298 | { "msgbufsize", CTLTYPE_INT }, \ | | 298 | { "msgbufsize", CTLTYPE_INT }, \ |
299 | { "fsync", CTLTYPE_INT }, \ | | 299 | { "fsync", CTLTYPE_INT }, \ |
300 | { 0, 0 }, \ | | 300 | { 0, 0 }, \ |
301 | { 0, 0 }, \ | | 301 | { 0, 0 }, \ |
302 | { 0, 0 }, \ | | 302 | { 0, 0 }, \ |
303 | { 0, 0 }, \ | | 303 | { 0, 0 }, \ |
304 | { "synchronized_io", CTLTYPE_INT }, \ | | 304 | { "synchronized_io", CTLTYPE_INT }, \ |
305 | { "iov_max", CTLTYPE_INT }, \ | | 305 | { "iov_max", CTLTYPE_INT }, \ |
306 | { "mbuf", CTLTYPE_NODE }, \ | | 306 | { "mbuf", CTLTYPE_NODE }, \ |
307 | { "mapped_files", CTLTYPE_INT }, \ | | 307 | { "mapped_files", CTLTYPE_INT }, \ |
308 | { "memlock", CTLTYPE_INT }, \ | | 308 | { "memlock", CTLTYPE_INT }, \ |
309 | { "memlock_range", CTLTYPE_INT }, \ | | 309 | { "memlock_range", CTLTYPE_INT }, \ |
310 | { "memory_protection", CTLTYPE_INT }, \ | | 310 | { "memory_protection", CTLTYPE_INT }, \ |
311 | { "login_name_max", CTLTYPE_INT }, \ | | 311 | { "login_name_max", CTLTYPE_INT }, \ |
312 | { "defcorename", CTLTYPE_STRING }, \ | | 312 | { "defcorename", CTLTYPE_STRING }, \ |
313 | { "logsigexit", CTLTYPE_INT }, \ | | 313 | { "logsigexit", CTLTYPE_INT }, \ |
314 | { "proc2", CTLTYPE_STRUCT }, \ | | 314 | { "proc2", CTLTYPE_STRUCT }, \ |
315 | { "proc_args", CTLTYPE_STRING }, \ | | 315 | { "proc_args", CTLTYPE_STRING }, \ |
316 | { "fscale", CTLTYPE_INT }, \ | | 316 | { "fscale", CTLTYPE_INT }, \ |
317 | { 0, 0 }, \ | | 317 | { 0, 0 }, \ |
318 | { "cp_time", CTLTYPE_STRUCT }, \ | | 318 | { "cp_time", CTLTYPE_STRUCT }, \ |
319 | { 0, 0 }, \ | | 319 | { 0, 0 }, \ |
320 | { "msgbuf", CTLTYPE_STRUCT }, \ | | 320 | { "msgbuf", CTLTYPE_STRUCT }, \ |
321 | { "consdev", CTLTYPE_STRUCT }, \ | | 321 | { "consdev", CTLTYPE_STRUCT }, \ |
322 | { "maxptys", CTLTYPE_INT }, \ | | 322 | { "maxptys", CTLTYPE_INT }, \ |
323 | { "pipe", CTLTYPE_NODE }, \ | | 323 | { "pipe", CTLTYPE_NODE }, \ |
324 | { "maxphys", CTLTYPE_INT }, \ | | 324 | { "maxphys", CTLTYPE_INT }, \ |
325 | { "sbmax", CTLTYPE_INT }, \ | | 325 | { "sbmax", CTLTYPE_INT }, \ |
326 | { "tkstat", CTLTYPE_NODE }, \ | | 326 | { "tkstat", CTLTYPE_NODE }, \ |
327 | { "monotonic_clock", CTLTYPE_INT }, \ | | 327 | { "monotonic_clock", CTLTYPE_INT }, \ |
328 | { "urandom", CTLTYPE_INT }, \ | | 328 | { "urandom", CTLTYPE_INT }, \ |
329 | { "labelsector", CTLTYPE_INT }, \ | | 329 | { "labelsector", CTLTYPE_INT }, \ |
330 | { "labeloffset", CTLTYPE_INT }, \ | | 330 | { "labeloffset", CTLTYPE_INT }, \ |
331 | { "lwp", CTLTYPE_STRUCT }, \ | | 331 | { "lwp", CTLTYPE_STRUCT }, \ |
332 | { "forkfsleep", CTLTYPE_INT }, \ | | 332 | { "forkfsleep", CTLTYPE_INT }, \ |
333 | { "posix_threads", CTLTYPE_INT }, \ | | 333 | { "posix_threads", CTLTYPE_INT }, \ |
334 | { "posix_semaphores", CTLTYPE_INT }, \ | | 334 | { "posix_semaphores", CTLTYPE_INT }, \ |
335 | { "posix_barriers", CTLTYPE_INT }, \ | | 335 | { "posix_barriers", CTLTYPE_INT }, \ |
336 | { "posix_timers", CTLTYPE_INT }, \ | | 336 | { "posix_timers", CTLTYPE_INT }, \ |
337 | { "posix_spin_locks", CTLTYPE_INT }, \ | | 337 | { "posix_spin_locks", CTLTYPE_INT }, \ |
338 | { "posix_reader_writer_locks", CTLTYPE_INT }, \ | | 338 | { "posix_reader_writer_locks", CTLTYPE_INT }, \ |
339 | { "dump_on_panic", CTLTYPE_INT}, \ | | 339 | { "dump_on_panic", CTLTYPE_INT}, \ |
340 | { "somaxkva", CTLTYPE_INT}, \ | | 340 | { "somaxkva", CTLTYPE_INT}, \ |
341 | { "root_partition", CTLTYPE_INT}, \ | | 341 | { "root_partition", CTLTYPE_INT}, \ |
342 | { "drivers", CTLTYPE_STRUCT }, \ | | 342 | { "drivers", CTLTYPE_STRUCT }, \ |
343 | { "buf", CTLTYPE_NODE }, \ | | 343 | { "buf", CTLTYPE_NODE }, \ |
344 | { "file2", CTLTYPE_STRUCT }, \ | | 344 | { "file2", CTLTYPE_STRUCT }, \ |
345 | { "veriexec", CTLTYPE_NODE }, \ | | 345 | { "veriexec", CTLTYPE_NODE }, \ |
346 | { "cp_id", CTLTYPE_STRUCT }, \ | | 346 | { "cp_id", CTLTYPE_STRUCT }, \ |
347 | { "hardclock_ticks", CTLTYPE_INT }, \ | | 347 | { "hardclock_ticks", CTLTYPE_INT }, \ |
348 | { "arandom", CTLTYPE_STRUCT }, \ | | 348 | { "arandom", CTLTYPE_STRUCT }, \ |
349 | { "sysvipc", CTLTYPE_STRUCT }, \ | | 349 | { "sysvipc", CTLTYPE_STRUCT }, \ |
350 | { "boottime", CTLTYPE_STRUCT }, \ | | 350 | { "boottime", CTLTYPE_STRUCT }, \ |
351 | { "evcnt", CTLTYPE_STRUCT }, \ | | 351 | { "evcnt", CTLTYPE_STRUCT }, \ |
352 | } | | 352 | } |
353 | | | 353 | |
354 | /* | | 354 | /* |
355 | * KERN_CLOCKRATE structure | | 355 | * KERN_CLOCKRATE structure |
356 | */ | | 356 | */ |
357 | struct clockinfo { | | 357 | struct clockinfo { |
358 | int hz; /* clock frequency */ | | 358 | int hz; /* clock frequency */ |
359 | int tick; /* micro-seconds per hz tick */ | | 359 | int tick; /* micro-seconds per hz tick */ |
360 | int tickadj; /* clock skew rate for adjtime() */ | | 360 | int tickadj; /* clock skew rate for adjtime() */ |
361 | int stathz; /* statistics clock frequency */ | | 361 | int stathz; /* statistics clock frequency */ |
362 | int profhz; /* profiling clock frequency */ | | 362 | int profhz; /* profiling clock frequency */ |
363 | }; | | 363 | }; |
364 | | | 364 | |
365 | /* | | 365 | /* |
366 | * KERN_PROC subtypes | | 366 | * KERN_PROC subtypes |
367 | */ | | 367 | */ |
368 | #define KERN_PROC_ALL 0 /* everything */ | | 368 | #define KERN_PROC_ALL 0 /* everything */ |
369 | #define KERN_PROC_PID 1 /* by process id */ | | 369 | #define KERN_PROC_PID 1 /* by process id */ |
370 | #define KERN_PROC_PGRP 2 /* by process group id */ | | 370 | #define KERN_PROC_PGRP 2 /* by process group id */ |
371 | #define KERN_PROC_SESSION 3 /* by session of pid */ | | 371 | #define KERN_PROC_SESSION 3 /* by session of pid */ |
372 | #define KERN_PROC_TTY 4 /* by controlling tty */ | | 372 | #define KERN_PROC_TTY 4 /* by controlling tty */ |
373 | #define KERN_PROC_UID 5 /* by effective uid */ | | 373 | #define KERN_PROC_UID 5 /* by effective uid */ |
374 | #define KERN_PROC_RUID 6 /* by real uid */ | | 374 | #define KERN_PROC_RUID 6 /* by real uid */ |
375 | #define KERN_PROC_GID 7 /* by effective gid */ | | 375 | #define KERN_PROC_GID 7 /* by effective gid */ |
376 | #define KERN_PROC_RGID 8 /* by real gid */ | | 376 | #define KERN_PROC_RGID 8 /* by real gid */ |
377 | | | 377 | |
378 | /* | | 378 | /* |
379 | * KERN_PROC_TTY sub-subtypes | | 379 | * KERN_PROC_TTY sub-subtypes |
380 | */ | | 380 | */ |
381 | #define KERN_PROC_TTY_NODEV NODEV /* no controlling tty */ | | 381 | #define KERN_PROC_TTY_NODEV NODEV /* no controlling tty */ |
382 | #define KERN_PROC_TTY_REVOKE ((dev_t)-2) /* revoked tty */ | | 382 | #define KERN_PROC_TTY_REVOKE ((dev_t)-2) /* revoked tty */ |
383 | | | 383 | |
384 | struct ki_pcred { | | 384 | struct ki_pcred { |
385 | void *p_pad; | | 385 | void *p_pad; |
386 | uid_t p_ruid; /* Real user id */ | | 386 | uid_t p_ruid; /* Real user id */ |
387 | uid_t p_svuid; /* Saved effective user id */ | | 387 | uid_t p_svuid; /* Saved effective user id */ |
388 | gid_t p_rgid; /* Real group id */ | | 388 | gid_t p_rgid; /* Real group id */ |
389 | gid_t p_svgid; /* Saved effective group id */ | | 389 | gid_t p_svgid; /* Saved effective group id */ |
390 | int p_refcnt; /* Number of references */ | | 390 | int p_refcnt; /* Number of references */ |
391 | }; | | 391 | }; |
392 | | | 392 | |
393 | struct ki_ucred { | | 393 | struct ki_ucred { |
394 | uint32_t cr_ref; /* reference count */ | | 394 | uint32_t cr_ref; /* reference count */ |
395 | uid_t cr_uid; /* effective user id */ | | 395 | uid_t cr_uid; /* effective user id */ |
396 | gid_t cr_gid; /* effective group id */ | | 396 | gid_t cr_gid; /* effective group id */ |
397 | uint32_t cr_ngroups; /* number of groups */ | | 397 | uint32_t cr_ngroups; /* number of groups */ |
398 | gid_t cr_groups[NGROUPS]; /* groups */ | | 398 | gid_t cr_groups[NGROUPS]; /* groups */ |
399 | }; | | 399 | }; |
400 | | | 400 | |
401 | /* | | 401 | /* |
402 | * KERN_PROC subtype ops return arrays of augmented proc structures: | | 402 | * KERN_PROC subtype ops return arrays of augmented proc structures: |
403 | */ | | 403 | */ |
404 | struct kinfo_proc { | | 404 | struct kinfo_proc { |
405 | struct proc kp_proc; /* proc structure */ | | 405 | struct proc kp_proc; /* proc structure */ |
406 | struct eproc { | | 406 | struct eproc { |
407 | struct proc *e_paddr; /* address of proc */ | | 407 | struct proc *e_paddr; /* address of proc */ |
408 | struct session *e_sess; /* session pointer */ | | 408 | struct session *e_sess; /* session pointer */ |
409 | struct ki_pcred e_pcred; /* process credentials */ | | 409 | struct ki_pcred e_pcred; /* process credentials */ |
410 | struct ki_ucred e_ucred; /* current credentials */ | | 410 | struct ki_ucred e_ucred; /* current credentials */ |
411 | struct vmspace e_vm; /* address space */ | | 411 | struct vmspace e_vm; /* address space */ |
412 | pid_t e_ppid; /* parent process id */ | | 412 | pid_t e_ppid; /* parent process id */ |
413 | pid_t e_pgid; /* process group id */ | | 413 | pid_t e_pgid; /* process group id */ |
414 | short e_jobc; /* job control counter */ | | 414 | short e_jobc; /* job control counter */ |
415 | uint32_t e_tdev; /* XXX: controlling tty dev */ | | 415 | uint32_t e_tdev; /* XXX: controlling tty dev */ |
416 | pid_t e_tpgid; /* tty process group id */ | | 416 | pid_t e_tpgid; /* tty process group id */ |
417 | struct session *e_tsess; /* tty session pointer */ | | 417 | struct session *e_tsess; /* tty session pointer */ |
418 | #define WMESGLEN 8 | | 418 | #define WMESGLEN 8 |
419 | char e_wmesg[WMESGLEN]; /* wchan message */ | | 419 | char e_wmesg[WMESGLEN]; /* wchan message */ |
420 | segsz_t e_xsize; /* text size */ | | 420 | segsz_t e_xsize; /* text size */ |
421 | short e_xrssize; /* text rss */ | | 421 | short e_xrssize; /* text rss */ |
422 | short e_xccount; /* text references */ | | 422 | short e_xccount; /* text references */ |
423 | short e_xswrss; | | 423 | short e_xswrss; |
424 | long e_flag; | | 424 | long e_flag; |
425 | #define EPROC_CTTY 0x01 /* controlling tty vnode active */ | | 425 | #define EPROC_CTTY 0x01 /* controlling tty vnode active */ |
426 | #define EPROC_SLEADER 0x02 /* session leader */ | | 426 | #define EPROC_SLEADER 0x02 /* session leader */ |
427 | char e_login[MAXLOGNAME]; /* setlogin() name */ | | 427 | char e_login[MAXLOGNAME]; /* setlogin() name */ |
428 | pid_t e_sid; /* session id */ | | 428 | pid_t e_sid; /* session id */ |
429 | long e_spare[3]; | | 429 | long e_spare[3]; |
430 | } kp_eproc; | | 430 | } kp_eproc; |
431 | }; | | 431 | }; |
432 | | | 432 | |
433 | /* | | 433 | /* |
434 | * Convert pointer to 64 bit unsigned integer for struct | | 434 | * Convert pointer to 64 bit unsigned integer for struct |
435 | * kinfo_proc2, etc. | | 435 | * kinfo_proc2, etc. |
436 | */ | | 436 | */ |
437 | #define PTRTOUINT64(p) ((uint64_t)(uintptr_t)(p)) | | 437 | #define PTRTOUINT64(p) ((uint64_t)(uintptr_t)(p)) |
438 | #define UINT64TOPTR(u) ((void *)(uintptr_t)(u)) | | 438 | #define UINT64TOPTR(u) ((void *)(uintptr_t)(u)) |
439 | | | 439 | |
440 | /* | | 440 | /* |
441 | * KERN_PROC2 subtype ops return arrays of relatively fixed size | | 441 | * KERN_PROC2 subtype ops return arrays of relatively fixed size |
442 | * structures of process info. Use 8 byte alignment, and new | | 442 | * structures of process info. Use 8 byte alignment, and new |
443 | * elements should only be added to the end of this structure so | | 443 | * elements should only be added to the end of this structure so |
444 | * binary compatibility can be preserved. | | 444 | * binary compatibility can be preserved. |
445 | */ | | 445 | */ |
446 | #define KI_NGROUPS 16 | | 446 | #define KI_NGROUPS 16 |
447 | #define KI_MAXCOMLEN 24 /* extra for 8 byte alignment */ | | 447 | #define KI_MAXCOMLEN 24 /* extra for 8 byte alignment */ |
448 | #define KI_WMESGLEN 8 | | 448 | #define KI_WMESGLEN 8 |
449 | #define KI_MAXLOGNAME 24 /* extra for 8 byte alignment */ | | 449 | #define KI_MAXLOGNAME 24 /* extra for 8 byte alignment */ |
450 | #define KI_MAXEMULLEN 16 | | 450 | #define KI_MAXEMULLEN 16 |
451 | #define KI_LNAMELEN 20 /* extra 4 for alignment */ | | 451 | #define KI_LNAMELEN 20 /* extra 4 for alignment */ |
452 | | | 452 | |
453 | #define KI_NOCPU (~(uint64_t)0) | | 453 | #define KI_NOCPU (~(uint64_t)0) |
454 | | | 454 | |
455 | typedef struct { | | 455 | typedef struct { |
456 | uint32_t __bits[4]; | | 456 | uint32_t __bits[4]; |
457 | } ki_sigset_t; | | 457 | } ki_sigset_t; |
458 | | | 458 | |
459 | struct kinfo_proc2 { | | 459 | struct kinfo_proc2 { |
460 | uint64_t p_forw; /* PTR: linked run/sleep queue. */ | | 460 | uint64_t p_forw; /* PTR: linked run/sleep queue. */ |
461 | uint64_t p_back; | | 461 | uint64_t p_back; |
462 | uint64_t p_paddr; /* PTR: address of proc */ | | 462 | uint64_t p_paddr; /* PTR: address of proc */ |
463 | | | 463 | |
464 | uint64_t p_addr; /* PTR: Kernel virtual addr of u-area */ | | 464 | uint64_t p_addr; /* PTR: Kernel virtual addr of u-area */ |
465 | uint64_t p_fd; /* PTR: Ptr to open files structure. */ | | 465 | uint64_t p_fd; /* PTR: Ptr to open files structure. */ |
466 | uint64_t p_cwdi; /* PTR: cdir/rdir/cmask info */ | | 466 | uint64_t p_cwdi; /* PTR: cdir/rdir/cmask info */ |
467 | uint64_t p_stats; /* PTR: Accounting/statistics */ | | 467 | uint64_t p_stats; /* PTR: Accounting/statistics */ |
468 | uint64_t p_limit; /* PTR: Process limits. */ | | 468 | uint64_t p_limit; /* PTR: Process limits. */ |
469 | uint64_t p_vmspace; /* PTR: Address space. */ | | 469 | uint64_t p_vmspace; /* PTR: Address space. */ |
470 | uint64_t p_sigacts; /* PTR: Signal actions, state */ | | 470 | uint64_t p_sigacts; /* PTR: Signal actions, state */ |
471 | uint64_t p_sess; /* PTR: session pointer */ | | 471 | uint64_t p_sess; /* PTR: session pointer */ |
472 | uint64_t p_tsess; /* PTR: tty session pointer */ | | 472 | uint64_t p_tsess; /* PTR: tty session pointer */ |
473 | uint64_t p_ru; /* PTR: Exit information. XXX */ | | 473 | uint64_t p_ru; /* PTR: Exit information. XXX */ |
474 | | | 474 | |
475 | int32_t p_eflag; /* LONG: extra kinfo_proc2 flags */ | | 475 | int32_t p_eflag; /* LONG: extra kinfo_proc2 flags */ |
476 | int32_t p_exitsig; /* INT: signal to sent to parent on exit */ | | 476 | int32_t p_exitsig; /* INT: signal to sent to parent on exit */ |
477 | int32_t p_flag; /* INT: P_* flags. */ | | 477 | int32_t p_flag; /* INT: P_* flags. */ |
478 | | | 478 | |
479 | int32_t p_pid; /* PID_T: Process identifier. */ | | 479 | int32_t p_pid; /* PID_T: Process identifier. */ |
480 | int32_t p_ppid; /* PID_T: Parent process id */ | | 480 | int32_t p_ppid; /* PID_T: Parent process id */ |
481 | int32_t p_sid; /* PID_T: session id */ | | 481 | int32_t p_sid; /* PID_T: session id */ |
482 | int32_t p__pgid; /* PID_T: process group id */ | | 482 | int32_t p__pgid; /* PID_T: process group id */ |
483 | /* XXX: <sys/proc.h> hijacks p_pgid */ | | 483 | /* XXX: <sys/proc.h> hijacks p_pgid */ |
484 | int32_t p_tpgid; /* PID_T: tty process group id */ | | 484 | int32_t p_tpgid; /* PID_T: tty process group id */ |
485 | | | 485 | |
486 | uint32_t p_uid; /* UID_T: effective user id */ | | 486 | uint32_t p_uid; /* UID_T: effective user id */ |
487 | uint32_t p_ruid; /* UID_T: real user id */ | | 487 | uint32_t p_ruid; /* UID_T: real user id */ |
488 | uint32_t p_gid; /* GID_T: effective group id */ | | 488 | uint32_t p_gid; /* GID_T: effective group id */ |
489 | uint32_t p_rgid; /* GID_T: real group id */ | | 489 | uint32_t p_rgid; /* GID_T: real group id */ |
490 | | | 490 | |
491 | uint32_t p_groups[KI_NGROUPS]; /* GID_T: groups */ | | 491 | uint32_t p_groups[KI_NGROUPS]; /* GID_T: groups */ |
492 | int16_t p_ngroups; /* SHORT: number of groups */ | | 492 | int16_t p_ngroups; /* SHORT: number of groups */ |
493 | | | 493 | |
494 | int16_t p_jobc; /* SHORT: job control counter */ | | 494 | int16_t p_jobc; /* SHORT: job control counter */ |
495 | uint32_t p_tdev; /* XXX: DEV_T: controlling tty dev */ | | 495 | uint32_t p_tdev; /* XXX: DEV_T: controlling tty dev */ |
496 | | | 496 | |
497 | uint32_t p_estcpu; /* U_INT: Time averaged value of p_cpticks. */ | | 497 | uint32_t p_estcpu; /* U_INT: Time averaged value of p_cpticks. */ |
498 | uint32_t p_rtime_sec; /* STRUCT TIMEVAL: Real time. */ | | 498 | uint32_t p_rtime_sec; /* STRUCT TIMEVAL: Real time. */ |
499 | uint32_t p_rtime_usec; /* STRUCT TIMEVAL: Real time. */ | | 499 | uint32_t p_rtime_usec; /* STRUCT TIMEVAL: Real time. */ |
500 | int32_t p_cpticks; /* INT: Ticks of CPU time. */ | | 500 | int32_t p_cpticks; /* INT: Ticks of CPU time. */ |
501 | uint32_t p_pctcpu; /* FIXPT_T: %cpu for this process during p_swtime */ | | 501 | uint32_t p_pctcpu; /* FIXPT_T: %cpu for this process during p_swtime */ |
502 | uint32_t p_swtime; /* U_INT: Time swapped in or out. */ | | 502 | uint32_t p_swtime; /* U_INT: Time swapped in or out. */ |
503 | uint32_t p_slptime; /* U_INT: Time since last blocked. */ | | 503 | uint32_t p_slptime; /* U_INT: Time since last blocked. */ |
504 | int32_t p_schedflags; /* INT: PSCHED_* flags */ | | 504 | int32_t p_schedflags; /* INT: PSCHED_* flags */ |
505 | | | 505 | |
506 | uint64_t p_uticks; /* U_QUAD_T: Statclock hits in user mode. */ | | 506 | uint64_t p_uticks; /* U_QUAD_T: Statclock hits in user mode. */ |
507 | uint64_t p_sticks; /* U_QUAD_T: Statclock hits in system mode. */ | | 507 | uint64_t p_sticks; /* U_QUAD_T: Statclock hits in system mode. */ |
508 | uint64_t p_iticks; /* U_QUAD_T: Statclock hits processing intr. */ | | 508 | uint64_t p_iticks; /* U_QUAD_T: Statclock hits processing intr. */ |
509 | | | 509 | |
510 | uint64_t p_tracep; /* PTR: Trace to vnode or file */ | | 510 | uint64_t p_tracep; /* PTR: Trace to vnode or file */ |
511 | int32_t p_traceflag; /* INT: Kernel trace points. */ | | 511 | int32_t p_traceflag; /* INT: Kernel trace points. */ |
512 | | | 512 | |
513 | int32_t p_holdcnt; /* INT: If non-zero, don't swap. */ | | 513 | int32_t p_holdcnt; /* INT: If non-zero, don't swap. */ |
514 | | | 514 | |
515 | ki_sigset_t p_siglist; /* SIGSET_T: Signals arrived but not delivered. */ | | 515 | ki_sigset_t p_siglist; /* SIGSET_T: Signals arrived but not delivered. */ |
516 | ki_sigset_t p_sigmask; /* SIGSET_T: Current signal mask. */ | | 516 | ki_sigset_t p_sigmask; /* SIGSET_T: Current signal mask. */ |
517 | ki_sigset_t p_sigignore; /* SIGSET_T: Signals being ignored. */ | | 517 | ki_sigset_t p_sigignore; /* SIGSET_T: Signals being ignored. */ |
518 | ki_sigset_t p_sigcatch; /* SIGSET_T: Signals being caught by user. */ | | 518 | ki_sigset_t p_sigcatch; /* SIGSET_T: Signals being caught by user. */ |
519 | | | 519 | |
520 | int8_t p_stat; /* CHAR: S* process status (from LWP). */ | | 520 | int8_t p_stat; /* CHAR: S* process status (from LWP). */ |
521 | uint8_t p_priority; /* U_CHAR: Process priority. */ | | 521 | uint8_t p_priority; /* U_CHAR: Process priority. */ |
522 | uint8_t p_usrpri; /* U_CHAR: User-priority based on p_cpu and p_nice. */ | | 522 | uint8_t p_usrpri; /* U_CHAR: User-priority based on p_cpu and p_nice. */ |
523 | uint8_t p_nice; /* U_CHAR: Process "nice" value. */ | | 523 | uint8_t p_nice; /* U_CHAR: Process "nice" value. */ |
524 | | | 524 | |
525 | uint16_t p_xstat; /* U_SHORT: Exit status for wait; also stop signal. */ | | 525 | uint16_t p_xstat; /* U_SHORT: Exit status for wait; also stop signal. */ |
526 | uint16_t p_acflag; /* U_SHORT: Accounting flags. */ | | 526 | uint16_t p_acflag; /* U_SHORT: Accounting flags. */ |
527 | | | 527 | |
528 | char p_comm[KI_MAXCOMLEN]; | | 528 | char p_comm[KI_MAXCOMLEN]; |
529 | | | 529 | |
530 | char p_wmesg[KI_WMESGLEN]; /* wchan message */ | | 530 | char p_wmesg[KI_WMESGLEN]; /* wchan message */ |
531 | uint64_t p_wchan; /* PTR: sleep address. */ | | 531 | uint64_t p_wchan; /* PTR: sleep address. */ |
532 | | | 532 | |
533 | char p_login[KI_MAXLOGNAME]; /* setlogin() name */ | | 533 | char p_login[KI_MAXLOGNAME]; /* setlogin() name */ |
534 | | | 534 | |
535 | int32_t p_vm_rssize; /* SEGSZ_T: current resident set size in pages */ | | 535 | int32_t p_vm_rssize; /* SEGSZ_T: current resident set size in pages */ |
536 | int32_t p_vm_tsize; /* SEGSZ_T: text size (pages) */ | | 536 | int32_t p_vm_tsize; /* SEGSZ_T: text size (pages) */ |
537 | int32_t p_vm_dsize; /* SEGSZ_T: data size (pages) */ | | 537 | int32_t p_vm_dsize; /* SEGSZ_T: data size (pages) */ |
538 | int32_t p_vm_ssize; /* SEGSZ_T: stack size (pages) */ | | 538 | int32_t p_vm_ssize; /* SEGSZ_T: stack size (pages) */ |
539 | | | 539 | |
540 | int64_t p_uvalid; /* CHAR: following p_u* parameters are valid */ | | 540 | int64_t p_uvalid; /* CHAR: following p_u* parameters are valid */ |
541 | /* XXX 64 bits for alignment */ | | 541 | /* XXX 64 bits for alignment */ |
542 | uint32_t p_ustart_sec; /* STRUCT TIMEVAL: starting time. */ | | 542 | uint32_t p_ustart_sec; /* STRUCT TIMEVAL: starting time. */ |
543 | uint32_t p_ustart_usec; /* STRUCT TIMEVAL: starting time. */ | | 543 | uint32_t p_ustart_usec; /* STRUCT TIMEVAL: starting time. */ |
544 | | | 544 | |
545 | uint32_t p_uutime_sec; /* STRUCT TIMEVAL: user time. */ | | 545 | uint32_t p_uutime_sec; /* STRUCT TIMEVAL: user time. */ |
546 | uint32_t p_uutime_usec; /* STRUCT TIMEVAL: user time. */ | | 546 | uint32_t p_uutime_usec; /* STRUCT TIMEVAL: user time. */ |
547 | uint32_t p_ustime_sec; /* STRUCT TIMEVAL: system time. */ | | 547 | uint32_t p_ustime_sec; /* STRUCT TIMEVAL: system time. */ |
548 | uint32_t p_ustime_usec; /* STRUCT TIMEVAL: system time. */ | | 548 | uint32_t p_ustime_usec; /* STRUCT TIMEVAL: system time. */ |
549 | | | 549 | |
550 | uint64_t p_uru_maxrss; /* LONG: max resident set size. */ | | 550 | uint64_t p_uru_maxrss; /* LONG: max resident set size. */ |
551 | uint64_t p_uru_ixrss; /* LONG: integral shared memory size. */ | | 551 | uint64_t p_uru_ixrss; /* LONG: integral shared memory size. */ |
552 | uint64_t p_uru_idrss; /* LONG: integral unshared data ". */ | | 552 | uint64_t p_uru_idrss; /* LONG: integral unshared data ". */ |
553 | uint64_t p_uru_isrss; /* LONG: integral unshared stack ". */ | | 553 | uint64_t p_uru_isrss; /* LONG: integral unshared stack ". */ |
554 | uint64_t p_uru_minflt; /* LONG: page reclaims. */ | | 554 | uint64_t p_uru_minflt; /* LONG: page reclaims. */ |
555 | uint64_t p_uru_majflt; /* LONG: page faults. */ | | 555 | uint64_t p_uru_majflt; /* LONG: page faults. */ |
556 | uint64_t p_uru_nswap; /* LONG: swaps. */ | | 556 | uint64_t p_uru_nswap; /* LONG: swaps. */ |
557 | uint64_t p_uru_inblock; /* LONG: block input operations. */ | | 557 | uint64_t p_uru_inblock; /* LONG: block input operations. */ |
558 | uint64_t p_uru_oublock; /* LONG: block output operations. */ | | 558 | uint64_t p_uru_oublock; /* LONG: block output operations. */ |
559 | uint64_t p_uru_msgsnd; /* LONG: messages sent. */ | | 559 | uint64_t p_uru_msgsnd; /* LONG: messages sent. */ |
560 | uint64_t p_uru_msgrcv; /* LONG: messages received. */ | | 560 | uint64_t p_uru_msgrcv; /* LONG: messages received. */ |
561 | uint64_t p_uru_nsignals; /* LONG: signals received. */ | | 561 | uint64_t p_uru_nsignals; /* LONG: signals received. */ |
562 | uint64_t p_uru_nvcsw; /* LONG: voluntary context switches. */ | | 562 | uint64_t p_uru_nvcsw; /* LONG: voluntary context switches. */ |
563 | uint64_t p_uru_nivcsw; /* LONG: involuntary ". */ | | 563 | uint64_t p_uru_nivcsw; /* LONG: involuntary ". */ |
564 | | | 564 | |
565 | uint32_t p_uctime_sec; /* STRUCT TIMEVAL: child u+s time. */ | | 565 | uint32_t p_uctime_sec; /* STRUCT TIMEVAL: child u+s time. */ |
566 | uint32_t p_uctime_usec; /* STRUCT TIMEVAL: child u+s time. */ | | 566 | uint32_t p_uctime_usec; /* STRUCT TIMEVAL: child u+s time. */ |
567 | uint64_t p_cpuid; /* LONG: CPU id */ | | 567 | uint64_t p_cpuid; /* LONG: CPU id */ |
568 | uint64_t p_realflag; /* INT: P_* flags (not including LWPs). */ | | 568 | uint64_t p_realflag; /* INT: P_* flags (not including LWPs). */ |
569 | uint64_t p_nlwps; /* LONG: Number of LWPs */ | | 569 | uint64_t p_nlwps; /* LONG: Number of LWPs */ |
570 | uint64_t p_nrlwps; /* LONG: Number of running LWPs */ | | 570 | uint64_t p_nrlwps; /* LONG: Number of running LWPs */ |
571 | uint64_t p_realstat; /* LONG: non-LWP process status */ | | 571 | uint64_t p_realstat; /* LONG: non-LWP process status */ |
572 | uint32_t p_svuid; /* UID_T: saved user id */ | | 572 | uint32_t p_svuid; /* UID_T: saved user id */ |
573 | uint32_t p_svgid; /* GID_T: saved group id */ | | 573 | uint32_t p_svgid; /* GID_T: saved group id */ |
574 | char p_ename[KI_MAXEMULLEN]; /* emulation name */ | | 574 | char p_ename[KI_MAXEMULLEN]; /* emulation name */ |
575 | int64_t p_vm_vsize; /* SEGSZ_T: total map size (pages) */ | | 575 | int64_t p_vm_vsize; /* SEGSZ_T: total map size (pages) */ |
576 | int64_t p_vm_msize; /* SEGSZ_T: stack-adjusted map size (pages) */ | | 576 | int64_t p_vm_msize; /* SEGSZ_T: stack-adjusted map size (pages) */ |
577 | }; | | 577 | }; |
578 | | | 578 | |
579 | /* | | 579 | /* |
580 | * Compat flags for kinfo_proc, kinfo_proc2. Not guarenteed to be stable. | | 580 | * Compat flags for kinfo_proc, kinfo_proc2. Not guarenteed to be stable. |
581 | * Some of them used to be shared with LWP flags. | | 581 | * Some of them used to be shared with LWP flags. |
582 | * XXXAD Trim to the minimum necessary... | | 582 | * XXXAD Trim to the minimum necessary... |
583 | */ | | 583 | */ |
584 | | | 584 | |
585 | #define P_ADVLOCK 0x00000001 | | 585 | #define P_ADVLOCK 0x00000001 |
586 | #define P_CONTROLT 0x00000002 | | 586 | #define P_CONTROLT 0x00000002 |
587 | #define L_INMEM 0x00000004 | | 587 | #define L_INMEM 0x00000004 |
588 | #define P_INMEM /* 0x00000004 */ L_INMEM | | 588 | #define P_INMEM /* 0x00000004 */ L_INMEM |
589 | #define P_NOCLDSTOP 0x00000008 | | 589 | #define P_NOCLDSTOP 0x00000008 |
590 | #define P_PPWAIT 0x00000010 | | 590 | #define P_PPWAIT 0x00000010 |
591 | #define P_PROFIL 0x00000020 | | 591 | #define P_PROFIL 0x00000020 |
592 | #define L_SELECT 0x00000040 | | 592 | #define L_SELECT 0x00000040 |
593 | #define P_SELECT /* 0x00000040 */ L_SELECT | | 593 | #define P_SELECT /* 0x00000040 */ L_SELECT |
594 | #define L_SINTR 0x00000080 | | 594 | #define L_SINTR 0x00000080 |
595 | #define P_SINTR /* 0x00000080 */ L_SINTR | | 595 | #define P_SINTR /* 0x00000080 */ L_SINTR |
596 | #define P_SUGID 0x00000100 | | 596 | #define P_SUGID 0x00000100 |
597 | #define L_SYSTEM 0x00000200 | | 597 | #define L_SYSTEM 0x00000200 |
598 | #define P_SYSTEM /* 0x00000200 */ L_SYSTEM | | 598 | #define P_SYSTEM /* 0x00000200 */ L_SYSTEM |
599 | #define L_SA 0x00000400 | | 599 | #define L_SA 0x00000400 |
600 | #define P_SA /* 0x00000400 */ L_SA | | 600 | #define P_SA /* 0x00000400 */ L_SA |
601 | #define P_TRACED 0x00000800 | | 601 | #define P_TRACED 0x00000800 |
602 | #define P_WAITED 0x00001000 | | 602 | #define P_WAITED 0x00001000 |
603 | #define P_WEXIT 0x00002000 | | 603 | #define P_WEXIT 0x00002000 |
604 | #define P_EXEC 0x00004000 | | 604 | #define P_EXEC 0x00004000 |
605 | #define P_OWEUPC 0x00008000 | | 605 | #define P_OWEUPC 0x00008000 |
606 | #define P_FSTRACE 0x00010000 | | 606 | #define P_FSTRACE 0x00010000 |
607 | #define P_NOCLDWAIT 0x00020000 | | 607 | #define P_NOCLDWAIT 0x00020000 |
608 | #define P_32 0x00040000 | | 608 | #define P_32 0x00040000 |
609 | #define P_CLDSIGIGN 0x00080000 | | 609 | #define P_CLDSIGIGN 0x00080000 |
610 | #define P_SYSTRACE 0x00200000 | | 610 | #define P_SYSTRACE 0x00200000 |
611 | #define P_CHTRACED 0x00400000 | | 611 | #define P_CHTRACED 0x00400000 |
612 | #define P_STOPFORK 0x00800000 | | 612 | #define P_STOPFORK 0x00800000 |
613 | #define P_STOPEXEC 0x01000000 | | 613 | #define P_STOPEXEC 0x01000000 |
614 | #define P_STOPEXIT 0x02000000 | | 614 | #define P_STOPEXIT 0x02000000 |
615 | #define P_SYSCALL 0x04000000 | | 615 | #define P_SYSCALL 0x04000000 |
616 | #define P_PAXMPROTECT 0x08000000 | | 616 | #define P_PAXMPROTECT 0x08000000 |
617 | #define P_PAXNOMPROTECT 0x10000000 | | 617 | #define P_PAXNOMPROTECT 0x10000000 |
618 | | | 618 | |
619 | /* | | 619 | /* |
620 | * LWP compat flags. | | 620 | * LWP compat flags. |
621 | */ | | 621 | */ |
622 | #define L_DETACHED 0x00800000 | | 622 | #define L_DETACHED 0x00800000 |
623 | | | 623 | |
624 | /* | | 624 | /* |
625 | * KERN_LWP structure. See notes on KERN_PROC2 about adding elements. | | 625 | * KERN_LWP structure. See notes on KERN_PROC2 about adding elements. |
626 | */ | | 626 | */ |
627 | struct kinfo_lwp { | | 627 | struct kinfo_lwp { |
628 | uint64_t l_forw; /* PTR: linked run/sleep queue. */ | | 628 | uint64_t l_forw; /* PTR: linked run/sleep queue. */ |
629 | uint64_t l_back; | | 629 | uint64_t l_back; |
630 | uint64_t l_laddr; /* PTR: Address of LWP */ | | 630 | uint64_t l_laddr; /* PTR: Address of LWP */ |
631 | uint64_t l_addr; /* PTR: Kernel virtual addr of u-area */ | | 631 | uint64_t l_addr; /* PTR: Kernel virtual addr of u-area */ |
632 | int32_t l_lid; /* LWPID_T: LWP identifier */ | | 632 | int32_t l_lid; /* LWPID_T: LWP identifier */ |
633 | int32_t l_flag; /* INT: L_* flags. */ | | 633 | int32_t l_flag; /* INT: L_* flags. */ |
634 | uint32_t l_swtime; /* U_INT: Time swapped in or out. */ | | 634 | uint32_t l_swtime; /* U_INT: Time swapped in or out. */ |
635 | uint32_t l_slptime; /* U_INT: Time since last blocked. */ | | 635 | uint32_t l_slptime; /* U_INT: Time since last blocked. */ |
636 | int32_t l_schedflags; /* INT: PSCHED_* flags */ | | 636 | int32_t l_schedflags; /* INT: PSCHED_* flags */ |
637 | int32_t l_holdcnt; /* INT: If non-zero, don't swap. */ | | 637 | int32_t l_holdcnt; /* INT: If non-zero, don't swap. */ |
638 | uint8_t l_priority; /* U_CHAR: Process priority. */ | | 638 | uint8_t l_priority; /* U_CHAR: Process priority. */ |
639 | uint8_t l_usrpri; /* U_CHAR: User-priority based on l_cpu and p_nice. */ | | 639 | uint8_t l_usrpri; /* U_CHAR: User-priority based on l_cpu and p_nice. */ |
640 | int8_t l_stat; /* CHAR: S* process status. */ | | 640 | int8_t l_stat; /* CHAR: S* process status. */ |
641 | int8_t l_pad1; /* fill out to 4-byte boundary */ | | 641 | int8_t l_pad1; /* fill out to 4-byte boundary */ |
642 | int32_t l_pad2; /* .. and then to an 8-byte boundary */ | | 642 | int32_t l_pad2; /* .. and then to an 8-byte boundary */ |
643 | char l_wmesg[KI_WMESGLEN]; /* wchan message */ | | 643 | char l_wmesg[KI_WMESGLEN]; /* wchan message */ |
644 | uint64_t l_wchan; /* PTR: sleep address. */ | | 644 | uint64_t l_wchan; /* PTR: sleep address. */ |
645 | uint64_t l_cpuid; /* LONG: CPU id */ | | 645 | uint64_t l_cpuid; /* LONG: CPU id */ |
646 | uint32_t l_rtime_sec; /* STRUCT TIMEVAL: Real time. */ | | 646 | uint32_t l_rtime_sec; /* STRUCT TIMEVAL: Real time. */ |
647 | uint32_t l_rtime_usec; /* STRUCT TIMEVAL: Real time. */ | | 647 | uint32_t l_rtime_usec; /* STRUCT TIMEVAL: Real time. */ |
648 | uint32_t l_cpticks; /* INT: ticks during l_swtime */ | | 648 | uint32_t l_cpticks; /* INT: ticks during l_swtime */ |
649 | uint32_t l_pctcpu; /* FIXPT_T: cpu usage for ps */ | | 649 | uint32_t l_pctcpu; /* FIXPT_T: cpu usage for ps */ |
650 | uint32_t l_pid; /* PID_T: process identifier */ | | 650 | uint32_t l_pid; /* PID_T: process identifier */ |
651 | char l_name[KI_LNAMELEN]; /* CHAR[]: name, may be empty */ | | 651 | char l_name[KI_LNAMELEN]; /* CHAR[]: name, may be empty */ |
652 | }; | | 652 | }; |
653 | | | 653 | |
654 | /* | | 654 | /* |
655 | * KERN_PROC_ARGS subtypes | | 655 | * KERN_PROC_ARGS subtypes |
656 | */ | | 656 | */ |
657 | #define KERN_PROC_ARGV 1 /* argv */ | | 657 | #define KERN_PROC_ARGV 1 /* argv */ |
658 | #define KERN_PROC_NARGV 2 /* number of strings in above */ | | 658 | #define KERN_PROC_NARGV 2 /* number of strings in above */ |
659 | #define KERN_PROC_ENV 3 /* environ */ | | 659 | #define KERN_PROC_ENV 3 /* environ */ |
660 | #define KERN_PROC_NENV 4 /* number of strings in above */ | | 660 | #define KERN_PROC_NENV 4 /* number of strings in above */ |
661 | | | 661 | |
662 | /* | | 662 | /* |
663 | * KERN_SYSVIPC subtypes | | 663 | * KERN_SYSVIPC subtypes |
664 | */ | | 664 | */ |
665 | #define KERN_SYSVIPC_INFO 1 /* struct: number of valid kern ids */ | | 665 | #define KERN_SYSVIPC_INFO 1 /* struct: number of valid kern ids */ |
666 | #define KERN_SYSVIPC_MSG 2 /* int: SysV message queue suppoprt */ | | 666 | #define KERN_SYSVIPC_MSG 2 /* int: SysV message queue suppoprt */ |
667 | #define KERN_SYSVIPC_SEM 3 /* int: SysV semaphore support */ | | 667 | #define KERN_SYSVIPC_SEM 3 /* int: SysV semaphore support */ |
668 | #define KERN_SYSVIPC_SHM 4 /* int: SysV shared memory support */ | | 668 | #define KERN_SYSVIPC_SHM 4 /* int: SysV shared memory support */ |
669 | #define KERN_SYSVIPC_SHMMAX 5 /* int: max shared memory segment size (bytes) */ | | 669 | #define KERN_SYSVIPC_SHMMAX 5 /* int: max shared memory segment size (bytes) */ |
670 | #define KERN_SYSVIPC_SHMMNI 6 /* int: max number of shared memory identifiers */ | | 670 | #define KERN_SYSVIPC_SHMMNI 6 /* int: max number of shared memory identifiers */ |
671 | #define KERN_SYSVIPC_SHMSEG 7 /* int: max shared memory segments per process */ | | 671 | #define KERN_SYSVIPC_SHMSEG 7 /* int: max shared memory segments per process */ |
672 | #define KERN_SYSVIPC_SHMMAXPGS 8 /* int: max amount of shared memory (pages) */ | | 672 | #define KERN_SYSVIPC_SHMMAXPGS 8 /* int: max amount of shared memory (pages) */ |
673 | #define KERN_SYSVIPC_SHMUSEPHYS 9 /* int: physical memory usage */ | | 673 | #define KERN_SYSVIPC_SHMUSEPHYS 9 /* int: physical memory usage */ |
674 | | | 674 | |
675 | /* | | 675 | /* |
676 | * KERN_SYSVIPC_INFO subtypes | | 676 | * KERN_SYSVIPC_INFO subtypes |
677 | */ | | 677 | */ |
678 | /* KERN_SYSVIPC_OMSG_INFO 1 */ | | 678 | /* KERN_SYSVIPC_OMSG_INFO 1 */ |
679 | /* KERN_SYSVIPC_OSEM_INFO 2 */ | | 679 | /* KERN_SYSVIPC_OSEM_INFO 2 */ |
680 | /* KERN_SYSVIPC_OSHM_INFO 3 */ | | 680 | /* KERN_SYSVIPC_OSHM_INFO 3 */ |
681 | #define KERN_SYSVIPC_MSG_INFO 4 /* msginfo and msqid_ds */ | | 681 | #define KERN_SYSVIPC_MSG_INFO 4 /* msginfo and msqid_ds */ |
682 | #define KERN_SYSVIPC_SEM_INFO 5 /* seminfo and semid_ds */ | | 682 | #define KERN_SYSVIPC_SEM_INFO 5 /* seminfo and semid_ds */ |
683 | #define KERN_SYSVIPC_SHM_INFO 6 /* shminfo and shmid_ds */ | | 683 | #define KERN_SYSVIPC_SHM_INFO 6 /* shminfo and shmid_ds */ |
684 | | | 684 | |
685 | /* | | 685 | /* |
686 | * tty counter sysctl variables | | 686 | * tty counter sysctl variables |
687 | */ | | 687 | */ |
688 | #define KERN_TKSTAT_NIN 1 /* total input character */ | | 688 | #define KERN_TKSTAT_NIN 1 /* total input character */ |
689 | #define KERN_TKSTAT_NOUT 2 /* total output character */ | | 689 | #define KERN_TKSTAT_NOUT 2 /* total output character */ |
690 | #define KERN_TKSTAT_CANCC 3 /* canonical input character */ | | 690 | #define KERN_TKSTAT_CANCC 3 /* canonical input character */ |
691 | #define KERN_TKSTAT_RAWCC 4 /* raw input character */ | | 691 | #define KERN_TKSTAT_RAWCC 4 /* raw input character */ |
692 | #define KERN_TKSTAT_MAXID 5 /* number of valid TKSTAT ids */ | | 692 | #define KERN_TKSTAT_MAXID 5 /* number of valid TKSTAT ids */ |
693 | | | 693 | |
694 | #define KERN_TKSTAT_NAMES { \ | | 694 | #define KERN_TKSTAT_NAMES { \ |
695 | { 0, 0 }, \ | | 695 | { 0, 0 }, \ |
696 | { "nin", CTLTYPE_QUAD }, \ | | 696 | { "nin", CTLTYPE_QUAD }, \ |
697 | { "nout", CTLTYPE_QUAD }, \ | | 697 | { "nout", CTLTYPE_QUAD }, \ |
698 | { "cancc", CTLTYPE_QUAD }, \ | | 698 | { "cancc", CTLTYPE_QUAD }, \ |
699 | { "rawcc", CTLTYPE_QUAD }, \ | | 699 | { "rawcc", CTLTYPE_QUAD }, \ |
700 | } | | 700 | } |
701 | | | 701 | |
702 | /* | | 702 | /* |
703 | * kern.drivers returns an array of these. | | 703 | * kern.drivers returns an array of these. |
704 | */ | | 704 | */ |
705 | | | 705 | |
706 | struct kinfo_drivers { | | 706 | struct kinfo_drivers { |
707 | devmajor_t d_cmajor; | | 707 | devmajor_t d_cmajor; |
708 | devmajor_t d_bmajor; | | 708 | devmajor_t d_bmajor; |
709 | char d_name[24]; | | 709 | char d_name[24]; |
710 | }; | | 710 | }; |
711 | | | 711 | |
712 | /* | | 712 | /* |
713 | * KERN_BUF subtypes, like KERN_PROC2, where the four following mib | | 713 | * KERN_BUF subtypes, like KERN_PROC2, where the four following mib |
714 | * entries specify "which type of buf", "which particular buf", | | 714 | * entries specify "which type of buf", "which particular buf", |
715 | * "sizeof buf", and "how many". Currently, only "all buf" is | | 715 | * "sizeof buf", and "how many". Currently, only "all buf" is |
716 | * defined. | | 716 | * defined. |
717 | */ | | 717 | */ |
718 | #define KERN_BUF_ALL 0 /* all buffers */ | | 718 | #define KERN_BUF_ALL 0 /* all buffers */ |
719 | | | 719 | |
720 | /* | | 720 | /* |
721 | * kern.buf returns an array of these structures, which are designed | | 721 | * kern.buf returns an array of these structures, which are designed |
722 | * both to be immune to 32/64 bit emulation issues and to provide | | 722 | * both to be immune to 32/64 bit emulation issues and to provide |
723 | * backwards compatibility. Note that the order here differs slightly | | 723 | * backwards compatibility. Note that the order here differs slightly |
724 | * from the real struct buf in order to achieve proper 64 bit | | 724 | * from the real struct buf in order to achieve proper 64 bit |
725 | * alignment. | | 725 | * alignment. |
726 | */ | | 726 | */ |
727 | struct buf_sysctl { | | 727 | struct buf_sysctl { |
728 | uint32_t b_flags; /* LONG: B_* flags */ | | 728 | uint32_t b_flags; /* LONG: B_* flags */ |
729 | int32_t b_error; /* INT: Errno value */ | | 729 | int32_t b_error; /* INT: Errno value */ |
730 | int32_t b_prio; /* INT: Hint for buffer queue discipline */ | | 730 | int32_t b_prio; /* INT: Hint for buffer queue discipline */ |
731 | uint32_t b_dev; /* DEV_T: Device associated with buffer */ | | 731 | uint32_t b_dev; /* DEV_T: Device associated with buffer */ |
732 | uint64_t b_bufsize; /* LONG: Allocated buffer size */ | | 732 | uint64_t b_bufsize; /* LONG: Allocated buffer size */ |
733 | uint64_t b_bcount; /* LONG: Valid bytes in buffer */ | | 733 | uint64_t b_bcount; /* LONG: Valid bytes in buffer */ |
734 | uint64_t b_resid; /* LONG: Remaining I/O */ | | 734 | uint64_t b_resid; /* LONG: Remaining I/O */ |
735 | uint64_t b_addr; /* CADDR_T: Memory, superblocks, indirect... */ | | 735 | uint64_t b_addr; /* CADDR_T: Memory, superblocks, indirect... */ |
736 | uint64_t b_blkno; /* DADDR_T: Underlying physical block number */ | | 736 | uint64_t b_blkno; /* DADDR_T: Underlying physical block number */ |
737 | uint64_t b_rawblkno; /* DADDR_T: Raw underlying physical block */ | | 737 | uint64_t b_rawblkno; /* DADDR_T: Raw underlying physical block */ |
738 | uint64_t b_iodone; /* PTR: Function called upon completion */ | | 738 | uint64_t b_iodone; /* PTR: Function called upon completion */ |
739 | uint64_t b_proc; /* PTR: Associated proc if B_PHYS set */ | | 739 | uint64_t b_proc; /* PTR: Associated proc if B_PHYS set */ |
740 | uint64_t b_vp; /* PTR: File vnode */ | | 740 | uint64_t b_vp; /* PTR: File vnode */ |
741 | uint64_t b_saveaddr; /* PTR: Original b_addr for physio */ | | 741 | uint64_t b_saveaddr; /* PTR: Original b_addr for physio */ |
742 | uint64_t b_lblkno; /* DADDR_T: Logical block number */ | | 742 | uint64_t b_lblkno; /* DADDR_T: Logical block number */ |
743 | }; | | 743 | }; |
744 | | | 744 | |
745 | /* | | 745 | /* |
746 | * kern.file2 returns an array of these structures, which are designed | | 746 | * kern.file2 returns an array of these structures, which are designed |
747 | * both to be immune to be immune to 32/64 bit emulation issues and to | | 747 | * both to be immune to be immune to 32/64 bit emulation issues and to |
748 | * provide backwards compatibility. The order differs slightly from | | 748 | * provide backwards compatibility. The order differs slightly from |
749 | * that of the real struct file, and some fields are taken from other | | 749 | * that of the real struct file, and some fields are taken from other |
750 | * structures (struct vnode, struct proc) in order to make the file | | 750 | * structures (struct vnode, struct proc) in order to make the file |
751 | * information more useful. | | 751 | * information more useful. |
752 | */ | | 752 | */ |
753 | struct kinfo_file { | | 753 | struct kinfo_file { |
754 | uint64_t ki_fileaddr; /* PTR: address of struct file */ | | 754 | uint64_t ki_fileaddr; /* PTR: address of struct file */ |
755 | uint32_t ki_flag; /* INT: flags (see fcntl.h) */ | | 755 | uint32_t ki_flag; /* INT: flags (see fcntl.h) */ |
756 | uint32_t ki_iflags; /* INT: internal flags */ | | 756 | uint32_t ki_iflags; /* INT: internal flags */ |
757 | uint32_t ki_ftype; /* INT: descriptor type */ | | 757 | uint32_t ki_ftype; /* INT: descriptor type */ |
758 | uint32_t ki_count; /* UINT: reference count */ | | 758 | uint32_t ki_count; /* UINT: reference count */ |
759 | uint32_t ki_msgcount; /* UINT: references from msg queue */ | | 759 | uint32_t ki_msgcount; /* UINT: references from msg queue */ |
760 | uint32_t ki_usecount; /* INT: number active users */ | | 760 | uint32_t ki_usecount; /* INT: number active users */ |
761 | uint64_t ki_fucred; /* PTR: creds for descriptor */ | | 761 | uint64_t ki_fucred; /* PTR: creds for descriptor */ |
762 | uint32_t ki_fuid; /* UID_T: descriptor credentials */ | | 762 | uint32_t ki_fuid; /* UID_T: descriptor credentials */ |
763 | uint32_t ki_fgid; /* GID_T: descriptor credentials */ | | 763 | uint32_t ki_fgid; /* GID_T: descriptor credentials */ |
764 | uint64_t ki_fops; /* PTR: address of fileops */ | | 764 | uint64_t ki_fops; /* PTR: address of fileops */ |
765 | uint64_t ki_foffset; /* OFF_T: offset */ | | 765 | uint64_t ki_foffset; /* OFF_T: offset */ |
766 | uint64_t ki_fdata; /* PTR: descriptor data */ | | 766 | uint64_t ki_fdata; /* PTR: descriptor data */ |
767 | | | 767 | |
768 | /* vnode information to glue this file to something */ | | 768 | /* vnode information to glue this file to something */ |
769 | uint64_t ki_vun; /* PTR: socket, specinfo, etc */ | | 769 | uint64_t ki_vun; /* PTR: socket, specinfo, etc */ |
770 | uint64_t ki_vsize; /* OFF_T: size of file */ | | 770 | uint64_t ki_vsize; /* OFF_T: size of file */ |
771 | uint32_t ki_vtype; /* ENUM: vnode type */ | | 771 | uint32_t ki_vtype; /* ENUM: vnode type */ |
772 | uint32_t ki_vtag; /* ENUM: type of underlying data */ | | 772 | uint32_t ki_vtag; /* ENUM: type of underlying data */ |
773 | uint64_t ki_vdata; /* PTR: private data for fs */ | | 773 | uint64_t ki_vdata; /* PTR: private data for fs */ |
774 | | | 774 | |
775 | /* process information when retrieved via KERN_FILE_BYPID */ | | 775 | /* process information when retrieved via KERN_FILE_BYPID */ |
776 | uint32_t ki_pid; /* PID_T: process id */ | | 776 | uint32_t ki_pid; /* PID_T: process id */ |
777 | int32_t ki_fd; /* INT: descriptor number */ | | 777 | int32_t ki_fd; /* INT: descriptor number */ |
778 | uint32_t ki_ofileflags; /* CHAR: open file flags */ | | 778 | uint32_t ki_ofileflags; /* CHAR: open file flags */ |
779 | uint32_t _ki_padto64bits; | | 779 | uint32_t _ki_padto64bits; |
780 | }; | | 780 | }; |
781 | | | 781 | |
782 | #define KERN_FILE_BYFILE 1 | | 782 | #define KERN_FILE_BYFILE 1 |
783 | #define KERN_FILE_BYPID 2 | | 783 | #define KERN_FILE_BYPID 2 |
784 | #define KERN_FILESLOP 10 | | 784 | #define KERN_FILESLOP 10 |
785 | | | 785 | |
786 | /* | | 786 | /* |
787 | * kern.evcnt returns an array of these structures, which are designed both to | | 787 | * kern.evcnt returns an array of these structures, which are designed both to |
788 | * be immune to 32/64 bit emulation issues. Note that the struct here differs | | 788 | * be immune to 32/64 bit emulation issues. Note that the struct here differs |
789 | * from the real struct evcnt but contains the same information in order to | | 789 | * from the real struct evcnt but contains the same information in order to |
790 | * accomodate sysctl. | | 790 | * accomodate sysctl. |
791 | */ | | 791 | */ |
792 | struct evcnt_sysctl { | | 792 | struct evcnt_sysctl { |
793 | uint64_t ev_count; /* current count */ | | 793 | uint64_t ev_count; /* current count */ |
794 | uint64_t ev_addr; /* kernel address of evcnt */ | | 794 | uint64_t ev_addr; /* kernel address of evcnt */ |
795 | uint64_t ev_parent; /* kernel address of parent */ | | 795 | uint64_t ev_parent; /* kernel address of parent */ |
796 | uint8_t ev_type; /* EVCNT_TRAP_* */ | | 796 | uint8_t ev_type; /* EVCNT_TRAP_* */ |
797 | uint8_t ev_grouplen; /* length of group with NUL */ | | 797 | uint8_t ev_grouplen; /* length of group with NUL */ |
798 | uint8_t ev_namelen; /* length of name with NUL */ | | 798 | uint8_t ev_namelen; /* length of name with NUL */ |
799 | uint8_t ev_len; /* multiply by 8 */ | | 799 | uint8_t ev_len; /* multiply by 8 */ |
800 | /* | | 800 | /* |
801 | * Now the group and name strings follow (both include the trailing | | 801 | * Now the group and name strings follow (both include the trailing |
802 | * NUL). ev_name start at &ev_strings[ev_grouplen+1] | | 802 | * NUL). ev_name start at &ev_strings[ev_grouplen+1] |
803 | */ | | 803 | */ |
804 | char ev_strings[0]; | | 804 | char ev_strings[0]; |
805 | }; | | 805 | }; |
806 | | | 806 | |
807 | #define KERN_EVCNT_COUNT_ANY 0 | | 807 | #define KERN_EVCNT_COUNT_ANY 0 |
808 | #define KERN_EVCNT_COUNT_NONZERO 1 | | 808 | #define KERN_EVCNT_COUNT_NONZERO 1 |
809 | | | 809 | |
810 | /* | | 810 | /* |
811 | * CTL_HW identifiers | | 811 | * CTL_HW identifiers |
812 | */ | | 812 | */ |
813 | #define HW_MACHINE 1 /* string: machine class */ | | 813 | #define HW_MACHINE 1 /* string: machine class */ |
814 | #define HW_MODEL 2 /* string: specific machine model */ | | 814 | #define HW_MODEL 2 /* string: specific machine model */ |
815 | #define HW_NCPU 3 /* int: number of cpus */ | | 815 | #define HW_NCPU 3 /* int: number of cpus */ |
816 | #define HW_BYTEORDER 4 /* int: machine byte order */ | | 816 | #define HW_BYTEORDER 4 /* int: machine byte order */ |
817 | #define HW_PHYSMEM 5 /* int: total memory (bytes) */ | | 817 | #define HW_PHYSMEM 5 /* int: total memory (bytes) */ |
818 | #define HW_USERMEM 6 /* int: non-kernel memory (bytes) */ | | 818 | #define HW_USERMEM 6 /* int: non-kernel memory (bytes) */ |
819 | #define HW_PAGESIZE 7 /* int: software page size */ | | 819 | #define HW_PAGESIZE 7 /* int: software page size */ |
820 | #define HW_DISKNAMES 8 /* string: disk drive names */ | | 820 | #define HW_DISKNAMES 8 /* string: disk drive names */ |
821 | #define HW_IOSTATS 9 /* struct: iostats[] */ | | 821 | #define HW_IOSTATS 9 /* struct: iostats[] */ |
822 | #define HW_MACHINE_ARCH 10 /* string: machine architecture */ | | 822 | #define HW_MACHINE_ARCH 10 /* string: machine architecture */ |
823 | #define HW_ALIGNBYTES 11 /* int: ALIGNBYTES for the kernel */ | | 823 | #define HW_ALIGNBYTES 11 /* int: ALIGNBYTES for the kernel */ |
824 | #define HW_CNMAGIC 12 /* string: console magic sequence(s) */ | | 824 | #define HW_CNMAGIC 12 /* string: console magic sequence(s) */ |
825 | #define HW_PHYSMEM64 13 /* quad: total memory (bytes) */ | | 825 | #define HW_PHYSMEM64 13 /* quad: total memory (bytes) */ |
826 | #define HW_USERMEM64 14 /* quad: non-kernel memory (bytes) */ | | 826 | #define HW_USERMEM64 14 /* quad: non-kernel memory (bytes) */ |
827 | #define HW_IOSTATNAMES 15 /* string: iostat names */ | | 827 | #define HW_IOSTATNAMES 15 /* string: iostat names */ |
828 | #define HW_MAXID 15 /* number of valid hw ids */ | | 828 | #define HW_MAXID 15 /* number of valid hw ids */ |
829 | #define HW_NCPUONLINE 16 /* number CPUs online */ | | 829 | #define HW_NCPUONLINE 16 /* number CPUs online */ |
830 | | | 830 | |
831 | #define CTL_HW_NAMES { \ | | 831 | #define CTL_HW_NAMES { \ |
832 | { 0, 0 }, \ | | 832 | { 0, 0 }, \ |
833 | { "machine", CTLTYPE_STRING }, \ | | 833 | { "machine", CTLTYPE_STRING }, \ |
834 | { "model", CTLTYPE_STRING }, \ | | 834 | { "model", CTLTYPE_STRING }, \ |
835 | { "ncpu", CTLTYPE_INT }, \ | | 835 | { "ncpu", CTLTYPE_INT }, \ |
836 | { "byteorder", CTLTYPE_INT }, \ | | 836 | { "byteorder", CTLTYPE_INT }, \ |
837 | { "physmem", CTLTYPE_INT }, \ | | 837 | { "physmem", CTLTYPE_INT }, \ |
838 | { "usermem", CTLTYPE_INT }, \ | | 838 | { "usermem", CTLTYPE_INT }, \ |
839 | { "pagesize", CTLTYPE_INT }, \ | | 839 | { "pagesize", CTLTYPE_INT }, \ |
840 | { "drivenames", CTLTYPE_STRING }, \ | | 840 | { "drivenames", CTLTYPE_STRING }, \ |
841 | { "drivestats", CTLTYPE_STRUCT }, \ | | 841 | { "drivestats", CTLTYPE_STRUCT }, \ |
842 | { "machine_arch", CTLTYPE_STRING }, \ | | 842 | { "machine_arch", CTLTYPE_STRING }, \ |
843 | { "alignbytes", CTLTYPE_INT }, \ | | 843 | { "alignbytes", CTLTYPE_INT }, \ |
844 | { "cnmagic", CTLTYPE_STRING }, \ | | 844 | { "cnmagic", CTLTYPE_STRING }, \ |
845 | { "physmem64", CTLTYPE_QUAD }, \ | | 845 | { "physmem64", CTLTYPE_QUAD }, \ |
846 | { "usermem64", CTLTYPE_QUAD }, \ | | 846 | { "usermem64", CTLTYPE_QUAD }, \ |
847 | { "ncpuonline", CTLTYPE_INT }, \ | | 847 | { "ncpuonline", CTLTYPE_INT }, \ |
848 | } | | 848 | } |
849 | | | 849 | |
850 | /* | | 850 | /* |
851 | * CTL_USER definitions | | 851 | * CTL_USER definitions |
852 | */ | | 852 | */ |
853 | #define USER_CS_PATH 1 /* string: _CS_PATH */ | | 853 | #define USER_CS_PATH 1 /* string: _CS_PATH */ |
854 | #define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */ | | 854 | #define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */ |
855 | #define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */ | | 855 | #define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */ |
856 | #define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */ | | 856 | #define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */ |
857 | #define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */ | | 857 | #define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */ |
858 | #define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */ | | 858 | #define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */ |
859 | #define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */ | | 859 | #define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */ |
860 | #define USER_LINE_MAX 8 /* int: LINE_MAX */ | | 860 | #define USER_LINE_MAX 8 /* int: LINE_MAX */ |
861 | #define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */ | | 861 | #define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */ |
862 | #define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */ | | 862 | #define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */ |
863 | #define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */ | | 863 | #define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */ |
864 | #define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */ | | 864 | #define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */ |
865 | #define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */ | | 865 | #define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */ |
866 | #define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */ | | 866 | #define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */ |
867 | #define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */ | | 867 | #define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */ |
868 | #define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */ | | 868 | #define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */ |
869 | #define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */ | | 869 | #define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */ |
870 | #define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */ | | 870 | #define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */ |
871 | #define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */ | | 871 | #define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */ |
872 | #define USER_TZNAME_MAX 20 /* int: _POSIX_TZNAME_MAX */ | | 872 | #define USER_TZNAME_MAX 20 /* int: _POSIX_TZNAME_MAX */ |
873 | #define USER_ATEXIT_MAX 21 /* int: {ATEXIT_MAX} */ | | 873 | #define USER_ATEXIT_MAX 21 /* int: {ATEXIT_MAX} */ |
874 | #define USER_MAXID 22 /* number of valid user ids */ | | 874 | #define USER_MAXID 22 /* number of valid user ids */ |
875 | | | 875 | |
876 | #define CTL_USER_NAMES { \ | | 876 | #define CTL_USER_NAMES { \ |
877 | { 0, 0 }, \ | | 877 | { 0, 0 }, \ |
878 | { "cs_path", CTLTYPE_STRING }, \ | | 878 | { "cs_path", CTLTYPE_STRING }, \ |
879 | { "bc_base_max", CTLTYPE_INT }, \ | | 879 | { "bc_base_max", CTLTYPE_INT }, \ |
880 | { "bc_dim_max", CTLTYPE_INT }, \ | | 880 | { "bc_dim_max", CTLTYPE_INT }, \ |
881 | { "bc_scale_max", CTLTYPE_INT }, \ | | 881 | { "bc_scale_max", CTLTYPE_INT }, \ |
882 | { "bc_string_max", CTLTYPE_INT }, \ | | 882 | { "bc_string_max", CTLTYPE_INT }, \ |
883 | { "coll_weights_max", CTLTYPE_INT }, \ | | 883 | { "coll_weights_max", CTLTYPE_INT }, \ |
884 | { "expr_nest_max", CTLTYPE_INT }, \ | | 884 | { "expr_nest_max", CTLTYPE_INT }, \ |
885 | { "line_max", CTLTYPE_INT }, \ | | 885 | { "line_max", CTLTYPE_INT }, \ |
886 | { "re_dup_max", CTLTYPE_INT }, \ | | 886 | { "re_dup_max", CTLTYPE_INT }, \ |
887 | { "posix2_version", CTLTYPE_INT }, \ | | 887 | { "posix2_version", CTLTYPE_INT }, \ |
888 | { "posix2_c_bind", CTLTYPE_INT }, \ | | 888 | { "posix2_c_bind", CTLTYPE_INT }, \ |
889 | { "posix2_c_dev", CTLTYPE_INT }, \ | | 889 | { "posix2_c_dev", CTLTYPE_INT }, \ |
890 | { "posix2_char_term", CTLTYPE_INT }, \ | | 890 | { "posix2_char_term", CTLTYPE_INT }, \ |
891 | { "posix2_fort_dev", CTLTYPE_INT }, \ | | 891 | { "posix2_fort_dev", CTLTYPE_INT }, \ |
892 | { "posix2_fort_run", CTLTYPE_INT }, \ | | 892 | { "posix2_fort_run", CTLTYPE_INT }, \ |
893 | { "posix2_localedef", CTLTYPE_INT }, \ | | 893 | { "posix2_localedef", CTLTYPE_INT }, \ |
894 | { "posix2_sw_dev", CTLTYPE_INT }, \ | | 894 | { "posix2_sw_dev", CTLTYPE_INT }, \ |
895 | { "posix2_upe", CTLTYPE_INT }, \ | | 895 | { "posix2_upe", CTLTYPE_INT }, \ |
896 | { "stream_max", CTLTYPE_INT }, \ | | 896 | { "stream_max", CTLTYPE_INT }, \ |
897 | { "tzname_max", CTLTYPE_INT }, \ | | 897 | { "tzname_max", CTLTYPE_INT }, \ |
898 | { "atexit_max", CTLTYPE_INT }, \ | | 898 | { "atexit_max", CTLTYPE_INT }, \ |
899 | } | | 899 | } |
900 | | | 900 | |
901 | /* | | 901 | /* |
902 | * CTL_DDB definitions | | 902 | * CTL_DDB definitions |
903 | */ | | 903 | */ |
904 | #define DDBCTL_RADIX 1 /* int: Input and output radix */ | | 904 | #define DDBCTL_RADIX 1 /* int: Input and output radix */ |
905 | #define DDBCTL_MAXOFF 2 /* int: max symbol offset */ | | 905 | #define DDBCTL_MAXOFF 2 /* int: max symbol offset */ |
906 | #define DDBCTL_MAXWIDTH 3 /* int: width of the display line */ | | 906 | #define DDBCTL_MAXWIDTH 3 /* int: width of the display line */ |
907 | #define DDBCTL_LINES 4 /* int: number of display lines */ | | 907 | #define DDBCTL_LINES 4 /* int: number of display lines */ |
908 | #define DDBCTL_TABSTOPS 5 /* int: tab width */ | | 908 | #define DDBCTL_TABSTOPS 5 /* int: tab width */ |
909 | #define DDBCTL_ONPANIC 6 /* int: DDB on panic if non-zero */ | | 909 | #define DDBCTL_ONPANIC 6 /* int: DDB on panic if non-zero */ |
910 | #define DDBCTL_FROMCONSOLE 7 /* int: DDB via console if non-zero */ | | 910 | #define DDBCTL_FROMCONSOLE 7 /* int: DDB via console if non-zero */ |
911 | #define DDBCTL_MAXID 8 /* number of valid DDB ids */ | | 911 | #define DDBCTL_MAXID 8 /* number of valid DDB ids */ |
912 | | | 912 | |
913 | #define CTL_DDB_NAMES { \ | | 913 | #define CTL_DDB_NAMES { \ |
914 | { 0, 0 }, \ | | 914 | { 0, 0 }, \ |
915 | { "radix", CTLTYPE_INT }, \ | | 915 | { "radix", CTLTYPE_INT }, \ |
916 | { "maxoff", CTLTYPE_INT }, \ | | 916 | { "maxoff", CTLTYPE_INT }, \ |
917 | { "maxwidth", CTLTYPE_INT }, \ | | 917 | { "maxwidth", CTLTYPE_INT }, \ |
918 | { "lines", CTLTYPE_INT }, \ | | 918 | { "lines", CTLTYPE_INT }, \ |
919 | { "tabstops", CTLTYPE_INT }, \ | | 919 | { "tabstops", CTLTYPE_INT }, \ |
920 | { "onpanic", CTLTYPE_INT }, \ | | 920 | { "onpanic", CTLTYPE_INT }, \ |
921 | { "fromconsole", CTLTYPE_INT }, \ | | 921 | { "fromconsole", CTLTYPE_INT }, \ |
922 | } | | 922 | } |
923 | | | 923 | |
924 | /* | | 924 | /* |
925 | * CTL_DEBUG definitions | | 925 | * CTL_DEBUG definitions |
926 | * | | 926 | * |
927 | * Second level identifier specifies which debug variable. | | 927 | * Second level identifier specifies which debug variable. |
928 | * Third level identifier specifies which structure component. | | 928 | * Third level identifier specifies which structure component. |
929 | */ | | 929 | */ |
930 | #define CTL_DEBUG_NAME 0 /* string: variable name */ | | 930 | #define CTL_DEBUG_NAME 0 /* string: variable name */ |
931 | #define CTL_DEBUG_VALUE 1 /* int: variable value */ | | 931 | #define CTL_DEBUG_VALUE 1 /* int: variable value */ |
932 | #define CTL_DEBUG_MAXID 20 | | 932 | #define CTL_DEBUG_MAXID 20 |
933 | | | 933 | |
934 | /* | | 934 | /* |
935 | * CTL_PROC subtype. Either a PID, or a magic value for the current proc. | | 935 | * CTL_PROC subtype. Either a PID, or a magic value for the current proc. |
936 | */ | | 936 | */ |
937 | | | 937 | |
938 | #define PROC_CURPROC (~((u_int)1 << 31)) | | 938 | #define PROC_CURPROC (~((u_int)1 << 31)) |
939 | | | 939 | |
940 | /* | | 940 | /* |
941 | * CTL_PROC tree: either corename (string), or a limit | | 941 | * CTL_PROC tree: either corename (string), or a limit |
942 | * (rlimit.<type>.{hard,soft}, int). | | 942 | * (rlimit.<type>.{hard,soft}, int). |
943 | */ | | 943 | */ |
944 | #define PROC_PID_CORENAME 1 | | 944 | #define PROC_PID_CORENAME 1 |
945 | #define PROC_PID_LIMIT 2 | | 945 | #define PROC_PID_LIMIT 2 |
946 | #define PROC_PID_STOPFORK 3 | | 946 | #define PROC_PID_STOPFORK 3 |
947 | #define PROC_PID_STOPEXEC 4 | | 947 | #define PROC_PID_STOPEXEC 4 |
948 | #define PROC_PID_STOPEXIT 5 | | 948 | #define PROC_PID_STOPEXIT 5 |
949 | #define PROC_PID_MAXID 6 | | 949 | #define PROC_PID_MAXID 6 |
950 | | | 950 | |
951 | #define PROC_PID_NAMES { \ | | 951 | #define PROC_PID_NAMES { \ |
952 | { 0, 0 }, \ | | 952 | { 0, 0 }, \ |
953 | { "corename", CTLTYPE_STRING }, \ | | 953 | { "corename", CTLTYPE_STRING }, \ |
954 | { "rlimit", CTLTYPE_NODE }, \ | | 954 | { "rlimit", CTLTYPE_NODE }, \ |
955 | { "stopfork", CTLTYPE_INT }, \ | | 955 | { "stopfork", CTLTYPE_INT }, \ |
956 | { "stopexec", CTLTYPE_INT }, \ | | 956 | { "stopexec", CTLTYPE_INT }, \ |
957 | { "stopexit", CTLTYPE_INT }, \ | | 957 | { "stopexit", CTLTYPE_INT }, \ |
958 | } | | 958 | } |
959 | | | 959 | |
960 | /* Limit types from <sys/resources.h> */ | | 960 | /* Limit types from <sys/resources.h> */ |
961 | #define PROC_PID_LIMIT_CPU (RLIMIT_CPU+1) | | 961 | #define PROC_PID_LIMIT_CPU (RLIMIT_CPU+1) |
962 | #define PROC_PID_LIMIT_FSIZE (RLIMIT_FSIZE+1) | | 962 | #define PROC_PID_LIMIT_FSIZE (RLIMIT_FSIZE+1) |
963 | #define PROC_PID_LIMIT_DATA (RLIMIT_DATA+1) | | 963 | #define PROC_PID_LIMIT_DATA (RLIMIT_DATA+1) |
964 | #define PROC_PID_LIMIT_STACK (RLIMIT_STACK+1) | | 964 | #define PROC_PID_LIMIT_STACK (RLIMIT_STACK+1) |
965 | #define PROC_PID_LIMIT_CORE (RLIMIT_CORE+1) | | 965 | #define PROC_PID_LIMIT_CORE (RLIMIT_CORE+1) |
966 | #define PROC_PID_LIMIT_RSS (RLIMIT_RSS+1) | | 966 | #define PROC_PID_LIMIT_RSS (RLIMIT_RSS+1) |
967 | #define PROC_PID_LIMIT_MEMLOCK (RLIMIT_MEMLOCK+1) | | 967 | #define PROC_PID_LIMIT_MEMLOCK (RLIMIT_MEMLOCK+1) |
968 | #define PROC_PID_LIMIT_NPROC (RLIMIT_NPROC+1) | | 968 | #define PROC_PID_LIMIT_NPROC (RLIMIT_NPROC+1) |
969 | #define PROC_PID_LIMIT_NOFILE (RLIMIT_NOFILE+1) | | 969 | #define PROC_PID_LIMIT_NOFILE (RLIMIT_NOFILE+1) |
970 | #define PROC_PID_LIMIT_SBSIZE (RLIMIT_SBSIZE+1) | | 970 | #define PROC_PID_LIMIT_SBSIZE (RLIMIT_SBSIZE+1) |
971 | #define PROC_PID_LIMIT_AS (RLIMIT_AS+1) | | 971 | #define PROC_PID_LIMIT_AS (RLIMIT_AS+1) |
972 | #define PROC_PID_LIMIT_MAXID (RLIM_NLIMITS+1) | | 972 | #define PROC_PID_LIMIT_MAXID (RLIM_NLIMITS+1) |
973 | | | 973 | |
974 | #define PROC_PID_LIMIT_NAMES { \ | | 974 | #define PROC_PID_LIMIT_NAMES { \ |
975 | { 0, 0 }, \ | | 975 | { 0, 0 }, \ |
976 | { "cputime", CTLTYPE_NODE }, \ | | 976 | { "cputime", CTLTYPE_NODE }, \ |
977 | { "filesize", CTLTYPE_NODE }, \ | | 977 | { "filesize", CTLTYPE_NODE }, \ |
978 | { "datasize", CTLTYPE_NODE }, \ | | 978 | { "datasize", CTLTYPE_NODE }, \ |
979 | { "stacksize", CTLTYPE_NODE }, \ | | 979 | { "stacksize", CTLTYPE_NODE }, \ |
980 | { "coredumpsize", CTLTYPE_NODE }, \ | | 980 | { "coredumpsize", CTLTYPE_NODE }, \ |
981 | { "memoryuse", CTLTYPE_NODE }, \ | | 981 | { "memoryuse", CTLTYPE_NODE }, \ |
982 | { "memorylocked", CTLTYPE_NODE }, \ | | 982 | { "memorylocked", CTLTYPE_NODE }, \ |
983 | { "maxproc", CTLTYPE_NODE }, \ | | 983 | { "maxproc", CTLTYPE_NODE }, \ |
984 | { "descriptors", CTLTYPE_NODE }, \ | | 984 | { "descriptors", CTLTYPE_NODE }, \ |
985 | { "sbsize", CTLTYPE_NODE }, \ | | 985 | { "sbsize", CTLTYPE_NODE }, \ |
986 | { "vmemoryuse", CTLTYPE_NODE }, \ | | 986 | { "vmemoryuse", CTLTYPE_NODE }, \ |
987 | } | | 987 | } |
988 | /* for each type, either hard or soft value */ | | 988 | /* for each type, either hard or soft value */ |
989 | #define PROC_PID_LIMIT_TYPE_SOFT 1 | | 989 | #define PROC_PID_LIMIT_TYPE_SOFT 1 |
990 | #define PROC_PID_LIMIT_TYPE_HARD 2 | | 990 | #define PROC_PID_LIMIT_TYPE_HARD 2 |
991 | #define PROC_PID_LIMIT_TYPE_MAXID 3 | | 991 | #define PROC_PID_LIMIT_TYPE_MAXID 3 |
992 | | | 992 | |
993 | #define PROC_PID_LIMIT_TYPE_NAMES { \ | | 993 | #define PROC_PID_LIMIT_TYPE_NAMES { \ |
994 | {0, 0}, \ | | 994 | {0, 0}, \ |
995 | { "soft", CTLTYPE_QUAD }, \ | | 995 | { "soft", CTLTYPE_QUAD }, \ |
996 | { "hard", CTLTYPE_QUAD }, \ | | 996 | { "hard", CTLTYPE_QUAD }, \ |
997 | } | | 997 | } |
998 | | | 998 | |
999 | /* | | 999 | /* |
1000 | * CTL_EMUL definitions | | 1000 | * CTL_EMUL definitions |
1001 | * | | 1001 | * |
1002 | * Second level identifier specifies which emulation variable. | | 1002 | * Second level identifier specifies which emulation variable. |
1003 | * Subsequent levels are specified in the emulations themselves. | | 1003 | * Subsequent levels are specified in the emulations themselves. |
1004 | */ | | 1004 | */ |
1005 | #define EMUL_LINUX 1 | | 1005 | #define EMUL_LINUX 1 |
1006 | #define EMUL_LINUX32 5 | | 1006 | #define EMUL_LINUX32 5 |
1007 | | | 1007 | |
1008 | #define EMUL_MAXID 6 | | 1008 | #define EMUL_MAXID 6 |
1009 | #define CTL_EMUL_NAMES { \ | | | |
1010 | { 0, 0 }, \ | | | |
1011 | { "linux", CTLTYPE_NODE }, \ | | | |
1012 | { "linux32", CTLTYPE_NODE }, \ | | | |
1013 | } | | | |
1014 | | | 1009 | |
1015 | #ifdef _KERNEL | | 1010 | #ifdef _KERNEL |
1016 | | | 1011 | |
1017 | #if defined(_KERNEL_OPT) | | 1012 | #if defined(_KERNEL_OPT) |
1018 | #include "opt_sysctl.h" | | 1013 | #include "opt_sysctl.h" |
1019 | #endif | | 1014 | #endif |
1020 | | | 1015 | |
1021 | /* Root node of the kernel sysctl tree */ | | 1016 | /* Root node of the kernel sysctl tree */ |
1022 | extern struct sysctlnode sysctl_root; | | 1017 | extern struct sysctlnode sysctl_root; |
1023 | | | 1018 | |
1024 | /* | | 1019 | /* |
1025 | * A log of nodes created by a setup function or set of setup | | 1020 | * A log of nodes created by a setup function or set of setup |
1026 | * functions so that they can be torn down in one "transaction" | | 1021 | * functions so that they can be torn down in one "transaction" |
1027 | * when no longer needed. | | 1022 | * when no longer needed. |
1028 | * | | 1023 | * |
1029 | * Users of the log merely pass a pointer to a pointer, and the sysctl | | 1024 | * Users of the log merely pass a pointer to a pointer, and the sysctl |
1030 | * infrastructure takes care of the rest. | | 1025 | * infrastructure takes care of the rest. |
1031 | */ | | 1026 | */ |
1032 | struct sysctllog; | | 1027 | struct sysctllog; |
1033 | | | 1028 | |
1034 | /* | | 1029 | /* |
1035 | * CTL_DEBUG variables. | | 1030 | * CTL_DEBUG variables. |
1036 | * | | 1031 | * |
1037 | * These are declared as separate variables so that they can be | | 1032 | * These are declared as separate variables so that they can be |
1038 | * individually initialized at the location of their associated | | 1033 | * individually initialized at the location of their associated |
1039 | * variable. The loader prevents multiple use by issuing errors | | 1034 | * variable. The loader prevents multiple use by issuing errors |
1040 | * if a variable is initialized in more than one place. They are | | 1035 | * if a variable is initialized in more than one place. They are |
1041 | * aggregated into an array in debug_sysctl(), so that it can | | 1036 | * aggregated into an array in debug_sysctl(), so that it can |
1042 | * conveniently locate them when querried. If more debugging | | 1037 | * conveniently locate them when querried. If more debugging |
1043 | * variables are added, they must also be declared here and also | | 1038 | * variables are added, they must also be declared here and also |
1044 | * entered into the array. | | 1039 | * entered into the array. |
1045 | * | | 1040 | * |
1046 | * Note that the debug subtree is largely obsolescent in terms of | | 1041 | * Note that the debug subtree is largely obsolescent in terms of |
1047 | * functionality now that we have dynamic sysctl, but the | | 1042 | * functionality now that we have dynamic sysctl, but the |
1048 | * infrastructure is retained for backwards compatibility. | | 1043 | * infrastructure is retained for backwards compatibility. |
1049 | */ | | 1044 | */ |
1050 | struct ctldebug { | | 1045 | struct ctldebug { |
1051 | const char *debugname; /* name of debugging variable */ | | 1046 | const char *debugname; /* name of debugging variable */ |
1052 | int *debugvar; /* pointer to debugging variable */ | | 1047 | int *debugvar; /* pointer to debugging variable */ |
1053 | }; | | 1048 | }; |
1054 | #ifdef DEBUG | | 1049 | #ifdef DEBUG |
1055 | extern struct ctldebug debug0, debug1, debug2, debug3, debug4; | | 1050 | extern struct ctldebug debug0, debug1, debug2, debug3, debug4; |
1056 | extern struct ctldebug debug5, debug6, debug7, debug8, debug9; | | 1051 | extern struct ctldebug debug5, debug6, debug7, debug8, debug9; |
1057 | extern struct ctldebug debug10, debug11, debug12, debug13, debug14; | | 1052 | extern struct ctldebug debug10, debug11, debug12, debug13, debug14; |
1058 | extern struct ctldebug debug15, debug16, debug17, debug18, debug19; | | 1053 | extern struct ctldebug debug15, debug16, debug17, debug18, debug19; |
1059 | #endif /* DEBUG */ | | 1054 | #endif /* DEBUG */ |
1060 | | | 1055 | |
1061 | #define SYSCTLFN_PROTO const int *, u_int, void *, \ | | 1056 | #define SYSCTLFN_PROTO const int *, u_int, void *, \ |
1062 | size_t *, const void *, size_t, \ | | 1057 | size_t *, const void *, size_t, \ |
1063 | const int *, struct lwp *, const struct sysctlnode * | | 1058 | const int *, struct lwp *, const struct sysctlnode * |
1064 | #define SYSCTLFN_ARGS const int *name, u_int namelen, \ | | 1059 | #define SYSCTLFN_ARGS const int *name, u_int namelen, \ |
1065 | void *oldp, size_t *oldlenp, \ | | 1060 | void *oldp, size_t *oldlenp, \ |
1066 | const void *newp, size_t newlen, \ | | 1061 | const void *newp, size_t newlen, \ |
1067 | const int *oname, struct lwp *l, \ | | 1062 | const int *oname, struct lwp *l, \ |
1068 | const struct sysctlnode *rnode | | 1063 | const struct sysctlnode *rnode |
1069 | #define SYSCTLFN_CALL(node) name, namelen, oldp, \ | | 1064 | #define SYSCTLFN_CALL(node) name, namelen, oldp, \ |
1070 | oldlenp, newp, newlen, \ | | 1065 | oldlenp, newp, newlen, \ |
1071 | oname, l, node | | 1066 | oname, l, node |
1072 | | | 1067 | |
1073 | #ifdef _MODULE | | 1068 | #ifdef _MODULE |
1074 | | | 1069 | |
1075 | #define SYSCTL_SETUP_PROTO(name) \ | | 1070 | #define SYSCTL_SETUP_PROTO(name) \ |
1076 | void name(struct sysctllog **) | | 1071 | void name(struct sysctllog **) |
1077 | #ifdef SYSCTL_DEBUG_SETUP | | 1072 | #ifdef SYSCTL_DEBUG_SETUP |
1078 | #define SYSCTL_SETUP(name, desc) \ | | 1073 | #define SYSCTL_SETUP(name, desc) \ |
1079 | SYSCTL_SETUP_PROTO(name); \ | | 1074 | SYSCTL_SETUP_PROTO(name); \ |
1080 | static void __CONCAT(___,name)(struct sysctllog **); \ | | 1075 | static void __CONCAT(___,name)(struct sysctllog **); \ |
1081 | void name(struct sysctllog **clog) { \ | | 1076 | void name(struct sysctllog **clog) { \ |
1082 | printf("%s\n", desc); \ | | 1077 | printf("%s\n", desc); \ |
1083 | __CONCAT(___,name)(clog); } \ | | 1078 | __CONCAT(___,name)(clog); } \ |
1084 | __link_set_add_text(sysctl_funcs, name); \ | | 1079 | __link_set_add_text(sysctl_funcs, name); \ |
1085 | static void __CONCAT(___,name)(struct sysctllog **clog) | | 1080 | static void __CONCAT(___,name)(struct sysctllog **clog) |
1086 | #else /* !SYSCTL_DEBUG_SETUP */ | | 1081 | #else /* !SYSCTL_DEBUG_SETUP */ |
1087 | #define SYSCTL_SETUP(name, desc) \ | | 1082 | #define SYSCTL_SETUP(name, desc) \ |
1088 | SYSCTL_SETUP_PROTO(name); \ | | 1083 | SYSCTL_SETUP_PROTO(name); \ |
1089 | __link_set_add_text(sysctl_funcs, name); \ | | 1084 | __link_set_add_text(sysctl_funcs, name); \ |
1090 | void name(struct sysctllog **clog) | | 1085 | void name(struct sysctllog **clog) |
1091 | #endif /* !SYSCTL_DEBUG_SETUP */ | | 1086 | #endif /* !SYSCTL_DEBUG_SETUP */ |
1092 | | | 1087 | |
1093 | #else /* !_MODULE */ | | 1088 | #else /* !_MODULE */ |
1094 | | | 1089 | |
1095 | #define SYSCTL_SETUP_PROTO(name) | | 1090 | #define SYSCTL_SETUP_PROTO(name) |
1096 | #ifdef SYSCTL_DEBUG_SETUP | | 1091 | #ifdef SYSCTL_DEBUG_SETUP |
1097 | #define SYSCTL_SETUP(name, desc) \ | | 1092 | #define SYSCTL_SETUP(name, desc) \ |
1098 | static void __CONCAT(___,name)(struct sysctllog **); \ | | 1093 | static void __CONCAT(___,name)(struct sysctllog **); \ |
1099 | static void name(struct sysctllog **clog) { \ | | 1094 | static void name(struct sysctllog **clog) { \ |
1100 | printf("%s\n", desc); \ | | 1095 | printf("%s\n", desc); \ |
1101 | __CONCAT(___,name)(clog); } \ | | 1096 | __CONCAT(___,name)(clog); } \ |
1102 | __link_set_add_text(sysctl_funcs, name); \ | | 1097 | __link_set_add_text(sysctl_funcs, name); \ |
1103 | static void __CONCAT(___,name)(struct sysctllog **clog) | | 1098 | static void __CONCAT(___,name)(struct sysctllog **clog) |
1104 | #else /* !SYSCTL_DEBUG_SETUP */ | | 1099 | #else /* !SYSCTL_DEBUG_SETUP */ |
1105 | #define SYSCTL_SETUP(name, desc) \ | | 1100 | #define SYSCTL_SETUP(name, desc) \ |
1106 | static void name(struct sysctllog **); \ | | 1101 | static void name(struct sysctllog **); \ |
1107 | __link_set_add_text(sysctl_funcs, name); \ | | 1102 | __link_set_add_text(sysctl_funcs, name); \ |
1108 | static void name(struct sysctllog **clog) | | 1103 | static void name(struct sysctllog **clog) |
1109 | #endif /* !SYSCTL_DEBUG_SETUP */ | | 1104 | #endif /* !SYSCTL_DEBUG_SETUP */ |
1110 | | | 1105 | |
1111 | #endif /* !_MODULE */ | | 1106 | #endif /* !_MODULE */ |
1112 | | | 1107 | |
1113 | /* | | 1108 | /* |
1114 | * Internal sysctl function calling convention: | | 1109 | * Internal sysctl function calling convention: |
1115 | * | | 1110 | * |
1116 | * (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen, | | 1111 | * (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen, |
1117 | * origname, lwp, node); | | 1112 | * origname, lwp, node); |
1118 | * | | 1113 | * |
1119 | * The name parameter points at the next component of the name to be | | 1114 | * The name parameter points at the next component of the name to be |
1120 | * interpreted. The namelen parameter is the number of integers in | | 1115 | * interpreted. The namelen parameter is the number of integers in |
1121 | * the name. The origname parameter points to the start of the name | | 1116 | * the name. The origname parameter points to the start of the name |
1122 | * being parsed. The node parameter points to the node on which the | | 1117 | * being parsed. The node parameter points to the node on which the |
1123 | * current operation is to be performed. | | 1118 | * current operation is to be performed. |
1124 | */ | | 1119 | */ |
1125 | typedef int (*sysctlfn)(SYSCTLFN_PROTO); | | 1120 | typedef int (*sysctlfn)(SYSCTLFN_PROTO); |
1126 | | | 1121 | |
1127 | /* | | 1122 | /* |
1128 | * used in more than just sysctl | | 1123 | * used in more than just sysctl |
1129 | */ | | 1124 | */ |
1130 | void fill_eproc(struct proc *, struct eproc *, bool); | | 1125 | void fill_eproc(struct proc *, struct eproc *, bool); |
1131 | | | 1126 | |
1132 | /* | | 1127 | /* |
1133 | * subsystem setup | | 1128 | * subsystem setup |
1134 | */ | | 1129 | */ |
1135 | void sysctl_init(void); | | 1130 | void sysctl_init(void); |
1136 | void sysctl_finalize(void); | | 1131 | void sysctl_finalize(void); |
1137 | | | 1132 | |
1138 | /* | | 1133 | /* |
1139 | * typical syscall call order | | 1134 | * typical syscall call order |
1140 | */ | | 1135 | */ |
1141 | void sysctl_lock(bool); | | 1136 | void sysctl_lock(bool); |
1142 | int sysctl_dispatch(SYSCTLFN_PROTO); | | 1137 | int sysctl_dispatch(SYSCTLFN_PROTO); |
1143 | void sysctl_unlock(void); | | 1138 | void sysctl_unlock(void); |
1144 | void sysctl_relock(void); | | 1139 | void sysctl_relock(void); |
1145 | | | 1140 | |
1146 | /* | | 1141 | /* |
1147 | * tree navigation primitives (must obtain lock before using these) | | 1142 | * tree navigation primitives (must obtain lock before using these) |
1148 | */ | | 1143 | */ |
1149 | int sysctl_locate(struct lwp *, const int *, u_int, | | 1144 | int sysctl_locate(struct lwp *, const int *, u_int, |
1150 | const struct sysctlnode **, int *); | | 1145 | const struct sysctlnode **, int *); |
1151 | int sysctl_query(SYSCTLFN_PROTO); | | 1146 | int sysctl_query(SYSCTLFN_PROTO); |
1152 | int sysctl_create(SYSCTLFN_PROTO); | | 1147 | int sysctl_create(SYSCTLFN_PROTO); |
1153 | int sysctl_destroy(SYSCTLFN_PROTO); | | 1148 | int sysctl_destroy(SYSCTLFN_PROTO); |
1154 | int sysctl_lookup(SYSCTLFN_PROTO); | | 1149 | int sysctl_lookup(SYSCTLFN_PROTO); |
1155 | int sysctl_describe(SYSCTLFN_PROTO); | | 1150 | int sysctl_describe(SYSCTLFN_PROTO); |
1156 | | | 1151 | |
1157 | /* | | 1152 | /* |
1158 | * simple variadic interface for adding/removing nodes | | 1153 | * simple variadic interface for adding/removing nodes |
1159 | */ | | 1154 | */ |
1160 | int sysctl_createv(struct sysctllog **, int, | | 1155 | int sysctl_createv(struct sysctllog **, int, |
1161 | const struct sysctlnode **, const struct sysctlnode **, | | 1156 | const struct sysctlnode **, const struct sysctlnode **, |
1162 | int, int, const char *, const char *, | | 1157 | int, int, const char *, const char *, |
1163 | sysctlfn, u_quad_t, void *, size_t, ...); | | 1158 | sysctlfn, u_quad_t, void *, size_t, ...); |
1164 | int sysctl_destroyv(struct sysctlnode *, ...); | | 1159 | int sysctl_destroyv(struct sysctlnode *, ...); |
1165 | | | 1160 | |
1166 | /* | | 1161 | /* |
1167 | * miscellany | | 1162 | * miscellany |
1168 | */ | | 1163 | */ |
1169 | void sysctl_dump(const struct sysctlnode *); | | 1164 | void sysctl_dump(const struct sysctlnode *); |
1170 | void sysctl_free(struct sysctlnode *); | | 1165 | void sysctl_free(struct sysctlnode *); |
1171 | void sysctl_teardown(struct sysctllog **); | | 1166 | void sysctl_teardown(struct sysctllog **); |
1172 | void sysctl_log_print(const struct sysctllog *); | | 1167 | void sysctl_log_print(const struct sysctllog *); |
1173 | | | 1168 | |
1174 | #ifdef SYSCTL_INCLUDE_DESCR | | 1169 | #ifdef SYSCTL_INCLUDE_DESCR |
1175 | #define SYSCTL_DESCR(s) s | | 1170 | #define SYSCTL_DESCR(s) s |
1176 | #else /* SYSCTL_INCLUDE_DESCR */ | | 1171 | #else /* SYSCTL_INCLUDE_DESCR */ |
1177 | #define SYSCTL_DESCR(s) NULL | | 1172 | #define SYSCTL_DESCR(s) NULL |
1178 | #endif /* SYSCTL_INCLUDE_DESCR */ | | 1173 | #endif /* SYSCTL_INCLUDE_DESCR */ |
1179 | | | 1174 | |
1180 | /* | | 1175 | /* |
1181 | * simple interface similar to old interface for in-kernel consumption | | 1176 | * simple interface similar to old interface for in-kernel consumption |
1182 | */ | | 1177 | */ |
1183 | int old_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct lwp *); | | 1178 | int old_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct lwp *); |
1184 | | | 1179 | |
1185 | /* | | 1180 | /* |
1186 | * these helpers are in other files (XXX so should the nodes be) or | | 1181 | * these helpers are in other files (XXX so should the nodes be) or |
1187 | * are used by more than one node | | 1182 | * are used by more than one node |
1188 | */ | | 1183 | */ |
1189 | int sysctl_hw_tapenames(SYSCTLFN_PROTO); | | 1184 | int sysctl_hw_tapenames(SYSCTLFN_PROTO); |
1190 | int sysctl_hw_tapestats(SYSCTLFN_PROTO); | | 1185 | int sysctl_hw_tapestats(SYSCTLFN_PROTO); |
1191 | int sysctl_kern_vnode(SYSCTLFN_PROTO); | | 1186 | int sysctl_kern_vnode(SYSCTLFN_PROTO); |
1192 | int sysctl_net_inet_ip_ports(SYSCTLFN_PROTO); | | 1187 | int sysctl_net_inet_ip_ports(SYSCTLFN_PROTO); |
1193 | int sysctl_consdev(SYSCTLFN_PROTO); | | 1188 | int sysctl_consdev(SYSCTLFN_PROTO); |
1194 | int sysctl_root_device(SYSCTLFN_PROTO); | | 1189 | int sysctl_root_device(SYSCTLFN_PROTO); |
1195 | int sysctl_vfs_generic_fstypes(SYSCTLFN_PROTO); | | 1190 | int sysctl_vfs_generic_fstypes(SYSCTLFN_PROTO); |
1196 | | | 1191 | |
1197 | /* | | 1192 | /* |
1198 | * primitive helper stubs | | 1193 | * primitive helper stubs |
1199 | */ | | 1194 | */ |
1200 | int sysctl_needfunc(SYSCTLFN_PROTO); | | 1195 | int sysctl_needfunc(SYSCTLFN_PROTO); |
1201 | int sysctl_notavail(SYSCTLFN_PROTO); | | 1196 | int sysctl_notavail(SYSCTLFN_PROTO); |
1202 | int sysctl_null(SYSCTLFN_PROTO); | | 1197 | int sysctl_null(SYSCTLFN_PROTO); |
1203 | | | 1198 | |
1204 | int sysctl_copyin(struct lwp *, const void *, void *, size_t); | | 1199 | int sysctl_copyin(struct lwp *, const void *, void *, size_t); |
1205 | int sysctl_copyout(struct lwp *, const void *, void *, size_t); | | 1200 | int sysctl_copyout(struct lwp *, const void *, void *, size_t); |
1206 | int sysctl_copyinstr(struct lwp *, const void *, void *, size_t, size_t *); | | 1201 | int sysctl_copyinstr(struct lwp *, const void *, void *, size_t, size_t *); |
1207 | | | 1202 | |
1208 | u_int sysctl_map_flags(const u_int *, u_int); | | 1203 | u_int sysctl_map_flags(const u_int *, u_int); |
1209 | | | 1204 | |
1210 | MALLOC_DECLARE(M_SYSCTLNODE); | | 1205 | MALLOC_DECLARE(M_SYSCTLNODE); |
1211 | MALLOC_DECLARE(M_SYSCTLDATA); | | 1206 | MALLOC_DECLARE(M_SYSCTLDATA); |
1212 | | | 1207 | |
1213 | extern const u_int sysctl_lwpflagmap[]; | | 1208 | extern const u_int sysctl_lwpflagmap[]; |
1214 | | | 1209 | |
1215 | #else /* !_KERNEL */ | | 1210 | #else /* !_KERNEL */ |
1216 | #include <sys/cdefs.h> | | 1211 | #include <sys/cdefs.h> |
1217 | | | 1212 | |
1218 | typedef void *sysctlfn; | | 1213 | typedef void *sysctlfn; |
1219 | | | 1214 | |
1220 | __BEGIN_DECLS | | 1215 | __BEGIN_DECLS |
1221 | int sysctl(const int *, u_int, void *, size_t *, const void *, size_t); | | 1216 | int sysctl(const int *, u_int, void *, size_t *, const void *, size_t); |
1222 | int sysctlbyname(const char *, void *, size_t *, const void *, size_t); | | 1217 | int sysctlbyname(const char *, void *, size_t *, const void *, size_t); |
1223 | int sysctlgetmibinfo(const char *, int *, u_int *, | | 1218 | int sysctlgetmibinfo(const char *, int *, u_int *, |
1224 | char *, size_t *, struct sysctlnode **, int); | | 1219 | char *, size_t *, struct sysctlnode **, int); |
1225 | int sysctlnametomib(const char *, int *, size_t *); | | 1220 | int sysctlnametomib(const char *, int *, size_t *); |
1226 | __END_DECLS | | 1221 | __END_DECLS |
1227 | | | 1222 | |
1228 | #endif /* !_KERNEL */ | | 1223 | #endif /* !_KERNEL */ |
1229 | | | 1224 | |
1230 | #ifdef __COMPAT_SYSCTL | | 1225 | #ifdef __COMPAT_SYSCTL |
1231 | /* | | 1226 | /* |
1232 | * old node definitions go here | | 1227 | * old node definitions go here |
1233 | */ | | 1228 | */ |
1234 | #endif /* __COMPAT_SYSCTL */ | | 1229 | #endif /* __COMPAT_SYSCTL */ |
1235 | | | 1230 | |
1236 | /* | | 1231 | /* |
1237 | * padding makes alignment magically "work" for 32/64 compatibility at | | 1232 | * padding makes alignment magically "work" for 32/64 compatibility at |
1238 | * the expense of making things bigger on 32 bit platforms. | | 1233 | * the expense of making things bigger on 32 bit platforms. |
1239 | */ | | 1234 | */ |
1240 | #if defined(_LP64) || (BYTE_ORDER == LITTLE_ENDIAN) | | 1235 | #if defined(_LP64) || (BYTE_ORDER == LITTLE_ENDIAN) |
1241 | #define __sysc_pad(type) union { uint64_t __sysc_upad; \ | | 1236 | #define __sysc_pad(type) union { uint64_t __sysc_upad; \ |
1242 | struct { type __sysc_sdatum; } __sysc_ustr; } | | 1237 | struct { type __sysc_sdatum; } __sysc_ustr; } |
1243 | #else | | 1238 | #else |
1244 | #define __sysc_pad(type) union { uint64_t __sysc_upad; \ | | 1239 | #define __sysc_pad(type) union { uint64_t __sysc_upad; \ |
1245 | struct { uint32_t __sysc_spad; type __sysc_sdatum; } __sysc_ustr; } | | 1240 | struct { uint32_t __sysc_spad; type __sysc_sdatum; } __sysc_ustr; } |
1246 | #endif | | 1241 | #endif |
1247 | #define __sysc_unpad(x) x.__sysc_ustr.__sysc_sdatum | | 1242 | #define __sysc_unpad(x) x.__sysc_ustr.__sysc_sdatum |
1248 | | | 1243 | |
1249 | /* | | 1244 | /* |
1250 | * The following is for gcc2, which doesn't handle __sysc_unpad(). | | 1245 | * The following is for gcc2, which doesn't handle __sysc_unpad(). |
1251 | * The code gets a little less ugly this way. | | 1246 | * The code gets a little less ugly this way. |
1252 | */ | | 1247 | */ |
1253 | #define sysc_init_field(field, value) \ | | 1248 | #define sysc_init_field(field, value) \ |
1254 | .field = { .__sysc_ustr = { .__sysc_sdatum = (value), }, } | | 1249 | .field = { .__sysc_ustr = { .__sysc_sdatum = (value), }, } |
1255 | | | 1250 | |
1256 | struct sysctlnode { | | 1251 | struct sysctlnode { |
1257 | uint32_t sysctl_flags; /* flags and type */ | | 1252 | uint32_t sysctl_flags; /* flags and type */ |
1258 | int32_t sysctl_num; /* mib number */ | | 1253 | int32_t sysctl_num; /* mib number */ |
1259 | char sysctl_name[SYSCTL_NAMELEN]; /* node name */ | | 1254 | char sysctl_name[SYSCTL_NAMELEN]; /* node name */ |
1260 | uint32_t sysctl_ver; /* node's version vs. rest of tree */ | | 1255 | uint32_t sysctl_ver; /* node's version vs. rest of tree */ |
1261 | uint32_t __rsvd; | | 1256 | uint32_t __rsvd; |
1262 | union { | | 1257 | union { |
1263 | struct { | | 1258 | struct { |
1264 | uint32_t suc_csize; /* size of child node array */ | | 1259 | uint32_t suc_csize; /* size of child node array */ |
1265 | uint32_t suc_clen; /* number of valid children */ | | 1260 | uint32_t suc_clen; /* number of valid children */ |
1266 | __sysc_pad(struct sysctlnode*) _suc_child; /* array of child nodes */ | | 1261 | __sysc_pad(struct sysctlnode*) _suc_child; /* array of child nodes */ |
1267 | } scu_child; | | 1262 | } scu_child; |
1268 | struct { | | 1263 | struct { |
1269 | __sysc_pad(void*) _sud_data; /* pointer to external data */ | | 1264 | __sysc_pad(void*) _sud_data; /* pointer to external data */ |
1270 | __sysc_pad(size_t) _sud_offset; /* offset to data */ | | 1265 | __sysc_pad(size_t) _sud_offset; /* offset to data */ |
1271 | } scu_data; | | 1266 | } scu_data; |
1272 | int32_t scu_alias; /* node this node refers to */ | | 1267 | int32_t scu_alias; /* node this node refers to */ |
1273 | int32_t scu_idata; /* immediate "int" data */ | | 1268 | int32_t scu_idata; /* immediate "int" data */ |
1274 | u_quad_t scu_qdata; /* immediate "u_quad_t" data */ | | 1269 | u_quad_t scu_qdata; /* immediate "u_quad_t" data */ |
1275 | bool scu_bdata; /* immediate bool data */ | | 1270 | bool scu_bdata; /* immediate bool data */ |
1276 | } sysctl_un; | | 1271 | } sysctl_un; |
1277 | __sysc_pad(size_t) _sysctl_size; /* size of instrumented data */ | | 1272 | __sysc_pad(size_t) _sysctl_size; /* size of instrumented data */ |
1278 | __sysc_pad(sysctlfn) _sysctl_func; /* access helper function */ | | 1273 | __sysc_pad(sysctlfn) _sysctl_func; /* access helper function */ |
1279 | __sysc_pad(struct sysctlnode*) _sysctl_parent; /* parent of this node */ | | 1274 | __sysc_pad(struct sysctlnode*) _sysctl_parent; /* parent of this node */ |
1280 | __sysc_pad(const char *) _sysctl_desc; /* description of node */ | | 1275 | __sysc_pad(const char *) _sysctl_desc; /* description of node */ |
1281 | }; | | 1276 | }; |
1282 | | | 1277 | |
1283 | /* | | 1278 | /* |
1284 | * padded data | | 1279 | * padded data |
1285 | */ | | 1280 | */ |
1286 | #define suc_child __sysc_unpad(_suc_child) | | 1281 | #define suc_child __sysc_unpad(_suc_child) |
1287 | #define sud_data __sysc_unpad(_sud_data) | | 1282 | #define sud_data __sysc_unpad(_sud_data) |
1288 | #define sud_offset __sysc_unpad(_sud_offset) | | 1283 | #define sud_offset __sysc_unpad(_sud_offset) |
1289 | #define sysctl_size __sysc_unpad(_sysctl_size) | | 1284 | #define sysctl_size __sysc_unpad(_sysctl_size) |
1290 | #define sysctl_func __sysc_unpad(_sysctl_func) | | 1285 | #define sysctl_func __sysc_unpad(_sysctl_func) |
1291 | #define sysctl_parent __sysc_unpad(_sysctl_parent) | | 1286 | #define sysctl_parent __sysc_unpad(_sysctl_parent) |
1292 | #define sysctl_desc __sysc_unpad(_sysctl_desc) | | 1287 | #define sysctl_desc __sysc_unpad(_sysctl_desc) |
1293 | | | 1288 | |
1294 | /* | | 1289 | /* |
1295 | * nested data (may also be padded) | | 1290 | * nested data (may also be padded) |
1296 | */ | | 1291 | */ |
1297 | #define sysctl_csize sysctl_un.scu_child.suc_csize | | 1292 | #define sysctl_csize sysctl_un.scu_child.suc_csize |
1298 | #define sysctl_clen sysctl_un.scu_child.suc_clen | | 1293 | #define sysctl_clen sysctl_un.scu_child.suc_clen |
1299 | #define sysctl_child sysctl_un.scu_child.suc_child | | 1294 | #define sysctl_child sysctl_un.scu_child.suc_child |
1300 | #define sysctl_data sysctl_un.scu_data.sud_data | | 1295 | #define sysctl_data sysctl_un.scu_data.sud_data |
1301 | #define sysctl_offset sysctl_un.scu_data.sud_offset | | 1296 | #define sysctl_offset sysctl_un.scu_data.sud_offset |
1302 | #define sysctl_alias sysctl_un.scu_alias | | 1297 | #define sysctl_alias sysctl_un.scu_alias |
1303 | #define sysctl_idata sysctl_un.scu_idata | | 1298 | #define sysctl_idata sysctl_un.scu_idata |
1304 | #define sysctl_qdata sysctl_un.scu_qdata | | 1299 | #define sysctl_qdata sysctl_un.scu_qdata |
1305 | #define sysctl_bdata sysctl_un.scu_bdata | | 1300 | #define sysctl_bdata sysctl_un.scu_bdata |
1306 | | | 1301 | |
1307 | /* | | 1302 | /* |
1308 | * when requesting a description of a node (a set of nodes, actually), | | 1303 | * when requesting a description of a node (a set of nodes, actually), |
1309 | * you get back an "array" of these, where the actual length of the | | 1304 | * you get back an "array" of these, where the actual length of the |
1310 | * descr_str is noted in descr_len (which includes the trailing nul | | 1305 | * descr_str is noted in descr_len (which includes the trailing nul |
1311 | * byte), rounded up to the nearest four (sizeof(int32_t) actually). | | 1306 | * byte), rounded up to the nearest four (sizeof(int32_t) actually). |
1312 | * | | 1307 | * |
1313 | * NEXT_DESCR() will take a pointer to a description and advance it to | | 1308 | * NEXT_DESCR() will take a pointer to a description and advance it to |
1314 | * the next description. | | 1309 | * the next description. |
1315 | */ | | 1310 | */ |
1316 | struct sysctldesc { | | 1311 | struct sysctldesc { |
1317 | int32_t descr_num; /* mib number of node */ | | 1312 | int32_t descr_num; /* mib number of node */ |
1318 | uint32_t descr_ver; /* version of node */ | | 1313 | uint32_t descr_ver; /* version of node */ |
1319 | uint32_t descr_len; /* length of description string */ | | 1314 | uint32_t descr_len; /* length of description string */ |
1320 | char descr_str[1]; /* not really 1...see above */ | | 1315 | char descr_str[1]; /* not really 1...see above */ |
1321 | }; | | 1316 | }; |
1322 | | | 1317 | |
1323 | #define __sysc_desc_roundup(x) ((((x) - 1) | (sizeof(int32_t) - 1)) + 1) | | 1318 | #define __sysc_desc_roundup(x) ((((x) - 1) | (sizeof(int32_t) - 1)) + 1) |
1324 | #define __sysc_desc_adv(d, l) \ | | 1319 | #define __sysc_desc_adv(d, l) \ |
1325 | (/*XXXUNCONST ptr cast*/(struct sysctldesc *) \ | | 1320 | (/*XXXUNCONST ptr cast*/(struct sysctldesc *) \ |
1326 | __UNCONST(((const char*)(d)) + offsetof(struct sysctldesc, descr_str) +\ | | 1321 | __UNCONST(((const char*)(d)) + offsetof(struct sysctldesc, descr_str) +\ |
1327 | __sysc_desc_roundup(l))) | | 1322 | __sysc_desc_roundup(l))) |
1328 | #define NEXT_DESCR(d) __sysc_desc_adv((d), (d)->descr_len) | | 1323 | #define NEXT_DESCR(d) __sysc_desc_adv((d), (d)->descr_len) |
1329 | | | 1324 | |
1330 | static __inline const struct sysctlnode * | | 1325 | static __inline const struct sysctlnode * |
1331 | sysctl_rootof(const struct sysctlnode *n) | | 1326 | sysctl_rootof(const struct sysctlnode *n) |
1332 | { | | 1327 | { |
1333 | while (n->sysctl_parent != NULL) | | 1328 | while (n->sysctl_parent != NULL) |
1334 | n = n->sysctl_parent; | | 1329 | n = n->sysctl_parent; |
1335 | return (n); | | 1330 | return (n); |
1336 | } | | 1331 | } |
1337 | | | 1332 | |
1338 | #endif /* !_SYS_SYSCTL_H_ */ | | 1333 | #endif /* !_SYS_SYSCTL_H_ */ |