1.\" $NetBSD: kvm_dump.3,v 1.14 2009/03/10 23:49:07 joerg Exp $ 2.\" 3.\" Copyright (c) 1996 Leo Weppelman 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. All advertising materials mentioning features or use of this software 15.\" must display the following acknowledgement: 16.\" This product includes software developed by Leo Weppelman. 17.\" 4. Neither the name of the University nor the names of its contributors 18.\" may be used to endorse or promote products derived from this software 19.\" without specific prior written permission. 20.\" 21.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31.\" 32.\" 33.Dd March 17, 1996 34.Dt KVM_DUMP 3 35.Os 36.Sh NAME 37.Nm kvm_dump_mkheader , 38.Nm kvm_dump_wrtheader , 39.Nm kvm_dump_inval 40.Nd crash dump support functions 41.Sh LIBRARY 42.Lb libkvm 43.Sh SYNOPSIS 44.In kvm.h 45.Ft int 46.Fn kvm_dump_mkheader "kvm_t *kd" "off_t dump_off" 47.Ft int 48.Fn kvm_dump_wrtheader "kvm_t *kd" "FILE *fp" "int dumpsize" 49.Ft int 50.Fn kvm_dump_inval "kvm_t *kd" 51.Sh DESCRIPTION 52First note that the functions described here were designed to be used by 53.Xr savecore 8 . 54.Pp 55The function 56.Fn kvm_dump_mkheader 57checks if the physical memory file associated with 58.Fa kd 59contains a valid crash dump header as generated by a dumping kernel. 60When a valid header is found, 61.Fn kvm_dump_mkheader 62initializes the internal kvm data structures as if a crash dump generated by 63the 64.Xr savecore 8 65program was opened. 66This has the intentional side effect of enabling the 67address translation machinery. 68.Pp 69A call to 70.Fn kvm_dump_mkheader 71will most likely be followed by a call to 72.Fn kvm_dump_wrtheader . 73This function takes care of generating the generic header, the CORE_CPU 74section and the section header of the CORE_DATA section. 75The data is written to the file pointed at by 76.Fa fp . 77The 78.Fa dumpsize 79argument is only used to properly the set the segment size of the CORE_DATA 80section. 81Note that this function assumes that 82.Fa fp 83is positioned at file location 0. 84This function will not seek and therefore allows 85.Fa fp 86to be a file pointer obtained by 87.Fn zopen . 88.Pp 89The 90.Fn kvm_dump_inval 91function clears the magic number in the physical memory file associated with 92.Fa kd . 93The address translations must be enabled for this to work (thus assuming 94that 95.Fn kvm_dump_mkheader 96was called earlier in the sequence). 97.Sh RETURN VALUES 98All functions except 99.Fn kvm_dump_mkheader 100return 0 on success, -1 on failure. 101The function 102.Fn kvm_dump_mkheader 103returns the size of the headers present before the actual dumpdata starts. 104If no valid headers were found but no fatal errors occurred, 0 is returned. 105On fatal errors the return value is -1. 106.Pp 107In the case of failure, 108.Xr kvm_geterr 3 109can be used to retrieve the cause of the error. 110.Sh SEE ALSO 111.Xr kvm 3 , 112.Xr kvm_open 3 113.Sh HISTORY 114These functions first appeared in 115.Nx 1.2 . 116