From 5f9840e94e891ad56d1d05400c8f42973f50334f Mon Sep 17 00:00:00 2001 From: thorpej Date: Sat, 6 Jun 1998 21:05:41 +0000 Subject: [PATCH] Add a -p option to halt(8), specifying that the system should be powered down. --- sbin/reboot/reboot.8 | 9 +++++++-- sbin/reboot/reboot.c | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/sbin/reboot/reboot.8 b/sbin/reboot/reboot.8 index 0fe6d12c8159..f35ea0fa06e4 100644 --- a/sbin/reboot/reboot.8 +++ b/sbin/reboot/reboot.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: reboot.8,v 1.8 1998/01/20 23:43:41 mycroft Exp $ +.\" $NetBSD: reboot.8,v 1.9 1998/06/06 21:05:41 thorpej Exp $ .\" .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -43,7 +43,7 @@ stopping and restarting the system .Sh SYNOPSIS .Nm halt -.Op Fl dlnq +.Op Fl dlnpq .Nm "" .Op Fl dlnq .Sh DESCRIPTION @@ -70,6 +70,11 @@ before halting or restarting. .It Fl n Do not flush the file system cache. This option should be used with extreme caution. +.It Fl p +Attempt to powerdown the system. If the powerdown fails, or the system +does not support software powerdown, the system will halt. This option +is only valid for +.Nm halt . .It Fl q Do not give processes a chance to shut down before halting or restarting. This option should not normally be used. diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c index ecd4461182a6..9510367e6ddb 100644 --- a/sbin/reboot/reboot.c +++ b/sbin/reboot/reboot.c @@ -1,4 +1,4 @@ -/* $NetBSD: reboot.c,v 1.18 1998/01/20 23:41:57 mycroft Exp $ */ +/* $NetBSD: reboot.c,v 1.19 1998/06/06 21:05:41 thorpej Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -44,7 +44,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1986, 1993\n" #if 0 static char sccsid[] = "@(#)reboot.c 8.1 (Berkeley) 6/5/93"; #else -__RCSID("$NetBSD: reboot.c,v 1.18 1998/01/20 23:41:57 mycroft Exp $"); +__RCSID("$NetBSD: reboot.c,v 1.19 1998/06/06 21:05:41 thorpej Exp $"); #endif #endif /* not lint */ @@ -84,7 +84,7 @@ main(argc, argv) } else howto = 0; lflag = nflag = qflag = 0; - while ((ch = getopt(argc, argv, "dlnq")) != -1) + while ((ch = getopt(argc, argv, "dlnpq")) != -1) switch(ch) { case 'd': howto |= RB_DUMP; @@ -96,6 +96,11 @@ main(argc, argv) nflag = 1; howto |= RB_NOSYNC; break; + case 'p': + if (dohalt == 0) + usage(); + howto |= RB_POWERDOWN; + break; case 'q': qflag = 1; break; @@ -211,7 +216,9 @@ restart: void usage() { - (void)fprintf(stderr, "usage: %s [-dlnq] [-- ]\n", - __progname); + const char *pflag = dohalt ? "p" : ""; + + (void)fprintf(stderr, "usage: %s [-dln%sq] [-- ]\n", + __progname, pflag); exit(1); }