History log of /netbsd-current/sbin/savecore/savecore.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.90 03-Apr-2020 maxv

Avoid overflows when reading strings.


Revision tags: phil-wifi-20191119
# 1.89 06-Nov-2019 mrg

elide recently introduced warnings that trigger in normal cases, eg:

savecore: dump_exists:471: kvm_read newdumpmag: _kvm_kvatop(ffffffff8180030c)


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.88 27-Dec-2018 mrg

avoid infinite loop in kmem_check(). fixes bug introduced in previous.


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126
# 1.87 06-Nov-2018 mrg

put a bunch of the kvm_read + warn on failure code into a macro that
describes more about what failed. now errors tell you which actual
variable was being requested instead of simply saying "not yours".

tested on amd64 as working. written for arm64 testing.


Revision tags: netbsd-8-2-RELEASE netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base tls-maxphys-base
# 1.86 13-May-2013 christos

branches: 1.86.26; 1.86.28;
- avoid using globals where it is simple.
- simplify: only use stdio for output.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.85 07-Apr-2012 christos

branches: 1.85.2;
factor out rawname() from dump, fsck, savecore.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.84 13-Sep-2011 christos

branches: 1.84.2;
print the missing flag if missing argument...


# 1.83 12-Sep-2011 christos

- always print corrupted dump messages instead of silently failing
- don't require /var/crash to be specified, default to it
- determine and print the kernel name
- print all messages to syslog


# 1.82 29-Aug-2011 joerg

static + __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.81 18-Aug-2009 dogcow

Instead of exiting with an obscure error message if -N /kernelname isn't
specified, blithely assume the kernel will consume around 20 megs.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.80 06-Apr-2009 lukem

fix sign-compare issues


# 1.79 21-Mar-2009 tls

Fix savecore so it uses /dev/ksyms when it can (doesn't override libkvm
default). Fixes misc/38425.


Revision tags: mjf-devfs2-base
# 1.78 28-Dec-2008 christos

branches: 1.78.2;
fix dev_t format.


# 1.77 05-Dec-2008 ad

Enable the faked ELF kernel by default, now that ksyms output works with
gdb. Makes it possible to do post-mortem debugging on a modular kernel.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.76 20-Oct-2008 ad

branches: 1.76.2;
- Add code to produce a fake ELF kernel containing only symbol info. Done
by extracting ksyms state from the dump, so we have symbols for modules
loaded at the time of the crash. If ksyms extraction fails, this falls
back to the current behaviour of copying /netbsd.

- Leave it disabled for the moment: (1) we are about to branch (2) most
tools understand the artificial kernel but gdb has trouble with it for
some reason.


# 1.75 09-Oct-2008 joerg

Explicitly check that the dump device is not the console, a tty or pty.
While the list is adhoc, the problems reported are always with
/dev/console. Adresses PR 38425 and similiar issues with Xen.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.74 20-Jul-2008 lukem

Remove the \n and tabs from the __COPYRIGHT() strings.
(Tweak some to use a consistent format.)


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.73 20-Apr-2008 ad

branches: 1.73.2;
sync() a couple of times to benefit diagnosis of sloppy kernel code that
crashes during boot to multiuser.


Revision tags: yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.72 15-Jan-2008 ad

branches: 1.72.4; 1.72.6;
Don't use the block device to read crashdumps, if possible.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.71 12-Nov-2007 pooka

branches: 1.71.2;
tyop: _time_seconf -> _time_second


Revision tags: matt-armv6-prevmlocking matt-mips64-base
# 1.70 18-Dec-2006 christos

branches: 1.70.4;
from Anon Ymous: remove (void)&var;


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.69 16-Oct-2006 christos

c99 initializers


Revision tags: abandoned-netbsd-4-base
# 1.68 09-Jul-2006 kardel

accept either "time_second" or "time" as kernel timevariable in
order to support common userland in enviroments where
timecounter kernels and non timecounter kernel co-exist
(e.g. xen & i386)


# 1.67 07-Jun-2006 kardel

support timecounters (struct time gone, use time_second then)


Revision tags: simonb-timecounters-base
# 1.66 17-Mar-2006 hubertf

Free some allocated memory in the failure case when trying to
fetch the panic string.

Fixes Coverity CID 1856.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.65 16-Oct-2004 dsainty

branches: 1.65.6;
Added -n option, which tests for a present core but doesn't write it
to disk or clear it (does 'nothing').

http://mail-index.netbsd.org/tech-userlevel/2004/10/09/0000.html


# 1.64 14-Jul-2004 tls

Fix an integer overflow that prevented saving cores from machines with
more than 2GB of RAM.

"dumpsize" in the on-disk core header is in pages, but, unfortunately,
c.size in our kcore format is an unsigned 32-bit int, gross.

We sleaze it, using a 64-bit int internally here and handing it to
libkvm as a *signed* 32-bit int. Won't always work, but shouldn't be
broken any worse than it is now, and sometimes work better.

We must fix the kcore format and libkvm.


