naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
923a60
From 8fc26bd114d2aa997da261ac7c488d4c25116af3 Mon Sep 17 00:00:00 2001
923a60
From: Andrew Jorgensen <ajorgens@amazon.com>
923a60
Date: Wed, 25 Jul 2018 08:06:57 -0700
923a60
Subject: [PATCH] shared/sleep-config: exclude zram devices from hibernation
923a60
 candidates
923a60
923a60
On a host with sufficiently large zram but with no actual swap, logind will
923a60
respond to CanHibernate() with yes. With this patch, it will correctly respond
923a60
no, unless there are other swap devices to consider.
923a60
923a60
(cherry picked from commit 411ae92b407bd7b4549b205ad754bcd0e3dfd81f)
923a60
923a60
Resolves: #1609816
923a60
---
923a60
 src/shared/sleep-config.c | 17 ++++++++++++++---
923a60
 1 file changed, 14 insertions(+), 3 deletions(-)
923a60
923a60
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c
923a60
index 1064fd5cbd..c4334652fc 100644
923a60
--- a/src/shared/sleep-config.c
923a60
+++ b/src/shared/sleep-config.c
923a60
@@ -25,6 +25,7 @@
923a60
 #include "sleep-config.h"
923a60
 #include "fileio.h"
923a60
 #include "log.h"
923a60
+#include "path-util.h"
923a60
 #include "strv.h"
923a60
 #include "util.h"
923a60
 
923a60
@@ -202,9 +203,19 @@ static int hibernation_partition_size(size_t *size, size_t *used) {
923a60
                         continue;
923a60
                 }
923a60
 
923a60
-                if (streq(type, "partition") && endswith(dev, "\\040(deleted)")) {
923a60
-                        log_warning("Ignoring deleted swapfile '%s'.", dev);
923a60
-                        continue;
923a60
+                if (streq(type, "partition")) {
923a60
+                        const char *fn;
923a60
+
923a60
+                        if (endswith(dev, "\\040(deleted)")) {
923a60
+                                log_warning("Ignoring deleted swapfile '%s'.", dev);
923a60
+                                continue;
923a60
+                        }
923a60
+
923a60
+                        fn = path_startswith(dev, "/dev/");
923a60
+                        if (fn && startswith(fn, "zram")) {
923a60
+                                log_debug("Ignoring compressed ram swap device '%s'.", dev);
923a60
+                                continue;
923a60
+                        }
923a60
                 }
923a60
 
923a60
                 *size = size_field;