diff options
author | Andrew Jorgensen <ajorgens@amazon.com> | 2018-07-25 08:06:57 -0700 |
---|---|---|
committer | Sven Eden <sven.eden@prydeworx.com> | 2018-10-29 10:18:24 +0100 |
commit | 88390a9d8b3ad57671c696f7b5b836ed164a84a1 (patch) | |
tree | 377ea8bf0a4084cd1a2e32c5457bf90fdd564753 /src/shared/sleep-config.c | |
parent | 47e5c14d2dba9e136e1ef0e51ebdb3116e9ecd3c (diff) |
shared/sleep-config: exclude zram devices from hibernation candidates
On a host with sufficiently large zram but with no actual swap, logind will
respond to CanHibernate() with yes. With this patch, it will correctly respond
no, unless there are other swap devices to consider.
(cherry picked from commit 411ae92b407bd7b4549b205ad754bcd0e3dfd81f)
Diffstat (limited to 'src/shared/sleep-config.c')
-rw-r--r-- | src/shared/sleep-config.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index 77b380ca3..88f2b7007 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -21,6 +21,7 @@ //#include "log.h" //#include "macro.h" #include "parse-util.h" +//#include "path-util.h" #include "sleep-config.h" #include "string-util.h" #include "strv.h" @@ -209,9 +210,18 @@ int find_hibernate_location(char **device, char **type, size_t *size, size_t *us continue; } - if (streq(type_field, "partition") && endswith(dev_field, "\\040(deleted)")) { - log_warning("Ignoring deleted swapfile '%s'.", dev_field); - continue; + if (streq(type_field, "partition")) { + if (endswith(dev_field, "\\040(deleted)")) { + log_warning("Ignoring deleted swapfile '%s'.", dev_field); + continue; + } + + const char *fn; + fn = path_startswith(dev_field, "/dev/"); + if (fn && startswith(fn, "zram")) { + log_debug("Ignoring compressed ram swap device '%s'.", dev_field); + continue; + } } if (device) *device = TAKE_PTR(dev_field); |