# 1.63 21-Apr-2004 christos

Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.


# 1.62 30-Mar-2004 christos

Give a 60 day leeway instead of a week when judging if the dumptime is valid.
7 days is too short when you are debugging time problems.


Revision tags: netbsd-2-0-base
# 1.61 07-Aug-2003 agc

branches: 1.61.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.


# 1.60 18-May-2003 itojun

simplify by strlcpy


Revision tags: fvdl_fs64_base
# 1.59 06-Dec-2002 thorpej

Remove prototype for non-existent function log().


# 1.58 27-Sep-2002 drochner

use humanize_number(3) for progress printout


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.57 19-Mar-2002 christos

branches: 1.57.2;
PR/15502: Wolfgang Rupprecht: savecore fails for > 2GB files.


# 1.56 06-Mar-2002 tsutsui

Change type of dumpmag and newdumpmag from int to u_int32_t
since they hold 32bit unsigned magic numbers. (sync with kernels)


# 1.55 01-Nov-2001 lukem

fix a couple of -Wshadow warnings


# 1.54 12-Sep-2001 lukem

explicitly set the default compression level to 1 (from the implicit 6),
because it's significantly faster and doesn't use that much more disk space.


# 1.53 12-Sep-2001 lukem

Add "-Z level" to control the compression level that -z uses (which
defaults to -Z 6). Depending on the relative speed of the CPU
versus disk, "-zZ1" might be faster than no compression at all.


# 1.52 13-Jun-2001 wiz

Use getbootfile(3) instead of _PATH_UNIX by default.
Sprinkle some const.


# 1.51 06-May-2001 simonb

If the position of the formatted panic string can be found in the
message buffer, use that instead of the raw panic string.

Suggested by Jason Thorpe eons ago.


# 1.50 11-Jan-2001 martin

Make option flag variables static. This avoids a conflict between
'int compress' in savecore.c and the function 'compress' in libz.
Gnu ld 2.10 (with BFD 2.10) used on sparc64 warns this conflict
(symbol "compress" changed size).


# 1.49 02-Jan-2001 joda

use gzip instead of compress


# 1.48 02-Jan-2001 lukem

Bump the field width of `K to go' from 6 to 8; some systems have more
than 999999 KB of RAM... (this will suffice until it's common to have
~ 100 GB of RAM :)


# 1.47 11-Dec-2000 wiz

Back out sysctl part for now, awaiting the result of further discussion,
on request of Andrew Doran.


# 1.46 08-Dec-2000 wiz

Output proper warning if dumplo == -1 (as it can happen on macppc without
swap partition), instead of "kvm_dump_mkheader: Pread: Invalid argument".


# 1.45 07-Dec-2000 wiz

de-__P(), and generally try to be more conforming to the new NetBSD style.
Use %m in syslog strings where appropriate.
Reduce warnings with WARNS=2.


# 1.44 07-Dec-2000 wiz

Fix argument handling, which was pretty broken.
If sysctl supports it, try to get the kernel name with CPU_BOOTED_KERNEL.
Get current kernels version string in all cases.
Adapt some error messages to the correct kernel name.
Reviewed by Simon Burge.


# 1.43 08-Oct-2000 darrenr

initialize kernel to _PATH_UNIX and remove local variables in functions
which are essentially copies of kernel.


# 1.42 01-Oct-2000 darrenr

savecore was looking up dumpdev, etc, from the wrong kernel


# 1.41 01-Aug-2000 eeh

time is a `struct timeval' not a `time_t', so read it in properly.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.40 02-Aug-1999 mycroft

branches: 1.40.8;
s/on device/in [dirname]/, to be a bit clearer...


# 1.39 01-Jul-1999 cgd

Remove an extraneous fclose() call which would cause savecore to crash
if the bounds file was unwritable (e.g. because /var was read-only).
Fix supplied by Ronald Khoo in PR#7887.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 1.38 27-Feb-1999 sommerfe

branches: 1.38.2;
Crash dumps should *not* be world readable.


# 1.37 23-Jul-1998 sommerfe

Avoid truncating partition size in freespace calculation


# 1.36 01-Apr-1998 kleink

Need <time.h> for time() and ctime() prototypes.


# 1.35 18-Feb-1998 thorpej

Avoid


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.34 16-Sep-1997 lukem

resolve conflicts from lite-2 merge


# 1.33 16-Sep-1997 mrg

make these compile on the alpha after WARNS=1.


# 1.32 15-Sep-1997 lukem

* cleanup for WARNS=1
* fix .Nm usage
* deprecate register


# 1.31 25-Aug-1997 kleink

Lseek(2) usage cleanup: the use of L_SET/L_INCR/L_XTND is deprecated,
use SEEK_SET/SEEK_CUR/SEEK_END instead.


# 1.30 19-May-1997 pk

More error checking.


# 1.29 21-Apr-1997 mrg

set umask for savecore.


# 1.28 01-Oct-1996 cgd

make datas item copied out from kernel (panicstr) and/or used as kvm pointers
(panicloc) be 'long's, not 'int's.


