[Midnightbsd-cvs] src [11227] trunk/sbin/dumpon/dumpon.c: sync dumpon(8) with freebsd 10 stable
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Jul 1 17:09:18 EDT 2018
Revision: 11227
http://svnweb.midnightbsd.org/src/?rev=11227
Author: laffer1
Date: 2018-07-01 17:09:18 -0400 (Sun, 01 Jul 2018)
Log Message:
-----------
sync dumpon(8) with freebsd 10 stable
Modified Paths:
--------------
trunk/sbin/dumpon/Makefile
trunk/sbin/dumpon/dumpon.8
trunk/sbin/dumpon/dumpon.c
Property Changed:
----------------
trunk/sbin/dumpon/dumpon.8
Modified: trunk/sbin/dumpon/Makefile
===================================================================
--- trunk/sbin/dumpon/Makefile 2018-07-01 21:08:46 UTC (rev 11226)
+++ trunk/sbin/dumpon/Makefile 2018-07-01 21:09:18 UTC (rev 11227)
@@ -1,4 +1,5 @@
# $MidnightBSD$
+# $FreeBSD: stable/10/sbin/dumpon/Makefile 198236 2009-10-19 16:00:24Z ru $
PROG= dumpon
MAN= dumpon.8
Modified: trunk/sbin/dumpon/dumpon.8
===================================================================
--- trunk/sbin/dumpon/dumpon.8 2018-07-01 21:08:46 UTC (rev 11226)
+++ trunk/sbin/dumpon/dumpon.8 2018-07-01 21:09:18 UTC (rev 11227)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -26,9 +27,9 @@
.\" SUCH DAMAGE.
.\"
.\" From: @(#)swapon.8 8.1 (Berkeley) 6/5/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/dumpon/dumpon.8 306983 2016-10-10 16:17:14Z sevan $
.\"
-.Dd May 12, 1995
+.Dd October 3, 2016
.Dt DUMPON 8
.Os
.Sh NAME
@@ -41,6 +42,9 @@
.Nm
.Op Fl v
.Cm off
+.Nm
+.Op Fl v
+.Fl l
.Sh DESCRIPTION
The
.Nm
@@ -56,14 +60,21 @@
variable in the boot time configuration file
.Pa /etc/rc.conf .
.Pp
-For most systems the size of the specified dump device must be at
+The default type of kernel crash dump is the mini crash dump.
+Mini crash dumps hold only memory pages in use by the kernel.
+Alternatively, full memory dumps can be enabled by setting the
+.Va debug.minidump
+.Xr sysctl 8
+variable to 0.
+.Pp
+For systems using full memory dumps, the size of the specified dump
+device must be at
least the size of physical memory.
Even though an additional 64 kB header is added to the dump, the BIOS for a
platform typically holds back some memory, so it is not usually
necessary to size the dump device larger than the actual amount of RAM
available in the machine.
-.Pp
-The
+Also, when using full memory dumps, the
.Nm
utility will refuse to enable a dump device which is smaller than the
total amount of physical memory as reported by the
@@ -72,6 +83,13 @@
variable.
.Pp
The
+.Fl l
+flag causes
+.Nm
+to print the current dump device or _PATH_DEVNULL ("/dev/null") if no device is
+configured.
+.Pp
+The
.Fl v
flag causes
.Nm
@@ -107,9 +125,18 @@
on
.Pa /dev/null
and thus instructs the kernel not to save crash dumps.
+.Pp
+Since
+.Nm
+cannot be used during kernel initialization, the
+.Va dumpdev
+variable of
+.Xr loader 8
+must be used to enable dumps for system panics which occur
+during kernel initialization.
.Sh FILES
-.Bl -tag -width "/dev/{ad,da}?s?b" -compact
-.It Pa /dev/{ad,da}?s?b
+.Bl -tag -width "/dev/{ada,da}?s?b" -compact
+.It Pa /dev/{ada,da}?s?b
standard swap areas
.It Pa /etc/rc.conf
boot-time system configuration
@@ -119,6 +146,7 @@
.Xr rc.conf 5 ,
.Xr config 8 ,
.Xr init 8 ,
+.Xr loader 8 ,
.Xr rc 8 ,
.Xr savecore 8 ,
.Xr swapon 8 ,
@@ -127,7 +155,7 @@
The
.Nm
utility appeared in
-.Fx 2.1 .
+.Fx 2.0.5 .
.Sh BUGS
Because the file system layer is already dead by the time a crash dump
is taken, it is not possible to send crash dumps directly to a file.
Property changes on: trunk/sbin/dumpon/dumpon.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/dumpon/dumpon.c
===================================================================
--- trunk/sbin/dumpon/dumpon.c 2018-07-01 21:08:46 UTC (rev 11226)
+++ trunk/sbin/dumpon/dumpon.c 2018-07-01 21:09:18 UTC (rev 11227)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -39,7 +40,7 @@
#endif /* not lint */
#endif
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/dumpon/dumpon.c 291480 2015-11-30 09:13:04Z smh $");
#include <sys/param.h>
#include <sys/disk.h>
@@ -46,6 +47,7 @@
#include <sys/sysctl.h>
#include <err.h>
+#include <errno.h>
#include <fcntl.h>
#include <paths.h>
#include <stdint.h>
@@ -60,9 +62,10 @@
static void
usage(void)
{
- fprintf(stderr, "%s\n%s\n",
+ fprintf(stderr, "%s\n%s\n%s\n",
"usage: dumpon [-v] special_file",
- " dumpon [-v] off");
+ " dumpon [-v] off",
+ " dumpon [-v] -l");
exit(EX_USAGE);
}
@@ -92,6 +95,32 @@
}
}
+static void
+listdumpdev(void)
+{
+ char dumpdev[PATH_MAX];
+ size_t len;
+ const char *sysctlname = "kern.shutdown.dumpdevname";
+
+ len = sizeof(dumpdev);
+ if (sysctlbyname(sysctlname, &dumpdev, &len, NULL, 0) != 0) {
+ if (errno == ENOMEM) {
+ err(EX_OSERR, "Kernel returned too large of a buffer for '%s'\n",
+ sysctlname);
+ } else {
+ err(EX_OSERR, "Sysctl get '%s'\n", sysctlname);
+ }
+ }
+ if (verbose) {
+ printf("kernel dumps on ");
+ }
+ if (strlen(dumpdev) == 0) {
+ printf("%s\n", _PATH_DEVNULL);
+ } else {
+ printf("%s\n", dumpdev);
+ }
+}
+
int
main(int argc, char *argv[])
{
@@ -98,9 +127,13 @@
int ch;
int i, fd;
u_int u;
+ int do_listdumpdev = 0;
- while ((ch = getopt(argc, argv, "v")) != -1)
+ while ((ch = getopt(argc, argv, "lv")) != -1)
switch((char)ch) {
+ case 'l':
+ do_listdumpdev = 1;
+ break;
case 'v':
verbose = 1;
break;
@@ -111,20 +144,40 @@
argc -= optind;
argv += optind;
+ if (do_listdumpdev) {
+ listdumpdev();
+ exit(EX_OK);
+ }
+
if (argc != 1)
usage();
if (strcmp(argv[0], "off") != 0) {
- fd = open(argv[0], O_RDONLY);
+ char tmp[PATH_MAX];
+ char *dumpdev;
+
+ if (strncmp(argv[0], _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) {
+ dumpdev = argv[0];
+ } else {
+ i = snprintf(tmp, PATH_MAX, "%s%s", _PATH_DEV, argv[0]);
+ if (i < 0) {
+ err(EX_OSERR, "%s", argv[0]);
+ } else if (i >= PATH_MAX) {
+ errno = EINVAL;
+ err(EX_DATAERR, "%s", argv[0]);
+ }
+ dumpdev = tmp;
+ }
+ fd = open(dumpdev, O_RDONLY);
if (fd < 0)
- err(EX_OSFILE, "%s", argv[0]);
- check_size(fd, argv[0]);
+ err(EX_OSFILE, "%s", dumpdev);
+ check_size(fd, dumpdev);
u = 0;
i = ioctl(fd, DIOCSKERNELDUMP, &u);
u = 1;
i = ioctl(fd, DIOCSKERNELDUMP, &u);
if (i == 0 && verbose)
- printf("kernel dumps on %s\n", argv[0]);
+ printf("kernel dumps on %s\n", dumpdev);
} else {
fd = open(_PATH_DEVNULL, O_RDONLY);
if (fd < 0)
More information about the Midnightbsd-cvs
mailing list