xref: /netbsd-src/include/kvm.h (revision 888c1340260ae6dfbec78463f891bb20ccfd9da0)
1*888c1340Sdholland /*	$NetBSD: kvm.h,v 1.17 2016/01/22 21:55:57 dholland Exp $	*/
24d2cbfceScgd 
361f28255Scgd /*-
4221bc33cScgd  * Copyright (c) 1989, 1993
5221bc33cScgd  *	The Regents of the University of California.  All rights reserved.
661f28255Scgd  *
761f28255Scgd  * Redistribution and use in source and binary forms, with or without
861f28255Scgd  * modification, are permitted provided that the following conditions
961f28255Scgd  * are met:
1061f28255Scgd  * 1. Redistributions of source code must retain the above copyright
1161f28255Scgd  *    notice, this list of conditions and the following disclaimer.
1261f28255Scgd  * 2. Redistributions in binary form must reproduce the above copyright
1361f28255Scgd  *    notice, this list of conditions and the following disclaimer in the
1461f28255Scgd  *    documentation and/or other materials provided with the distribution.
15039cc956Sagc  * 3. Neither the name of the University nor the names of its contributors
1661f28255Scgd  *    may be used to endorse or promote products derived from this software
1761f28255Scgd  *    without specific prior written permission.
1861f28255Scgd  *
1961f28255Scgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2061f28255Scgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2161f28255Scgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2261f28255Scgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2361f28255Scgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2461f28255Scgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2561f28255Scgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2661f28255Scgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2761f28255Scgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2861f28255Scgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2961f28255Scgd  * SUCH DAMAGE.
3061f28255Scgd  *
31221bc33cScgd  *	@(#)kvm.h	8.1 (Berkeley) 6/2/93
3261f28255Scgd  */
3361f28255Scgd 
3461f28255Scgd #ifndef _KVM_H_
3561f28255Scgd #define	_KVM_H_
3661f28255Scgd 
3761f28255Scgd /* Default version symbol. */
3861f28255Scgd #define	VRS_SYM		"_version"
3961f28255Scgd #define	VRS_KEY		"VERSION"
4061f28255Scgd 
4110e8b6d0Ssimonb /*
4210e8b6d0Ssimonb  * Flag for kvm_open*() to disable opening of kernel files - used
4310e8b6d0Ssimonb  * by programs that use only sysctl() function to access kernel
4410e8b6d0Ssimonb  * information.
4510e8b6d0Ssimonb  */
4676e7e3eaSchristos #define KVM_NO_FILES	((int)0x80000000)
4710e8b6d0Ssimonb 
48221bc33cScgd #include <nlist.h>
4989dea210Skleink #include <sys/cdefs.h>
509cd8e0d3Skleink #include <sys/types.h>
516475789bSjoerg #include <stdbool.h>
52987ebf3fSleo #include <stdio.h>
5361f28255Scgd 
5461f28255Scgd __BEGIN_DECLS
55221bc33cScgd 
56221bc33cScgd typedef struct __kvm kvm_t;
57221bc33cScgd 
58221bc33cScgd struct kinfo_proc;
5910e8b6d0Ssimonb struct kinfo_proc2;
6019b7469aSperry int	  kvm_close(kvm_t *);
6119b7469aSperry int	  kvm_dump_inval(kvm_t *);
6219b7469aSperry int	  kvm_dump_mkheader(kvm_t *, off_t);
636475789bSjoerg int	  kvm_dump_header(kvm_t *, bool (*)(void *, const void *, size_t),
646475789bSjoerg 			  void *, int);
6519b7469aSperry int	  kvm_dump_wrtheader(kvm_t *, FILE *, int);
6619b7469aSperry char	**kvm_getargv(kvm_t *, const struct kinfo_proc *, int);
6719b7469aSperry char	**kvm_getargv2(kvm_t *, const struct kinfo_proc2 *, int);
6819b7469aSperry char	**kvm_getenvv(kvm_t *, const struct kinfo_proc *, int);
6919b7469aSperry char	**kvm_getenvv2(kvm_t *, const struct kinfo_proc2 *, int);
7019b7469aSperry char	 *kvm_geterr(kvm_t *);
7119b7469aSperry int	  kvm_getloadavg(kvm_t *, double [], int);
7219b7469aSperry char	 *kvm_getfiles(kvm_t *, int, int, int *);
73c62a74e6Sthorpej struct kinfo_lwp *
74*888c1340Sdholland 	  kvm_getlwps(kvm_t *, int, unsigned long, size_t, int *);
7510e8b6d0Ssimonb struct kinfo_proc2 *
7619b7469aSperry 	  kvm_getproc2(kvm_t *, int, int, size_t, int *);
77221bc33cScgd struct kinfo_proc *
7819b7469aSperry 	  kvm_getprocs(kvm_t *, int, int, int *);
7919b7469aSperry int	  kvm_nlist(kvm_t *, struct nlist *);
80221bc33cScgd kvm_t	 *kvm_open
8119b7469aSperry 	    (const char *, const char *, const char *, int, const char *);
8219b7469aSperry kvm_t	 *kvm_openfiles(const char *, const char *, const char *, int, char *);
83*888c1340Sdholland ssize_t	  kvm_read(kvm_t *, unsigned long, void *, size_t);
84*888c1340Sdholland ssize_t	  kvm_write(kvm_t *, unsigned long, const void *, size_t);
85ea9367e3Schristos const char *kvm_getkernelname(kvm_t *);
86221bc33cScgd 
8761f28255Scgd __END_DECLS
8861f28255Scgd 
8961f28255Scgd #endif /* !_KVM_H_ */
90