# 1.27 23-Jun-1996 leo

If kvm_dump_mkheader() returns 0, simply state 'no core dump' instead
of logging and error.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.26 18-Mar-1996 leo

Omit kd_live argument to kvm_dump_mkheader().


# 1.25 16-Mar-1996 leo

New libkvm/savecore implementation. With the following differences:
1) savecore will not access the dump or live-kernel directly. It
will always use the kvm-functions. Allowing it to work on kernels
that don't have a 1-1 PA-VA mapping.
2) the kvm-lib has some additional functions to accomplish 1
- kvm_dump_mkheader()
- kvm_dump_wrtheader()
- kvm_dump_inval()
3) the file formats of the dump generated by the kernel and the dump
generated by savecore have been changed. The file format now looks
like the format produced for 'normal' core dumps.
Ports not yet supporting the new kvm-format will be using libkvm.old/
savecore.old for the time being.


# 1.24 08-Mar-1996 mycroft

Put the compression suffix *last*.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.23 24-Jul-1995 cgd

set dumpsize in dump_exists(), not save_core(), so that minfree check
works again. solves pr 1257, but sets dumpsize earlier than suggested
in that pr, so that dumpsize is set if a core doesn't appear to be
present (because dumpsize would be used if the '-f' flag is given).


# 1.22 25-Jun-1995 cgd

fix verbose printf of dumplo, clean up printfs slightly


# 1.21 18-Mar-1995 cgd

convert to new RCS Id conventions; reduce my headache


# 1.20 04-Jan-1995 mycroft

Fix getopt string and test on return value.


# 1.19 31-Oct-1994 cgd

oops; get rid of previous (iffy) zopen declaration


# 1.18 31-Oct-1994 cgd

make a proto for zopen (yech)


# 1.17 23-Sep-1994 mycroft

Eliminate uses of some obsolete functions.


# 1.16 18-Sep-1994 deraadt

prototype zopen()
NBPG --> getpagesize()


# 1.15 17-Sep-1994 mycroft

vmunix --> kernel (for variable names), and make the core file naming
convention match that of other executables.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.14 11-Jun-1994 mycroft

Fix up RCS ids.


# 1.13 10-Jun-1994 pk

Update to 4.4-lite, local changes to man page.


# 1.12 31-May-1994 pk

Initialize return value from save_core() in case dumpsize == 0.


# 1.11 27-May-1994 pk

Don't clear dump if writing it to the filesystem fails (eg. file system full)


# 1.10 21-Apr-1994 cgd

queue/struct changes


# 1.9 06-Apr-1994 cgd

kill two casts


# 1.8 06-Apr-1994 cgd

serious perversion:
most of the 'off' arguments to Lseek() (the internal lseek() wrapper)
are unsigned longs. we need them to be sign extended, though, so change
Lseek() to take a 'long' rather than an 'off_t', and let the compiler
do the dirty work via implicit casts.


# 1.7 04-Apr-1994 cgd

lseek stuff, and clean up. this is perverse.


# 1.6 14-Feb-1994 cgd

correct ok() calculation for all architectures.


# 1.5 08-Dec-1993 pk

Check for dumpdev being NODEV. If so, exit silently, unless verbose is on.


# 1.4 01-Aug-1993 mycroft

Add RCS identifiers.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base netbsd-0-8 netbsd-alpha-1
# 1.3 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.89 06-Nov-2019 mrg

elide recently introduced warnings that trigger in normal cases, eg:

savecore: dump_exists:471: kvm_read newdumpmag: _kvm_kvatop(ffffffff8180030c)


Revision tags: netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.88 27-Dec-2018 mrg

avoid infinite loop in kmem_check(). fixes bug introduced in previous.


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126
# 1.87 06-Nov-2018 mrg

put a bunch of the kvm_read + warn on failure code into a macro that
describes more about what failed. now errors tell you which actual
variable was being requested instead of simply saying "not yours".

tested on amd64 as working. written for arm64 testing.


Revision tags: netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base tls-maxphys-base
# 1.86 13-May-2013 christos

branches: 1.86.26; 1.86.28;
- avoid using globals where it is simple.
- simplify: only use stdio for output.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.85 07-Apr-2012 christos

branches: 1.85.2;
factor out rawname() from dump, fsck, savecore.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.84 13-Sep-2011 christos

branches: 1.84.2;
print the missing flag if missing argument...


# 1.83 12-Sep-2011 christos

- always print corrupted dump messages instead of silently failing
- don't require /var/crash to be specified, default to it
- determine and print the kernel name
- print all messages to syslog


# 1.82 29-Aug-2011 joerg

static + __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.81 18-Aug-2009 dogcow

Instead of exiting with an obscure error message if -N /kernelname isn't
specified, blithely assume the kernel will consume around 20 megs.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.80 06-Apr-2009 lukem

fix sign-compare issues


# 1.79 21-Mar-2009 tls

Fix savecore so it uses /dev/ksyms when it can (doesn't override libkvm
default). Fixes misc/38425.


