sysctl.h 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994
  1. /* $OpenBSD: sysctl.h,v 1.156 2015/07/18 15:51:17 mpi Exp $ */
  2. /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */
  3. /*
  4. * Copyright (c) 1989, 1993
  5. * The Regents of the University of California. All rights reserved.
  6. *
  7. * This code is derived from software contributed to Berkeley by
  8. * Mike Karels at Berkeley Software Design, Inc.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. * 3. 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
  20. * without specific prior written permission.
  21. *
  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
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  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
  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
  32. * SUCH DAMAGE.
  33. *
  34. * @(#)sysctl.h 8.2 (Berkeley) 3/30/95
  35. */
  36. #ifndef _SYS_SYSCTL_H_
  37. #define _SYS_SYSCTL_H_
  38. #include <uvm/uvmexp.h>
  39. /*
  40. * Definitions for sysctl call. The sysctl call uses a hierarchical name
  41. * for objects that can be examined or modified. The name is expressed as
  42. * a sequence of integers. Like a file path name, the meaning of each
  43. * component depends on its place in the hierarchy. The top-level and kern
  44. * identifiers are defined here, and other identifiers are defined in the
  45. * respective subsystem header files.
  46. */
  47. #define CTL_MAXNAME 12 /* largest number of components supported */
  48. /*
  49. * Each subsystem defined by sysctl defines a list of variables
  50. * for that subsystem. Each name is either a node with further
  51. * levels defined below it, or it is a leaf of some particular
  52. * type given below. Each sysctl level defines a set of name/type
  53. * pairs to be used by sysctl(1) in manipulating the subsystem.
  54. */
  55. struct ctlname {
  56. char *ctl_name; /* subsystem name */
  57. int ctl_type; /* type of name */
  58. };
  59. #define CTLTYPE_NODE 1 /* name is a node */
  60. #define CTLTYPE_INT 2 /* name describes an integer */
  61. #define CTLTYPE_STRING 3 /* name describes a string */
  62. #define CTLTYPE_QUAD 4 /* name describes a 64-bit number */
  63. #define CTLTYPE_STRUCT 5 /* name describes a structure */
  64. /*
  65. * Top-level identifiers
  66. */
  67. #define CTL_UNSPEC 0 /* unused */
  68. #define CTL_KERN 1 /* "high kernel": proc, limits */
  69. #define CTL_VM 2 /* virtual memory */
  70. #define CTL_FS 3 /* file system, mount type is next */
  71. #define CTL_NET 4 /* network, see socket.h */
  72. #define CTL_DEBUG 5 /* debugging parameters */
  73. #define CTL_HW 6 /* generic cpu/io */
  74. #define CTL_MACHDEP 7 /* machine dependent */
  75. /*define gap 8 was CTL_USER: removed 2013-04 */
  76. #define CTL_DDB 9 /* DDB user interface, see db_var.h */
  77. #define CTL_VFS 10 /* VFS sysctl's */
  78. #define CTL_MAXID 11 /* number of valid top-level ids */
  79. #define CTL_NAMES { \
  80. { 0, 0 }, \
  81. { "kern", CTLTYPE_NODE }, \
  82. { "vm", CTLTYPE_NODE }, \
  83. { "fs", CTLTYPE_NODE }, \
  84. { "net", CTLTYPE_NODE }, \
  85. { "debug", CTLTYPE_NODE }, \
  86. { "hw", CTLTYPE_NODE }, \
  87. { "machdep", CTLTYPE_NODE }, \
  88. { "gap", 0 }, \
  89. { "ddb", CTLTYPE_NODE }, \
  90. { "vfs", CTLTYPE_NODE }, \
  91. }
  92. /*
  93. * CTL_KERN identifiers
  94. */
  95. #define KERN_OSTYPE 1 /* string: system version */
  96. #define KERN_OSRELEASE 2 /* string: system release */
  97. #define KERN_OSREV 3 /* int: system revision */
  98. #define KERN_VERSION 4 /* string: compile time info */
  99. #define KERN_MAXVNODES 5 /* int: max vnodes */
  100. #define KERN_MAXPROC 6 /* int: max processes */
  101. #define KERN_MAXFILES 7 /* int: max open files */
  102. #define KERN_ARGMAX 8 /* int: max arguments to exec */
  103. #define KERN_SECURELVL 9 /* int: system security level */
  104. #define KERN_HOSTNAME 10 /* string: hostname */
  105. #define KERN_HOSTID 11 /* int: host identifier */
  106. #define KERN_CLOCKRATE 12 /* struct: struct clockinfo */
  107. /* was KERN_VNODE 13 */
  108. /* was KERN_PROC 14 */
  109. /* was KERN_FILE 15 */
  110. #define KERN_PROF 16 /* node: kernel profiling info */
  111. #define KERN_POSIX1 17 /* int: POSIX.1 version */
  112. #define KERN_NGROUPS 18 /* int: # of supplemental group ids */
  113. #define KERN_JOB_CONTROL 19 /* int: is job control available */
  114. #define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */
  115. #define KERN_BOOTTIME 21 /* struct: time kernel was booted */
  116. #define KERN_DOMAINNAME 22 /* string: (YP) domainname */
  117. #define KERN_MAXPARTITIONS 23 /* int: number of partitions/disk */
  118. #define KERN_RAWPARTITION 24 /* int: raw partition number */
  119. #define KERN_MAXTHREAD 25 /* int: max threads */
  120. #define KERN_NTHREADS 26 /* int: number of threads */
  121. #define KERN_OSVERSION 27 /* string: kernel build version */
  122. #define KERN_SOMAXCONN 28 /* int: listen queue maximum */
  123. #define KERN_SOMINCONN 29 /* int: half-open controllable param */
  124. #define KERN_USERMOUNT 30 /* int: users may mount filesystems */
  125. #define KERN_RND 31 /* struct: rnd(4) statistics */
  126. #define KERN_NOSUIDCOREDUMP 32 /* int: no setuid coredumps ever */
  127. #define KERN_FSYNC 33 /* int: file synchronization support */
  128. #define KERN_SYSVMSG 34 /* int: SysV message queue suppoprt */
  129. #define KERN_SYSVSEM 35 /* int: SysV semaphore support */
  130. #define KERN_SYSVSHM 36 /* int: SysV shared memory support */
  131. #define KERN_ARND 37 /* int: random integer from arc4rnd */
  132. #define KERN_MSGBUFSIZE 38 /* int: size of message buffer */
  133. #define KERN_MALLOCSTATS 39 /* node: malloc statistics */
  134. #define KERN_CPTIME 40 /* array: cp_time */
  135. #define KERN_NCHSTATS 41 /* struct: vfs cache statistics */
  136. #define KERN_FORKSTAT 42 /* struct: fork statistics */
  137. #define KERN_NSELCOLL 43 /* int: select(2) collisions */
  138. #define KERN_TTY 44 /* node: tty information */
  139. #define KERN_CCPU 45 /* int: ccpu */
  140. #define KERN_FSCALE 46 /* int: fscale */
  141. #define KERN_NPROCS 47 /* int: number of processes */
  142. #define KERN_MSGBUF 48 /* message buffer, KERN_MSGBUFSIZE */
  143. #define KERN_POOL 49 /* struct: pool information */
  144. #define KERN_STACKGAPRANDOM 50 /* int: stackgap_random */
  145. #define KERN_SYSVIPC_INFO 51 /* struct: SysV sem/shm/msg info */
  146. /* was KERN_USERCRYPTO 52 */
  147. /* was KERN_CRYPTODEVALLOWSOFT 53 */
  148. #define KERN_SPLASSERT 54 /* int: splassert */
  149. #define KERN_PROC_ARGS 55 /* node: proc args and env */
  150. #define KERN_NFILES 56 /* int: number of open files */
  151. #define KERN_TTYCOUNT 57 /* int: number of tty devices */
  152. #define KERN_NUMVNODES 58 /* int: number of vnodes in use */
  153. #define KERN_MBSTAT 59 /* struct: mbuf statistics */
  154. /* was KERN_USERASYMCRYPTO 60 */
  155. #define KERN_SEMINFO 61 /* struct: SysV struct seminfo */
  156. #define KERN_SHMINFO 62 /* struct: SysV struct shminfo */
  157. #define KERN_INTRCNT 63 /* node: interrupt counters */
  158. #define KERN_WATCHDOG 64 /* node: watchdog */
  159. #define KERN_EMUL 65 /* node: emuls */
  160. #define KERN_PROC 66 /* struct: process entries */
  161. #define KERN_MAXCLUSTERS 67 /* number of mclusters */
  162. #define KERN_EVCOUNT 68 /* node: event counters */
  163. #define KERN_TIMECOUNTER 69 /* node: timecounter */
  164. #define KERN_MAXLOCKSPERUID 70 /* int: locks per uid */
  165. #define KERN_CPTIME2 71 /* array: cp_time2 */
  166. #define KERN_CACHEPCT 72 /* buffer cache % of physmem */
  167. #define KERN_FILE 73 /* struct: file entries */
  168. /* was KERN_RTHREADS 74 */
  169. #define KERN_CONSDEV 75 /* dev_t: console terminal device */
  170. #define KERN_NETLIVELOCKS 76 /* int: number of network livelocks */
  171. #define KERN_POOL_DEBUG 77 /* int: enable pool_debug */
  172. #define KERN_PROC_CWD 78 /* node: proc cwd */
  173. #define KERN_PROC_NOBROADCASTKILL 79 /* node: proc no broadcast kill */
  174. #define KERN_PROC_VMMAP 80 /* node: proc vmmap */
  175. #define KERN_GLOBAL_PTRACE 81 /* allow ptrace globally */
  176. #define KERN_CONSBUFSIZE 82 /* int: console message buffer size */
  177. #define KERN_CONSBUF 83 /* console message buffer */
  178. #define KERN_MAXID 84 /* number of valid kern ids */
  179. #define CTL_KERN_NAMES { \
  180. { 0, 0 }, \
  181. { "ostype", CTLTYPE_STRING }, \
  182. { "osrelease", CTLTYPE_STRING }, \
  183. { "osrevision", CTLTYPE_INT }, \
  184. { "version", CTLTYPE_STRING }, \
  185. { "maxvnodes", CTLTYPE_INT }, \
  186. { "maxproc", CTLTYPE_INT }, \
  187. { "maxfiles", CTLTYPE_INT }, \
  188. { "argmax", CTLTYPE_INT }, \
  189. { "securelevel", CTLTYPE_INT }, \
  190. { "hostname", CTLTYPE_STRING }, \
  191. { "hostid", CTLTYPE_INT }, \
  192. { "clockrate", CTLTYPE_STRUCT }, \
  193. { "gap", 0 }, \
  194. { "gap", 0 }, \
  195. { "gap", 0 }, \
  196. { "profiling", CTLTYPE_NODE }, \
  197. { "posix1version", CTLTYPE_INT }, \
  198. { "ngroups", CTLTYPE_INT }, \
  199. { "job_control", CTLTYPE_INT }, \
  200. { "saved_ids", CTLTYPE_INT }, \
  201. { "boottime", CTLTYPE_STRUCT }, \
  202. { "domainname", CTLTYPE_STRING }, \
  203. { "maxpartitions", CTLTYPE_INT }, \
  204. { "rawpartition", CTLTYPE_INT }, \
  205. { "maxthread", CTLTYPE_INT }, \
  206. { "nthreads", CTLTYPE_INT }, \
  207. { "osversion", CTLTYPE_STRING }, \
  208. { "somaxconn", CTLTYPE_INT }, \
  209. { "sominconn", CTLTYPE_INT }, \
  210. { "usermount", CTLTYPE_INT }, \
  211. { "random", CTLTYPE_STRUCT }, \
  212. { "nosuidcoredump", CTLTYPE_INT }, \
  213. { "fsync", CTLTYPE_INT }, \
  214. { "sysvmsg", CTLTYPE_INT }, \
  215. { "sysvsem", CTLTYPE_INT }, \
  216. { "sysvshm", CTLTYPE_INT }, \
  217. { "arandom", CTLTYPE_INT }, \
  218. { "msgbufsize", CTLTYPE_INT }, \
  219. { "malloc", CTLTYPE_NODE }, \
  220. { "cp_time", CTLTYPE_STRUCT }, \
  221. { "nchstats", CTLTYPE_STRUCT }, \
  222. { "forkstat", CTLTYPE_STRUCT }, \
  223. { "nselcoll", CTLTYPE_INT }, \
  224. { "tty", CTLTYPE_NODE }, \
  225. { "ccpu", CTLTYPE_INT }, \
  226. { "fscale", CTLTYPE_INT }, \
  227. { "nprocs", CTLTYPE_INT }, \
  228. { "msgbuf", CTLTYPE_STRUCT }, \
  229. { "pool", CTLTYPE_NODE }, \
  230. { "stackgap_random", CTLTYPE_INT }, \
  231. { "sysvipc_info", CTLTYPE_INT }, \
  232. { "gap", 0 }, \
  233. { "gap", 0 }, \
  234. { "splassert", CTLTYPE_INT }, \
  235. { "procargs", CTLTYPE_NODE }, \
  236. { "nfiles", CTLTYPE_INT }, \
  237. { "ttycount", CTLTYPE_INT }, \
  238. { "numvnodes", CTLTYPE_INT }, \
  239. { "mbstat", CTLTYPE_STRUCT }, \
  240. { "gap", 0 }, \
  241. { "seminfo", CTLTYPE_STRUCT }, \
  242. { "shminfo", CTLTYPE_STRUCT }, \
  243. { "intrcnt", CTLTYPE_NODE }, \
  244. { "watchdog", CTLTYPE_NODE }, \
  245. { "emul", CTLTYPE_NODE }, \
  246. { "proc", CTLTYPE_STRUCT }, \
  247. { "maxclusters", CTLTYPE_INT }, \
  248. { "evcount", CTLTYPE_NODE }, \
  249. { "timecounter", CTLTYPE_NODE }, \
  250. { "maxlocksperuid", CTLTYPE_INT }, \
  251. { "cp_time2", CTLTYPE_STRUCT }, \
  252. { "bufcachepercent", CTLTYPE_INT }, \
  253. { "file", CTLTYPE_STRUCT }, \
  254. { "gap", 0 }, \
  255. { "consdev", CTLTYPE_STRUCT }, \
  256. { "netlivelocks", CTLTYPE_INT }, \
  257. { "pool_debug", CTLTYPE_INT }, \
  258. { "proc_cwd", CTLTYPE_NODE }, \
  259. { "proc_nobroadcastkill", CTLTYPE_NODE }, \
  260. { "proc_vmmap", CTLTYPE_NODE }, \
  261. { "global_ptrace", CTLTYPE_INT }, \
  262. }
  263. /*
  264. * KERN_EMUL subtypes.
  265. */
  266. #define KERN_EMUL_NUM 0
  267. /* Fourth level sysctl names */
  268. #define KERN_EMUL_NAME 0
  269. #define KERN_EMUL_ENABLED 1
  270. /*
  271. * KERN_PROC subtypes
  272. */
  273. #define KERN_PROC_ALL 0 /* everything but kernel threads */
  274. #define KERN_PROC_PID 1 /* by process id */
  275. #define KERN_PROC_PGRP 2 /* by process group id */
  276. #define KERN_PROC_SESSION 3 /* by session of pid */
  277. #define KERN_PROC_TTY 4 /* by controlling tty */
  278. #define KERN_PROC_UID 5 /* by effective uid */
  279. #define KERN_PROC_RUID 6 /* by real uid */
  280. #define KERN_PROC_KTHREAD 7 /* also return kernel threads */
  281. #define KERN_PROC_SHOW_THREADS 0x40000000/* also return normal threads */
  282. /*
  283. * KERN_SYSVIPC_INFO subtypes
  284. */
  285. #define KERN_SYSVIPC_MSG_INFO 1 /* msginfo and msqid_ds */
  286. #define KERN_SYSVIPC_SEM_INFO 2 /* seminfo and semid_ds */
  287. #define KERN_SYSVIPC_SHM_INFO 3 /* shminfo and shmid_ds */
  288. /*
  289. * KERN_PROC_ARGS subtypes
  290. */
  291. #define KERN_PROC_ARGV 1
  292. #define KERN_PROC_NARGV 2
  293. #define KERN_PROC_ENV 3
  294. #define KERN_PROC_NENV 4
  295. /*
  296. * KERN_PROC subtype ops return arrays of relatively fixed size
  297. * structures of process info. Use 8 byte alignment, and new
  298. * elements should only be added to the end of this structure so
  299. * binary compatibility can be preserved.
  300. */
  301. #define KI_NGROUPS 16
  302. #define KI_MAXCOMLEN 24 /* extra for 8 byte alignment */
  303. #define KI_WMESGLEN 8
  304. #define KI_MAXLOGNAME 32
  305. #define KI_EMULNAMELEN 8
  306. #define KI_NOCPU (~(u_int64_t)0)
  307. struct kinfo_proc {
  308. u_int64_t p_forw; /* PTR: linked run/sleep queue. */
  309. u_int64_t p_back;
  310. u_int64_t p_paddr; /* PTR: address of proc */
  311. u_int64_t p_addr; /* PTR: Kernel virtual addr of u-area */
  312. u_int64_t p_fd; /* PTR: Ptr to open files structure. */
  313. u_int64_t p_stats; /* unused, always zero. */
  314. u_int64_t p_limit; /* PTR: Process limits. */
  315. u_int64_t p_vmspace; /* PTR: Address space. */
  316. u_int64_t p_sigacts; /* PTR: Signal actions, state */
  317. u_int64_t p_sess; /* PTR: session pointer */
  318. u_int64_t p_tsess; /* PTR: tty session pointer */
  319. u_int64_t p_ru; /* PTR: Exit information. XXX */
  320. int32_t p_eflag; /* LONG: extra kinfo_proc flags */
  321. #define EPROC_CTTY 0x01 /* controlling tty vnode active */
  322. #define EPROC_SLEADER 0x02 /* session leader */
  323. int32_t p_exitsig; /* unused, always zero. */
  324. int32_t p_flag; /* INT: P_* flags. */
  325. int32_t p_pid; /* PID_T: Process identifier. */
  326. int32_t p_ppid; /* PID_T: Parent process id */
  327. int32_t p_sid; /* PID_T: session id */
  328. int32_t p__pgid; /* PID_T: process group id */
  329. /* XXX: <sys/proc.h> hijacks p_pgid */
  330. int32_t p_tpgid; /* PID_T: tty process group id */
  331. u_int32_t p_uid; /* UID_T: effective user id */
  332. u_int32_t p_ruid; /* UID_T: real user id */
  333. u_int32_t p_gid; /* GID_T: effective group id */
  334. u_int32_t p_rgid; /* GID_T: real group id */
  335. u_int32_t p_groups[KI_NGROUPS]; /* GID_T: groups */
  336. int16_t p_ngroups; /* SHORT: number of groups */
  337. int16_t p_jobc; /* SHORT: job control counter */
  338. u_int32_t p_tdev; /* DEV_T: controlling tty dev */
  339. u_int32_t p_estcpu; /* U_INT: Time averaged value of p_cpticks. */
  340. u_int32_t p_rtime_sec; /* STRUCT TIMEVAL: Real time. */
  341. u_int32_t p_rtime_usec; /* STRUCT TIMEVAL: Real time. */
  342. int32_t p_cpticks; /* INT: Ticks of cpu time. */
  343. u_int32_t p_pctcpu; /* FIXPT_T: %cpu for this process */
  344. u_int32_t p_swtime; /* unused, always zero */
  345. u_int32_t p_slptime; /* U_INT: Time since last blocked. */
  346. int32_t p_schedflags; /* INT: PSCHED_* flags */
  347. u_int64_t p_uticks; /* U_QUAD_T: Statclock hits in user mode. */
  348. u_int64_t p_sticks; /* U_QUAD_T: Statclock hits in system mode. */
  349. u_int64_t p_iticks; /* U_QUAD_T: Statclock hits processing intr. */
  350. u_int64_t p_tracep; /* PTR: Trace to vnode or file */
  351. int32_t p_traceflag; /* INT: Kernel trace points. */
  352. int32_t p_holdcnt; /* INT: If non-zero, don't swap. */
  353. int32_t p_siglist; /* INT: Signals arrived but not delivered. */
  354. u_int32_t p_sigmask; /* SIGSET_T: Current signal mask. */
  355. u_int32_t p_sigignore; /* SIGSET_T: Signals being ignored. */
  356. u_int32_t p_sigcatch; /* SIGSET_T: Signals being caught by user. */
  357. int8_t p_stat; /* CHAR: S* process status (from LWP). */
  358. u_int8_t p_priority; /* U_CHAR: Process priority. */
  359. u_int8_t p_usrpri; /* U_CHAR: User-priority based on p_cpu and ps_nice. */
  360. u_int8_t p_nice; /* U_CHAR: Process "nice" value. */
  361. u_int16_t p_xstat; /* U_SHORT: Exit status for wait; also stop signal. */
  362. u_int16_t p_acflag; /* U_SHORT: Accounting flags. */
  363. char p_comm[KI_MAXCOMLEN];
  364. char p_wmesg[KI_WMESGLEN]; /* wchan message */
  365. u_int64_t p_wchan; /* PTR: sleep address. */
  366. char p_login[KI_MAXLOGNAME]; /* setlogin() name */
  367. int32_t p_vm_rssize; /* SEGSZ_T: current resident set size in pages */
  368. int32_t p_vm_tsize; /* SEGSZ_T: text size (pages) */
  369. int32_t p_vm_dsize; /* SEGSZ_T: data size (pages) */
  370. int32_t p_vm_ssize; /* SEGSZ_T: stack size (pages) */
  371. int64_t p_uvalid; /* CHAR: following p_u* members from struct user are valid */
  372. /* XXX 64 bits for alignment */
  373. u_int64_t p_ustart_sec; /* STRUCT TIMEVAL: starting time. */
  374. u_int32_t p_ustart_usec; /* STRUCT TIMEVAL: starting time. */
  375. u_int32_t p_uutime_sec; /* STRUCT TIMEVAL: user time. */
  376. u_int32_t p_uutime_usec; /* STRUCT TIMEVAL: user time. */
  377. u_int32_t p_ustime_sec; /* STRUCT TIMEVAL: system time. */
  378. u_int32_t p_ustime_usec; /* STRUCT TIMEVAL: system time. */
  379. u_int64_t p_uru_maxrss; /* LONG: max resident set size. */
  380. u_int64_t p_uru_ixrss; /* LONG: integral shared memory size. */
  381. u_int64_t p_uru_idrss; /* LONG: integral unshared data ". */
  382. u_int64_t p_uru_isrss; /* LONG: integral unshared stack ". */
  383. u_int64_t p_uru_minflt; /* LONG: page reclaims. */
  384. u_int64_t p_uru_majflt; /* LONG: page faults. */
  385. u_int64_t p_uru_nswap; /* LONG: swaps. */
  386. u_int64_t p_uru_inblock; /* LONG: block input operations. */
  387. u_int64_t p_uru_oublock; /* LONG: block output operations. */
  388. u_int64_t p_uru_msgsnd; /* LONG: messages sent. */
  389. u_int64_t p_uru_msgrcv; /* LONG: messages received. */
  390. u_int64_t p_uru_nsignals; /* LONG: signals received. */
  391. u_int64_t p_uru_nvcsw; /* LONG: voluntary context switches. */
  392. u_int64_t p_uru_nivcsw; /* LONG: involuntary ". */
  393. u_int32_t p_uctime_sec; /* STRUCT TIMEVAL: child u+s time. */
  394. u_int32_t p_uctime_usec; /* STRUCT TIMEVAL: child u+s time. */
  395. int32_t p_psflags; /* INT: PS_* flags on the process. */
  396. int32_t p_spare; /* INT: unused. */
  397. u_int32_t p_svuid; /* UID_T: saved user id */
  398. u_int32_t p_svgid; /* GID_T: saved group id */
  399. char p_emul[KI_EMULNAMELEN]; /* syscall emulation name */
  400. u_int64_t p_rlim_rss_cur; /* RLIM_T: soft limit for rss */
  401. u_int64_t p_cpuid; /* LONG: CPU id */
  402. u_int64_t p_vm_map_size; /* VSIZE_T: virtual size */
  403. int32_t p_tid; /* PID_T: Thread identifier. */
  404. u_int32_t p_rtableid; /* U_INT: Routing table identifier. */
  405. };
  406. /*
  407. * VM address range entry, matching struct vm_map_entry. Useful for
  408. * debuggers to know process's addresses.
  409. *
  410. * To iterate entries, set the last kve_end as the base address into
  411. * kve_start.
  412. */
  413. struct kinfo_vmentry {
  414. u_long kve_start; /* vaddr_t */
  415. u_long kve_end; /* vaddr_t */
  416. u_long kve_guard; /* vsize_t */
  417. u_long kve_fspace; /* vsize_t */
  418. u_long kve_fspace_augment; /* vsize_t */
  419. u_int64_t kve_offset; /* voff_t */
  420. int kve_wired_count;
  421. int kve_etype;
  422. int kve_protection;
  423. int kve_max_protection;
  424. int kve_advice;
  425. int kve_inheritance;
  426. u_int8_t kve_flags; /* u_int8_t */
  427. };
  428. #define KVE_ET_OBJ 0x00000001
  429. #define KVE_ET_SUBMAP 0x00000002
  430. #define KVE_ET_COPYONWRITE 0x00000004
  431. #define KVE_ET_NEEDSCOPY 0x00000008
  432. #define KVE_ET_HOLE 0x00000010
  433. #define KVE_ET_NOFAULT 0x00000020
  434. #define KVE_ET_FREEMAPPED 0x00000080
  435. #define KVE_PROT_NONE 0x00000000
  436. #define KVE_PROT_READ 0x00000001
  437. #define KVE_PROT_WRITE 0x00000002
  438. #define KVE_PROT_EXEC 0x00000004
  439. #define KVE_ADV_NORMAL 0x00000000
  440. #define KVE_ADV_RANDOM 0x00000001
  441. #define KVE_ADV_SEQUENTIAL 0x00000002
  442. #define KVE_INH_SHARE 0x00000000
  443. #define KVE_INH_COPY 0x00000010
  444. #define KVE_INH_NONE 0x00000020
  445. #define KVE_INH_ZERO 0x00000030
  446. #define KVE_F_STATIC 0x01
  447. #define KVE_F_KMEM 0x02
  448. #if defined(_KERNEL) || defined(_LIBKVM)
  449. /*
  450. * Macros for filling in the bulk of a kinfo_proc structure, used
  451. * in the kernel to implement the KERN_PROC sysctl and in userland
  452. * in libkvm to implement reading from kernel crashes. The macro
  453. * arguments are all pointers; by name they are:
  454. * kp - target kinfo_proc structure
  455. * copy_str - a function or macro invoked as copy_str(dst,src,maxlen)
  456. * that has strlcpy or memcpy semantics; the destination is
  457. * pre-filled with zeros; for libkvm, src is a kvm address
  458. * p - source struct proc
  459. * pr - source struct process
  460. * uc - source struct ucreds
  461. * pg - source struct pgrp
  462. * paddr - kernel address of the source struct proc
  463. * sess - source struct session
  464. * vm - source struct vmspace
  465. * lim - source struct plimits
  466. * sa - source struct sigacts
  467. * There are some members that are not handled by these macros
  468. * because they're too painful to generalize: p_pid, p_ppid, p_sid, p_tdev,
  469. * p_tpgid, p_tsess, p_vm_rssize, p_u[us]time_{sec,usec}, p_cpuid
  470. */
  471. #define PTRTOINT64(_x) ((u_int64_t)(u_long)(_x))
  472. #define FILL_KPROC(kp, copy_str, p, pr, uc, pg, paddr, \
  473. praddr, sess, vm, lim, sa, isthread, show_addresses) \
  474. do { \
  475. memset((kp), 0, sizeof(*(kp))); \
  476. \
  477. if (show_addresses) { \
  478. (kp)->p_paddr = PTRTOINT64(paddr); \
  479. (kp)->p_fd = PTRTOINT64((pr)->ps_fd); \
  480. (kp)->p_limit = PTRTOINT64((pr)->ps_limit); \
  481. (kp)->p_vmspace = PTRTOINT64((pr)->ps_vmspace); \
  482. (kp)->p_sigacts = PTRTOINT64((pr)->ps_sigacts); \
  483. (kp)->p_sess = PTRTOINT64((pg)->pg_session); \
  484. (kp)->p_ru = PTRTOINT64((pr)->ps_ru); \
  485. } \
  486. (kp)->p_stats = 0; \
  487. (kp)->p_exitsig = 0; \
  488. (kp)->p_flag = (p)->p_flag; \
  489. (kp)->p_psflags = (pr)->ps_flags; \
  490. \
  491. (kp)->p__pgid = (pg)->pg_id; \
  492. \
  493. (kp)->p_uid = (uc)->cr_uid; \
  494. (kp)->p_ruid = (uc)->cr_ruid; \
  495. (kp)->p_gid = (uc)->cr_gid; \
  496. (kp)->p_rgid = (uc)->cr_rgid; \
  497. (kp)->p_svuid = (uc)->cr_svuid; \
  498. (kp)->p_svgid = (uc)->cr_svgid; \
  499. \
  500. memcpy((kp)->p_groups, (uc)->cr_groups, \
  501. MIN(sizeof((kp)->p_groups), sizeof((uc)->cr_groups))); \
  502. (kp)->p_ngroups = (uc)->cr_ngroups; \
  503. \
  504. (kp)->p_jobc = (pg)->pg_jobc; \
  505. \
  506. (kp)->p_estcpu = (p)->p_estcpu; \
  507. if (isthread) { \
  508. (kp)->p_rtime_sec = (p)->p_tu.tu_runtime.tv_sec; \
  509. (kp)->p_rtime_usec = (p)->p_tu.tu_runtime.tv_nsec/1000; \
  510. (kp)->p_tid = (p)->p_pid + THREAD_PID_OFFSET; \
  511. (kp)->p_uticks = (p)->p_tu.tu_uticks; \
  512. (kp)->p_sticks = (p)->p_tu.tu_sticks; \
  513. (kp)->p_iticks = (p)->p_tu.tu_iticks; \
  514. } else { \
  515. (kp)->p_rtime_sec = (pr)->ps_tu.tu_runtime.tv_sec; \
  516. (kp)->p_rtime_usec = (pr)->ps_tu.tu_runtime.tv_nsec/1000; \
  517. (kp)->p_tid = -1; \
  518. (kp)->p_uticks = (pr)->ps_tu.tu_uticks; \
  519. (kp)->p_sticks = (pr)->ps_tu.tu_sticks; \
  520. (kp)->p_iticks = (pr)->ps_tu.tu_iticks; \
  521. } \
  522. (kp)->p_cpticks = (p)->p_cpticks; \
  523. \
  524. if (show_addresses) \
  525. (kp)->p_tracep = PTRTOINT64((pr)->ps_tracevp); \
  526. (kp)->p_traceflag = (pr)->ps_traceflag; \
  527. \
  528. (kp)->p_siglist = (p)->p_siglist; \
  529. (kp)->p_sigmask = (p)->p_sigmask; \
  530. (kp)->p_sigignore = (sa) ? (sa)->ps_sigignore : 0; \
  531. (kp)->p_sigcatch = (sa) ? (sa)->ps_sigcatch : 0; \
  532. \
  533. (kp)->p_stat = (p)->p_stat; \
  534. (kp)->p_nice = (pr)->ps_nice; \
  535. \
  536. (kp)->p_xstat = (p)->p_xstat; \
  537. (kp)->p_acflag = (pr)->ps_acflag; \
  538. \
  539. /* XXX depends on e_name being an array and not a pointer */ \
  540. copy_str((kp)->p_emul, (char *)(pr)->ps_emul + \
  541. offsetof(struct emul, e_name), sizeof((kp)->p_emul)); \
  542. strlcpy((kp)->p_comm, (p)->p_comm, sizeof((kp)->p_comm)); \
  543. strlcpy((kp)->p_login, (sess)->s_login, \
  544. MIN(sizeof((kp)->p_login), sizeof((sess)->s_login))); \
  545. \
  546. if ((sess)->s_ttyvp) \
  547. (kp)->p_eflag |= EPROC_CTTY; \
  548. if ((sess)->s_leader == (praddr)) \
  549. (kp)->p_eflag |= EPROC_SLEADER; \
  550. \
  551. if (((pr)->ps_flags & (PS_EMBRYO | PS_ZOMBIE)) == 0) { \
  552. if ((vm) != NULL) { \
  553. (kp)->p_vm_rssize = (vm)->vm_rssize; \
  554. (kp)->p_vm_tsize = (vm)->vm_tsize; \
  555. (kp)->p_vm_dsize = (vm)->vm_dused; \
  556. (kp)->p_vm_ssize = (vm)->vm_ssize; \
  557. } \
  558. (kp)->p_addr = PTRTOINT64((p)->p_addr); \
  559. (kp)->p_stat = (p)->p_stat; \
  560. (kp)->p_slptime = (p)->p_slptime; \
  561. (kp)->p_holdcnt = 1; \
  562. (kp)->p_priority = (p)->p_priority; \
  563. (kp)->p_usrpri = (p)->p_usrpri; \
  564. if ((p)->p_wchan && (p)->p_wmesg) \
  565. copy_str((kp)->p_wmesg, (p)->p_wmesg, \
  566. sizeof((kp)->p_wmesg)); \
  567. if (show_addresses) \
  568. (kp)->p_wchan = PTRTOINT64((p)->p_wchan); \
  569. } \
  570. \
  571. if (lim) \
  572. (kp)->p_rlim_rss_cur = \
  573. (lim)->pl_rlimit[RLIMIT_RSS].rlim_cur; \
  574. \
  575. if (((pr)->ps_flags & PS_ZOMBIE) == 0) { \
  576. struct timeval tv; \
  577. \
  578. (kp)->p_uvalid = 1; \
  579. \
  580. (kp)->p_ustart_sec = (pr)->ps_start.tv_sec; \
  581. (kp)->p_ustart_usec = (pr)->ps_start.tv_nsec/1000; \
  582. \
  583. (kp)->p_uru_maxrss = (p)->p_ru.ru_maxrss; \
  584. (kp)->p_uru_ixrss = (p)->p_ru.ru_ixrss; \
  585. (kp)->p_uru_idrss = (p)->p_ru.ru_idrss; \
  586. (kp)->p_uru_isrss = (p)->p_ru.ru_isrss; \
  587. (kp)->p_uru_minflt = (p)->p_ru.ru_minflt; \
  588. (kp)->p_uru_majflt = (p)->p_ru.ru_majflt; \
  589. (kp)->p_uru_nswap = (p)->p_ru.ru_nswap; \
  590. (kp)->p_uru_inblock = (p)->p_ru.ru_inblock; \
  591. (kp)->p_uru_oublock = (p)->p_ru.ru_oublock; \
  592. (kp)->p_uru_msgsnd = (p)->p_ru.ru_msgsnd; \
  593. (kp)->p_uru_msgrcv = (p)->p_ru.ru_msgrcv; \
  594. (kp)->p_uru_nsignals = (p)->p_ru.ru_nsignals; \
  595. (kp)->p_uru_nvcsw = (p)->p_ru.ru_nvcsw; \
  596. (kp)->p_uru_nivcsw = (p)->p_ru.ru_nivcsw; \
  597. \
  598. timeradd(&(pr)->ps_cru.ru_utime, \
  599. &(pr)->ps_cru.ru_stime, &tv); \
  600. (kp)->p_uctime_sec = tv.tv_sec; \
  601. (kp)->p_uctime_usec = tv.tv_usec; \
  602. } \
  603. \
  604. (kp)->p_cpuid = KI_NOCPU; \
  605. (kp)->p_rtableid = (pr)->ps_rtableid; \
  606. } while (0)
  607. #endif /* defined(_KERNEL) || defined(_LIBKVM) */
  608. /*
  609. * kern.file returns an array of these structures, which are designed
  610. * both to be immune to 32/64 bit emulation issues and to
  611. * provide backwards compatibility. The order differs slightly from
  612. * that of the real struct file, and some fields are taken from other
  613. * structures (struct vnode, struct proc) in order to make the file
  614. * information more useful.
  615. */
  616. #define KERN_FILE_BYFILE 1
  617. #define KERN_FILE_BYPID 2
  618. #define KERN_FILE_BYUID 3
  619. #define KERN_FILESLOP 10
  620. #define KERN_FILE_TEXT -1
  621. #define KERN_FILE_CDIR -2
  622. #define KERN_FILE_RDIR -3
  623. #define KERN_FILE_TRACE -4
  624. #define KI_MNAMELEN 96 /* rounded up from 90 */
  625. #define KI_UNPPATHLEN 104
  626. struct kinfo_file {
  627. uint64_t f_fileaddr; /* PTR: address of struct file */
  628. uint32_t f_flag; /* SHORT: flags (see fcntl.h) */
  629. uint32_t f_iflags; /* INT: internal flags */
  630. uint32_t f_type; /* INT: descriptor type */
  631. uint32_t f_count; /* UINT: reference count */
  632. uint32_t f_msgcount; /* UINT: references from msg queue */
  633. uint32_t f_usecount; /* INT: number active users */
  634. uint64_t f_ucred; /* PTR: creds for descriptor */
  635. uint32_t f_uid; /* UID_T: descriptor credentials */
  636. uint32_t f_gid; /* GID_T: descriptor credentials */
  637. uint64_t f_ops; /* PTR: address of fileops */
  638. uint64_t f_offset; /* OFF_T: offset */
  639. uint64_t f_data; /* PTR: descriptor data */
  640. uint64_t f_rxfer; /* UINT64: number of read xfers */
  641. uint64_t f_rwfer; /* UINT64: number of write xfers */
  642. uint64_t f_seek; /* UINT64: number of seek operations */
  643. uint64_t f_rbytes; /* UINT64: total bytes read */
  644. uint64_t f_wbytes; /* UINT64: total bytes written */
  645. /* information about the vnode associated with this file */
  646. uint64_t v_un; /* PTR: socket, specinfo, etc */
  647. uint32_t v_type; /* ENUM: vnode type */
  648. uint32_t v_tag; /* ENUM: type of underlying data */
  649. uint32_t v_flag; /* UINT: vnode flags */
  650. uint32_t va_rdev; /* DEV_T: raw device */
  651. uint64_t v_data; /* PTR: private data for fs */
  652. uint64_t v_mount; /* PTR: mount info for fs */
  653. uint64_t va_fileid; /* LONG: file id */
  654. uint64_t va_size; /* UINT64_T: file size in bytes */
  655. uint32_t va_mode; /* MODE_T: file access mode and type */
  656. uint32_t va_fsid; /* DEV_T: filesystem device */
  657. char f_mntonname[KI_MNAMELEN];
  658. /* socket information */
  659. uint32_t so_type; /* SHORT: socket type */
  660. uint32_t so_state; /* SHORT: socket state */
  661. uint64_t so_pcb; /* PTR: socket pcb */
  662. /* for non-root: -1 if not NULL */
  663. uint32_t so_protocol; /* SHORT: socket protocol type */
  664. uint32_t so_family; /* INT: socket domain family */
  665. uint64_t inp_ppcb; /* PTR: pointer to per-protocol pcb */
  666. uint32_t inp_lport; /* SHORT: local inet port */
  667. uint32_t inp_laddru[4]; /* STRUCT: local inet addr */
  668. uint32_t inp_fport; /* SHORT: foreign inet port */
  669. uint32_t inp_faddru[4]; /* STRUCT: foreign inet addr */
  670. uint64_t unp_conn; /* PTR: connected socket cntrl block */
  671. /* pipe information */
  672. uint64_t pipe_peer; /* PTR: link with other direction */
  673. uint32_t pipe_state; /* UINT: pipe status info */
  674. /* kqueue information */
  675. uint32_t kq_count; /* INT: number of pending events */
  676. uint32_t kq_state; /* INT: kqueue status information */
  677. /* systrace information */
  678. uint32_t str_npolicies; /* INT: number systrace policies */
  679. /* process information when retrieved via KERN_FILE_BY[PU]ID */
  680. uint32_t p_pid; /* PID_T: process id */
  681. int32_t fd_fd; /* INT: descriptor number */
  682. uint32_t fd_ofileflags; /* CHAR: open file flags */
  683. uint32_t p_uid; /* UID_T: process credentials */
  684. uint32_t p_gid; /* GID_T: process credentials */
  685. uint32_t p_tid; /* PID_T: thread id */
  686. char p_comm[KI_MAXCOMLEN];
  687. /* more socket information */
  688. uint32_t inp_rtableid; /* UINT: Routing table identifier. */
  689. uint64_t so_splice; /* PTR: f_data of spliced socket */
  690. int64_t so_splicelen; /* OFF_T: already spliced count or */
  691. /* -1 if this is target of splice */
  692. uint64_t so_rcv_cc; /* LONG: chars in receive buf */
  693. uint64_t so_snd_cc; /* LONG: chars in send buf */
  694. uint64_t unp_refs; /* PTR: connected sockets */
  695. uint64_t unp_nextref; /* PTR: link to next connected socket */
  696. uint64_t unp_addr; /* PTR: address of the socket address */
  697. char unp_path[KI_UNPPATHLEN];
  698. uint32_t inp_proto; /* CHAR: raw protocol id */
  699. uint32_t t_state; /* SHORT: tcp state */
  700. uint64_t t_rcv_wnd; /* ULONG: tcp receive window */
  701. uint64_t t_snd_wnd; /* ULONG: tcp send window */
  702. uint64_t t_snd_cwnd; /* ULONG: congestion-controlled win */
  703. };
  704. /*
  705. * KERN_INTRCNT
  706. */
  707. #define KERN_INTRCNT_NUM 1 /* int: # intrcnt */
  708. #define KERN_INTRCNT_CNT 2 /* node: intrcnt */
  709. #define KERN_INTRCNT_NAME 3 /* node: names */
  710. #define KERN_INTRCNT_VECTOR 4 /* node: interrupt vector # */
  711. #define KERN_INTRCNT_MAXID 5
  712. #define CTL_KERN_INTRCNT_NAMES { \
  713. { 0, 0 }, \
  714. { "nintrcnt", CTLTYPE_INT }, \
  715. { "intrcnt", CTLTYPE_NODE }, \
  716. { "intrname", CTLTYPE_NODE }, \
  717. }
  718. /*
  719. * KERN_WATCHDOG
  720. */
  721. #define KERN_WATCHDOG_PERIOD 1 /* int: watchdog period */
  722. #define KERN_WATCHDOG_AUTO 2 /* int: automatic tickle */
  723. #define KERN_WATCHDOG_MAXID 3
  724. #define CTL_KERN_WATCHDOG_NAMES { \
  725. { 0, 0 }, \
  726. { "period", CTLTYPE_INT }, \
  727. { "auto", CTLTYPE_INT }, \
  728. }
  729. /*
  730. * KERN_TIMECOUNTER
  731. */
  732. #define KERN_TIMECOUNTER_TICK 1 /* int: number of revolutions */
  733. #define KERN_TIMECOUNTER_TIMESTEPWARNINGS 2 /* int: log a warning when time changes */
  734. #define KERN_TIMECOUNTER_HARDWARE 3 /* string: tick hardware used */
  735. #define KERN_TIMECOUNTER_CHOICE 4 /* string: tick hardware used */
  736. #define KERN_TIMECOUNTER_MAXID 5
  737. #define CTL_KERN_TIMECOUNTER_NAMES { \
  738. { 0, 0 }, \
  739. { "tick", CTLTYPE_INT }, \
  740. { "timestepwarnings", CTLTYPE_INT }, \
  741. { "hardware", CTLTYPE_STRING }, \
  742. { "choice", CTLTYPE_STRING }, \
  743. }
  744. /*
  745. * CTL_FS identifiers
  746. */
  747. #define FS_POSIX 1 /* POSIX flags */
  748. #define FS_MAXID 2
  749. #define CTL_FS_NAMES { \
  750. { 0, 0 }, \
  751. { "posix", CTLTYPE_NODE }, \
  752. }
  753. /*
  754. * CTL_FS identifiers
  755. */
  756. #define FS_POSIX_SETUID 1 /* int: always clear SGID/SUID bit when owner change */
  757. #define FS_POSIX_MAXID 2
  758. #define CTL_FS_POSIX_NAMES { \
  759. { 0, 0 }, \
  760. { "setuid", CTLTYPE_INT }, \
  761. }
  762. /*
  763. * CTL_HW identifiers
  764. */
  765. #define HW_MACHINE 1 /* string: machine class */
  766. #define HW_MODEL 2 /* string: specific machine model */
  767. #define HW_NCPU 3 /* int: number of cpus being used */
  768. #define HW_BYTEORDER 4 /* int: machine byte order */
  769. #define HW_PHYSMEM 5 /* int: total memory */
  770. #define HW_USERMEM 6 /* int: non-kernel memory */
  771. #define HW_PAGESIZE 7 /* int: software page size */
  772. #define HW_DISKNAMES 8 /* strings: disk drive names */
  773. #define HW_DISKSTATS 9 /* struct: diskstats[] */
  774. #define HW_DISKCOUNT 10 /* int: number of disks */
  775. #define HW_SENSORS 11 /* node: hardware monitors */
  776. #define HW_CPUSPEED 12 /* get CPU frequency */
  777. #define HW_SETPERF 13 /* set CPU performance % */
  778. #define HW_VENDOR 14 /* string: vendor name */
  779. #define HW_PRODUCT 15 /* string: product name */
  780. #define HW_VERSION 16 /* string: hardware version */
  781. #define HW_SERIALNO 17 /* string: hardware serial number */
  782. #define HW_UUID 18 /* string: universal unique id */
  783. #define HW_PHYSMEM64 19 /* quad: total memory */
  784. #define HW_USERMEM64 20 /* quad: non-kernel memory */
  785. #define HW_NCPUFOUND 21 /* int: number of cpus found*/
  786. #define HW_ALLOWPOWERDOWN 22 /* allow power button shutdown */
  787. #define HW_PERFPOLICY 23 /* set performance policy */
  788. #define HW_MAXID 24 /* number of valid hw ids */
  789. #define CTL_HW_NAMES { \
  790. { 0, 0 }, \
  791. { "machine", CTLTYPE_STRING }, \
  792. { "model", CTLTYPE_STRING }, \
  793. { "ncpu", CTLTYPE_INT }, \
  794. { "byteorder", CTLTYPE_INT }, \
  795. { "gap", 0 }, \
  796. { "gap", 0 }, \
  797. { "pagesize", CTLTYPE_INT }, \
  798. { "disknames", CTLTYPE_STRING }, \
  799. { "diskstats", CTLTYPE_STRUCT }, \
  800. { "diskcount", CTLTYPE_INT }, \
  801. { "sensors", CTLTYPE_NODE}, \
  802. { "cpuspeed", CTLTYPE_INT }, \
  803. { "setperf", CTLTYPE_INT }, \
  804. { "vendor", CTLTYPE_STRING }, \
  805. { "product", CTLTYPE_STRING }, \
  806. { "version", CTLTYPE_STRING }, \
  807. { "serialno", CTLTYPE_STRING }, \
  808. { "uuid", CTLTYPE_STRING }, \
  809. { "physmem", CTLTYPE_QUAD }, \
  810. { "usermem", CTLTYPE_QUAD }, \
  811. { "ncpufound", CTLTYPE_INT }, \
  812. { "allowpowerdown", CTLTYPE_INT }, \
  813. { "perfpolicy", CTLTYPE_STRING }, \
  814. }
  815. /*
  816. * CTL_DEBUG definitions
  817. *
  818. * Second level identifier specifies which debug variable.
  819. * Third level identifier specifies which structure component.
  820. */
  821. #define CTL_DEBUG_NAME 0 /* string: variable name */
  822. #define CTL_DEBUG_VALUE 1 /* int: variable value */
  823. #define CTL_DEBUG_MAXID 20
  824. #ifdef _KERNEL
  825. #ifdef DEBUG
  826. /*
  827. * CTL_DEBUG variables.
  828. *
  829. * These are declared as separate variables so that they can be
  830. * individually initialized at the location of their associated
  831. * variable. The loader prevents multiple use by issuing errors
  832. * if a variable is initialized in more than one place. They are
  833. * aggregated into an array in debug_sysctl(), so that it can
  834. * conveniently locate them when querried. If more debugging
  835. * variables are added, they must also be declared here and also
  836. * entered into the array.
  837. */
  838. struct ctldebug {
  839. char *debugname; /* name of debugging variable */
  840. int *debugvar; /* pointer to debugging variable */
  841. };
  842. extern struct ctldebug debug0, debug1, debug2, debug3, debug4;
  843. extern struct ctldebug debug5, debug6, debug7, debug8, debug9;
  844. extern struct ctldebug debug10, debug11, debug12, debug13, debug14;
  845. extern struct ctldebug debug15, debug16, debug17, debug18, debug19;
  846. #endif /* DEBUG */
  847. /*
  848. * Internal sysctl function calling convention:
  849. *
  850. * (*sysctlfn)(name, namelen, oldval, oldlenp, newval, newlen);
  851. *
  852. * The name parameter points at the next component of the name to be
  853. * interpreted. The namelen parameter is the number of integers in
  854. * the name.
  855. */
  856. typedef int (sysctlfn)(int *, u_int, void *, size_t *, void *, size_t, struct proc *);
  857. int sysctl_int(void *, size_t *, void *, size_t, int *);
  858. int sysctl_int_lower(void *, size_t *, void *, size_t, int *);
  859. int sysctl_rdint(void *, size_t *, void *, int);
  860. int sysctl_int_arr(int **, int *, u_int, void *, size_t *, void *, size_t);
  861. int sysctl_quad(void *, size_t *, void *, size_t, int64_t *);
  862. int sysctl_rdquad(void *, size_t *, void *, int64_t);
  863. int sysctl_string(void *, size_t *, void *, size_t, char *, int);
  864. int sysctl_tstring(void *, size_t *, void *, size_t, char *, int);
  865. int sysctl__string(void *, size_t *, void *, size_t, char *, int, int);
  866. int sysctl_rdstring(void *, size_t *, void *, const char *);
  867. int sysctl_rdstruct(void *, size_t *, void *, const void *, int);
  868. int sysctl_struct(void *, size_t *, void *, size_t, void *, int);
  869. int sysctl_file(int *, u_int, char *, size_t *, struct proc *);
  870. int sysctl_doproc(int *, u_int, char *, size_t *);
  871. struct rtentry;
  872. struct walkarg;
  873. int sysctl_dumpentry(struct rtentry *, void *, unsigned int);
  874. int sysctl_iflist(int, struct walkarg *);
  875. int sysctl_rtable(int *, u_int, void *, size_t *, void *, size_t);
  876. int sysctl_clockrate(char *, size_t *, void *);
  877. int sysctl_vnode(char *, size_t *, struct proc *);
  878. #ifdef GPROF
  879. int sysctl_doprof(int *, u_int, void *, size_t *, void *, size_t);
  880. #endif
  881. int sysctl_dopool(int *, u_int, char *, size_t *);
  882. int kern_sysctl(int *, u_int, void *, size_t *, void *, size_t,
  883. struct proc *);
  884. int hw_sysctl(int *, u_int, void *, size_t *, void *, size_t,
  885. struct proc *);
  886. #ifdef DEBUG
  887. int debug_sysctl(int *, u_int, void *, size_t *, void *, size_t,
  888. struct proc *);
  889. #endif
  890. int vm_sysctl(int *, u_int, void *, size_t *, void *, size_t,
  891. struct proc *);
  892. int fs_sysctl(int *, u_int, void *, size_t *, void *, size_t,
  893. struct proc *);
  894. int fs_posix_sysctl(int *, u_int, void *, size_t *, void *, size_t,
  895. struct proc *);
  896. int net_sysctl(int *, u_int, void *, size_t *, void *, size_t,
  897. struct proc *);
  898. int cpu_sysctl(int *, u_int, void *, size_t *, void *, size_t,
  899. struct proc *);
  900. int vfs_sysctl(int *, u_int, void *, size_t *, void *, size_t,
  901. struct proc *);
  902. int sysctl_sysvipc(int *, u_int, void *, size_t *);
  903. int sysctl_wdog(int *, u_int, void *, size_t *, void *, size_t);
  904. extern int (*cpu_cpuspeed)(int *);
  905. extern void (*cpu_setperf)(int);
  906. int bpf_sysctl(int *, u_int, void *, size_t *, void *, size_t);
  907. int pflow_sysctl(int *, u_int, void *, size_t *, void *, size_t);
  908. int pipex_sysctl(int *, u_int, void *, size_t *, void *, size_t);
  909. #else /* !_KERNEL */
  910. __BEGIN_DECLS
  911. int sysctl(const int *, u_int, void *, size_t *, void *, size_t);
  912. __END_DECLS
  913. #endif /* _KERNEL */
  914. #endif /* !_SYS_SYSCTL_H_ */