chiark / gitweb /
sleep-config: fix useless check for swapfile type
authorDave Reisner <dreisner@archlinux.org>
Tue, 24 Dec 2013 21:42:06 +0000 (16:42 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 24 Dec 2013 21:43:33 +0000 (16:43 -0500)
Since 0c6f1f4ea49 the check was useless, because the kernel will
ever only write "partition" or "file" there.

OTOH, it is possible that "\\040(deleted)" (escaped " (deleted)")
will be added for removed files. This should not happen, so add
a warning to detect those cases.

src/shared/sleep-config.c

index 2bb0493812ca92ac9ed4c3a760e8187a17a2262a..d76e3ad0365411b46dd4c4ac7e7c985675833f2e 100644 (file)
@@ -183,7 +183,7 @@ static int hibernation_partition_size(size_t *size, size_t *used) {
         (void) fscanf(f, "%*s %*s %*s %*s %*s\n");
 
         for (i = 1;; i++) {
-                _cleanup_free_ char *dev = NULL, *d = NULL, *type = NULL;
+                _cleanup_free_ char *dev = NULL, *type = NULL;
                 size_t size_field, used_field;
                 int k;
 
@@ -202,12 +202,8 @@ static int hibernation_partition_size(size_t *size, size_t *used) {
                         continue;
                 }
 
-                d = cunescape(dev);
-                if (!d)
-                        return -ENOMEM;
-
-                if (!streq(type, "partition") && !streq(type, "file")) {
-                        log_debug("Partition %s has type %s, ignoring.", d, type);
+                if (streq(type, "partition") && endswith(dev, "\\040(deleted)")) {
+                        log_warning("Ignoring deleted swapfile '%s'.", dev);
                         continue;
                 }