gentoo/sys-kernel/dracut/files/dracut-060-fix-resume-hostonly.patch

66 lines
2.6 KiB
Diff
Raw Normal View History

https://bugs.gentoo.org/917000
https://github.com/dracutdevs/dracut/pull/2494
From b88d0bab791bdc4ca75d13802f0391caf537650d Mon Sep 17 00:00:00 2001
From: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
Date: Sun, 20 Aug 2023 11:47:22 +0200
Subject: [PATCH] fix(resume): include in hostonly mode if resume= on cmdline
The grep introduced in commit e3a7112bef794e2f2dd741ec2c74fa9cb9117651
does not work as intended. The resume module is always excluded in hostonly
mode.
Made this a bit more explicit with if/else so it is more clear what is going
on. The in-line ||/&& makes the line really long and makes it more difficult
to understand what is going on.
Bug: https://github.com/dracutdevs/dracut/issues/924
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
---
modules.d/95resume/module-setup.sh | 32 +++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/modules.d/95resume/module-setup.sh b/modules.d/95resume/module-setup.sh
index d255103366..2d48043827 100755
--- a/modules.d/95resume/module-setup.sh
+++ b/modules.d/95resume/module-setup.sh
@@ -10,13 +10,31 @@ check() {
return 1
}
- # Only support resume if hibernation is currently on
- # and no swap is mounted on a net device
- [[ $hostonly ]] || [[ $mount_needs ]] && {
- swap_on_netdevice || [[ -f /sys/power/resume && "$(< /sys/power/resume)" == "0:0" ]] || grep -rq '^\|[[:space:]]resume=' /proc/cmdline /etc/cmdline /etc/cmdline.d /etc/kernel/cmdline /usr/lib/kernel/cmdline 2> /dev/null && return 255
- }
-
- return 0
+ # If hostonly check if we want to include the resume module
+ if [[ $hostonly ]] || [[ $mount_needs ]]; then
+ # Resuming won't work if swap is on a netdevice
+ swap_on_netdevice && return 255
+ if grep -rq 'resume=' /proc/cmdline /etc/cmdline /etc/cmdline.d /etc/kernel/cmdline /usr/lib/kernel/cmdline 2> /dev/null; then
+ # hibernation support requested on kernel command line
+ return 0
+ else
+ # resume= not set on kernel command line
+ if [[ -f /sys/power/resume ]]; then
+ if [[ "$(< /sys/power/resume)" == "0:0" ]]; then
+ # hibernation supported by the kernel, but not enabled
+ return 255
+ else
+ # hibernation supported by the kernel and enabled
+ return 0
+ fi
+ else
+ # resume file doesn't exist, hibernation not supported by kernel
+ return 255
+ fi
+ fi
+ else
+ return 0
+ fi
}
# called by dracut