SHA256
1
0
forked from pool/systemd
systemd/Forward-suspend-hibernate-calls-to-pm-utils.patch
Stephan Kulow bbba62be60 Accepting request 225408 from Base:System
- Add or port upstream bugfix patches: 
  0001-Fix-systemd-stdio-bridge-symlink.patch
  0002-execute-free-directory-path-if-we-fail-to-remove-it-.patch
  0003-Do-not-print-invalid-UTF-8-in-error-messages.patch
  0004-man-document-missing-options-of-systemd-run.patch
  0005-systemd-run-add-some-extra-safety-checks.patch
  0006-journal-assume-that-next-entry-is-after-previous-ent.patch
  0007-journal-forget-file-after-encountering-an-error.patch
  0008-core-correctly-unregister-PIDs-from-PID-hashtables.patch
  0009-logind-fix-reference-to-systemd-user-sessions.servic.patch
  0010-man-update-link-to-LSB.patch
  0011-man-systemd-bootchart-fix-spacing-in-command.patch
  0012-man-add-missing-comma.patch
  0013-units-Do-not-unescape-instance-name-in-systemd-backl.patch

- Add linker scripts as place holder of the old systemd shared
  libraries now all included in libsystemd.so  (bnc#867128)

- Make patch 1006-udev-always-rename-network.patch work again
  and add it again. 

- address missing owner functionality in systemd-tmpfiles (fate#314974)
  1022-systemd-tmpfiles-ownerkeep.patch

- Generate the bash completion files on the fly for the case of
  not having the package bash-completion around 
- Add or port upstream bugfix patches:
  0001-nspawn-fix-detection-of-missing-proc-self-loginuid.patch
  0002-cdrom_id-use-the-old-MMC-fallback.patch
  0003-journalctl-refuse-extra-arguments-with-verify-and-si.patch

OBS-URL: https://build.opensuse.org/request/show/225408
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=177
2014-03-11 08:24:11 +00:00

95 lines
2.7 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 | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
--- systemd-206.orig/src/sleep/sleep.c
+++ systemd-206/src/sleep/sleep.c
@@ -24,6 +24,7 @@
#include <errno.h>
#include <string.h>
#include <getopt.h>
+#include <stdlib.h>
#include "systemd/sd-id128.h"
#include "systemd/sd-messages.h"
@@ -35,6 +36,8 @@
#include "sleep-config.h"
static char* arg_verb = NULL;
+static bool delegate_to_pmutils = false;
+static const char *pmtools;
static int write_mode(char **modes) {
int r = 0;
@@ -50,9 +53,6 @@ static int write_mode(char **modes) {
r = k;
}
- if (r < 0)
- log_error("Failed to write mode to /sys/power/disk: %s",
- strerror(-r));
return r;
}
@@ -90,6 +90,8 @@ static int execute(char **modes, char **
_cleanup_fclose_ FILE *f = NULL;
const char* note = strappenda("SLEEP=", arg_verb);
+ if (!delegate_to_pmutils) {
+
/* 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");
@@ -102,6 +104,7 @@ static int execute(char **modes, char **
r = write_mode(modes);
if (r < 0)
return r;
+ }
arguments[0] = NULL;
arguments[1] = (char*) "pre";
@@ -114,8 +117,10 @@ static int execute(char **modes, char **
"MESSAGE=Suspending system...",
note,
NULL);
-
+ if (!delegate_to_pmutils)
r = write_state(&f, states);
+ else
+ r = -system(pmtools);
if (r < 0)
return r;
@@ -158,6 +163,7 @@ static int parse_argv(int argc, char *ar
};
int c;
+ struct stat buf;
assert(argc >= 0);
assert(argv);
@@ -196,6 +202,18 @@ static int parse_argv(int argc, char *ar
return -EINVAL;
}
+ if (streq(arg_verb, "suspend")) {
+ pmtools = "/usr/sbin/pm-suspend";
+ }
+ else if (streq(arg_verb, "hibernate") || streq(arg_verb, "hybrid-sleep")) {
+ if (streq(arg_verb, "hibernate"))
+ pmtools = "/usr/sbin/pm-hibernate";
+ else
+ pmtools = "/usr/sbin/pm-suspend-hybrid";
+ }
+
+ delegate_to_pmutils = (stat(pmtools, &buf) >= 0 && S_ISREG(buf.st_mode) && (buf.st_mode & 0111));
+
return 1 /* work to do */;
}