logind: Add new flag for kexec reboot
Add new flag to allow kexec reboot if kernel is already loaded.
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
a93af34a40
commit
0d96caa5c0
@@ -161,7 +161,7 @@ int halt_main(void) {
|
||||
|
||||
/* Try logind if we are a normal user and no special mode applies. Maybe polkit allows us to
|
||||
* shutdown the machine. */
|
||||
if (IN_SET(arg_action, ACTION_POWEROFF, ACTION_REBOOT, ACTION_HALT)) {
|
||||
if (IN_SET(arg_action, ACTION_POWEROFF, ACTION_REBOOT, ACTION_KEXEC, ACTION_HALT)) {
|
||||
r = logind_reboot(arg_action);
|
||||
if (r >= 0)
|
||||
return r;
|
||||
|
||||
@@ -50,6 +50,7 @@ int logind_reboot(enum action a) {
|
||||
} actions[_ACTION_MAX] = {
|
||||
[ACTION_POWEROFF] = { "PowerOff", "power off system" },
|
||||
[ACTION_REBOOT] = { "Reboot", "reboot system" },
|
||||
[ACTION_KEXEC] = { "Reboot", "kexec reboot system" },
|
||||
[ACTION_HALT] = { "Halt", "halt system" },
|
||||
[ACTION_SUSPEND] = { "Suspend", "suspend system" },
|
||||
[ACTION_HIBERNATE] = { "Hibernate", "hibernate system" },
|
||||
@@ -79,6 +80,7 @@ int logind_reboot(enum action a) {
|
||||
return 0;
|
||||
|
||||
SET_FLAG(flags, SD_LOGIND_ROOT_CHECK_INHIBITORS, arg_check_inhibitors > 0);
|
||||
SET_FLAG(flags, SD_LOGIND_KEXEC_REBOOT, a == ACTION_KEXEC);
|
||||
|
||||
method_with_flags = strjoina(actions[a].method, "WithFlags");
|
||||
|
||||
|
||||
@@ -201,6 +201,7 @@ int start_special(int argc, char *argv[], void *userdata) {
|
||||
if (IN_SET(a,
|
||||
ACTION_POWEROFF,
|
||||
ACTION_REBOOT,
|
||||
ACTION_KEXEC,
|
||||
ACTION_HALT,
|
||||
ACTION_SUSPEND,
|
||||
ACTION_HIBERNATE,
|
||||
@@ -220,9 +221,9 @@ int start_special(int argc, char *argv[], void *userdata) {
|
||||
|
||||
arg_no_block = true;
|
||||
|
||||
} else if (IN_SET(a, ACTION_EXIT, ACTION_KEXEC))
|
||||
/* Since exit/kexec are so close in behaviour to power-off/reboot, let's also make
|
||||
* them asynchronous, in order to not confuse the user needlessly with unexpected
|
||||
} else if (IN_SET(a, ACTION_EXIT))
|
||||
/* Since exit is so close in behaviour to power-off/reboot, let's also make
|
||||
* it asynchronous, in order to not confuse the user needlessly with unexpected
|
||||
* behaviour. */
|
||||
arg_no_block = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user