sysctl.h

来自「基于组件方式开发操作系统的OSKIT源代码」· C头文件 代码 · 共 681 行 · 第 1/2 页

H
681
字号
/*	$NetBSD: sysctl.h,v 1.59 2000/11/20 01:46:56 simonb Exp $	*//* * Copyright (c) 1989, 1993 *	The Regents of the University of California.  All rights reserved. * * This code is derived from software contributed to Berkeley by * Mike Karels at Berkeley Software Design, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by the University of *	California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * *	@(#)sysctl.h	8.1 (Berkeley) 6/2/93 */#ifndef _SYS_SYSCTL_H_#define	_SYS_SYSCTL_H_/* * These are for the eproc structure defined below. */#include <sys/time.h>#include <sys/ucred.h>#include <sys/proc.h>#include <uvm/uvm_extern.h>/* * Definitions for sysctl call.  The sysctl call uses a hierarchical name * for objects that can be examined or modified.  The name is expressed as * a sequence of integers.  Like a file path name, the meaning of each * component depends on its place in the hierarchy.  The top-level and kern * identifiers are defined here, and other identifiers are defined in the * respective subsystem header files. */#define	CTL_MAXNAME	12	/* largest number of components supported *//* * Each subsystem defined by sysctl defines a list of variables * for that subsystem. Each name is either a node with further * levels defined below it, or it is a leaf of some particular * type given below. Each sysctl level defines a set of name/type * pairs to be used by sysctl(1) in manipulating the subsystem. */struct ctlname {	const char *ctl_name;	/* subsystem name */	int	ctl_type;	/* type of name */};#define	CTLTYPE_NODE	1	/* name is a node */#define	CTLTYPE_INT	2	/* name describes an integer */#define	CTLTYPE_STRING	3	/* name describes a string */#define	CTLTYPE_QUAD	4	/* name describes a 64-bit number */#define	CTLTYPE_STRUCT	5	/* name describes a structure *//* * Top-level identifiers */#define	CTL_UNSPEC	0		/* unused */#define	CTL_KERN	1		/* "high kernel": proc, limits */#define	CTL_VM		2		/* virtual memory */#define	CTL_VFS		3		/* file system, mount type is next */#define	CTL_NET		4		/* network, see socket.h */#define	CTL_DEBUG	5		/* debugging parameters */#define	CTL_HW		6		/* generic cpu/io */#define	CTL_MACHDEP	7		/* machine dependent */#define	CTL_USER	8		/* user-level */#define	CTL_DDB		9		/* in-kernel debugger */#define	CTL_PROC	10		/* per-proc attr */#define	CTL_MAXID	11		/* number of valid top-level ids */#define	CTL_NAMES { \	{ 0, 0 }, \	{ "kern", CTLTYPE_NODE }, \	{ "vm", CTLTYPE_NODE }, \	{ "vfs", CTLTYPE_NODE }, \	{ "net", CTLTYPE_NODE }, \	{ "debug", CTLTYPE_NODE }, \	{ "hw", CTLTYPE_NODE }, \	{ "machdep", CTLTYPE_NODE }, \	{ "user", CTLTYPE_NODE }, \	{ "ddb", CTLTYPE_NODE }, \	{ "proc", CTLTYPE_NODE }, \}/* * CTL_KERN identifiers */#define	KERN_OSTYPE	 	 1	/* string: system version */#define	KERN_OSRELEASE	 	 2	/* string: system release */#define	KERN_OSREV	 	 3	/* int: system revision */#define	KERN_VERSION	 	 4	/* string: compile time info */#define	KERN_MAXVNODES	 	 5	/* int: max vnodes */#define	KERN_MAXPROC	 	 6	/* int: max processes */#define	KERN_MAXFILES	 	 7	/* int: max open files */#define	KERN_ARGMAX	 	 8	/* int: max arguments to exec */#define	KERN_SECURELVL	 	 9	/* int: system security level */#define	KERN_HOSTNAME		10	/* string: hostname */#define	KERN_HOSTID		11	/* int: host identifier */#define	KERN_CLOCKRATE		12	/* struct: struct clockrate */#define	KERN_VNODE		13	/* struct: vnode structures */#define	KERN_PROC		14	/* struct: process entries */#define	KERN_FILE		15	/* struct: file entries */#define	KERN_PROF		16	/* node: kernel profiling info */#define	KERN_POSIX1		17	/* int: POSIX.1 version */#define	KERN_NGROUPS		18	/* int: # of supplemental group ids */#define	KERN_JOB_CONTROL	19	/* int: is job control available */#define	KERN_SAVED_IDS		20	/* int: saved set-user/group-ID */#define	KERN_BOOTTIME		21	/* struct: time kernel was booted */#define	KERN_DOMAINNAME		22	/* string: (YP) domainname */#define	KERN_MAXPARTITIONS	23	/* int: number of partitions/disk */#define	KERN_RAWPARTITION	24	/* int: raw partition number */#define	KERN_NTPTIME		25	/* struct: extended-precision time */#define	KERN_TIMEX		26	/* struct: ntp timekeeping state */#define	KERN_AUTONICETIME	27	/* int: proc time before autonice */#define	KERN_AUTONICEVAL	28	/* int: auto nice value */#define	KERN_RTC_OFFSET		29	/* int: offset of rtc from gmt */#define	KERN_ROOT_DEVICE	30	/* string: root device */#define	KERN_MSGBUFSIZE		31	/* int: max # of chars in msg buffer */#define	KERN_FSYNC		32	/* int: file synchronization support */#define	KERN_SYSVMSG		33	/* int: SysV message queue suppoprt */#define	KERN_SYSVSEM		34	/* int: SysV semaphore support */#define	KERN_SYSVSHM		35	/* int: SysV shared memory support */#define	KERN_OLDSHORTCORENAME	36	/* old, unimplemented */#define	KERN_SYNCHRONIZED_IO	37	/* int: POSIX synchronized I/O */#define	KERN_IOV_MAX		38	/* int: max iovec's for readv(2) etc. */#define	KERN_MBUF		39	/* node: mbuf parameters */#define	KERN_MAPPED_FILES	40	/* int: POSIX memory mapped files */#define	KERN_MEMLOCK		41	/* int: POSIX memory locking */#define	KERN_MEMLOCK_RANGE	42	/* int: POSIX memory range locking */#define	KERN_MEMORY_PROTECTION	43	/* int: POSIX memory protections */#define	KERN_LOGIN_NAME_MAX	44	/* int: max length login name + NUL */#define	KERN_DEFCORENAME	45	/* old: sort core name format */#define	KERN_LOGSIGEXIT		46	/* int: log signalled processes */#define	KERN_PROC2		47	/* struct: process entries */#define	KERN_PROC_ARGS		48	/* struct: process argv/env */#define	KERN_FSCALE		49	/* int: fixpt FSCALE */#define	KERN_CCPU		50	/* int: fixpt ccpu */#define	KERN_CP_TIME		51	/* struct: cpu time counters */#define	KERN_SYSVIPC_INFO	52	/* number of valid kern ids */#define	KERN_MSGBUF		53	/* kernel message buffer */#define	KERN_CONSDEV		54	/* dev_t: console terminal device */#define	KERN_MAXPTYS		55	/* int: maximum number of ptys */#define	KERN_MAXID		57	/* number of valid kern ids */#define	CTL_KERN_NAMES { \	{ 0, 0 }, \	{ "ostype", CTLTYPE_STRING }, \	{ "osrelease", CTLTYPE_STRING }, \	{ "osrevision", CTLTYPE_INT }, \	{ "version", CTLTYPE_STRING }, \	{ "maxvnodes", CTLTYPE_INT }, \	{ "maxproc", CTLTYPE_INT }, \	{ "maxfiles", CTLTYPE_INT }, \	{ "argmax", CTLTYPE_INT }, \	{ "securelevel", CTLTYPE_INT }, \	{ "hostname", CTLTYPE_STRING }, \	{ "hostid", CTLTYPE_INT }, \	{ "clockrate", CTLTYPE_STRUCT }, \	{ "vnode", CTLTYPE_STRUCT }, \	{ "proc", CTLTYPE_STRUCT }, \	{ "file", CTLTYPE_STRUCT }, \	{ "profiling", CTLTYPE_NODE }, \	{ "posix1version", CTLTYPE_INT }, \	{ "ngroups", CTLTYPE_INT }, \	{ "job_control", CTLTYPE_INT }, \	{ "saved_ids", CTLTYPE_INT }, \	{ "boottime", CTLTYPE_STRUCT }, \	{ "domainname", CTLTYPE_STRING }, \	{ "maxpartitions", CTLTYPE_INT }, \	{ "rawpartition", CTLTYPE_INT }, \	{ "ntptime", CTLTYPE_STRUCT }, \	{ "timex", CTLTYPE_STRUCT }, \	{ "autonicetime", CTLTYPE_INT }, \	{ "autoniceval", CTLTYPE_INT }, \	{ "rtc_offset", CTLTYPE_INT }, \	{ "root_device", CTLTYPE_STRING }, \	{ "msgbufsize", CTLTYPE_INT }, \	{ "fsync", CTLTYPE_INT }, \	{ "sysvmsg", CTLTYPE_INT }, \	{ "sysvsem", CTLTYPE_INT }, \	{ "sysvshm", CTLTYPE_INT }, \	{ 0, 0 }, \	{ "synchronized_io", CTLTYPE_INT }, \	{ "iov_max", CTLTYPE_INT }, \	{ "mbuf", CTLTYPE_NODE }, \	{ "mapped_files", CTLTYPE_INT }, \	{ "memlock", CTLTYPE_INT }, \	{ "memlock_range", CTLTYPE_INT }, \	{ "memory_protection", CTLTYPE_INT }, \	{ "login_name_max", CTLTYPE_INT }, \	{ "defcorename", CTLTYPE_STRING }, \	{ "logsigexit", CTLTYPE_INT }, \	{ "proc2", CTLTYPE_STRUCT }, \	{ "proc_args", CTLTYPE_STRING }, \	{ "fscale", CTLTYPE_INT }, \	{ "ccpu", CTLTYPE_INT }, \	{ "cp_time", CTLTYPE_STRUCT }, \	{ "sysvipc_info", CTLTYPE_STRUCT }, \	{ "msgbuf", CTLTYPE_STRUCT }, \	{ "consdev", CTLTYPE_STRUCT }, \	{ "maxptys", CTLTYPE_INT }, \}/* * KERN_PROC subtypes */#define	KERN_PROC_ALL		 0	/* everything */#define	KERN_PROC_PID		 1	/* by process id */#define	KERN_PROC_PGRP		 2	/* by process group id */#define	KERN_PROC_SESSION	 3	/* by session of pid */#define	KERN_PROC_TTY		 4	/* by controlling tty */#define	KERN_PROC_UID		 5	/* by effective uid */#define	KERN_PROC_RUID		 6	/* by real uid */#define	KERN_PROC_GID		 7	/* by effective gid */#define	KERN_PROC_RGID		 8	/* by real gid *//* * KERN_PROC_TTY sub-subtypes */#define	KERN_PROC_TTY_NODEV	NODEV		/* no controlling tty */#define	KERN_PROC_TTY_REVOKE	((dev_t)-2)	/* revoked tty *//* * KERN_PROC subtype ops return arrays of augmented proc structures: */struct kinfo_proc {	struct	proc kp_proc;			/* proc structure */	struct	eproc {		struct	proc *e_paddr;		/* address of proc */		struct	session *e_sess;	/* session pointer */		struct	pcred e_pcred;		/* process credentials */		struct	ucred e_ucred;		/* current credentials */		struct	vmspace e_vm;		/* address space */		pid_t	e_ppid;			/* parent process id */		pid_t	e_pgid;			/* process group id */		short	e_jobc;			/* job control counter */		dev_t	e_tdev;			/* controlling tty dev */		pid_t	e_tpgid;		/* tty process group id */		struct	session *e_tsess;	/* tty session pointer */#define	WMESGLEN	8		char	e_wmesg[WMESGLEN];	/* wchan message */		segsz_t e_xsize;		/* text size */		short	e_xrssize;		/* text rss */		short	e_xccount;		/* text references */		short	e_xswrss;		long	e_flag;#define	EPROC_CTTY	0x01	/* controlling tty vnode active */#define	EPROC_SLEADER	0x02	/* session leader */		char	e_login[MAXLOGNAME];	/* setlogin() name */		pid_t	e_sid;			/* session id */		long	e_spare[3];	} kp_eproc;};/* * KERN_PROC2 subtype ops return arrays of relatively fixed size * structures of process info.   Use 8 byte alignment, and new * elements should only be added to the end of this structure so * binary compatibility can be preserved. */#define	KI_NGROUPS	16#define	KI_MAXCOMLEN	24	/* extra for 8 byte alignment */#define	KI_WMESGLEN	8#define	KI_MAXLOGNAME	24	/* extra for 8 byte alignment */#define KI_NOCPU	(~(u_int64_t)0)typedef struct {	u_int32_t	__bits[4];} ki_sigset_t;struct kinfo_proc2 {	u_int64_t p_forw;		/* PTR: linked run/sleep queue. */	u_int64_t p_back;	u_int64_t p_paddr;		/* PTR: address of proc */	u_int64_t p_addr;		/* PTR: Kernel virtual addr of u-area */	u_int64_t p_fd;			/* PTR: Ptr to open files structure. */	u_int64_t p_cwdi;		/* PTR: cdir/rdir/cmask info */	u_int64_t p_stats;		/* PTR: Accounting/statistics */	u_int64_t p_limit;		/* PTR: Process limits. */	u_int64_t p_vmspace;		/* PTR: Address space. */	u_int64_t p_sigacts;		/* PTR: Signal actions, state */	u_int64_t p_sess;		/* PTR: session pointer */	u_int64_t p_tsess;		/* PTR: tty session pointer */	u_int64_t p_ru;			/* PTR: Exit information. XXX */	int32_t	p_eflag;		/* LONG: extra kinfo_proc2 flags */	int32_t	p_exitsig;		/* INT: signal to sent to parent on exit */	int32_t	p_flag;			/* INT: P_* flags. */	int32_t	p_pid;			/* PID_T: Process identifier. */	int32_t	p_ppid;			/* PID_T: Parent process id */	int32_t	p_sid;			/* PID_T: session id */	int32_t	p__pgid;		/* PID_T: process group id */					/* XXX: <sys/proc.h> hijacks p_pgid */	int32_t	p_tpgid;		/* PID_T: tty process group id */	u_int32_t p_uid;		/* UID_T: effective user id */	u_int32_t p_ruid;		/* UID_T: real user id */	u_int32_t p_gid;		/* GID_T: effective group id */	u_int32_t p_rgid;		/* GID_T: real group id */	u_int32_t p_groups[KI_NGROUPS];	/* GID_T: groups */	int16_t	p_ngroups;		/* SHORT: number of groups */	int16_t	p_jobc;			/* SHORT: job control counter */	u_int32_t p_tdev;		/* DEV_T: controlling tty dev */	u_int32_t p_estcpu;		/* U_INT: Time averaged value of p_cpticks. */	u_int32_t p_rtime_sec;		/* STRUCT TIMEVAL: Real time. */	u_int32_t p_rtime_usec;		/* STRUCT TIMEVAL: Real time. */	int32_t	p_cpticks;		/* INT: Ticks of cpu time. */	u_int32_t p_pctcpu;		/* FIXPT_T: %cpu for this process during p_swtime */	u_int32_t p_swtime;		/* U_INT: Time swapped in or out. */	u_int32_t p_slptime;		/* U_INT: Time since last blocked. */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?