diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-04-11 08:51:06 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-04-11 09:26:14 +0200 |
commit | b71c9758d131e5f2b38fcbc6393579a4aab3cb82 (patch) | |
tree | 367a46d547e5ea6f16b9aa0e1f79469688557cf9 /src/login | |
parent | c8c8ee85af35f1e9593a7397cfa289a126dfcb8c (diff) | |
download | systemd-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/login')
-rw-r--r-- | src/login/logind-dbus.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index acf05601a2..83f1aa76b9 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -1835,11 +1835,14 @@ static int method_do_shutdown_or_sleep( if (sleep_verb) { r = can_sleep(sleep_verb); + if (r == -ENOSPC) + return sd_bus_error_set(error, BUS_ERROR_SLEEP_VERB_NOT_SUPPORTED, + "Not enough swap space for hibernation"); + if (r == 0) + return sd_bus_error_setf(error, BUS_ERROR_SLEEP_VERB_NOT_SUPPORTED, + "Sleep verb \"%s\" not supported", sleep_verb); if (r < 0) return r; - - if (r == 0) - return sd_bus_error_setf(error, BUS_ERROR_SLEEP_VERB_NOT_SUPPORTED, "Sleep verb not supported"); } r = verify_shutdown_creds(m, message, w, interactive, action, action_multiple_sessions, @@ -2262,10 +2265,10 @@ static int method_can_shutdown_or_sleep( if (sleep_verb) { r = can_sleep(sleep_verb); + if (IN_SET(r, 0, -ENOSPC)) + return sd_bus_reply_method_return(message, "s", "na"); if (r < 0) return r; - if (r == 0) - return sd_bus_reply_method_return(message, "s", "na"); } r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_EUID, &creds); |