Commit Graph

178 Commits

Author SHA1 Message Date
Bryan Drewery
5e93a4b46b If fgets(3) fails in getbounds(), show strerror(3) if not an EOF. Also fix
a FILE* leak in getbounds().

Submitted by:	Conrad Meyer <conrad.meyer@isilon.com>
PR:		192032
Sponsored by:	EMC / Isilon Storage Division
MFC after:	1 week
2014-09-17 19:09:58 +00:00
Simon J. Gerraty
fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty
76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty
3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Christian Brueffer
27e21758b8 Fix double fclose() in an error case.
CID:		1006120
Found with:	Coverity Prevent(tm)
MFC after:	1 week
2014-04-14 21:44:34 +00:00
Mark Johnston
776f03d204 Log the name of the device that we failed to open rather than an
uninitialized buffer.

MFC after:	3 days
2014-03-05 04:15:17 +00:00
Simon J. Gerraty
7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Simon J. Gerraty
f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
David E. O'Brien
d9a447559b Sync with HEAD. 2013-02-08 16:10:16 +00:00
Pawel Jakub Dawidek
165557e269 With rotating kernel dumps the higest dump number is not necessarily the
last one. To make it easier to find the last one create symlinks with 'last'
suffix that will point to the files of the last coredump, eg.:

	info.last -> info.5
	textdump.tar.last.gz -> textdump.tar.5.gz

Reviewed by:	avg
Obtained from:	WHEEL Systems
2012-12-16 23:09:27 +00:00
Pawel Jakub Dawidek
eeff0b1b27 Implement -m option to savecore(8) that allows to limit number of kernel
dumps stored. Once the limit is reached it restarts from 0.

Reviewed by:	avg
Obtained from:	WHEEL Systems
2012-12-16 23:06:12 +00:00
Pawel Jakub Dawidek
30f6c389ae Make use of the fact that we changed working directory to the dump directory
earlier.

Obtained from:	WHEEL Systems
2012-12-16 23:04:31 +00:00
Pawel Jakub Dawidek
3a6e0febc2 Sort flags properly.
Obtained from:	WHEEL Systems
2012-12-16 22:59:58 +00:00
Pawel Jakub Dawidek
87c3930b34 Prefer snprintf() over sprintf().
Obtained from:	WHEEL Systems
2012-12-16 22:59:25 +00:00
Pawel Jakub Dawidek
349d039bdb - When checking if a dump exists on the given device there is no need to
provide dump directory. Eliminate this redundant argument. This changes
  the usage, but the only risk here is that a warning will be printed
  about directory given as device.

- Update usage of -C option.

- When clearing dump header from the given device there is also no need to
  provide dump directory, although additional arguments for -c were not
  documented.

- Document that -v can be used with -c and that list of devices can be given.

Obtained from:	WHEEL Systems
2012-12-14 15:12:08 +00:00
Pawel Jakub Dawidek
22374de9ca The clear option (-c) is not compatible with keep (-k) and compress (-z)
options.

Obtained from:	WHEEL Systems
2012-12-14 15:04:39 +00:00
Pawel Jakub Dawidek
410604696d If we are not going to clear the dump (we are either just checking if the dump
exists or we want to keep it), open device read-only.

Obtained from:	WHEEL Systems
2012-12-14 15:03:12 +00:00
Pawel Jakub Dawidek
26ef9e4a3f Whitespace cleanups. 2012-12-14 15:01:23 +00:00
Marcel Moolenaar
7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Robert Millan
453856145c Include <signal.h> (for SIGINFO). 2012-04-09 20:55:23 +00:00
Kevin Lo
ecd9e552d0 Remove duplicated header files 2011-06-24 07:29:04 +00:00
Joel Dahl
f041f6a7b7 Remove the advertising clause from UCB copyrighted files in sbin. This
is in accordance with the information at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
2010-12-12 21:26:12 +00:00
Ruslan Ermilov
106d839190 Switch the default WARNS level for sbin/ to 6.
Submitted by:	Ulrich Spörlein
2009-10-19 16:00:24 +00:00
Ruslan Ermilov
20ba6b0d61 Fixed markup. 2009-09-17 19:15:49 +00:00
Ulf Lilleengen
0d239eefe5 - Add a SIGINFO handler for savecore. 2009-08-25 06:21:45 +00:00
Christian Brueffer
2a72feb42b Correct the information about when the respective functionality first
appeared in FreeBSD.

