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: src/lib/libkvm/kvm_getswapinfo.3,v 1.5.2.6 2001/12/17 10:08:30 ru Exp $ 8.\" $DragonFly: src/lib/libkvm/kvm_getswapinfo.3,v 1.3 2004/06/28 02:57:10 drhodus Exp $ 9.\" 10.Dd January 22, 1999 11.Dt KVM_SWAPINFO 3 12.Os 13.Sh NAME 14.Nm kvm_getswapinfo 15.Nd return swap summary statistics for the system 16.Sh LIBRARY 17.Lb libkvm 18.Sh SYNOPSIS 19.In sys/types.h 20.In kvm.h 21.Ft int 22.Fn kvm_getswapinfo "kvm_t *kd" "struct kvm_swap *" "int maxswap" "int flags" 23.Sh DESCRIPTION 24The 25.Fn kvm_getswapinfo 26function fills an array of 27.Vt kvm_swap 28structures with swap summary 29information for each swap device, for up to 30.Fa maxswap 31\- 1 devices. 32The number of devices, up to 33.Fa maxswap 34\- 1, is returned. A grand 35total of all swap devices (including any devices that go beyond 36.Fa maxswap 37\- 1) is returned in one additional array entry. This 38entry is not counted in the return value. 39Thus, if you specify a 40.Fa maxswap 41value of 1, the function will typically return the 42value 0 and the single 43.Vt kvm_swap 44structure will be filled with 45the grand total over all swap devices. The grand total is calculated 46from all available swap devices whether or not you made room 47for them all in the array. 48The grand total is returned. 49.Pp 50The flags argument is currently unused and must be passed as 0. 51.Pp 52If an error occurs, -1 is returned. 53.Pp 54Each swap partition and the grand total is summarized in the 55.Vt kvm_swap 56structure. This structure contains the following fields: 57.Pp 58.Bl -item -offset indent -compact 59.It 60.Va char ksw_devname[] ; 61.It 62.Va int ksw_total ; 63.It 64.Va int ksw_used ; 65.It 66.Va int ksw_flags ; 67.El 68.Pp 69Values are in 70.Dv PAGE_SIZE Ns 'd 71chunks (see 72.Xr getpagesize 3 ) . 73.Va ksw_flags 74contains 75a copy of the swap device flags. 76.Sh CACHING 77This function caches the nlist values for various kernel variables which 78it reuses in successive calls. 79You may call the function with 80.Fa kd 81== 82.Dv NULL 83to clear the cache. 84.Sh DIAGNOSTICS 85If the load average was unobtainable, \-1 is returned; otherwise, 86the number of swap devices actually retrieved is returned. 87.Pp 88If the name of the swap device does not fit in the static char buffer 89in the structure, it is truncated. The buffer is always zero terminated. 90.Sh SEE ALSO 91.Xr kvm 3 92