Re: [systemd-devel] [PATCH] [RFC] Make reboot to support additional command

2013-11-06 Thread Zbigniew Jędrzejewski-Szmek
On Wed, Nov 06, 2013 at 05:42:23PM +0900, WaLyong Cho wrote:
Applied. I updated the man page, and simplified the code a bit.
Please check if it still works, I can't really test this.

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] [RFC] Make reboot to support additional command

2013-11-06 Thread WaLyong Cho


On 11/06/2013 03:53 PM, Zbigniew Jędrzejewski-Szmek wrote:
> On Wed, Nov 06, 2013 at 03:22:49PM +0900, WaLyong Cho wrote:
>>
>>
>> On 09/12/2013 02:20 AM, Lennart Poettering wrote:
>>> On Tue, 13.08.13 03:01, WaLyong Cho (fyd0...@gmail.com) wrote:
>>>
 From: WaLyong Cho 

 reboot syscall can be performed with additional argument. In some of
 system, this functionality can be useful to ask next boot mode to
 bootloader.
>>>
>>> Hmm, interesting stuff. 
>>>
 @@ -5200,9 +5204,19 @@ static int halt_parse_argv(int argc, char *argv[]) {
  }
  }
  
>>>
>>> Note that halt is not called during normal shutdown, but is only a
>>> compat fallback for the old sysv "halt" command. If you want this to
>>> work we probably need to come up with a way to pass the string from
>>> systemctl to the final systemd-shutdown process.
>>>
>>> (A bit of background: systemctl normally will just tell PID 1 to
>>> shutdown cleanly, via D-Bus. As last step of that PID 1 will execute the
>>> special systemd-shutdown binary -- which will then also run as PID 1 --
>>> which will do some final shutdown steps and then invoke the reboot()
>>> syscall -- see src/core/shutdown.c for details)
>>
>> Sorry for my long silence.
>>
>> You were right. Previous my patch did not pass the argument without
>> force option. So I modified according to your opinion. But I think we
>> have to keep some codes in systemctl for supporting forced reboot.
>>
>>>
>>> So, before we continue with this, could you point me to some
>>> docs/commits/code which explain a bit how the new reboot() syscall
>>> semantics work? i.e. what the possible params are and such?
>>
>> There are not any params specified. Any string can be used. That string
>> is used in kernel side.
>> http://lxr.linux.no/linux+v3.4/kernel/sys.c#L486
>>
>> Sorry, there are no visible commits for Tizen in the web. But, for
>> simple example, fota, recovery, download and more are used in Tizen.
>> fota is used when restart to enter fota updated mode. In the mobile,
>> user can download firmware image by on air. And update device firmware
>> to downloaded. During this, reboot is performed. See
>> http://www.redbend.com/en/products-solutions/fota-updating for detail.
>> recovery is used for detecting hacked kernel. I am not sure that I can
>> explain more.
>> download is used to enter download mode. As you may know, most of
>> devices are downloaded(not installed) when the device is produced. At
>> this time, special boot mode is used to flush device.
>>
>> I found similar codes in android.
>> https://github.com/CyanogenMod/android_system_core/blob/gingerbread/toolbox/reboot.c
>> https://github.com/CyanogenMod/android_system_core/blob/gingerbread/libreboot/reboot.c
>>
>>>
>>> One way to implement this could be to add add a new parameter to
>>> systemctl which is written to /run/systemd/reboot-param or so if
>>> specified. systemd-shutdown would then look for that file and pass it to
>>> the reboot() syscall.
>>
>> According to man page of reboot. They called this 'arg'.
>> http://man7.org/linux/man-pages/man2/reboot.2.htm
>> I'm not sure which is more suitable word between 'param' and 'arg'. You
>> offered 'param', so I used also 'param'. Because, 'arg' can be confused
>> with argc/argv.
>>
>>>
 -if (optind < argc) {
 -log_error("Too many arguments.");
 -return -EINVAL;
 +if (arg_action == ACTION_REBOOT) {
 +/* reboot allow just one argument for his command string 
 */
 +if (optind+1 == argc)
 +arg_reboot = strdup(argv[argc-1]);
 +else if (optind+1 < argc) {
 +log_error("Too many arguments.");
 +return -EINVAL;
 +}
 +} else {
 +if (optind < argc) {
 +log_error("Too many arguments.");
 +return -EINVAL;
 +}
  }
  
  return 1;
 @@ -5949,7 +5963,11 @@ static _noreturn_ void halt_now(enum action a) {
  
  case ACTION_REBOOT:
  log_info("Rebooting.");
 -reboot(RB_AUTOBOOT);
 +if (arg_reboot)
 +syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, 
 LINUX_REBOOT_MAGIC2,
 +LINUX_REBOOT_CMD_RESTART2, arg_reboot);
 +else
 +reboot(RB_AUTOBOOT);
  break;
  
  default:
>>>
>>>
>>> Lennart
>>>
>>
>> WaLyong
> 
>> From 3e68b25edab207cdeffb267368e24f6c3a5830ae Mon Sep 17 00:00:00 2001
>> From: WaLyong Cho 
>> Date: Tue, 5 Nov 2013 17:11:09 +0900
>> Subject: [PATCH] make reboot to support additional command
>>
>> reboot syscall can be performed with additional argument. In some of
>> s

Re: [systemd-devel] [PATCH] [RFC] Make reboot to support additional command

2013-11-05 Thread Zbigniew Jędrzejewski-Szmek
On Wed, Nov 06, 2013 at 03:22:49PM +0900, WaLyong Cho wrote:
> 
> 
> On 09/12/2013 02:20 AM, Lennart Poettering wrote:
> > On Tue, 13.08.13 03:01, WaLyong Cho (fyd0...@gmail.com) wrote:
> > 
> >> From: WaLyong Cho 
> >>
> >> reboot syscall can be performed with additional argument. In some of
> >> system, this functionality can be useful to ask next boot mode to
> >> bootloader.
> > 
> > Hmm, interesting stuff. 
> > 
> >> @@ -5200,9 +5204,19 @@ static int halt_parse_argv(int argc, char *argv[]) {
> >>  }
> >>  }
> >>  
> > 
> > Note that halt is not called during normal shutdown, but is only a
> > compat fallback for the old sysv "halt" command. If you want this to
> > work we probably need to come up with a way to pass the string from
> > systemctl to the final systemd-shutdown process.
> > 
> > (A bit of background: systemctl normally will just tell PID 1 to
> > shutdown cleanly, via D-Bus. As last step of that PID 1 will execute the
> > special systemd-shutdown binary -- which will then also run as PID 1 --
> > which will do some final shutdown steps and then invoke the reboot()
> > syscall -- see src/core/shutdown.c for details)
> 
> Sorry for my long silence.
> 
> You were right. Previous my patch did not pass the argument without
> force option. So I modified according to your opinion. But I think we
> have to keep some codes in systemctl for supporting forced reboot.
> 
> > 
> > So, before we continue with this, could you point me to some
> > docs/commits/code which explain a bit how the new reboot() syscall
> > semantics work? i.e. what the possible params are and such?
> 
> There are not any params specified. Any string can be used. That string
> is used in kernel side.
> http://lxr.linux.no/linux+v3.4/kernel/sys.c#L486
> 
> Sorry, there are no visible commits for Tizen in the web. But, for
> simple example, fota, recovery, download and more are used in Tizen.
> fota is used when restart to enter fota updated mode. In the mobile,
> user can download firmware image by on air. And update device firmware
> to downloaded. During this, reboot is performed. See
> http://www.redbend.com/en/products-solutions/fota-updating for detail.
> recovery is used for detecting hacked kernel. I am not sure that I can
> explain more.
> download is used to enter download mode. As you may know, most of
> devices are downloaded(not installed) when the device is produced. At
> this time, special boot mode is used to flush device.
> 
> I found similar codes in android.
> https://github.com/CyanogenMod/android_system_core/blob/gingerbread/toolbox/reboot.c
> https://github.com/CyanogenMod/android_system_core/blob/gingerbread/libreboot/reboot.c
> 
> > 
> > One way to implement this could be to add add a new parameter to
> > systemctl which is written to /run/systemd/reboot-param or so if
> > specified. systemd-shutdown would then look for that file and pass it to
> > the reboot() syscall.
> 
> According to man page of reboot. They called this 'arg'.
> http://man7.org/linux/man-pages/man2/reboot.2.htm
> I'm not sure which is more suitable word between 'param' and 'arg'. You
> offered 'param', so I used also 'param'. Because, 'arg' can be confused
> with argc/argv.
> 
> > 
> >> -if (optind < argc) {
> >> -log_error("Too many arguments.");
> >> -return -EINVAL;
> >> +if (arg_action == ACTION_REBOOT) {
> >> +/* reboot allow just one argument for his command string 
> >> */
> >> +if (optind+1 == argc)
> >> +arg_reboot = strdup(argv[argc-1]);
> >> +else if (optind+1 < argc) {
> >> +log_error("Too many arguments.");
> >> +return -EINVAL;
> >> +}
> >> +} else {
> >> +if (optind < argc) {
> >> +log_error("Too many arguments.");
> >> +return -EINVAL;
> >> +}
> >>  }
> >>  
> >>  return 1;
> >> @@ -5949,7 +5963,11 @@ static _noreturn_ void halt_now(enum action a) {
> >>  
> >>  case ACTION_REBOOT:
> >>  log_info("Rebooting.");
> >> -reboot(RB_AUTOBOOT);
> >> +if (arg_reboot)
> >> +syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, 
> >> LINUX_REBOOT_MAGIC2,
> >> +LINUX_REBOOT_CMD_RESTART2, arg_reboot);
> >> +else
> >> +reboot(RB_AUTOBOOT);
> >>  break;
> >>  
> >>  default:
> > 
> > 
> > Lennart
> > 
> 
> WaLyong

> From 3e68b25edab207cdeffb267368e24f6c3a5830ae Mon Sep 17 00:00:00 2001
> From: WaLyong Cho 
> Date: Tue, 5 Nov 2013 17:11:09 +0900
> Subject: [PATCH] make reboot to support additional command
> 
> reboot syscall can be performed with additional argument. In some of
> system, this functionality can be useful to ask next boot mode to
> bootloader.
> ---
>  

Re: [systemd-devel] [PATCH] [RFC] Make reboot to support additional command

2013-11-05 Thread WaLyong Cho


On 09/12/2013 02:20 AM, Lennart Poettering wrote:
> On Tue, 13.08.13 03:01, WaLyong Cho (fyd0...@gmail.com) wrote:
> 
>> From: WaLyong Cho 
>>
>> reboot syscall can be performed with additional argument. In some of
>> system, this functionality can be useful to ask next boot mode to
>> bootloader.
> 
> Hmm, interesting stuff. 
> 
>> @@ -5200,9 +5204,19 @@ static int halt_parse_argv(int argc, char *argv[]) {
>>  }
>>  }
>>  
> 
> Note that halt is not called during normal shutdown, but is only a
> compat fallback for the old sysv "halt" command. If you want this to
> work we probably need to come up with a way to pass the string from
> systemctl to the final systemd-shutdown process.
> 
> (A bit of background: systemctl normally will just tell PID 1 to
> shutdown cleanly, via D-Bus. As last step of that PID 1 will execute the
> special systemd-shutdown binary -- which will then also run as PID 1 --
> which will do some final shutdown steps and then invoke the reboot()
> syscall -- see src/core/shutdown.c for details)