Revision tags: mjf-devfs2-base
# 1.78 28-Dec-2008 christos

branches: 1.78.2;
fix dev_t format.


# 1.77 05-Dec-2008 ad

Enable the faked ELF kernel by default, now that ksyms output works with
gdb. Makes it possible to do post-mortem debugging on a modular kernel.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.76 20-Oct-2008 ad

branches: 1.76.2;
- Add code to produce a fake ELF kernel containing only symbol info. Done
by extracting ksyms state from the dump, so we have symbols for modules
loaded at the time of the crash. If ksyms extraction fails, this falls
back to the current behaviour of copying /netbsd.

- Leave it disabled for the moment: (1) we are about to branch (2) most
tools understand the artificial kernel but gdb has trouble with it for
some reason.


# 1.75 09-Oct-2008 joerg

Explicitly check that the dump device is not the console, a tty or pty.
While the list is adhoc, the problems reported are always with
/dev/console. Adresses PR 38425 and similiar issues with Xen.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.74 20-Jul-2008 lukem

Remove the \n and tabs from the __COPYRIGHT() strings.
(Tweak some to use a consistent format.)


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.73 20-Apr-2008 ad

branches: 1.73.2;
sync() a couple of times to benefit diagnosis of sloppy kernel code that
crashes during boot to multiuser.


Revision tags: yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.72 15-Jan-2008 ad

branches: 1.72.4; 1.72.6;
Don't use the block device to read crashdumps, if possible.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.71 12-Nov-2007 pooka

branches: 1.71.2;
tyop: _time_seconf -> _time_second


Revision tags: matt-armv6-prevmlocking matt-mips64-base
# 1.70 18-Dec-2006 christos

branches: 1.70.4;
from Anon Ymous: remove (void)&var;


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.69 16-Oct-2006 christos

c99 initializers


Revision tags: abandoned-netbsd-4-base
# 1.68 09-Jul-2006 kardel

accept either "time_second" or "time" as kernel timevariable in
order to support common userland in enviroments where
timecounter kernels and non timecounter kernel co-exist
(e.g. xen & i386)


# 1.67 07-Jun-2006 kardel

support timecounters (struct time gone, use time_second then)


Revision tags: simonb-timecounters-base
# 1.66 17-Mar-2006 hubertf

Free some allocated memory in the failure case when trying to
fetch the panic string.

Fixes Coverity CID 1856.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.65 16-Oct-2004 dsainty

branches: 1.65.6;
Added -n option, which tests for a present core but doesn't write it
to disk or clear it (does 'nothing').

http://mail-index.netbsd.org/tech-userlevel/2004/10/09/0000.html


# 1.64 14-Jul-2004 tls

Fix an integer overflow that prevented saving cores from machines with
more than 2GB of RAM.

"dumpsize" in the on-disk core header is in pages, but, unfortunately,
c.size in our kcore format is an unsigned 32-bit int, gross.

We sleaze it, using a 64-bit int internally here and handing it to
libkvm as a *signed* 32-bit int. Won't always work, but shouldn't be
broken any worse than it is now, and sometimes work better.

We must fix the kcore format and libkvm.


# 1.63 21-Apr-2004 christos

Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.


# 1.62 30-Mar-2004 christos

Give a 60 day leeway instead of a week when judging if the dumptime is valid.
7 days is too short when you are debugging time problems.


Revision tags: netbsd-2-0-base
# 1.61 07-Aug-2003 agc

branches: 1.61.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.


# 1.60 18-May-2003 itojun

simplify by strlcpy


Revision tags: fvdl_fs64_base
# 1.59 06-Dec-2002 thorpej

Remove prototype for non-existent function log().


# 1.58 27-Sep-2002 drochner

use humanize_number(3) for progress printout


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.57 19-Mar-2002 christos

branches: 1.57.2;
PR/15502: Wolfgang Rupprecht: savecore fails for > 2GB files.


# 1.56 06-Mar-2002 tsutsui

Change type of dumpmag and newdumpmag from int to u_int32_t
since they hold 32bit unsigned magic numbers. (sync with kernels)


# 1.55 01-Nov-2001 lukem

fix a couple of -Wshadow warnings


# 1.54 12-Sep-2001 lukem

explicitly set the default compression level to 1 (from the implicit 6),
because it's significantly faster and doesn't use that much more disk space.


# 1.53 12-Sep-2001 lukem

Add "-Z level" to control the compression level that -z uses (which
defaults to -Z 6). Depending on the relative speed of the CPU
versus disk, "-zZ1" might be faster than no compression at all.


# 1.52 13-Jun-2001 wiz

Use getbootfile(3) instead of _PATH_UNIX by default.
Sprinkle some const.


# 1.51 06-May-2001 simonb

If the position of the formatted panic string can be found in the
message buffer, use that instead of the raw panic string.

Suggested by Jason Thorpe eons ago.


# 1.50 11-Jan-2001 martin

