xref: /freebsd/lib/libkvm/kvm_getswapinfo.3 (revision c75526d5a0e2846c16a9bf0c4763664bf1e9dedf)
1e92324a2SMatthew Dillon.\" Copyright (c) 1999, Matthew Dillon.  All rights reserved.
2e92324a2SMatthew Dillon.\"
3e92324a2SMatthew Dillon.\" Redistribution and use in source and binary forms, with or without
4e92324a2SMatthew Dillon.\" modification, are permitted provided under the terms of the BSD
5e92324a2SMatthew Dillon.\" Copyright as found in /usr/src/COPYRIGHT in the FreeBSD source tree.
6e92324a2SMatthew Dillon.\"
77f3dea24SPeter Wemm.\" $FreeBSD$
8e92324a2SMatthew Dillon.\"
9e92324a2SMatthew Dillon.Dd January 22, 1999
10e92324a2SMatthew Dillon.Dt KVM_SWAPINFO 3
11e92324a2SMatthew Dillon.Os
12e92324a2SMatthew Dillon.Sh NAME
136a389e51SMatthew Dillon.Nm kvm_getswapinfo
14e92324a2SMatthew Dillon.Nd return swap summary statistics for the system
157f5e8c84SAlexey Zelkin.Sh LIBRARY
167f5e8c84SAlexey Zelkin.Lb libkvm
17e92324a2SMatthew Dillon.Sh SYNOPSIS
18e92324a2SMatthew Dillon.Fd #include <kvm.h>
19e92324a2SMatthew Dillon.Ft int
206a389e51SMatthew Dillon.Fn kvm_getswapinfo "kvm_t *kd" "struct kvm_swap *" "int maxswap" "int flags"
21e92324a2SMatthew Dillon.Sh DESCRIPTION
22e92324a2SMatthew DillonThe
236a389e51SMatthew Dillon.Fn kvm_getswapinfo
24d0353b83SRuslan Ermilovfunction fills an array of
25d0353b83SRuslan Ermilov.Vt kvm_swap
26d0353b83SRuslan Ermilovstructures with swap summary
27d0353b83SRuslan Ermilovinformation for each swap device, for up to
28d0353b83SRuslan Ermilov.Fa maxswap
29d0353b83SRuslan Ermilov\- 1 devices.
30d0353b83SRuslan ErmilovThe number of devices, up to
31d0353b83SRuslan Ermilov.Fa maxswap
32d0353b83SRuslan Ermilov\- 1, is returned.  A grand
33e92324a2SMatthew Dillontotal of all swap devices (including any devices that go beyond
34d0353b83SRuslan Ermilov.Fa maxswap
35d0353b83SRuslan Ermilov\- 1) is returned in one additional array entry.  This
36d0353b83SRuslan Ermiloventry is not counted in the return value.
37d0353b83SRuslan ErmilovThus, if you specify a
38d0353b83SRuslan Ermilov.Fa maxswap
39d0353b83SRuslan Ermilovvalue of 1, the function will typically return the
40d0353b83SRuslan Ermilovvalue 0 and the single
41d0353b83SRuslan Ermilov.Vt kvm_swap
42d0353b83SRuslan Ermilovstructure will be filled with
43e92324a2SMatthew Dillonthe grand total over all swap devices.  The grand total is calculated
44e92324a2SMatthew Dillonfrom all available swap devices whether or not you made room
45e92324a2SMatthew Dillonfor them all in the array.
46c75526d5SRuslan ErmilovThe grand total is returned.
47e92324a2SMatthew Dillon.Pp
48e92324a2SMatthew DillonThe flags argument is currently unused and must be passed as 0.
49e92324a2SMatthew Dillon.Pp
50e92324a2SMatthew DillonIf an error occurs, -1 is returned.
51e92324a2SMatthew Dillon.Pp
52d0353b83SRuslan ErmilovEach swap partition and the grand total is summarized in the
53d0353b83SRuslan Ermilov.Vt kvm_swap
54e92324a2SMatthew Dillonstructure.  This structure contains the following fields:
55d0353b83SRuslan Ermilov.Pp
56d0353b83SRuslan Ermilov.Bl -item -offset indent -compact
57d0353b83SRuslan Ermilov.It
58d0353b83SRuslan Ermilov.Va char ksw_devname[] ;
59d0353b83SRuslan Ermilov.It
60d0353b83SRuslan Ermilov.Va int ksw_total ;
61d0353b83SRuslan Ermilov.It
62d0353b83SRuslan Ermilov.Va int ksw_used ;
63d0353b83SRuslan Ermilov.It
64d0353b83SRuslan Ermilov.Va int ksw_flags ;
65e92324a2SMatthew Dillon.El
66e92324a2SMatthew Dillon.Pp
67d0353b83SRuslan ErmilovValues are in
68d0353b83SRuslan Ermilov.Dv PAGE_SIZE Ns 'd
69d0353b83SRuslan Ermilovchunks (see
70d0353b83SRuslan Ermilov.Xr getpagesize 3 ) .
71d0353b83SRuslan Ermilov.Va ksw_flags
72d0353b83SRuslan Ermilovcontains
73e92324a2SMatthew Dillona copy of the swap device flags.
74e92324a2SMatthew Dillon.Sh CACHING
75e92324a2SMatthew DillonThis function caches the nlist values for various kernel variables which
76d0353b83SRuslan Ermilovit reuses in successive calls.
77d0353b83SRuslan ErmilovYou may call the function with
78d0353b83SRuslan Ermilov.Fa kd
79d0353b83SRuslan Ermilov==
80d0353b83SRuslan Ermilov.Dv NULL
81e92324a2SMatthew Dillonto clear the cache.
82e92324a2SMatthew Dillon.Sh DIAGNOSTICS
83e92324a2SMatthew DillonIf the load average was unobtainable, \-1 is returned; otherwise,
84e92324a2SMatthew Dillonthe number of swap devices actually retrieved is returned.
85e92324a2SMatthew Dillon.Pp
86e92324a2SMatthew DillonIf the name of the swap device does not fit in the static char buffer
87e92324a2SMatthew Dillonin the structure, it is truncated.  The buffer is always zero terminated.
88e92324a2SMatthew Dillon.Sh SEE ALSO
89e92324a2SMatthew Dillon.Xr kvm 3
90