Hi there,

According to the manpage of shutdown(8) a brief description says about the options -f, -F:

The -f flag means `reboot fast'. This only creates an advisory file /fastboot which can be tested by the system when it comes up again. The boot rc file can test if this file is present, and decide not to run fsck(1) since the system has been shut down in the proper way. After that, the boot process should remove /fastboot.

The -F flag means `force fsck'. This only creates an advisory file /forcefsck which can be tested by the system when it comes up again. The boot rc file can test if this file is present, and decide to run fsck(1) with a special `force' flag so that even properly unmounted file systems get checked. After that, the boot process should remove /forcefsck.

IMHO, this seems unsafe and unnecessary. Unsafe in the sense that `shutdown' -f or -F will try to create a file in / (or where it is defined, paths.h) -- the creation of the file can fail if the file system is in read-only mode; this can be done simply in the initialization script if the scripts checks the boot prompt line, to see if the user has passed: "fastboot", "forcefsck" via /proc/cmdline. This avoids the following: 1. Additional lines: remove the files (generally at the end) on the initialization script - 2. Code in shutdown. (I attach a diff just in case).

Index: src/shutdown.c
===================================================================
--- src/shutdown.c	(revision 174)
+++ src/shutdown.c	(working copy)
@@ -5,8 +5,6 @@
  *		  -k: don't really shutdown, only warn.
  *		  -r: reboot after shutdown.
  *		  -h: halt after shutdown.
- *		  -f: do a 'fast' reboot (skip fsck).
- *		  -F: Force fsck on reboot.
  *		  -n: do not go through init but do it ourselves.
  *		  -c: cancel an already running shutdown.
  *		  -t secs: delay between SIGTERM and SIGKILL for init.
@@ -66,8 +64,6 @@
 int dontshut = 0;	/* Don't shutdown, only warn	*/
 char down_level[2];	/* What runlevel to go to.	*/
 int dosync = 1;		/* Sync before reboot or halt	*/
-int fastboot = 0;	/* Do a 'fast' reboot		*/
-int forcefsck = 0;	/* Force fsck on reboot		*/
 char message[MESSAGELEN];	/* Warning message	*/
 char *sltime = 0;	/* Sleep time			*/
 char newstate[64];	/* What are we gonna do		*/
@@ -110,8 +106,6 @@
 
 {
 	unlink(NOLOGIN);
-	unlink(FASTBOOT);
-	unlink(FORCEFSCK);
 	unlink(SDPID);
 	printf("\r\nShutdown cancelled.\r\n");
 	exit(0);
@@ -123,15 +117,13 @@
 void usage(void)
 {
 	fprintf(stderr,
-	"Usage:\t  shutdown [-akrhPHfFnc] [-t sec] time [warning message]\n"
+	"Usage:\t  shutdown [-akrhPHnc] [-t sec] time [warning message]\n"
 	"\t\t  -a:      use /etc/shutdown.allow\n"
 	"\t\t  -k:      don't really shutdown, only warn.\n"
 	"\t\t  -r:      reboot after shutdown.\n"
 	"\t\t  -h:      halt after shutdown.\n"
 	"\t\t  -P:      halt action is to turn off power.\n"
 	"\t\t  -H:      halt action is to just halt.\n"
-	"\t\t  -f:      do a 'fast' reboot (skip fsck).\n"
-	"\t\t  -F:      Force fsck on reboot.\n"
 	"\t\t  -n:      do not go through \"init\" but go down real fast.\n"
 	"\t\t  -c:      cancel a running shutdown.\n"
 	"\t\t  -t secs: delay between warning and kill signal.\n"
@@ -441,8 +433,6 @@
 
 	/* Oops - failed. */
 	fprintf(stderr, "\rshutdown: cannot execute %s\r\n", INIT);
-	unlink(FASTBOOT);
-	unlink(FORCEFSCK);
 	init_setenv("INIT_HALT", NULL);
 	openlog("shutdown", LOG_PID, LOG_USER);
 	syslog(LOG_NOTICE, "shutdown failed");
@@ -532,12 +522,6 @@
   			case 'h': /* Halt after shutdown */
 				down_level[0] = '0';
   				break;
-  			case 'f': /* Don't perform fsck after next boot */
-  				fastboot = 1;
-  				break;
-  			case 'F': /* Force fsck after next boot */
-  				forcefsck = 1;
-  				break;
 			case 'n': /* Don't switch runlevels. */
 				doself = 1;
 				break;
@@ -721,9 +705,6 @@
 	sa.sa_handler = stopit;
 	sigaction(SIGINT, &sa, NULL);
 
-	if (fastboot)  close(open(FASTBOOT,  O_CREAT | O_RDWR, 0644));
-	if (forcefsck) close(open(FORCEFSCK, O_CREAT | O_RDWR, 0644));
-
 	/* Alias now and take care of old '+mins' notation. */
 	if (!strcmp(when, "now")) strcpy(when, "0");
 	if (when[0] == '+') when++;
Index: src/paths.h
===================================================================
--- src/paths.h	(revision 174)
+++ src/paths.h	(working copy)
@@ -29,8 +29,6 @@
 #define INITTAB		"/etc/inittab"		/* Location of inittab */
 #define INIT		"/sbin/init"		/* Location of init itself. */
 #define NOLOGIN		"/etc/nologin"		/* Stop user logging in. */
-#define FASTBOOT	"/fastboot"		/* Enable fast boot. */
-#define FORCEFSCK	"/forcefsck"		/* Force fsck on boot */
 #define SDPID		"/var/run/shutdown.pid"	/* PID of shutdown program */
 #define SHELL		"/bin/sh"		/* Default shell */
 #define SULOGIN		"/sbin/sulogin"		/* Sulogin */

Reply via email to