Sorry for my long silence.

You were right. Previous my patch did not pass the argument without
force option. So I modified according to your opinion. But I think we
have to keep some codes in systemctl for supporting forced reboot.

> 
> So, before we continue with this, could you point me to some
> docs/commits/code which explain a bit how the new reboot() syscall
> semantics work? i.e. what the possible params are and such?

There are not any params specified. Any string can be used. That string
is used in kernel side.
http://lxr.linux.no/linux+v3.4/kernel/sys.c#L486

Sorry, there are no visible commits for Tizen in the web. But, for
simple example, fota, recovery, download and more are used in Tizen.
fota is used when restart to enter fota updated mode. In the mobile,
user can download firmware image by on air. And update device firmware
to downloaded. During this, reboot is performed. See
http://www.redbend.com/en/products-solutions/fota-updating for detail.
recovery is used for detecting hacked kernel. I am not sure that I can
explain more.
download is used to enter download mode. As you may know, most of
devices are downloaded(not installed) when the device is produced. At
this time, special boot mode is used to flush device.

I found similar codes in android.
https://github.com/CyanogenMod/android_system_core/blob/gingerbread/toolbox/reboot.c
https://github.com/CyanogenMod/android_system_core/blob/gingerbread/libreboot/reboot.c

> 
> One way to implement this could be to add add a new parameter to
> systemctl which is written to /run/systemd/reboot-param or so if
> specified. systemd-shutdown would then look for that file and pass it to
> the reboot() syscall.

