mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
hibernate-util: check 'noresume' before reading resume setting
Also hibernation_is_safe() should really take this into consideration too.
This commit is contained in:
@@ -2154,7 +2154,7 @@ static int method_do_shutdown_or_sleep(
|
||||
|
||||
case SLEEP_RESUME_NOT_SUPPORTED:
|
||||
return sd_bus_error_set(error, BUS_ERROR_SLEEP_VERB_NOT_SUPPORTED,
|
||||
"Not running on EFI and resume= is not set. No available method to resume from hibernation");
|
||||
"Not running on EFI and resume= is not set, or noresume is set. No available method to resume from hibernation");
|
||||
|
||||
case SLEEP_NOT_ENOUGH_SWAP_SPACE:
|
||||
return sd_bus_error_set(error, BUS_ERROR_SLEEP_VERB_NOT_SUPPORTED,
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "log.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "proc-cmdline.h"
|
||||
#include "stat-util.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
@@ -129,6 +130,13 @@ static int read_resume_config(dev_t *ret_devno, uint64_t *ret_offset) {
|
||||
assert(ret_devno);
|
||||
assert(ret_offset);
|
||||
|
||||
r = proc_cmdline_get_key("noresume", /* flags = */ 0, /* ret_value = */ NULL);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to check if 'noresume' kernel command line option is set: %m");
|
||||
if (r > 0)
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(ENOTRECOVERABLE),
|
||||
"'noresume' kernel command line option is set, refusing hibernation device lookup.");
|
||||
|
||||
r = read_one_line_file("/sys/power/resume", &devno_str);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to read /sys/power/resume: %m");
|
||||
|
||||
Reference in New Issue
Block a user