Make option flag variables static. This avoids a conflict between
'int compress' in savecore.c and the function 'compress' in libz.
Gnu ld 2.10 (with BFD 2.10) used on sparc64 warns this conflict
(symbol "compress" changed size).


# 1.49 02-Jan-2001 joda

use gzip instead of compress


# 1.48 02-Jan-2001 lukem

Bump the field width of `K to go' from 6 to 8; some systems have more
than 999999 KB of RAM... (this will suffice until it's common to have
~ 100 GB of RAM :)


# 1.47 11-Dec-2000 wiz

Back out sysctl part for now, awaiting the result of further discussion,
on request of Andrew Doran.


# 1.46 08-Dec-2000 wiz

Output proper warning if dumplo == -1 (as it can happen on macppc without
swap partition), instead of "kvm_dump_mkheader: Pread: Invalid argument".


# 1.45 07-Dec-2000 wiz

de-__P(), and generally try to be more conforming to the new NetBSD style.
Use %m in syslog strings where appropriate.
Reduce warnings with WARNS=2.


# 1.44 07-Dec-2000 wiz

Fix argument handling, which was pretty broken.
If sysctl supports it, try to get the kernel name with CPU_BOOTED_KERNEL.
Get current kernels version string in all cases.
Adapt some error messages to the correct kernel name.
Reviewed by Simon Burge.


# 1.43 08-Oct-2000 darrenr

initialize kernel to _PATH_UNIX and remove local variables in functions
which are essentially copies of kernel.


# 1.42 01-Oct-2000 darrenr

savecore was looking up dumpdev, etc, from the wrong kernel


# 1.41 01-Aug-2000 eeh

time is a `struct timeval' not a `time_t', so read it in properly.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.40 02-Aug-1999 mycroft

branches: 1.40.8;
s/on device/in [dirname]/, to be a bit clearer...


# 1.39 01-Jul-1999 cgd

Remove an extraneous fclose() call which would cause savecore to crash
if the bounds file was unwritable (e.g. because /var was read-only).
Fix supplied by Ronald Khoo in PR#7887.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 1.38 27-Feb-1999 sommerfe

branches: 1.38.2;
Crash dumps should *not* be world readable.


# 1.37 23-Jul-1998 sommerfe

Avoid truncating partition size in freespace calculation


# 1.36 01-Apr-1998 kleink

Need <time.h> for time() and ctime() prototypes.


# 1.35 18-Feb-1998 thorpej

Avoid


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.34 16-Sep-1997 lukem

resolve conflicts from lite-2 merge


# 1.33 16-Sep-1997 mrg

make these compile on the alpha after WARNS=1.


# 1.32 15-Sep-1997 lukem

* cleanup for WARNS=1
* fix .Nm usage
* deprecate register


# 1.31 25-Aug-1997 kleink

Lseek(2) usage cleanup: the use of L_SET/L_INCR/L_XTND is deprecated,
use SEEK_SET/SEEK_CUR/SEEK_END instead.


# 1.30 19-May-1997 pk

More error checking.


# 1.29 21-Apr-1997 mrg

set umask for savecore.


# 1.28 01-Oct-1996 cgd

make datas item copied out from kernel (panicstr) and/or used as kvm pointers
(panicloc) be 'long's, not 'int's.


# 1.27 23-Jun-1996 leo

If kvm_dump_mkheader() returns 0, simply state 'no core dump' instead
of logging and error.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.26 18-Mar-1996 leo

Omit kd_live argument to kvm_dump_mkheader().


# 1.25 16-Mar-1996 leo

New libkvm/savecore implementation. With the following differences:
1) savecore will not access the dump or live-kernel directly. It
will always use the kvm-functions. Allowing it to work on kernels
that don't have a 1-1 PA-VA mapping.
2) the kvm-lib has some additional functions to accomplish 1
- kvm_dump_mkheader()
- kvm_dump_wrtheader()
- kvm_dump_inval()
3) the file formats of the dump generated by the kernel and the dump
generated by savecore have been changed. The file format now looks
like the format produced for 'normal' core dumps.
Ports not yet supporting the new kvm-format will be using libkvm.old/
savecore.old for the time being.


# 1.24 08-Mar-1996 mycroft

Put the compression suffix *last*.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.23 24-Jul-1995 cgd

set dumpsize in dump_exists(), not save_core(), so that minfree check
works again. solves pr 1257, but sets dumpsize earlier than suggested
in that pr, so that dumpsize is set if a core doesn't appear to be
present (because dumpsize would be used if the '-f' flag is given).


# 1.22 25-Jun-1995 cgd

fix verbose printf of dumplo, clean up printfs slightly


# 1.21 18-Mar-1995 cgd

convert to new RCS Id conventions; reduce my headache


# 1.20 04-Jan-1995 mycroft

Fix getopt string and test on return value.


# 1.19 31-Oct-1994 cgd

oops; get rid of previous (iffy) zopen declaration


# 1.18 31-Oct-1994 cgd

make a proto for zopen (yech)


# 1.17 23-Sep-1994 mycroft

