Dmitrijs Ledkovs has proposed merging lp:~xnox/upstart/rebootcmd into 
lp:upstart.

Requested reviews:
  Upstart Reviewers (upstart-reviewers)

For more details, see:
https://code.launchpad.net/~xnox/upstart/rebootcmd/+merge/149619

Useful for nexus7 to execute: reboot -f bootloader, such that one is back into 
fastboot mode.
I'm planning to cherry pick & upload into ubuntu package, as this is needed for 
automated QA testing of nexus7 images.
-- 
https://code.launchpad.net/~xnox/upstart/rebootcmd/+merge/149619
Your team Upstart Reviewers is requested to review the proposed merge of 
lp:~xnox/upstart/rebootcmd into lp:upstart.
=== modified file 'util/man/reboot.8'
--- util/man/reboot.8	2009-07-09 13:21:16 +0000
+++ util/man/reboot.8	2013-02-20 16:31:03 +0000
@@ -5,6 +5,7 @@
 .\"
 .SH SYNOPSIS
 \fBreboot\fR [\fIOPTION\fR]...
+.RI [ REBOOTCOMMAND ]
 
 \fBhalt\fR [\fIOPTION\fR]...
 
@@ -23,10 +24,11 @@
 .BR 6 ,
 this tool invokes the
 .BR reboot (2)
-system call itself and directly reboots the system.  Otherwise this
-simply invokes the
+system call itself (with REBOOTCOMMAND argument passed) and directly
+reboots the system.  Otherwise this simply invokes the
 .BR shutdown (8)
-tool with the appropriate arguments.
+tool with the appropriate arguments without passing REBOOTCOMMAND
+argument.
 
 Before invoking
 .BR reboot (2),

=== modified file 'util/reboot.c'
--- util/reboot.c	2011-06-06 17:05:11 +0000
+++ util/reboot.c	2013-02-20 16:31:03 +0000
@@ -22,7 +22,9 @@
 #endif /* HAVE_CONFIG_H */
 
 
+#include <linux/reboot.h>
 #include <sys/reboot.h>
+#include <sys/syscall.h>
 
 #include <errno.h>
 #include <stdlib.h>
@@ -71,7 +73,8 @@
 enum {
 	REBOOT,
 	HALT,
-	POWEROFF
+	POWEROFF,
+	REBOOTCOMMAND,
 };
 
 
@@ -135,6 +138,7 @@
 	char **args;
 	int    mode;
 	int    runlevel;
+	char  *rebootcommand=NULL;
 
 	nih_main_init (argv[0]);
 
@@ -181,6 +185,12 @@
 	if ((mode == HALT) && poweroff)
 		mode = POWEROFF;
 
+	/* Check for rebootcommand to pass in the syscall */
+	if ((mode == REBOOT) && args && *args) {
+		mode = REBOOTCOMMAND;
+		rebootcommand = *args;
+	}
+
 	/* Normally we just exec shutdown, which notifies everyone and
 	 * signals init.
 	 */
@@ -242,6 +252,13 @@
 		nih_info (_("Powering off"));
 		reboot (RB_POWER_OFF);
 		break;
+	case REBOOTCOMMAND:
+		nih_info (_("Rebooting with %s"), rebootcommand);
+		syscall (SYS_reboot,
+	                 LINUX_REBOOT_MAGIC1,
+			 LINUX_REBOOT_MAGIC2,
+			 LINUX_REBOOT_CMD_RESTART2,
+			 rebootcommand);
 	}
 
 	/* Shouldn't get here, but if we do, carry on */

-- 
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/upstart-devel

Reply via email to