mirror of
https://github.com/systemd/systemd.git
synced 2025-02-08 09:57:41 +03:00
hibernate-util: de-duplicate clear_efi_hibernate_location
This commit is contained in:
parent
3a4e3d4f9e
commit
8ad973ed99
@ -225,17 +225,6 @@ void compare_hibernate_location_and_warn(const HibernateInfo *info) {
|
||||
log_warning("resume_offset=%" PRIu64 " doesn't match with EFI HibernateLocation offset %" PRIu64 ", proceeding anyway with resume_offset=.",
|
||||
info->cmdline->offset, info->efi->offset);
|
||||
}
|
||||
|
||||
void clear_efi_hibernate_location(void) {
|
||||
int r;
|
||||
|
||||
if (!is_efi_boot())
|
||||
return;
|
||||
|
||||
r = efi_set_variable(EFI_SYSTEMD_VARIABLE(HibernateLocation), NULL, 0);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to clear EFI variable HibernateLocation, ignoring: %m");
|
||||
}
|
||||
#endif
|
||||
|
||||
int acquire_hibernate_info(HibernateInfo *ret) {
|
||||
|
@ -40,16 +40,10 @@ int acquire_hibernate_info(HibernateInfo *ret);
|
||||
|
||||
void compare_hibernate_location_and_warn(const HibernateInfo *info);
|
||||
|
||||
void clear_efi_hibernate_location(void);
|
||||
|
||||
#else
|
||||
|
||||
static inline void compare_hibernate_location_and_warn(const HibernateInfo *info) {
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void clear_efi_hibernate_location(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -60,7 +60,7 @@ static int run(int argc, char *argv[]) {
|
||||
return r;
|
||||
|
||||
if (arg_info.efi)
|
||||
clear_efi_hibernate_location();
|
||||
clear_efi_hibernate_location_and_warn();
|
||||
}
|
||||
|
||||
if (stat(arg_info.device, &st) < 0)
|
||||
|
@ -506,3 +506,14 @@ int write_resume_config(dev_t devno, uint64_t offset, const char *device) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void clear_efi_hibernate_location_and_warn(void) {
|
||||
int r;
|
||||
|
||||
if (!is_efi_boot())
|
||||
return;
|
||||
|
||||
r = efi_set_variable(EFI_SYSTEMD_VARIABLE(HibernateLocation), NULL, 0);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to clear EFI variable HibernateLocation, ignoring: %m");
|
||||
}
|
||||
|
@ -22,5 +22,7 @@ int hibernation_is_safe(void);
|
||||
|
||||
int write_resume_config(dev_t devno, uint64_t offset, const char *device);
|
||||
|
||||
void clear_efi_hibernate_location_and_warn(void);
|
||||
|
||||
/* Only for test-fiemap */
|
||||
int read_fiemap(int fd, struct fiemap **ret);
|
||||
|
@ -301,8 +301,8 @@ static int execute(
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
if (sleep_operation_is_hibernation(operation) && is_efi_boot())
|
||||
(void) efi_set_variable(EFI_SYSTEMD_VARIABLE(HibernateLocation), NULL, 0);
|
||||
if (sleep_operation_is_hibernation(operation))
|
||||
clear_efi_hibernate_location_and_warn();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user