Eliminate uses of some obsolete functions.


# 1.16 18-Sep-1994 deraadt

prototype zopen()
NBPG --> getpagesize()


# 1.15 17-Sep-1994 mycroft

vmunix --> kernel (for variable names), and make the core file naming
convention match that of other executables.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.14 11-Jun-1994 mycroft

Fix up RCS ids.


# 1.13 10-Jun-1994 pk

Update to 4.4-lite, local changes to man page.


# 1.12 31-May-1994 pk

Initialize return value from save_core() in case dumpsize == 0.


# 1.11 27-May-1994 pk

Don't clear dump if writing it to the filesystem fails (eg. file system full)


# 1.10 21-Apr-1994 cgd

queue/struct changes


# 1.9 06-Apr-1994 cgd

kill two casts


# 1.8 06-Apr-1994 cgd

serious perversion:
most of the 'off' arguments to Lseek() (the internal lseek() wrapper)
are unsigned longs. we need them to be sign extended, though, so change
Lseek() to take a 'long' rather than an 'off_t', and let the compiler
do the dirty work via implicit casts.


# 1.7 04-Apr-1994 cgd

lseek stuff, and clean up. this is perverse.


# 1.6 14-Feb-1994 cgd

correct ok() calculation for all architectures.


# 1.5 08-Dec-1993 pk

Check for dumpdev being NODEV. If so, exit silently, unless verbose is on.


# 1.4 01-Aug-1993 mycroft

Add RCS identifiers.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base netbsd-0-8 netbsd-alpha-1
# 1.3 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.88 27-Dec-2018 mrg

avoid infinite loop in kmem_check(). fixes bug introduced in previous.


Revision tags: pgoyette-compat-1226 pgoyette-compat-1126
# 1.87 06-Nov-2018 mrg

put a bunch of the kvm_read + warn on failure code into a macro that
describes more about what failed. now errors tell you which actual
variable was being requested instead of simply saying "not yours".

tested on amd64 as working. written for arm64 testing.


Revision tags: netbsd-8-1-RC1 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base tls-maxphys-base
# 1.86 13-May-2013 christos

branches: 1.86.26;
- avoid using globals where it is simple.
- simplify: only use stdio for output.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6 yamt-pagecache-base5 yamt-pagecache-base4
# 1.85 07-Apr-2012 christos

branches: 1.85.2;
factor out rawname() from dump, fsck, savecore.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.84 13-Sep-2011 christos

branches: 1.84.2;
print the missing flag if missing argument...


# 1.83 12-Sep-2011 christos

- always print corrupted dump messages instead of silently failing
- don't require /var/crash to be specified, default to it
- determine and print the kernel name
- print all messages to syslog


# 1.82 29-Aug-2011 joerg

static + __dead


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.81 18-Aug-2009 dogcow

Instead of exiting with an obscure error message if -N /kernelname isn't
specified, blithely assume the kernel will consume around 20 megs.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.80 06-Apr-2009 lukem

fix sign-compare issues


# 1.79 21-Mar-2009 tls

Fix savecore so it uses /dev/ksyms when it can (doesn't override libkvm
default). Fixes misc/38425.


Revision tags: mjf-devfs2-base
# 1.78 28-Dec-2008 christos

branches: 1.78.2;
fix dev_t format.


# 1.77 05-Dec-2008 ad

Enable the faked ELF kernel by default, now that ksyms output works with
gdb. Makes it possible to do post-mortem debugging on a modular kernel.


Revision tags: netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2
# 1.76 20-Oct-2008 ad

branches: 1.76.2;
- Add code to produce a fake ELF kernel containing only symbol info. Done
by extracting ksyms state from the dump, so we have symbols for modules
loaded at the time of the crash. If ksyms extraction fails, this falls
back to the current behaviour of copying /netbsd.

- Leave it disabled for the moment: (1) we are about to branch (2) most
tools understand the artificial kernel but gdb has trouble with it for
some reason.


# 1.75 09-Oct-2008 joerg

Explicitly check that the dump device is not the console, a tty or pty.
While the list is adhoc, the problems reported are always with
/dev/console. Adresses PR 38425 and similiar issues with Xen.


Revision tags: wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.74 20-Jul-2008 lukem

Remove the \n and tabs from the __COPYRIGHT() strings.
(Tweak some to use a consistent format.)


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.73 20-Apr-2008 ad

branches: 1.73.2;
sync() a couple of times to benefit diagnosis of sloppy kernel code that
crashes during boot to multiuser.


Revision tags: yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.72 15-Jan-2008 ad

branches: 1.72.4; 1.72.6;
Don't use the block device to read crashdumps, if possible.


Revision tags: cube-autoconf-base matt-armv6-base
# 1.71 12-Nov-2007 pooka

branches: 1.71.2;
tyop: _time_seconf -> _time_second


Revision tags: matt-armv6-prevmlocking matt-mips64-base
# 1.70 18-Dec-2006 christos

branches: 1.70.4;
from Anon Ymous: remove (void)&var;


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.69 16-Oct-2006 christos

