Bugfix: Support command delivery to syscall 2.1b_release accepted/tizen_2.1/20130425.040606 submit/tizen_2.1/20130424.230028
authorSangjung Woo <sangjung.woo@samsung.com>
Fri, 22 Mar 2013 07:26:08 +0000 (16:26 +0900)
committerSangjung Woo <sangjung.woo@samsung.com>
Fri, 22 Mar 2013 07:26:08 +0000 (16:26 +0900)
This work is for bug fixing TDIS-2302: "Reboot download" can't reload to
download mode.

Previous sysvinit supports special command passing mechanism when
calling reboot, shutdown, halt. For example, when executing 'reboot
download', the 'download' command is delivered to reboot syscall so
system automatically enter the download mode after rebooting without any
hand action. (Press 'power' and 'volume down' button simultaneously)

However in systemd, when executing 'reboot/halt/shutdown', only realtime
signal is passed through '/dev/initctl'. So systemd daemon can't get the
command to execute.

In order to solve this issue, the command to be delivered is temporally
written to tmp file and shutdown service of systemd will read the
command if existing.

Change-Id: Ic5a07bfa144962f39276c36c33405931d4e592be
Signed-off-by: Sangjung Woo <sangjung.woo@samsung.com>
packaging/reboot_syscall_param.patch [new file with mode: 0644]
packaging/systemd.spec

diff --git a/packaging/reboot_syscall_param.patch b/packaging/reboot_syscall_param.patch
new file mode 100644 (file)
index 0000000..d1eadf7
--- /dev/null
@@ -0,0 +1,44 @@
+diff --git a/src/shutdown.c b/src/shutdown.c
+index d157e0f..f3e29cd 100644
+--- a/src/shutdown.c
++++ b/src/shutdown.c
+@@ -45,6 +45,7 @@
+ #define TIMEOUT_USEC (5 * USEC_PER_SEC)
+ #define FINALIZE_ATTEMPTS 50
++#define REBOOT_MODE_FILE    "/run/reboot_mode"
+ static bool ignore_proc(pid_t pid) {
+         char buf[PATH_MAX];
+@@ -307,6 +308,7 @@ int main(int argc, char *argv[]) {
+         unsigned retries;
+         bool need_umount = true, need_swapoff = true, need_loop_detach = true, need_dm_detach = true;
+         bool killed_everbody = false, in_container;
++        char *reboot_param;
+         log_parse_environment();
+         log_set_target(LOG_TARGET_CONSOLE); /* syslog will die if not gone yet */
+@@ -326,6 +328,9 @@ int main(int argc, char *argv[]) {
+                 goto error;
+         }
++        if(read_one_line_file(REBOOT_MODE_FILE, &reboot_param))
++                reboot_param=NULL;
++
+         in_container = detect_container(NULL) > 0;
+         if (streq(argv[1], "reboot"))
+@@ -473,7 +478,12 @@ int main(int argc, char *argv[]) {
+                 cmd = RB_AUTOBOOT;
+         }
+-        reboot(cmd);
++        if(reboot_param){
++                      syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, reboot_param);
++        } else {
++                reboot(cmd);
++        }
++
+         log_error("Failed to invoke reboot(): %m");
+         r = -errno;
index 1278b0c..5666f23 100644 (file)
@@ -20,6 +20,7 @@ Patch8:     util-introduce-memdup.patch
 Patch9:     main-allow-system-wide-limits-for-services.patch
 Patch10:    enable-core-dumps-globally.patch
 Patch11:    SMACK-Add-configuration-options.-v3.patch
+Patch12:    reboot_syscall_param.patch
 
 BuildRequires:  pkgconfig(dbus-1) >= 1.4.0
 BuildRequires:  pkgconfig(dbus-glib-1)
@@ -173,6 +174,7 @@ This package includes the man pages for systemd.
 %patch9 -p1
 %patch10 -p1
 %patch11 -p1
+%patch12 -p1
 
 %build
 cp %{SOURCE1001} .