From: Mike Yuan Date: Tue, 5 Dec 2023 08:37:36 +0000 (+0800) Subject: hibernate-resume: always clear HibernateLocation if system info matches X-Git-Tag: v256-rc1~1564^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=24ab77c3cd72306f23edef11091feec100603cac;p=thirdparty%2Fsystemd.git hibernate-resume: always clear HibernateLocation if system info matches Follow-up for a628d933cc67cc8b183dc809ba1451aa5b2996e5 HibernateInfo.from_efi is not actually useful. info.efi is only set if the system identifier stored in EFI variable matches with that of the running system, and thus the variable should be cleared no matter whether resume= is set from kernel cmdline or not. --- diff --git a/src/hibernate-resume/hibernate-resume-config.c b/src/hibernate-resume/hibernate-resume-config.c index fe4add2c19f..e4be7ca2451 100644 --- a/src/hibernate-resume/hibernate-resume-config.c +++ b/src/hibernate-resume/hibernate-resume-config.c @@ -204,13 +204,12 @@ void compare_hibernate_location_and_warn(const HibernateInfo *info) { int r; assert(info); - assert(info->from_efi || info->cmdline); - if (info->from_efi) - return; - if (!info->efi) + if (!info->cmdline || !info->efi) return; + assert(info->device == info->cmdline->device); + if (!path_equal(info->cmdline->device, info->efi->device)) { r = devnode_same(info->cmdline->device, info->efi->device); if (r < 0) @@ -256,11 +255,9 @@ int acquire_hibernate_info(HibernateInfo *ret) { if (i.cmdline) { i.device = i.cmdline->device; i.offset = i.cmdline->offset; - i.from_efi = false; } else if (i.efi) { i.device = i.efi->device; i.offset = i.efi->offset; - i.from_efi = true; } else return -ENODEV; diff --git a/src/hibernate-resume/hibernate-resume-config.h b/src/hibernate-resume/hibernate-resume-config.h index 364abf79128..365d9ccda59 100644 --- a/src/hibernate-resume/hibernate-resume-config.h +++ b/src/hibernate-resume/hibernate-resume-config.h @@ -27,7 +27,6 @@ typedef struct EFIHibernateLocation { typedef struct HibernateInfo { const char *device; uint64_t offset; /* in memory pages */ - bool from_efi; KernelHibernateLocation *cmdline; EFIHibernateLocation *efi; diff --git a/src/hibernate-resume/hibernate-resume.c b/src/hibernate-resume/hibernate-resume.c index 9d81332f26c..175a0bda960 100644 --- a/src/hibernate-resume/hibernate-resume.c +++ b/src/hibernate-resume/hibernate-resume.c @@ -59,7 +59,7 @@ static int run(int argc, char *argv[]) { if (r <= 0) return r; - if (arg_info.from_efi) + if (arg_info.efi) clear_efi_hibernate_location(); }