According to man page of reboot. They called this 'arg'.
http://man7.org/linux/man-pages/man2/reboot.2.htm
I'm not sure which is more suitable word between 'param' and 'arg'. You
offered 'param', so I used also 'param'. Because, 'arg' can be confused
with argc/argv.

> 
>> -if (optind < argc) {
>> -log_error("Too many arguments.");
>> -return -EINVAL;
>> +if (arg_action == ACTION_REBOOT) {
>> +/* reboot allow just one argument for his command string */
>> +if (optind+1 == argc)
>> +arg_reboot = strdup(argv[argc-1]);
>> +else if (optind+1 < argc) {
>> +log_error("Too many arguments.");
>> +return -EINVAL;
>> +}
>> +} else {
>> +if (optind < argc) {
>> +log_error("Too many arguments.");
>> +return -EINVAL;
>> +}
>>  }
>>  
>>  return 1;
>> @@ -5949,7 +5963,11 @@ static _noreturn_ void halt_now(enum action a) {
>>  
>>  case ACTION_REBOOT:
>>  log_info("Rebooting.");
>> -reboot(RB_AUTOBOOT);
>> +if (arg_reboot)
>> +syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, 
>> LINUX_REBOOT_MAGIC2,
>> +LINUX_REBOOT_CMD_RESTART2, arg_reboot);
>> +else
>> +reboot(RB_AUTOBOOT);
>>  break;
>>  
>>  default:
> 
> 
> Lennart
> 

WaLyong
>From 3e68b25edab207cdeffb267368e24f6c3a5830ae Mon Sep 17 00:00:00 2001
From: WaLyong Cho 
Date: Tue, 5 Nov 2013 17:11:09 +0900
Subject: [PATCH] make reboot to support additional command

reboot syscall can be performed with additional argument. In some of
system, this functionality can be useful to ask next boot mode to
bootloader.
---
 Makefile.am   |4 ++-
 src/core/shutdown.c   |   15 +++---
 src/shared/reboot-param.c |   68 +
 src/shared/reboot-param.h |   28 +++
 src/systemctl/systemctl.c |   43 +---
 5 files changed, 149 insertions

Re: [systemd-devel] [PATCH] [RFC] Make reboot to support additional command

2013-09-11 Thread Lennart Poettering
On Tue, 13.08.13 03:01, WaLyong Cho (fyd0...@gmail.com) wrote:

> From: WaLyong Cho 
> 
> reboot syscall can be performed with additional argument. In some of
> system, this functionality can be useful to ask next boot mode to
> bootloader.

Hmm, interesting stuff. 

> @@ -5200,9 +5204,19 @@ static int halt_parse_argv(int argc, char *argv[]) {
>  }
>  }
>  

