Skip to content

Commit e683470

Browse files
committed
remove force_resume, improve checks to handle errors more effectively
Signed-off-by: Zen <[email protected]>
1 parent 3042ce7 commit e683470

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

src/ugrd/fs/resume.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
def handle_resume(self) -> None:
55
"""Returns a bash script handling resume from hibernation.
66
Checks that /sys/power/resume is writable, resume= is set, and noresume is not set, if so,
7-
checks if a = is in the resume var, and tries to use blkid to find the resume device.
7+
checks if PARTUUID= is in the resume var, and tries to use blkid to find the resume device.
88
If the specified device exists, writes resume device to /sys/power/resume.
9-
In the event of failure, it prints an error message and a list of block devices.
9+
In the event of failure, it prints an error message, a list of block devuices, then runs rd_fail.
10+
1011
1112
Resuming or failing to do so is potentially dangerous.
1213
If the system was hibernated, and fails to resume, it will be in an inconsistent state.
1314
If the system is freshly booted, it will not be able to resume, as there is no hibernation image.
1415
Distinguising between a fresh boot and missing/borked hibernation image is not possible at run time.
1516
"""
16-
out_str = [
17+
return [
1718
"resumeval=$(readvar resume)", # read the cmdline resume var
1819
'if ! check_var noresume && [ -n "$resumeval" ] && [ -w /sys/power/resume ]; then',
1920
' if echo "$resumeval" | grep -q "PARTUUID="; then', # resolve partuuid to device
@@ -24,20 +25,13 @@ def handle_resume(self) -> None:
2425
' if [ -e "$resume" ]; then', # Check if the resume device exists
2526
' einfo "Resuming from: $resume"',
2627
' echo -n "$resume" > /sys/power/resume', # Attempt to resume
27-
' ewarn "Failed to resume from $resume"',
28+
' ewarn "Failed to resume from: $resume"',
2829
" else",
2930
' ewarn "Resume device not found: $resume)"', # Warn if the resume device does not exist
3031
r' eerror "Block devices:\n$(blkid)"',
32+
' eerror "If you wish to continue booting, remove the resume= kernel parameter."',
33+
''' eerror " or run 'setvar noresume 1' from the recovery shell to skip resuming."''',
34+
' rd_fail "Failed to resume from $(readvar resume)."',
35+
" fi",
36+
"fi",
3137
]
32-
if self["force_resume"]: # if force_resume is set, print a message and fail
33-
out_str += [
34-
' eerror "If you wish to continue booting, remove the resume= kernel parameter."',
35-
''' eerror " or run 'setvar noresume 1' from the recovery shell to skip resuming."''',
36-
' rd_fail "Failed to resume from $(readvar resume)."',
37-
]
38-
else:
39-
out_str += [' eerror "Failed to resume from $(readvar resume)"']
40-
41-
out_str += [" fi", "fi"]
42-
43-
return out_str

src/ugrd/fs/resume.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,3 @@ cmdline_strings = [ "resume" ]
22

33
[imports.init_early]
44
"ugrd.fs.resume" = [ "handle_resume" ]
5-
6-
[custom_parameters]
7-
force_resume = "bool" # Fail if resume is not possible

0 commit comments

Comments
 (0)