a52f674
From 873186b8f64a8c1e37300e9e82876a21244bf9cf Mon Sep 17 00:00:00 2001
b12ff75
From: Dave Reisner <dreisner@archlinux.org>
b12ff75
Date: Tue, 24 Dec 2013 16:42:06 -0500
b12ff75
Subject: [PATCH] sleep-config: fix useless check for swapfile type
b12ff75
b12ff75
Since 0c6f1f4ea49 the check was useless, because the kernel will
b12ff75
ever only write "partition" or "file" there.
b12ff75
b12ff75
OTOH, it is possible that "\\040(deleted)" (escaped " (deleted)")
b12ff75
will be added for removed files. This should not happen, so add
b12ff75
a warning to detect those cases.
a52f674
a52f674
(cherry picked from commit db69869f264af2d1afcdd3e573e0e9fdd5bef065)
b12ff75
---
b12ff75
 src/shared/sleep-config.c | 10 +++-------
b12ff75
 1 file changed, 3 insertions(+), 7 deletions(-)
b12ff75
b12ff75
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c
b12ff75
index 2bb0493..d76e3ad 100644
b12ff75
--- a/src/shared/sleep-config.c
b12ff75
+++ b/src/shared/sleep-config.c
b12ff75
@@ -183,7 +183,7 @@ static int hibernation_partition_size(size_t *size, size_t *used) {
b12ff75
         (void) fscanf(f, "%*s %*s %*s %*s %*s\n");
b12ff75
 
b12ff75
         for (i = 1;; i++) {
b12ff75
-                _cleanup_free_ char *dev = NULL, *d = NULL, *type = NULL;
b12ff75
+                _cleanup_free_ char *dev = NULL, *type = NULL;
b12ff75
                 size_t size_field, used_field;
b12ff75
                 int k;
b12ff75
 
b12ff75
@@ -202,12 +202,8 @@ static int hibernation_partition_size(size_t *size, size_t *used) {
b12ff75
                         continue;
b12ff75
                 }
b12ff75
 
b12ff75
-                d = cunescape(dev);
b12ff75
-                if (!d)
b12ff75
-                        return -ENOMEM;
b12ff75
-
b12ff75
-                if (!streq(type, "partition") && !streq(type, "file")) {
b12ff75
-                        log_debug("Partition %s has type %s, ignoring.", d, type);
b12ff75
+                if (streq(type, "partition") && endswith(dev, "\\040(deleted)")) {
b12ff75
+                        log_warning("Ignoring deleted swapfile '%s'.", dev);
b12ff75
                         continue;
b12ff75
                 }
b12ff75