Note that halt is not called during normal shutdown, but is only a
compat fallback for the old sysv "halt" command. If you want this to
work we probably need to come up with a way to pass the string from
systemctl to the final systemd-shutdown process.

(A bit of background: systemctl normally will just tell PID 1 to
shutdown cleanly, via D-Bus. As last step of that PID 1 will execute the
special systemd-shutdown binary -- which will then also run as PID 1 --
which will do some final shutdown steps and then invoke the reboot()
syscall -- see src/core/shutdown.c for details)

So, before we continue with this, could you point me to some
docs/commits/code which explain a bit how the new reboot() syscall
semantics work? i.e. what the possible params are and such?

One way to implement this could be to add add a new parameter to
systemctl which is written to /run/systemd/reboot-param or so if
specified. systemd-shutdown would then look for that file and pass it to
the reboot() syscall.

> -if (optind < argc) {
> -log_error("Too many arguments.");
> -return -EINVAL;
> +if (arg_action == ACTION_REBOOT) {
> +/* reboot allow just one argument for his command string */
> +if (optind+1 == argc)
> +arg_reboot = strdup(argv[argc-1]);
> +else if (optind+1 < argc) {
> +log_error("Too many arguments.");
> +return -EINVAL;
> +}
> +} else {
> +if (optind < argc) {
> +log_error("Too many arguments.");
> +return -EINVAL;
> +}
>  }
>  
>  return 1;
> @@ -5949,7 +5963,11 @@ static _noreturn_ void halt_now(enum action a) {
>  
>  case ACTION_REBOOT:
>  log_info("Rebooting.");
> -reboot(RB_AUTOBOOT);
> +if (arg_reboot)
> +syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, 
> LINUX_REBOOT_MAGIC2,
> +LINUX_REBOOT_CMD_RESTART2, arg_reboot);
> +else
> +reboot(RB_AUTOBOOT);
>  break;
>  
>  default:


Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] [RFC] Make reboot to support additional command

2013-08-25 Thread WaLyong Cho


