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