summaryrefslogtreecommitdiffstats
path: root/src/hibernate-resume
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2023-07-09 00:10:18 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2023-07-09 13:13:16 +0200
commitc089af84c460204eba04dfe663875c50016e1446 (patch)
tree2cf0f152ec3901654bb89f6dd898bb854f45264e /src/hibernate-resume
parentcoccinelle/take-fd: match for -EBADF instead of -1 (diff)
downloadsystemd-c089af84c460204eba04dfe663875c50016e1446.tar.xz
systemd-c089af84c460204eba04dfe663875c50016e1446.zip
hibernate-resume: refuse resume if resume_offset= is set but not resume=
Diffstat (limited to 'src/hibernate-resume')
-rw-r--r--src/hibernate-resume/hibernate-resume-generator.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/hibernate-resume/hibernate-resume-generator.c b/src/hibernate-resume/hibernate-resume-generator.c
index 5ace8543f0..32b65a5913 100644
--- a/src/hibernate-resume/hibernate-resume-generator.c
+++ b/src/hibernate-resume/hibernate-resume-generator.c
@@ -32,6 +32,7 @@ static char *arg_resume_options = NULL;
static char *arg_root_options = NULL;
static bool arg_noresume = false;
static uint64_t arg_resume_offset = 0;
+static bool arg_resume_offset_set = false;
STATIC_DESTRUCTOR_REGISTER(arg_resume_device, freep);
STATIC_DESTRUCTOR_REGISTER(arg_resume_options, freep);
@@ -73,6 +74,8 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
if (r < 0)
return log_error_errno(r, "Failed to parse resume_offset=%s: %m", value);
+ arg_resume_offset_set = true;
+
} else if (proc_cmdline_key_streq(key, "resumeflags")) {
if (proc_cmdline_value_missing(key, value))
@@ -263,6 +266,11 @@ static int run(const char *dest, const char *dest_early, const char *dest_late)
return 0;
}
+ if (!arg_resume_device && arg_resume_offset_set)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Found resume_offset=%" PRIu64 " but resume= is unset, refusing.",
+ arg_resume_offset);
+
r = parse_efi_hibernate_location();
if (r == -ENOMEM)
return r;