From 37c076d26669a3c39fd6e931da5b66b9edb4ce63 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 25 Jul 2018 21:41:58 +0200 Subject: sleep-config: partitions can't be deleted, only files can This fixes something I think was basically a typo introduced in db69869f264af2d1afcdd3e573e0e9fdd5bef065. (cherry picked from commit 3dea6886c20a32d832971e589cbc1807c549b66f) --- src/shared/sleep-config.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index 88f2b7007..347858a12 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -202,27 +202,30 @@ int find_hibernate_location(char **device, char **type, size_t *size, size_t *us "%zu " /* used */ "%*i\n", /* priority */ &dev_field, &type_field, &size_field, &used_field); + if (k == EOF) + break; if (k != 4) { - if (k == EOF) - break; - log_warning("Failed to parse /proc/swaps:%u", i); continue; } - if (streq(type_field, "partition")) { + if (streq(type_field, "file")) { + if (endswith(dev_field, "\\040(deleted)")) { - log_warning("Ignoring deleted swapfile '%s'.", dev_field); + log_warning("Ignoring deleted swap file '%s'.", dev_field); continue; } + } else if (streq(type_field, "partition")) { const char *fn; + fn = path_startswith(dev_field, "/dev/"); if (fn && startswith(fn, "zram")) { - log_debug("Ignoring compressed ram swap device '%s'.", dev_field); + log_debug("Ignoring compressed RAM swap device '%s'.", dev_field); continue; } } + if (device) *device = TAKE_PTR(dev_field); if (type) -- cgit v1.2.3