X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flogin%2Flogind-action.c;h=61dddae84c3ec110fbd139e298df8840dae378b5;hp=b0ff774dfd615b6ba3e3b91cd871008067afaaf1;hb=01c94c5d0aff09b4c0e429d483c8eeba40017071;hpb=ef2aa93b7a4c742ae74496566344fd71e411fa72 diff --git a/src/login/logind-action.c b/src/login/logind-action.c index b0ff774df..61dddae84 100644 --- a/src/login/logind-action.c +++ b/src/login/logind-action.c @@ -35,6 +35,7 @@ #include "bus-error.h" #include "bus-util.h" #include "logind-action.h" +#include "formats-util.h" int manager_handle_action( Manager *m, @@ -223,8 +224,7 @@ static int write_state(FILE **f, char **states) { return r; } -static int do_sleep(const char *arg_verb) { - _cleanup_strv_free_ char **modes = NULL, **states = NULL; +static int do_sleep(const char *arg_verb, const char **modes, const char **states) { char *arguments[] = { NULL, (char*) "pre", @@ -235,10 +235,6 @@ static int do_sleep(const char *arg_verb) { int r; _cleanup_fclose_ FILE *f = NULL; - r = parse_sleep_config(arg_verb, &modes, &states); - if (r < 0) - return r; - /* This file is opened first, so that if we hit an error, * we can abort before modifying any state. */ f = fopen("/sys/power/state", "we"); @@ -274,7 +270,7 @@ static int do_sleep(const char *arg_verb) { return r; } -int shutdown_or_sleep(HandleAction action) { +int shutdown_or_sleep(Manager *m, HandleAction action) { switch (action) { case HANDLE_POWEROFF: return run_helper(HALT); @@ -285,11 +281,11 @@ int shutdown_or_sleep(HandleAction action) { case HANDLE_KEXEC: return run_helper(KEXEC); case HANDLE_SUSPEND: - return do_sleep("suspend"); + return do_sleep("suspend", m->suspend_mode, m->suspend_state); case HANDLE_HIBERNATE: - return do_sleep("hibernate"); + return do_sleep("hibernate", m->hibernate_mode, m->hibernate_state); case HANDLE_HYBRID_SLEEP: - return do_sleep("hybrid-sleep"); + return do_sleep("hybrid-sleep", m->hybrid_sleep_mode, m->hybrid_sleep_state); default: return -EINVAL; }