c99 initializers


Revision tags: abandoned-netbsd-4-base
# 1.68 09-Jul-2006 kardel

accept either "time_second" or "time" as kernel timevariable in
order to support common userland in enviroments where
timecounter kernels and non timecounter kernel co-exist
(e.g. xen & i386)


# 1.67 07-Jun-2006 kardel

support timecounters (struct time gone, use time_second then)


Revision tags: simonb-timecounters-base
# 1.66 17-Mar-2006 hubertf

Free some allocated memory in the failure case when trying to
fetch the panic string.

Fixes Coverity CID 1856.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.65 16-Oct-2004 dsainty

branches: 1.65.6;
Added -n option, which tests for a present core but doesn't write it
to disk or clear it (does 'nothing').

http://mail-index.netbsd.org/tech-userlevel/2004/10/09/0000.html


# 1.64 14-Jul-2004 tls

Fix an integer overflow that prevented saving cores from machines with
more than 2GB of RAM.

"dumpsize" in the on-disk core header is in pages, but, unfortunately,
c.size in our kcore format is an unsigned 32-bit int, gross.

We sleaze it, using a 64-bit int internally here and handing it to
libkvm as a *signed* 32-bit int. Won't always work, but shouldn't be
broken any worse than it is now, and sometimes work better.

We must fix the kcore format and libkvm.


# 1.63 21-Apr-2004 christos

Replace the statfs() family of system calls with statvfs().
Retain binary compatibility.


# 1.62 30-Mar-2004 christos

Give a 60 day leeway instead of a week when judging if the dumptime is valid.
7 days is too short when you are debugging time problems.


Revision tags: netbsd-2-0-base
# 1.61 07-Aug-2003 agc

branches: 1.61.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.


# 1.60 18-May-2003 itojun

simplify by strlcpy


Revision tags: fvdl_fs64_base
# 1.59 06-Dec-2002 thorpej

Remove prototype for non-existent function log().


# 1.58 27-Sep-2002 drochner

use humanize_number(3) for progress printout


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.57 19-Mar-2002 christos

branches: 1.57.2;
PR/15502: Wolfgang Rupprecht: savecore fails for > 2GB files.


# 1.56 06-Mar-2002 tsutsui

Change type of dumpmag and newdumpmag from int to u_int32_t
since they hold 32bit unsigned magic numbers. (sync with kernels)


# 1.55 01-Nov-2001 lukem

fix a couple of -Wshadow warnings


# 1.54 12-Sep-2001 lukem

explicitly set the default compression level to 1 (from the implicit 6),
because it's significantly faster and doesn't use that much more disk space.


# 1.53 12-Sep-2001 lukem

Add "-Z level" to control the compression level that -z uses (which
defaults to -Z 6). Depending on the relative speed of the CPU
versus disk, "-zZ1" might be faster than no compression at all.


# 1.52 13-Jun-2001 wiz

Use getbootfile(3) instead of _PATH_UNIX by default.
Sprinkle some const.


# 1.51 06-May-2001 simonb

If the position of the formatted panic string can be found in the
message buffer, use that instead of the raw panic string.

Suggested by Jason Thorpe eons ago.


# 1.50 11-Jan-2001 martin

Make option flag variables static. This avoids a conflict between
'int compress' in savecore.c and the function 'compress' in libz.
Gnu ld 2.10 (with BFD 2.10) used on sparc64 warns this conflict
(symbol "compress" changed size).


# 1.49 02-Jan-2001 joda

use gzip instead of compress


# 1.48 02-Jan-2001 lukem

Bump the field width of `K to go' from 6 to 8; some systems have more
than 999999 KB of RAM... (this will suffice until it's common to have
~ 100 GB of RAM :)


# 1.47 11-Dec-2000 wiz

Back out sysctl part for now, awaiting the result of further discussion,
on request of Andrew Doran.


# 1.46 08-Dec-2000 wiz

Output proper warning if dumplo == -1 (as it can happen on macppc without
swap partition), instead of "kvm_dump_mkheader: Pread: Invalid argument".


# 1.45 07-Dec-2000 wiz

de-__P(), and generally try to be more conforming to the new NetBSD style.
Use %m in syslog strings where appropriate.
Reduce warnings with WARNS=2.


# 1.44 07-Dec-2000 wiz

Fix argument handling, which was pretty broken.
If sysctl supports it, try to get the kernel name with CPU_BOOTED_KERNEL.
Get current kernels version string in all cases.
Adapt some error messages to the correct kernel name.
Reviewed by Simon Burge.


# 1.43 08-Oct-2000 darrenr

initialize kernel to _PATH_UNIX and remove local variables in functions
which are essentially copies of kernel.


# 1.42 01-Oct-2000 darrenr

savecore was looking up dumpdev, etc, from the wrong kernel


# 1.41 01-Aug-2000 eeh

time is a `struct timeval' not a `time_t', so read it in properly.


