Bugfix: Support command delivery to syscall tizen_2.1 2.1b_release accepted/tizen_2.1/20130425.040607 submit/tizen_2.1/20130424.230036
authorSangjung Woo <sangjung.woo@samsung.com>
Fri, 22 Mar 2013 08:16:45 +0000 (17:16 +0900)
committerSangjung Woo <sangjung.woo@samsung.com>
Fri, 22 Mar 2013 08:16:45 +0000 (17:16 +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: Ib833ced3059d900ef1c001cf1715ecf1b32ac3f0
Signed-off-by: Sangjung Woo <sangjung.woo@samsung.com>
packaging/systemd_param.patch [new file with mode: 0644]
packaging/sysvinit.spec

diff --git a/packaging/systemd_param.patch b/packaging/systemd_param.patch
new file mode 100644 (file)
index 0000000..e91e9cb
--- /dev/null
@@ -0,0 +1,57 @@
+diff --git a/src/shutdown.c b/src/shutdown.c
+index 7c5ffcd..b63bddf 100644
+--- a/src/shutdown.c
++++ b/src/shutdown.c
+@@ -46,6 +46,8 @@ char *Version = "@(#) shutdown 2.86-1 31-Jul-2004 miquels@cistron.nl";
+ #define MESSAGELEN    256
++#define REBOOT_MODE_FILE      "/run/reboot_mode"
++
+ 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   */
+@@ -432,6 +434,32 @@ static int needwarning(int wt)
+       return ret;
+ }
++static int write_reboot_cmd(const char *line)
++{
++      FILE *f;
++      int r;
++
++      f=fopen(REBOOT_MODE_FILE, "we");
++      if(!f)  return -errno;
++
++      if(fputs(line, f)<0){
++              r-=errno;
++              goto final;
++      }
++      fflush(f);
++
++      if((r=ferror(f))!=0){
++              r = (r > 0) ? -r : r;
++              goto final;
++      }
++
++      r=0;    /* Success to write */
++
++final:
++      fclose(f);
++      return r;
++}
++
+ /*
+  *    Main program.
+  *    Process the options and do the final countdown.
+@@ -609,6 +637,10 @@ int main(int argc, char **argv)
+               opts[strlen(message)-1] = 0;
+               if (opts) {
+                       init_setenv("INIT_OPTS", opts);
++
++                      /* To support the command passing of systemd(for example, 'reboot download'),
++                         the command which delivered to reboot syscall is stored into '/run'reboot_mode' file */
++                      write_reboot_cmd(opts);
+               }
+       }
index b692bfa..d9cecd8 100755 (executable)
@@ -33,6 +33,7 @@ Patch15: dont_set_ownership.patch
 Patch16: add_initscripts.patch
 Patch18: 64_init_add_cmd_for_reboot.dpatch
 Patch19: 0001-Fixing-syntax-error-in-start-stop-daemon.c.patch
+Patch20: systemd_param.patch
 
 %description
 The sysvinit package contains a group of processes that control
@@ -86,6 +87,7 @@ Requires: /lib/lsb/init-functions
 %patch16 -p1
 %patch18 -p1
 %patch19 -p1
+%patch20 -p1
 
 %build
 cp %{SOURCE1001} .