forked from pool/systemd
a6c42807cc
- Update to release 202: + 'systemctl list-jobs' got some polishing. '--type=' argument may now be passed more than once. 'systemctl list-sockets' has been added. + systemd gained a new unit 'systemd-static-nodes.service' that generates static device nodes earlier during boot, and can run in conjunction with udev. + systemd-nspawn now places all containers in the new /machine top-level cgroup directory in the name=systemd hierarchy. + bootchart can now store its data in the journal. + journactl can now take multiple --unit= and --user-unit= switches. + The cryptsetup logic now understands the "luks.key=" kernel command line switch. If a configured key file is missing, it will fallback to prompting the user. - Rebase some patches - Update handle-SYSTEMCTL_OPTIONS-environment-variable.patch to properly handle SYSTEMCTL_OPTIONS - Fix regression in the default for tmp auto-deletion (systemd-tmp-safe-defaults.patch, FATE#314974). - Add chromebook lid switch as a power switch to logind rule to enable suspend on lid close - Update to release 202: + 'systemctl list-jobs' got some polishing. '--type=' argument may now be passed more than once. 'systemctl list-sockets' has been added. + systemd gained a new unit 'systemd-static-nodes.service' OBS-URL: https://build.opensuse.org/request/show/172582 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=365
103 lines
3.1 KiB
Diff
103 lines
3.1 KiB
Diff
From: Frederic Crozat <fcrozat@suse.com>
|
|
Date: Tue, 19 Feb 2013 11:20:31 +0100
|
|
Subject: Forward suspend / hibernate calls to pm-utils
|
|
|
|
forward suspend/hibernation calls to pm-utils, if installed (bnc#790157)
|
|
---
|
|
src/sleep/sleep.c | 27 ++++++++++++++++++++++++---
|
|
1 file changed, 24 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c
|
|
index f5e78c1..8d91117 100644
|
|
--- a/src/sleep/sleep.c
|
|
+++ b/src/sleep/sleep.c
|
|
@@ -22,6 +22,7 @@
|
|
#include <stdio.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
+#include <stdlib.h>
|
|
|
|
#include "log.h"
|
|
#include "util.h"
|
|
@@ -32,6 +33,9 @@
|
|
int main(int argc, char *argv[]) {
|
|
const char *verb;
|
|
char* arguments[4];
|
|
+ const char *pmtools;
|
|
+ bool delegate_to_pmutils = false;
|
|
+ struct stat buf;
|
|
int r;
|
|
FILE *f;
|
|
|
|
@@ -45,17 +49,27 @@ int main(int argc, char *argv[]) {
|
|
goto finish;
|
|
}
|
|
|
|
- if (streq(argv[1], "suspend"))
|
|
+ if (streq(argv[1], "suspend")) {
|
|
verb = "mem";
|
|
- else if (streq(argv[1], "hibernate") || streq(argv[1], "hybrid-sleep"))
|
|
+ pmtools = "/usr/sbin/pm-suspend";
|
|
+ }
|
|
+ else if (streq(argv[1], "hibernate") || streq(argv[1], "hybrid-sleep")) {
|
|
verb = "disk";
|
|
+ if (streq(argv[1], "hibernate"))
|
|
+ pmtools = "/usr/sbin/pm-hibernate";
|
|
+ else
|
|
+ pmtools = "/usr/sbin/pm-suspend-hybrid";
|
|
+ }
|
|
else {
|
|
log_error("Unknown action '%s'.", argv[1]);
|
|
r = -EINVAL;
|
|
goto finish;
|
|
}
|
|
|
|
+ delegate_to_pmutils = (stat(pmtools, &buf) >= 0 && S_ISREG(buf.st_mode) && (buf.st_mode & 0111));
|
|
+
|
|
/* Configure the hibernation mode */
|
|
+ if (!delegate_to_pmutils) {
|
|
if (streq(argv[1], "hibernate")) {
|
|
if (write_string_file("/sys/power/disk", "platform") < 0)
|
|
write_string_file("/sys/power/disk", "shutdown");
|
|
@@ -65,13 +79,14 @@ int main(int argc, char *argv[]) {
|
|
write_string_file("/sys/power/disk", "shutdown");
|
|
}
|
|
|
|
+
|
|
f = fopen("/sys/power/state", "we");
|
|
if (!f) {
|
|
log_error("Failed to open /sys/power/state: %m");
|
|
r = -errno;
|
|
goto finish;
|
|
}
|
|
-
|
|
+ }
|
|
arguments[0] = NULL;
|
|
arguments[1] = (char*) "pre";
|
|
arguments[2] = argv[1];
|
|
@@ -97,11 +112,16 @@ int main(int argc, char *argv[]) {
|
|
"SLEEP=hybrid-sleep",
|
|
NULL);
|
|
|
|
+ if (delegate_to_pmutils) {
|
|
+ r = -system(pmtools);
|
|
+ }
|
|
+ else {
|
|
fputs(verb, f);
|
|
fputc('\n', f);
|
|
fflush(f);
|
|
|
|
r = ferror(f) ? -errno : 0;
|
|
+ }
|
|
|
|
if (streq(argv[1], "suspend"))
|
|
log_struct(LOG_INFO,
|
|
@@ -119,6 +139,7 @@ int main(int argc, char *argv[]) {
|
|
arguments[1] = (char*) "post";
|
|
execute_directory(SYSTEM_SLEEP_PATH, NULL, arguments);
|
|
|
|
+ if (!delegate_to_pmutils)
|
|
fclose(f);
|
|
|
|
finish:
|