From 85c981cc3f30163eac99ed8d6a9b4a346493cc64 Mon Sep 17 00:00:00 2001 From: John Polstra Date: Sun, 21 Nov 1999 21:52:40 +0000 Subject: [PATCH] Add a "-d" option which causes the system to generate a crash dump. --- sbin/reboot/reboot.8 | 11 +++++++++-- sbin/reboot/reboot.c | 10 ++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/sbin/reboot/reboot.8 b/sbin/reboot/reboot.8 index 49b6e8c80f26..af8d6857a1e4 100644 --- a/sbin/reboot/reboot.8 +++ b/sbin/reboot/reboot.8 @@ -44,11 +44,11 @@ stopping and restarting the system .Nm halt .Op Fl nqp .Nm reboot -.Op Fl nqp +.Op Fl dnqp .Nm fasthalt .Op Fl nqp .Nm fastboot -.Op Fl nqp +.Op Fl dnqp .Sh DESCRIPTION The .Nm halt @@ -66,6 +66,11 @@ file. .Pp The options are as follows: .Bl -tag -width indent +.It Fl d +The system is requested to create a crash dump. This option is +supported only when rebooting, and it has no effect unless a dump +device has previously been specified with +.Xr dumpon 8 . .It Fl n The file system cache is not flushed. This option should probably not be used. @@ -101,6 +106,8 @@ specific programs. .Sh SEE ALSO .Xr wtmp 5 , .Xr boot 8 , +.Xr dumpon 8 , +.Xr savecore 8 , .Xr shutdown 8 , .Xr sync 8 .Sh HISTORY diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c index 0bb84822fe0b..be3c81b04358 100644 --- a/sbin/reboot/reboot.c +++ b/sbin/reboot/reboot.c @@ -77,8 +77,11 @@ main(argc, argv) } else howto = 0; lflag = nflag = qflag = 0; - while ((ch = getopt(argc, argv, "lnpq")) != -1) + while ((ch = getopt(argc, argv, "dlnpq")) != -1) switch(ch) { + case 'd': + howto |= RB_DUMP; + break; case 'l': /* Undocumented; used by shutdown. */ lflag = 1; break; @@ -100,6 +103,8 @@ main(argc, argv) argc -= optind; argv += optind; + if ((howto & (RB_DUMP | RB_HALT)) == (RB_DUMP | RB_HALT)) + errx(1, "cannot dump (-d) when halting; must reboot instead"); if (geteuid()) { errno = EPERM; err(1, NULL); @@ -181,6 +186,7 @@ main(argc, argv) void usage() { - (void)fprintf(stderr, "usage: %s [-npq]\n", dohalt ? "halt" : "reboot"); + (void)fprintf(stderr, "usage: %s [-dnpq]\n", + dohalt ? "halt" : "reboot"); exit(1); }