1 /*	$MirOS: src/include/kvm.h,v 1.2 2013/10/31 20:06:07 tg Exp $ */
2 /*	$OpenBSD: kvm.h,v 1.12 2004/09/14 22:39:56 deraadt Exp $	*/
3 /*	$NetBSD: kvm.h,v 1.7 1996/04/19 12:02:50 leo Exp $	*/
4 
5 /*-
6  * Copyright © 2013
7  *	Thorsten “mirabilos” Glaser <tg@mirbsd.org>
8  * Copyright (c) 1989, 1993
9  *	The Regents of the University of California.  All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. Neither the name of the University nor the names of its contributors
20  *    may be used to endorse or promote products derived from this software
21  *    without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  *
35  *	@(#)kvm.h	8.1 (Berkeley) 6/2/93
36  */
37 
38 #ifndef _KVM_H_
39 #define	_KVM_H_
40 
41 /* Default version symbol. */
42 #define	VRS_SYM		"_version"
43 #define	VRS_KEY		"VERSION"
44 
45 /*
46  * Flag for kvm_open* that disables opening of any files. We're just
47  * interested in a handle to run sysctls.
48  */
49 #define KVM_NO_FILES	0x80000000
50 
51 #include <nlist.h>
52 #include <sys/cdefs.h>
53 #include <stdio.h>
54 
55 __BEGIN_DECLS
56 
57 typedef struct __kvm kvm_t;
58 
59 struct kinfo_proc;
60 struct kinfo_proc2;
61 int	  kvm_close(kvm_t *);
62 int	  kvm_dump_inval(kvm_t *);
63 int	  kvm_dump_mkheader(kvm_t *, off_t);
64 int	  kvm_dump_wrtheader(kvm_t *, FILE *, int);
65 char	**kvm_getargv(kvm_t *, const struct kinfo_proc *, int);
66 char	**kvm_getargv2(kvm_t *, const struct kinfo_proc2 *, int);
67 char	**kvm_getenvv(kvm_t *, const struct kinfo_proc *, int);
68 char	**kvm_getenvv2(kvm_t *, const struct kinfo_proc2 *, int);
69 char	 *kvm_geterr(kvm_t *);
70 int	  kvm_getloadavg(kvm_t *, double [], int);
71 char	 *kvm_getfiles(kvm_t *, int, int, int *);
72 struct kinfo_proc *
73 	  kvm_getprocs(kvm_t *, int, int, int *);
74 struct kinfo_proc2 *
75 	  kvm_getproc2(kvm_t *, int, int, size_t, int *);
76 int	  kvm_nlist(kvm_t *, struct nlist *);
77 kvm_t	 *kvm_open(const char *, const char *, const char *, int, const char *);
78 kvm_t	 *kvm_openfiles(const char *, const char *, const char *,
79 	        unsigned int, char *);
80 ssize_t	  kvm_read(kvm_t *, unsigned long, void *, size_t)
81 		__attribute__((__bounded__(__buffer__, 3, 4)));
82 ssize_t	  kvm_write(kvm_t *, unsigned long, const void *, size_t)
83 		__attribute__((__bounded__(__buffer__, 3, 4)));
84 
85 __END_DECLS
86 
87 #endif /* !_KVM_H_ */
88