Merge pull request #30322 from YHNdnzj/hibernate-improvements

A few improvements for hibernate-util/hibernate-resume
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2023-12-06 22:29:43 +01:00
committed by GitHub
5 changed files with 6 additions and 10 deletions
@@ -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;
@@ -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;
+1 -1
View 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();
}
+1 -1
View File
@@ -446,7 +446,7 @@ int hibernation_is_safe(void) {
"Not running on EFI and resume= is not set. Hibernation is not safe.");
if (bypass_space_check)
return true;
return 0;
r = get_proc_meminfo_active(&active);
if (r < 0)
+1 -1
View File
@@ -218,7 +218,6 @@ static int execute(
NULL
};
_cleanup_(hibernation_device_done) HibernationDevice hibernation_device = {};
_cleanup_close_ int state_fd = -EBADF;
int r;
@@ -238,6 +237,7 @@ static int execute(
/* Configure hibernation settings if we are supposed to hibernate */
if (sleep_operation_is_hibernation(operation)) {
_cleanup_(hibernation_device_done) HibernationDevice hibernation_device = {};
bool resume_set;
r = find_suitable_hibernation_device(&hibernation_device);