xref: /freebsd/lib/libkvm/kvm_getswapinfo.3 (revision f4b37ed0f8b307b1f3f0f630ca725d68f1dff30d)
1.\" Copyright (C) 1999 Matthew Dillon. All rights reserved.
2.\"
3.\" Redistribution and use in source and binary forms, with or without
4.\" modification, are permitted provided that the following conditions
5.\" are met:
6.\" 1. Redistributions of source code must retain the above copyright
7.\"    notice, this list of conditions and the following disclaimer.
8.\" 2. Redistributions in binary form must reproduce the above copyright
9.\"    notice, this list of conditions and the following disclaimer in the
10.\"    documentation and/or other materials provided with the distribution.
11.\"
12.\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15.\" ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
16.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22.\" SUCH DAMAGE.
23.\"
24.\" $FreeBSD$
25.\"
26.Dd January 22, 1999
27.Dt KVM_SWAPINFO 3
28.Os
29.Sh NAME
30.Nm kvm_getswapinfo
31.Nd return swap summary statistics for the system
32.Sh LIBRARY
33.Lb libkvm
34.Sh SYNOPSIS
35.In kvm.h
36.Ft int
37.Fn kvm_getswapinfo "kvm_t *kd" "struct kvm_swap *" "int maxswap" "int flags"
38.Sh DESCRIPTION
39The
40.Fn kvm_getswapinfo
41function fills an array of
42.Vt kvm_swap
43structures with swap summary
44information for each swap device, for up to
45.Fa maxswap
46\- 1 devices.
47The number of devices, up to
48.Fa maxswap
49\- 1, is returned.
50A grand
51total of all swap devices (including any devices that go beyond
52.Fa maxswap
53\- 1) is returned in one additional array entry.
54This
55entry is not counted in the return value.
56Thus, if you specify a
57.Fa maxswap
58value of 1, the function will typically return the
59value 0 and the single
60.Vt kvm_swap
61structure will be filled with
62the grand total over all swap devices.
63The grand total is calculated
64from all available swap devices whether or not you made room
65for them all in the array.
66The grand total is returned.
67.Pp
68The flags argument is currently unused and must be passed as 0.
69.Pp
70If an error occurs, -1 is returned.
71.Pp
72Each swap partition and the grand total is summarized in the
73.Vt kvm_swap
74structure.
75This structure contains the following fields:
76.Pp
77.Bl -item -offset indent -compact
78.It
79.Va char ksw_devname[] ;
80.It
81.Va int ksw_total ;
82.It
83.Va int ksw_used ;
84.It
85.Va int ksw_flags ;
86.El
87.Pp
88Values are in
89.Dv PAGE_SIZE Ns 'd
90chunks (see
91.Xr getpagesize 3 ) .
92.Va ksw_flags
93contains
94a copy of the swap device flags.
95.Sh CACHING
96This function caches the nlist values for various kernel variables which
97it reuses in successive calls.
98You may call the function with
99.Fa kd
100==
101.Dv NULL
102to clear the cache.
103.Sh DIAGNOSTICS
104If the load average was unobtainable, \-1 is returned; otherwise,
105the number of swap devices actually retrieved is returned.
106.Pp
107If the name of the swap device does not fit in the static char buffer
108in the structure, it is truncated.
109The buffer is always zero terminated.
110.Sh SEE ALSO
111.Xr kvm 3
112