]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - lib/libkvm/kvm_getswapinfo.3
MFC r362623:
[FreeBSD/stable/10.git] / lib / libkvm / kvm_getswapinfo.3
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 2, 2017
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
39 The
40 .Fn kvm_getswapinfo
41 function fills an array of
42 .Vt kvm_swap
43 structures with swap summary
44 information for each swap device, for up to
45 .Fa maxswap
46 \- 1 devices.
47 The number of devices, up to
48 .Fa maxswap
49 \- 1, is returned.
50 A grand
51 total of all swap devices (including any devices that go beyond
52 .Fa maxswap
53 \- 1) is returned in one additional array entry.
54 This
55 entry is not counted in the return value.
56 Thus, if you specify a
57 .Fa maxswap
58 value of 1, the function will typically return the
59 value 0 and the single
60 .Vt kvm_swap
61 structure will be filled with
62 the grand total over all swap devices.
63 The grand total is calculated
64 from all available swap devices whether or not you made room
65 for them all in the array.
66 The grand total is returned.
67 .Pp
68 The flags argument is currently unused and must be passed as 0.
69 .Pp
70 If an error occurs, -1 is returned.
71 .Pp
72 Each swap partition and the grand total is summarized in the
73 .Vt kvm_swap
74 structure.
75 This structure contains the following fields:
76 .Pp
77 .Bl -item -offset indent -compact
78 .It
79 .Va char ksw_devname[] ;
80 .It
81 .Va u_int ksw_total ;
82 .It
83 .Va u_int ksw_used ;
84 .It
85 .Va int ksw_flags ;
86 .El
87 .Pp
88 Values are in
89 .Dv PAGE_SIZE Ns 'd
90 chunks (see
91 .Xr getpagesize 3 ) .
92 .Va ksw_flags
93 contains
94 a copy of the swap device flags.
95 .Sh CACHING
96 This function caches the nlist values for various kernel variables which
97 it reuses in successive calls.
98 You may call the function with
99 .Fa kd
100 ==
101 .Dv NULL
102 to clear the cache.
103 .Sh DIAGNOSTICS
104 If the swap summary information was unobtainable, \-1 is returned;
105 otherwise, the number of swap devices actually retrieved is returned.
106 .Pp
107 If the name of the swap device does not fit in the static char buffer
108 in the structure, it is truncated.
109 The buffer is always zero terminated.
110 .Sh SEE ALSO
111 .Xr kvm 3