xref: /freebsd/lib/libkvm/kvm_getswapinfo.3 (revision daf1cffce2e07931f27c6c6998652e90df6ba87e)
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 under the terms of the BSD
5.\" Copyright as found in /usr/src/COPYRIGHT in the FreeBSD source tree.
6.\"
7.\" $FreeBSD$
8.\"
9.Dd January 22, 1999
10.Dt KVM_SWAPINFO 3
11.Os
12.Sh NAME
13.Nm kvm_getswapinfo
14.Nd return swap summary statistics for the system
15.Sh SYNOPSIS
16.Fd #include <kvm.h>
17.Ft int
18.Fn kvm_getswapinfo "kvm_t *kd" "struct kvm_swap *" "int maxswap" "int flags"
19.Sh DESCRIPTION
20The
21.Fn kvm_getswapinfo
22function fills an array of kvm_swap structures with swap summary
23information for each swap device, for up to maxswap - 1 devices.
24The number of devices, up to maxswap - 1, is returned.  A grand
25total of all swap devices ( including any devices that go beyond
26maxswap - 1 ) is returned in one additional array entry.  This
27entry is not counted in the return value.  Thus, if you specify
28a maxswap value of 1, the function will typically return the
29value 0 and the single kvm_swap structure will be filled with
30the grand total over all swap devices.  The grand total is calculated
31from all available swap devices whether or not you made room
32for them all in the array.
33the grant total is returned.
34.Pp
35The flags argument is currently unused and must be passed as 0.
36.Pp
37If an error occurs, -1 is returned.
38.Pp
39Each swap partition and the grand total is summarized in the kvm_swap
40structure.  This structure contains the following fields:
41.Bl -inset -width indent
42.It char ksw_devname[];
43.It int ksw_total;
44.It int ksw_used;
45.It int ksw_flags;
46.El
47.Pp
48Values are in PAGE_SIZE'd chunks ( see getpagesize() ).  ksw_flags contains
49a copy of the swap device flags.
50.Pp
51.Sh CACHING
52This function caches the nlist values for various kernel variables which
53it reuses in successive calls.  You may call the function with kd == NULL
54to clear the cache.
55.Sh DIAGNOSTICS
56If the load average was unobtainable, \-1 is returned; otherwise,
57the number of swap devices actually retrieved is returned.
58.Pp
59If the name of the swap device does not fit in the static char buffer
60in the structure, it is truncated.  The buffer is always zero terminated.
61.Sh SEE ALSO
62.Xr kvm 3
63