svn commit: r224260 - stable/7/sbin/shutdown

Glen Barber gjb at FreeBSD.org
Fri Jul 22 00:58:09 UTC 2011


Author: gjb (doc committer)
Date: Fri Jul 22 00:58:09 2011
New Revision: 224260
URL: http://svn.freebsd.org/changeset/base/224260

Log:
  MFC 216823, 223991, 223992:
  
  216823 (by pjd):
  - For compatibility with Linux and Solaris add poweroff(8).
    It is implemented as a hard link to shutdown(8) and it is equivalent
    of:
  
          # shutdown -p now
  
    While I'm here put one line of usage into one line of C code so it
    is easier to grep(1) and separate unrelated code with empty line.
  
  223991:
  - Improvements to the shutdown(8) manual.
  
  223992:
  - Remove trailing whitespace in the shutdown(8) manual.
  
  Approved by:		delphij

Modified:
  stable/7/sbin/shutdown/Makefile
  stable/7/sbin/shutdown/shutdown.8
  stable/7/sbin/shutdown/shutdown.c
Directory Properties:
  stable/7/sbin/shutdown/   (props changed)

Modified: stable/7/sbin/shutdown/Makefile
==============================================================================
--- stable/7/sbin/shutdown/Makefile	Fri Jul 22 00:57:37 2011	(r224259)
+++ stable/7/sbin/shutdown/Makefile	Fri Jul 22 00:58:09 2011	(r224260)
@@ -3,6 +3,8 @@
 
 PROG=	shutdown
 MAN=	shutdown.8
+LINKS=	${BINDIR}/shutdown ${BINDIR}/poweroff
+MLINKS=	shutdown.8 poweroff.8
 
 WARNS?=	6
 

Modified: stable/7/sbin/shutdown/shutdown.8
==============================================================================
--- stable/7/sbin/shutdown/shutdown.8	Fri Jul 22 00:57:37 2011	(r224259)
+++ stable/7/sbin/shutdown/shutdown.8	Fri Jul 22 00:58:09 2011	(r224260)
@@ -28,11 +28,12 @@
 .\"     @(#)shutdown.8	8.2 (Berkeley) 4/27/95
 .\" $FreeBSD$
 .\"
-.Dd December 23, 2008
+.Dd July 13, 2011
 .Dt SHUTDOWN 8
 .Os
 .Sh NAME
-.Nm shutdown
+.Nm shutdown ,
+.Nm poweroff
 .Nd "close down the system at a given time"
 .Sh SYNOPSIS
 .Nm
@@ -47,6 +48,7 @@
 .Oc
 .Ar time
 .Op Ar warning-message ...
+.Nm poweroff
 .Sh DESCRIPTION
 The
 .Nm
@@ -81,20 +83,20 @@ If one of the
 .Fl p
 or
 .Fl r
-is specified,
+options are specified,
 .Nm
 will execute
 .Xr halt 8
 or
 .Xr reboot 8
-instead of sending signal to
+instead of sending a signal to
 .Xr init 8 .
 .It Fl n
 If the
 .Fl o
-is specified, prevent the file system cache from being flushed by passing
+option is specified, prevent the file system cache from being flushed by passing
 .Fl n
-option to
+to
 .Xr halt 8
 or
 .Xr reboot 8 .
@@ -104,10 +106,10 @@ This option should probably not be used.
 is the time at which
 .Nm
 will bring the system down and
-may be the word
+may be the case-insensitive word
 .Ar now
 (indicating an immediate shutdown) or
-specify a future time in one of two formats:
+a future time in one of two formats:
 .Ar +number ,
 or
 .Ar yymmddhhmm ,
@@ -146,7 +148,7 @@ exits.
 .Pp
 At shutdown time a message is written to the system log, containing the
 time of shutdown, the person who initiated the shutdown and the reason.
-Corresponding signal is then sent to
+The corresponding signal is then sent to
 .Xr init 8
 to respectively halt, reboot or bring the system down to single-user state
 (depending on the above options).
@@ -168,15 +170,24 @@ file that
 .Nm
 created will be removed automatically.
 .Pp
-When run without options, the  
+When run without options, the
 .Nm
-utility will place the system into single user mode at the 
+utility will place the system into single user mode at the
 .Ar time
 specified.
+.Pp
+Calling
+.Dq Nm poweroff
+is equivalent to running:
+.Bd -literal -offset indent
+shutdown -p now
+.Ed
 .Sh FILES
 .Bl -tag -width /var/run/nologin -compact
 .It Pa /var/run/nologin
-tells login not to let anyone log in
+tells
+.Xr login 1
+not to let anyone log in
 .El
 .Sh COMPATIBILITY
 The hours and minutes in the second time format may be separated by

Modified: stable/7/sbin/shutdown/shutdown.c
==============================================================================
--- stable/7/sbin/shutdown/shutdown.c	Fri Jul 22 00:57:37 2011	(r224259)
+++ stable/7/sbin/shutdown/shutdown.c	Fri Jul 22 00:58:09 2011	(r224260)
@@ -115,8 +115,31 @@ main(int argc, char **argv)
 	if (geteuid())
 		errx(1, "NOT super-user");
 #endif
+
 	nosync = NULL;
 	readstdin = 0;
+
+	/*
+	 * Test for the special case where the utility is called as
+	 * "poweroff", for which it runs 'shutdown -p now'.
+	 */
+	if ((p = rindex(argv[0], '/')) == NULL)
+		p = argv[0];
+	else
+		++p;
+	if (strcmp(p, "poweroff") == 0) {
+		if (getopt(argc, argv, "") != -1)
+			usage((char *)NULL);
+		argc -= optind;
+		argv += optind;
+		if (argc != 0)
+			usage((char *)NULL);
+		dopower = 1;
+		offset = 0;
+		(void)time(&shuttime);
+		goto poweroff;
+	}
+
 	while ((ch = getopt(argc, argv, "-hknopr")) != -1)
 		switch (ch) {
 		case '-':
@@ -161,6 +184,7 @@ main(int argc, char **argv)
 
 	getoffset(*argv++);
 
+poweroff:
 	if (*argv) {
 		for (p = mbuf, len = sizeof(mbuf); *argv; ++argv) {
 			arglen = strlen(*argv);
@@ -510,7 +534,7 @@ usage(const char *cp)
 	if (cp != NULL)
 		warnx("%s", cp);
 	(void)fprintf(stderr,
-	    "usage: shutdown [-] [-h | -p | -r | -k] [-o [-n]]"
-	    " time [warning-message ...]\n");
+	    "usage: shutdown [-] [-h | -p | -r | -k] [-o [-n]] time [warning-message ...]\n"
+	    "       poweroff\n");
 	exit(1);
 }


More information about the svn-src-stable mailing list