On 08/24/2013 11:38 PM, Zbigniew Jędrzejewski-Szmek wrote:
> On Sat, Aug 24, 2013 at 01:12:42PM +0900, WaLyong Cho wrote:
>> On 08/24/2013 01:47 AM, Zbigniew Jędrzejewski-Szmek wrote:
>>> On Tue, Aug 13, 2013 at 03:01:25AM +0900, WaLyong Cho wrote:
 From: WaLyong Cho 

 reboot syscall can be performed with additional argument. In some of
 system, this functionality can be useful to ask next boot mode to
 bootloader.
>>> What are the possible values of this additional argument?
>>> What systems support it?
>>
>> Any string can be. i.e. download and fota(firmware update by air) can
>> be. In mobile system(actually tizen), if user try to update the firmware
>> by air, then the system should be booted special mode at the next boot.
>> To ask this information to bootloader, reboot can use boot parameter.
> Google tells me that the argument is architecture and firmware specific.
> Do you have some examples of strings that are actually used?

In our system, that is handled by bootloader. Now we are using below
lists. normal, download, fus, fus_rw, ramdump, recovery, fota,
charging.(fus is similar with download)
If I assume some case, in mobile phone, user can upgrade his
firmware(means entire system) through the mobile network. Some of user
interface will be offered to verify of users choice. If user want to
upgrade device then newly released firmware will be downloaded and will
be rebooted for applying that firmware. In this case, device should be
entered special boot mode to upgrade to new firmware. For this we are
using reboot with command argument.(maybe fota in this case)
Reboot parameter is used when trying to enter some other special mode
in(after) the normal boot.

> 
> Zbyszek
> 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] [RFC] Make reboot to support additional command

2013-08-24 Thread Zbigniew Jędrzejewski-Szmek
On Sat, Aug 24, 2013 at 12:58:23PM +0200, Kay Sievers wrote:
> On Sat, Aug 24, 2013 at 6:12 AM, WaLyong Cho  wrote:
> > On 08/24/2013 01:47 AM, Zbigniew Jędrzejewski-Szmek wrote:
> >> On Tue, Aug 13, 2013 at 03:01:25AM +0900, WaLyong Cho wrote:
> >>> From: WaLyong Cho 
> >>>
> >>> reboot syscall can be performed with additional argument. In some of
> >>> system, this functionality can be useful to ask next boot mode to
> >>> bootloader.
> >> What are the possible values of this additional argument?
> >> What systems support it?
> >
> > Any string can be. i.e. download and fota(firmware update by air) can
> > be. In mobile system(actually tizen), if user try to update the firmware
> > by air, then the system should be booted special mode at the next boot.
> > To ask this information to bootloader, reboot can use boot parameter.
> 
> EFI supports something similar:
>   
> http://wiki.phoenix.com/wiki/index.php/EFI_RUNTIME_SERVICES#ResetSystem.28.29
> 
> We need to be careful how to add or support that. If we do that, it
> needs to be supported in PID1 and over the D-Bus interface too, I
> guess.
Right, the first question is whether there's a closed set of options, or
do arbitrary strings need to be supported.

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] [RFC] Make reboot to support additional command

2013-08-24 Thread Zbigniew Jędrzejewski-Szmek
On Sat, Aug 24, 2013 at 01:12:42PM +0900, WaLyong Cho wrote:
> On 08/24/2013 01:47 AM, Zbigniew Jędrzejewski-Szmek wrote:
> > On Tue, Aug 13, 2013 at 03:01:25AM +0900, WaLyong Cho wrote:
> >> From: WaLyong Cho 
> >>
> >> reboot syscall can be performed with additional argument. In some of
> >> system, this functionality can be useful to ask next boot mode to
> >> bootloader.
> > What are the possible values of this additional argument?
> > What systems support it?
> 
> Any string can be. i.e. download and fota(firmware update by air) can
> be. In mobile system(actually tizen), if user try to update the firmware
> by air, then the system should be booted special mode at the next boot.
> To ask this information to bootloader, reboot can use boot parameter.
Google tells me that the argument is architecture and firmware specific.
Do you have some examples of strings that are actually used?

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] [RFC] Make reboot to support additional command

2013-08-24 Thread Kay Sievers
On Sat, Aug 24, 2013 at 6:12 AM, WaLyong Cho  wrote:
> On 08/24/2013 01:47 AM, Zbigniew Jędrzejewski-Szmek wrote:
>> On Tue, Aug 13, 2013 at 03:01:25AM +0900, WaLyong Cho wrote:
>>> From: WaLyong Cho 
>>>
>>> reboot syscall can be performed with additional argument. In some of
>>> system, this functionality can be useful to ask next boot mode to
>>> bootloader.
>> What are the possible values of this additional argument?
>> What systems support it?
>
> Any string can be. i.e. download and fota(firmware update by air) can
> be. In mobile system(actually tizen), if user try to update the firmware
> by air, then the system should be booted special mode at the next boot.
> To ask this information to bootloader, reboot can use boot parameter.