PR:		133785
Submitted by:	Ulrich Spoerlein <uqs@spoerlein.net>
MFC after:	3 days
2009-04-23 08:37:56 +00:00
Tom Rhodes
138f7e4b30 Apply various fixes:
Silence mdoc(7) warnings;
Xref correct manual pages;
Point user to the ddb.8 manual page.

PR:		129398
Submitted by:	gavin
2008-12-24 11:12:21 +00:00
Robert Watson
df0b82f150 Compare kernel dump header magic with textdump magic using strncmp()
rather than the memcmp() which is used for regular dumps: the
textdump string is one character shorter, so we need to stop
comparing at the end of the string.

Use independent version checking logic for architecture-specific
version number vs. textdump version number, as the version sequences
may (someday) differ.

Run into by:	rrs
2007-12-27 21:28:48 +00:00
Robert Watson
10187cae6e Teach savecore(8) how to extract textdump(4) dumps.
Update savecore(8) man page to reflect textdump additions.

MFC after:	3 months
2007-12-26 11:42:10 +00:00
Kevin Lo
76f23bd523 Check fdopen return value.
Reviewed by: phk
2007-05-28 09:48:25 +00:00
Maxim Konovalov
125450bbb7 o Restore kerneldumpheader.architectureversion bytes swopping
mangled in rev. 1.72.

PR:		bin/86805
Submitted by:	Gavin Atkinson
MFC after:	3 days
2005-10-02 11:31:45 +00:00
Robert Watson
d32e7ba722 Don't consider being unable to open the bounds file worthy of printing
at LOG_WARNING by default; instead, consider it something to be printed
to the tty when 'verbose' mode is set.  This avoids printing out extra
lines at every boot on a system with crash dumps enabled, but that has
not yet had to generate a crashdump.

MFC after:	1 week
2005-09-13 19:15:28 +00:00
Doug White
9520784e29 Don't bump bounds every time savecore(8) is run.
Submitted by:	Ed Maste <emaste@sandvine.com>
Approved by:	re
2005-06-20 20:01:29 +00:00
Ruslan Ermilov
55c82bf0d4 Markup fixes.
Approved by:	re (blanket)
2005-06-14 11:24:56 +00:00
Philip Paeps
ff869641ae Fix a silly little typo I just spotted. 2005-06-06 06:47:33 +00:00
Xin LI
466e103c7d Constify savedir pointer, and remove an accompaning strdup() call. 2005-05-29 16:28:07 +00:00
David E. O'Brien
ecb90dcc75 style(9). 2005-02-26 01:19:21 +00:00
David E. O'Brien
5fb7027c82 Allow a forced dump even if the dump header information is inconsistent.
Output more verbosity with additional -v's.

Submitted by:	seanc
2005-02-24 02:45:10 +00:00
Ruslan Ermilov
8d646af581 Sync program's usage() with manpage's SYNOPSIS. 2005-02-10 09:19:34 +00:00
Ruslan Ermilov
6087df9e8b Sort sections. 2005-01-18 10:09:38 +00:00
Xin LI
e80cfa4631 Initialize "he" in DoFile, so savecore(8) is WARNS=6 clean.
Bump WARNS accordingly.
2005-01-10 10:44:56 +00:00
Ruslan Ermilov
9f676d2ed6 Use a local "compress" symbol corresponding to a variable in BSS,
rather than the one from libz, corresponding to a function, when
linking statically.

PR:		bin/70392
2004-08-16 07:02:14 +00:00
Mark Murray
4c723140a4 Remove advertising clause from University of California Regent's license,
per letter dated July 22, 1999.

Approved by: core, imp
2004-04-09 19:58:40 +00:00
Maxim Konovalov
34ee70a6a0 o Remove obsoleted '-N' and '-d' flags. 2004-02-28 10:42:27 +00:00
Maxim Konovalov
1e581b9759 o Sync usage() with reality: add 'z' flag.
MFC after:	1 week
2004-02-28 10:22:17 +00:00
Johan Karlsson
604d24db95 style.Makefile(5):
Use WARNS?= instead of WARNS=.
2004-02-23 20:25:27 +00:00
Tim J. Robbins
65922d0bb2 Merge from RELENG_4 1.28.2.13: Fix saving system crash dumps larger than
2 GB by using fseeko() instead of fseek().
2004-02-20 12:22:52 +00:00
Marcel Moolenaar
4b290df1dd Revision 1.61 changed the allocation of buffer 'buf' in DoFile() from
the stack to the heap to work around a problem on ia64. Now, roughly
16 months and two compiler updates later, it isn't an issue anymore
in the sense that putting a 1M buffer on the stack just works and we
don't actually need to work around anything anymore.
However, since there's no advantage or need to put the buffer on the
stack (again), this change merely removes the XXX comment describing
that there's an explicit reason for the heap allocation. Hence, this
change is a functional no-op.

PR: ia64/38677
2003-10-08 07:37:11 +00:00
Doug Barton
628d16a388 Add a flag that reports the existence of a dump, and does nothing else.
The immediate purpose for this option is to use it in rc.d so that we
can make savecore behavior conditional.

Tremendous assistance with ideas and sanity checking provided by tjr
and b@etek.chalmers.se.
2003-09-04 10:07:01 +00:00
Jens Schweikhardt
9d5abbddbf Correct typos, mostly s/ a / an / where appropriate. Some whitespace cleanup,
especially in troff files.
2003-01-01 18:49:04 +00:00
Tom Rhodes
ce66ddb763 s/filesystem/file system/g as discussed on -developers 2002-08-21 18:11:48 +00:00
Philippe Charnier
629e80effb The .Nm utility. 2002-07-06 19:35:14 +00:00
Marcel Moolenaar
acc6623066 Fix breakage caused by allocating the I/O buffer. There was a
sizeof(buf) lurking around that I missed.

PR: 38811
Submitted by: Adrian Colley <aecolley@spamcop.net>
2002-06-02 19:20:37 +00:00
Ruslan Ermilov
1fa8142d87 mdoc(7) police: nits. 2002-05-29 16:53:27 +00:00
Marcel Moolenaar
6db5f8a79e Work around a memory fault on ia64 caused by having the 1MB buffer on
the stack in DoFile(). This needs some investigation. In the mean time
we do a one time malloc() for the buffer to have it on the heap instead.
2002-05-27 07:54:43 +00:00
Ruslan Ermilov
89a600f197 Style. 2002-05-13 12:07:57 +00:00
Marcel Moolenaar
fac09f6b79 Make argument to printf match format. 2002-05-06 08:27:21 +00:00
Bill Fenner
edc4f96e24 - revert back to vmcore.#
- reimplement -z
- use syslog()
- improve consistancy of messages
- allow -f to recover cleared dumps
- return bufsize to 1024 * 1024
- return the ability to write sparse files
- update man page
- fix minfree to require 2k for info file instead of the kernel size
- include Berkeley copyright too due to amount of old code copied

Submitted by:	Chad David <davidc@acns.ab.ca>
2002-05-05 01:04:00 +00:00
Maxime Henrion
3203428dc5 Restore the minfree functionality into savecore. This patch
restores the check_space() function with small modifications
to make it work with the current code.  The patch was slightly
modified by Bill Fenner to handle error messages better.

