Remove advertising header from man pages.
[dragonfly.git] / lib / libkvm / kvm_read.3
1 .\" Copyright (c) 1992, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" This code is derived from software developed by the Computer Systems
5 .\" Engineering group at Lawrence Berkeley Laboratory under DARPA contract
6 .\" BG 91-66 and contributed to Berkeley.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)kvm_read.3  8.1 (Berkeley) 6/4/93
33 .\" $FreeBSD: src/lib/libkvm/kvm_read.3,v 1.6.2.3 2001/12/17 10:08:30 ru Exp $
34 .\" $DragonFly: src/lib/libkvm/kvm_read.3,v 1.4 2008/09/07 08:36:54 swildner Exp $
35 .\"
36 .Dd January 8, 2006
37 .Dt KVM_READ 3
38 .Os
39 .Sh NAME
40 .Nm kvm_read ,
41 .Nm kvm_readstr ,
42 .Nm kvm_write
43 .Nd read or write kernel virtual memory
44 .Sh LIBRARY
45 .Lb libkvm
46 .Sh SYNOPSIS
47 .In sys/types.h
48 .In kvm.h
49 .Ft ssize_t
50 .Fn kvm_read "kvm_t *kd" "unsigned long addr" "void *buf" "size_t nbytes"
51 .Ft "char *"
52 .Fn kvm_readstr "kvm_t *kd" "unsigned long addr" "char *buf" "size_t *len"
53 .Ft ssize_t
54 .Fn kvm_write "kvm_t *kd" "unsigned long addr" "const void *buf" "size_t nbytes"
55 .Sh DESCRIPTION
56 The
57 .Fn kvm_read ,
58 .Fn kvm_readstr
59 and
60 .Fn kvm_write
61 functions are used to read and write kernel virtual memory (or a crash
62 dump file). See
63 .Fn kvm_open 3
64 or
65 .Fn kvm_openfiles 3
66 for information regarding opening kernel virtual memory and crash dumps.
67 .Pp
68 The
69 .Fn kvm_read
70 function transfers
71 .Fa nbytes
72 bytes of data from
73 the kernel space address
74 .Fa addr
75 to
76 .Fa buf .
77 Conversely,
78 .Fn kvm_write
79 transfers data from
80 .Fa buf
81 to
82 .Fa addr .
83 Unlike their SunOS counterparts, these functions cannot be used to
84 read or write process address spaces.
85 .Pp
86 The
87 .Fn kvm_readstr
88 function exists for convenience to read NUL terminated strings
89 from the kernel address space.
90 If
91 .Fa buf
92 is
93 .Dv NULL ,
94 .Fn kvm_readstr
95 will allocate a sufficiently large buffer, which needs to be
96 deallocated via
97 .Xr free 3
98 by the caller.
99 If
100 .Fa len
101 is not
102 .Dv NULL ,
103 .Fn kvm_readstr
104 will interpret the value it is pointing to as the size of
105 .Fa buf
106 and will store the size of the complete string at
107 .Fa addr .
108 Note that if only
109 .Fa buf
110 is too small to hold the complete string,
111 .Fn kvm_readstr
112 will return
113 .Dv NULL
114 but set
115 .Fa len
116 to the size needed.
117 .Sh RETURN VALUES
118 For
119 .Fn kvm_read
120 and
121 .Fn kvm_write
122 the number of bytes actually transferred is returned, if the request
123 was successful.
124 Otherwise, -1 is returned.
125 .Pp
126 For
127 .Fn kvm_readstr
128 .Dv NULL
129 is returned on failure.
130 Upon success, the address of the string is returned, which will be
131 .Fa buf
132 if this was supplied.
133 .Sh SEE ALSO
134 .Xr kvm 3 ,
135 .Xr kvm_close 3 ,
136 .Xr kvm_getargv 3 ,
137 .Xr kvm_getenvv 3 ,
138 .Xr kvm_geterr 3 ,
139 .Xr kvm_getprocs 3 ,
140 .Xr kvm_nlist 3 ,
141 .Xr kvm_open 3 ,
142 .Xr kvm_openfiles 3