Revision tags: netbsd-1-5-base minoura-xpg4dl-base wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.40 02-Aug-1999 mycroft

branches: 1.40.8;
s/on device/in [dirname]/, to be a bit clearer...


# 1.39 01-Jul-1999 cgd

Remove an extraneous fclose() call which would cause savecore to crash
if the bounds file was unwritable (e.g. because /var was read-only).
Fix supplied by Ronald Khoo in PR#7887.


Revision tags: netbsd-1-4-RELEASE netbsd-1-4-base
# 1.38 27-Feb-1999 sommerfe

branches: 1.38.2;
Crash dumps should *not* be world readable.


# 1.37 23-Jul-1998 sommerfe

Avoid truncating partition size in freespace calculation


# 1.36 01-Apr-1998 kleink

Need <time.h> for time() and ctime() prototypes.


# 1.35 18-Feb-1998 thorpej

Avoid


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.34 16-Sep-1997 lukem

resolve conflicts from lite-2 merge


# 1.33 16-Sep-1997 mrg

make these compile on the alpha after WARNS=1.


# 1.32 15-Sep-1997 lukem

* cleanup for WARNS=1
* fix .Nm usage
* deprecate register


# 1.31 25-Aug-1997 kleink

Lseek(2) usage cleanup: the use of L_SET/L_INCR/L_XTND is deprecated,
use SEEK_SET/SEEK_CUR/SEEK_END instead.


# 1.30 19-May-1997 pk

More error checking.


# 1.29 21-Apr-1997 mrg

set umask for savecore.


# 1.28 01-Oct-1996 cgd

make datas item copied out from kernel (panicstr) and/or used as kvm pointers
(panicloc) be 'long's, not 'int's.


# 1.27 23-Jun-1996 leo

If kvm_dump_mkheader() returns 0, simply state 'no core dump' instead
of logging and error.


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.26 18-Mar-1996 leo

Omit kd_live argument to kvm_dump_mkheader().


# 1.25 16-Mar-1996 leo

New libkvm/savecore implementation. With the following differences:
1) savecore will not access the dump or live-kernel directly. It
will always use the kvm-functions. Allowing it to work on kernels
that don't have a 1-1 PA-VA mapping.
2) the kvm-lib has some additional functions to accomplish 1
- kvm_dump_mkheader()
- kvm_dump_wrtheader()
- kvm_dump_inval()
3) the file formats of the dump generated by the kernel and the dump
generated by savecore have been changed. The file format now looks
like the format produced for 'normal' core dumps.
Ports not yet supporting the new kvm-format will be using libkvm.old/
savecore.old for the time being.


# 1.24 08-Mar-1996 mycroft

Put the compression suffix *last*.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.23 24-Jul-1995 cgd

set dumpsize in dump_exists(), not save_core(), so that minfree check
works again. solves pr 1257, but sets dumpsize earlier than suggested
in that pr, so that dumpsize is set if a core doesn't appear to be
present (because dumpsize would be used if the '-f' flag is given).


# 1.22 25-Jun-1995 cgd

fix verbose printf of dumplo, clean up printfs slightly


# 1.21 18-Mar-1995 cgd

convert to new RCS Id conventions; reduce my headache


# 1.20 04-Jan-1995 mycroft

Fix getopt string and test on return value.


# 1.19 31-Oct-1994 cgd

oops; get rid of previous (iffy) zopen declaration


# 1.18 31-Oct-1994 cgd

make a proto for zopen (yech)


# 1.17 23-Sep-1994 mycroft

Eliminate uses of some obsolete functions.


# 1.16 18-Sep-1994 deraadt

prototype zopen()
NBPG --> getpagesize()


# 1.15 17-Sep-1994 mycroft

vmunix --> kernel (for variable names), and make the core file naming
convention match that of other executables.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.14 11-Jun-1994 mycroft

Fix up RCS ids.


# 1.13 10-Jun-1994 pk

Update to 4.4-lite, local changes to man page.


# 1.12 31-May-1994 pk

Initialize return value from save_core() in case dumpsize == 0.


# 1.11 27-May-1994 pk

Don't clear dump if writing it to the filesystem fails (eg. file system full)


# 1.10 21-Apr-1994 cgd

queue/struct changes


# 1.9 06-Apr-1994 cgd

kill two casts


# 1.8 06-Apr-1994 cgd

serious perversion:
most of the 'off' arguments to Lseek() (the internal lseek() wrapper)
are unsigned longs. we need them to be sign extended, though, so change
Lseek() to take a 'long' rather than an 'off_t', and let the compiler
do the dirty work via implicit casts.


# 1.7 04-Apr-1994 cgd

lseek stuff, and clean up. this is perverse.


# 1.6 14-Feb-1994 cgd

correct ok() calculation for all architectures.


# 1.5 08-Dec-1993 pk

Check for dumpdev being NODEV. If so, exit silently, unless verbose is on.


# 1.4 01-Aug-1993 mycroft

Add RCS identifiers.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base netbsd-0-8 netbsd-alpha-1
# 1.3 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision