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