return r;
}
-static int do_sleep(const char *arg_verb, const char **modes, const char **states) {
+static int do_sleep(const char *arg_verb) {
+ _cleanup_strv_free_ char **modes = NULL, **states = NULL;
char *arguments[] = {
NULL,
(char*) "pre",
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");
return r;
}
-int shutdown_or_sleep(Manager *m, HandleAction action) {
+int shutdown_or_sleep(HandleAction action) {
switch (action) {
case HANDLE_POWEROFF:
return run_helper(HALT);
case HANDLE_KEXEC:
return run_helper(KEXEC);
case HANDLE_SUSPEND:
- return do_sleep("suspend", m->suspend_mode, m->suspend_state);
+ return do_sleep("suspend");
case HANDLE_HIBERNATE:
- return do_sleep("hibernate", m->hibernate_mode, m->hibernate_state);
+ return do_sleep("hibernate");
case HANDLE_HYBRID_SLEEP:
- return do_sleep("hybrid-sleep", m->hybrid_sleep_mode, m->hybrid_sleep_state);
+ return do_sleep("hybrid-sleep");
default:
return -EINVAL;
}