EFI supports something similar:
  http://wiki.phoenix.com/wiki/index.php/EFI_RUNTIME_SERVICES#ResetSystem.28.29

We need to be careful how to add or support that. If we do that, it
needs to be supported in PID1 and over the D-Bus interface too, I
guess.

Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] [RFC] Make reboot to support additional command

2013-08-23 Thread WaLyong Cho
On 08/24/2013 01:47 AM, Zbigniew Jędrzejewski-Szmek wrote:
> On Tue, Aug 13, 2013 at 03:01:25AM +0900, WaLyong Cho wrote:
>> From: WaLyong Cho 
>>
>> reboot syscall can be performed with additional argument. In some of
>> system, this functionality can be useful to ask next boot mode to
>> bootloader.
> What are the possible values of this additional argument?
> What systems support it?

Any string can be. i.e. download and fota(firmware update by air) can
be. In mobile system(actually tizen), if user try to update the firmware
by air, then the system should be booted special mode at the next boot.
To ask this information to bootloader, reboot can use boot parameter.

> 
> Zbyszek
> 
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] [RFC] Make reboot to support additional command

2013-08-23 Thread Zbigniew Jędrzejewski-Szmek
On Tue, Aug 13, 2013 at 03:01:25AM +0900, WaLyong Cho wrote:
> From: WaLyong Cho 
> 
> reboot syscall can be performed with additional argument. In some of
> system, this functionality can be useful to ask next boot mode to
> bootloader.
What are the possible values of this additional argument?
What systems support it?

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] [RFC] Make reboot to support additional command

2013-08-12 Thread WaLyong Cho
From: WaLyong Cho 

reboot syscall can be performed with additional argument. In some of
system, this functionality can be useful to ask next boot mode to
bootloader.
---
 src/systemctl/systemctl.c |   28 +++-
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index a635891..5b46350 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -19,6 +19,8 @@
   along with systemd; If not, see .
 ***/
 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -133,6 +135,7 @@ static char *arg_user = NULL;
 static unsigned arg_lines = 10;
 static OutputMode arg_output = OUTPUT_SHORT;
 static bool arg_plain = false;
+static char *arg_reboot = NULL;
 
 static bool private_bus = false;
 
@@ -4703,7 +4706,7 @@ static int systemctl_help(void) {
 
 static int halt_help(void) {
 
-printf("%s [OPTIONS...]\n\n"
+printf("%s [OPTIONS...]%s\n\n"
"%s the system.\n\n"
" --help  Show this help\n"
" --halt  Halt the machine\n"
@@ -4714,6 +4717,7 @@ static int halt_help(void) {
"  -d --no-wtmp   Don't write wtmp record\n"
" --no-wall   Don't send wall message before 
halt/power-off/reboot\n",
program_invocation_short_name,
+   arg_action == ACTION_REBOOT   ? " " : "",
arg_action == ACTION_REBOOT   ? "Reboot" :
arg_action == ACTION_POWEROFF ? "Power off" :
"Halt");
@@ -5200,9 +5204,19 @@ static int halt_parse_argv(int argc, char *argv[]) {
 }
 }
 
-if (optind < argc) {
-log_error("Too many arguments.");
-return -EINVAL;
+if (arg_action == ACTION_REBOOT) {
+/* reboot allow just one argument for his command string */
+if (optind+1 == argc)
+arg_reboot = strdup(argv[argc-1]);
+else if (optind+1 < argc) {
+log_error("Too many arguments.");
+return -EINVAL;
+}
+} else {
+if (optind < argc) {
+log_error("Too many arguments.");
+return -EINVAL;
+}
 }
 
 return 1;
@@ -5949,7 +5963,11 @@ static _noreturn_ void halt_now(enum action a) {
 
 case ACTION_REBOOT:
 log_info("Rebooting.");
-reboot(RB_AUTOBOOT);
+if (arg_reboot)
+syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, 
LINUX_REBOOT_MAGIC2,
+LINUX_REBOOT_CMD_RESTART2, arg_reboot);
+else
+reboot(RB_AUTOBOOT);
 break;
 
 default:
-- 
1.7.9.5

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel