aboutsummaryrefslogtreecommitdiff
path: root/sbin/dumpon
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2012-11-04 02:52:03 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2012-11-04 02:52:03 +0000
commit23090366f729c56cab62de74c7a51792357e98a9 (patch)
treec511c885796e28ec571b5267e8f11f3b103d35e9 /sbin/dumpon
parent7750ad47a9a7dbc83f87158464170c8640723293 (diff)
parent22ff74b2f44234d31540b1f7fd6c91489c37cad3 (diff)
downloadsrc-23090366f729c56cab62de74c7a51792357e98a9.tar.gz
src-23090366f729c56cab62de74c7a51792357e98a9.zip
Sync from head
Notes
Notes: svn path=/projects/bmake/; revision=242545
Diffstat (limited to 'sbin/dumpon')
-rw-r--r--sbin/dumpon/dumpon.810
-rw-r--r--sbin/dumpon/dumpon.c43
2 files changed, 50 insertions, 3 deletions
diff --git a/sbin/dumpon/dumpon.8 b/sbin/dumpon/dumpon.8
index ff47bcb19479..2c09e85cda85 100644
--- a/sbin/dumpon/dumpon.8
+++ b/sbin/dumpon/dumpon.8
@@ -41,6 +41,9 @@
.Nm
.Op Fl v
.Cm off
+.Nm
+.Op Fl v
+.Fl l
.Sh DESCRIPTION
The
.Nm
@@ -72,6 +75,13 @@ total amount of physical memory as reported by the
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
diff --git a/sbin/dumpon/dumpon.c b/sbin/dumpon/dumpon.c
index 73d46b00eb3c..eebcc694e68d 100644
--- a/sbin/dumpon/dumpon.c
+++ b/sbin/dumpon/dumpon.c
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <err.h>
+#include <errno.h>
#include <fcntl.h>
#include <paths.h>
#include <stdint.h>
@@ -60,9 +61,10 @@ static int verbose;
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,15 +94,45 @@ check_size(int fd, const char *fn)
}
}
+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[])
{
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,6 +143,11 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
+ if (do_listdumpdev) {
+ listdumpdev();
+ exit(EX_OK);
+ }
+
if (argc != 1)
usage();