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