diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-04-11 08:51:06 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-08-24 16:47:08 +0200 |
commit | adeb587a08c5f314cb74ccd31128e8dece59a945 (patch) | |
tree | 011e6c027a19abc0b341b271ea6733cb89ef8591 /src/shared | |
parent | 797ec1bf0caeea2b72de01f8082bba2d785a20e4 (diff) |
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')
-rw-r--r-- | src/shared/sleep-config.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index 210e753c4..28d19c59b 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -380,12 +380,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; @@ -426,5 +426,12 @@ int can_sleep(const char *verb) { 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; } #endif // 0 |