]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hibernate-resume: always clear HibernateLocation if system info matches 30322/head
authorMike Yuan <me@yhndnzj.com>
Tue, 5 Dec 2023 08:37:36 +0000 (16:37 +0800)
committerMike Yuan <me@yhndnzj.com>
Tue, 5 Dec 2023 08:52:19 +0000 (16:52 +0800)
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.

src/hibernate-resume/hibernate-resume-config.c
src/hibernate-resume/hibernate-resume-config.h
src/hibernate-resume/hibernate-resume.c

index fe4add2c19f28cbddf487e64ef1949f5439eadf2..e4be7ca245171ce0245c0866b40d26e34344a185 100644 (file)
@@ -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;
 
index 364abf79128cbb06c6704aeacb081fee8e77518e..365d9ccda5934bded24b7c040aee4d488d00aa1e 100644 (file)
@@ -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;
index 9d81332f26c7473a64818aff6efdfc7b511afe4e..175a0bda960274c7c9117ec1237b7f8ce296eb02 100644 (file)
@@ -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();
         }