Reviewed by:	fenner
2002-05-04 10:36:35 +00:00
Philippe Charnier
4b8b67343c Add FBSDID. Start errx(3) messages with lowercase. Remove a ')' with no '('.
In usage(), use fprintf(3) instead of errx(3), to make the printed string really
start with `usage: ...'.
Reviewed by:	 marcel
2002-04-21 07:18:16 +00:00
Poul-Henning Kamp
dce9aaab45 Push the .info file contents out when we're done so people can
read the description while the megs shift from one place to another.
2002-04-19 09:38:45 +00:00
Marcel Moolenaar
5da217f64c High-level changes (user visible):
o  Implement -c (clear) to clear previously kept headers (note that
   dumps not cleared will remain until -c is used),
o  Implement -f (force) to allow re-saving a previously saved dump,
o  Implement -k (keep) and make clearing the dump header the default,
o  Implement -v (verbose) and make most output conditional upon it,
o  Emit minimal output for the non-verbose case with the assumption
   that savecore is run mostly from within /etc/rc,
o  Update usage message to reflect what is and what's not,
o  mark -d as obsolete.

Low-level changes:
o  Rename devname to device, for devname mirrors a global declaration
   and GCC 3.x warns about it,
o  Open the dump device R/W for clear and !keep to work,
o  Reorder the locals of DoFile according to style(9),
o  Remove newlines from strings passed to warn* and err*,
o  Use stat(2) to check if a dump has been saved before,
o  Truncate existing core and info files to support force,
o  First check for the magic and the version before we complain about
   parity errors. This prevents emitting parity error messages when
   there's no dump,
o  Keep track of the number of headers found and the number of headers
   saved to support the minimal output,
o  Close files we opened in DoFile. Not critical, but cleaner.
2002-04-13 08:20:15 +00:00
Poul-Henning Kamp
2dd527b3ac Move generic disk ioctls from <sys/disklabel.h> to <sys/disk.h>.
Sponsored by:	DARPA & NAI Labs
2002-04-08 09:20:07 +00:00
Marcel Moolenaar
5cb87b0c59 Make the kernel dump header endianness invariant by always dumping
in dump byte order (=network byte order). Swap blocksize and dumptime
to avoid extraneous padding on 64-bit architectures. Use CTASSERT
instead of runtime checks to make sure the header is 512 bytes large.
Various style(9) fixes.

Reviewed by: phk, bde, mike
2002-04-03 07:24:12 +00:00
John Baldwin
3837db64a7 Add long long casts so that this compiles on archs with 64-bit longs.
Pointy-hat to:	phk
2002-04-01 18:23:58 +00:00
Poul-Henning Kamp
d94f51a007 Duh, savecore is called savecore. 2002-04-01 08:27:19 +00:00
Poul-Henning Kamp
d503fad022 Savecore:
Commandline compatible with the previous savecore unless you specify
any options, none of them are implemented (yet).

Scans all devices marked "dump" or "swap" for dump header signatures
and saves dumps off under a name which is a MD5 hash of the header
information.  This should give unique filenames.  A *.info file contains
ascii version of the header information.
2002-03-31 22:26:56 +00:00
Warner Losh
d476a036e2 o remove __P
o remove main prototype
2002-03-21 13:20:49 +00:00
David E. O'Brien
3d438ad61f Remove 'register' keyword.
It does not help modern compilers, and some may take some hit from it.
(I also found several functions that listed *every* of its 10 local vars with
 "register" -- just how many free registers do people think machines have?)
2002-03-20 17:55:10 +00:00
Dag-Erling Smørgrav
66a79b3d49 Sparc64 support. 2002-03-11 11:23:48 +00:00
David E. O'Brien
2d68bf45bf Default to WARNS=2.
Binary builds that cannot handle this must explicitly set WARNS=0.

Reviewed by:	mike
2001-12-04 02:19:58 +00:00
Nick Hibma
e2fb2db567 Add a Xref to dumpon. 2001-10-28 16:41:56 +00:00
Peter Wemm
9ee1532786 Remove some bogus "(off_t)(dumplo + value)" and "(off_t)dumplo" casts,
since dumplo is now an off_t.  Scratch a couple of other itches as well.
s/L_SET/SEEK_SET/
2001-10-05 03:13:13 +00:00
Peter Wemm
1ade1386ba Argh. Fix another >2GB savecore problem.
Reported by:   mki@mozone.net
2001-10-05 03:06:35 +00:00
Andrew Gallatin
c97e08fb94 fix savecore so that it works on the alpha after the size change
of dumpmag from an int to a u_long in rev 1.41 -- without this
change, savecore will always fail like this:

#savecore -v /var/crash
dumplo = 874356736 (1707728 * 512)
savecore: magic number mismatch (8fca0101 != 8fca0101)
savecore: no core dump
2001-09-13 21:19:13 +00:00
Ruslan Ermilov
e8ae41c3db mdoc(7) police: restore the correct sorting of SEE ALSO. 2001-09-11 09:58:34 +00:00
Kris Kennaway
dff462c363 * Switch from doing compress(1)ed crashdumps with the -z flag to using
gzip(1).  gdb doesn't understand these, but then again it didn't
  understand compressed crashdumps either.
* Change a stray lseek() into a Lseek()
* Remove the extraneous prototype for log() which has apparently never
  existed in FreeBSD's sources

Obtained from:  NetBSD (partially)
MFC after:      2 weeks
2001-09-06 09:30:09 +00:00
Peter Wemm
241ca2287a Banish hard-coded KERNBASE references from savecore. Dynamically
adjust to whatever kernbase is in the kernel that we are dumping.
2001-08-24 09:26:17 +00:00
Kris Kennaway
5979df34a6 Silence non-constant format string warnings by marking functions
as __printflike()/__printf0like(), adding const, or adding missing "%s"
format strings, as appropriate.

MFC after:	2 weeks
2001-08-19 08:19:37 +00:00
Ruslan Ermilov
9fe48c6e8d mdoc(7) police: removed HISTORY info from the .Os call. 2001-07-10 11:04:34 +00:00
Peter Wemm
9b0a8ba37a dumpmag is 'u_long dumpmag' in the kernel, not 'int'. If this worked on
the Alpha, it was because of luck that it was little endian.

Tidy up the dumpsize/dumppages confusion and the out of date comments.
2001-06-09 01:41:03 +00:00
Peter Wemm
1c08773e6e 'int dumpsize; /* memory size in bytes */' is not good for machines
with 2GB or more of ram.
2001-06-08 03:06:24 +00:00
Ruslan Ermilov
0a5779d45b - Backout botched attempt to introduce MANSECT feature.
- MAN[1-9] -> MAN.
2001-03-26 14:33:27 +00:00
Ruslan Ermilov
fe655281c5 Set the default manual section for sbin/ to 8. 2001-03-20 18:13:31 +00:00
Dag-Erling Smørgrav
867dd03869 Restore the -c option, which was accidentally removed from the getopt
string two revisions ago.
2001-03-06 01:58:30 +00:00
Dag-Erling Smørgrav
4c98f36d94 Document the new -k option in usage message and man page. 2001-02-16 16:28:36 +00:00
Dag-Erling Smørgrav
532c19016b Add a -k option that prevents clearing the dump after saving it.
Use sysctlbyname() instead of sysctl().

Clear up and simplify the version extraction code.

Attempt to detect stretches of zeroes in the dump and avoid writing
them to disk to save space and time.
2001-02-16 16:27:32 +00:00
Ruslan Ermilov
896eb7d10c Prepare for mdoc(7)NG. 2001-01-16 09:15:57 +00:00
Ruslan Ermilov
7c7fb079b9 mdoc(7) police: use the new features of the Nm macro. 2000-11-20 16:52:27 +00:00
Dag-Erling Smørgrav
c74e16f917 Work much harder at obtaining a correct device node. If what devname(3)
returns doesn't exist, or doesn't match the desired device, fall back to
scanning /dev for a matching node, and as a last resort, if that fails,
try to create the node ourselves as /dev/dump.

Add comments to several variables and functions.

Clean up syslog(3) usage; use %m instead of strerror(3).

Other minor cleanup.
2000-10-17 22:43:41 +00:00
Dag-Erling Smørgrav
c548151f51 Remove superfluous code:
1) use devname() instead of searching /dev for the dump device

   2) use fopen() instead of open() so we don't need to differentiate
      between compressing and not compressing when writing the core
      file or the kernel (zopen() returns a FILE *, so we just use
      fwrite() in both cases)

There should be no functional changes.
2000-09-28 20:09:36 +00:00
Peter Wemm
7365d61d00 I'm not sure what changed to cause this, but using 'dirname' as a variable
was colliding with dirname() in libc.a and causing a Sig 10/bus error.
Just change dirname to savedir and be done with it.
2000-09-03 07:02:00 +00:00
Paul Saab
e0ab5cb523 Tidy up the offset calculations.
Submitted by:	bde
2000-05-09 22:20:14 +00:00
Paul Saab
8df53a80dc Read the correct size into kdumplo.
Botched/Noticed by:	peter
2000-05-09 01:08:00 +00:00
Paul Saab
332dbf570d Allow savecore to work on > 2GB partitions.
Submitted by:	peter
2000-05-08 22:57:35 +00:00
Bruce Evans
e9ae1d4b2d Fixed style bugs in rev.1.28. Rev.1.28 was not submitted by bde. 2000-03-20 20:07:28 +00:00
Paul Saab
2837fe5558 Only character devices exsist these days. Make savecore understand
this.
2000-03-20 06:54:06 +00:00
David E. O'Brien
7c815b0db8 Fix bogus initialization of using a sledge hammer to quite -Wall, bad
indention, and size issue between 32 and 64bit machines.

Submitted by:	bde
1999-12-21 07:41:07 +00:00
David E. O'Brien
3eb8166fc0 When erroring out that there is not enough space to write the corefile,
tell the user how much space is avaible for writing the corefile, and how
much space we wanted.
1999-12-08 06:22:58 +00:00
Andrey A. Chernov
4805de8700 Allow character devices too 1999-11-30 03:48:04 +00:00