summaryrefslogtreecommitdiff
path: root/src/shared/sleep-config.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-04-11 08:51:06 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-04-11 09:26:14 +0200
commitb71c9758d131e5f2b38fcbc6393579a4aab3cb82 (patch)
tree367a46d547e5ea6f16b9aa0e1f79469688557cf9 /src/shared/sleep-config.c
parentc8c8ee85af35f1e9593a7397cfa289a126dfcb8c (diff)
downloadsystemd-b71c9758d131e5f2b38fcbc6393579a4aab3cb82.tar.gz
shared/sleep-config: return a custom message when not enough swap for hibernation
$ sudo swapoff -av swapoff /dev/vda4 $ sudo systemctl hibernate Failed to hibernate system via logind: Not enough swap space for hibernation Fixes #6729.
Diffstat (limited to 'src/shared/sleep-config.c')
-rw-r--r--src/shared/sleep-config.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c
index 03fd497f52..1b684b90cb 100644
--- a/src/shared/sleep-config.c
+++ b/src/shared/sleep-config.c
@@ -369,12 +369,12 @@ static bool can_s2h(void) {
FOREACH_STRING(p, "suspend", "hibernate") {
r = can_sleep(p);
- if (r < 0)
- return log_debug_errno(r, "Failed to check if %s is possible: %m", p);
- if (r == 0) {
+ if (IN_SET(r, 0, -ENOSPC)) {
log_debug("Unable to %s system.", p);
return false;
}
+ if (r < 0)
+ return log_debug_errno(r, "Failed to check if %s is possible: %m", p);
}
return true;
@@ -396,5 +396,11 @@ int can_sleep(const char *verb) {
if (!can_sleep_state(states) || !can_sleep_disk(modes))
return false;
- return streq(verb, "suspend") || enough_memory_for_hibernation();
+ if (streq(verb, "suspend"))
+ return true;
+
+ if (!enough_memory_for_hibernation())
+ return -ENOSPC;
+
+ return true;
}