Merge authors:
  Dmitrijs Ledkovs (xnox)
Related merge proposals:
  https://code.launchpad.net/~xnox/upstart/rebootcmd/+merge/149619
  proposed by: Dmitrijs Ledkovs (xnox)
  review: Approve - James Hunt (jamesodhunt)
------------------------------------------------------------
revno: 1436 [merge]
committer: James Hunt <[email protected]>
branch nick: upstart
timestamp: Mon 2013-02-25 09:55:47 +0000
message:
  * Merge of lp:~xnox/upstart/rebootcmd.
modified:
  util/man/reboot.8
  util/reboot.c


--
lp:upstart
https://code.launchpad.net/~upstart-devel/upstart/trunk

Your team Upstart Reviewers is subscribed to branch lp:upstart.
To unsubscribe from this branch go to 
https://code.launchpad.net/~upstart-devel/upstart/trunk/+edit-subscription
=== 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:26:48 +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:26:48 +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