[Pm-utils] [RFC] check for swap partition in pm-is-supported for hibernate / suspend-hybrid
Victor Lowther
victor.lowther at gmail.com
Fri Feb 8 14:25:26 PST 2008
On Fri, Feb 08, 2008 at 11:05:31PM +0100, Till Maas wrote:
> Unless userland applications are used (e.g. s2ram),
> resume=/dev/your_swap_partition is needed as a kernel parameter according to
> Documentation/power/swsusp.txt (2.6.23.14-64.fc7). Also the remaining
> documentation indicates, that this is an active swap partition (or file) is a
> requirement.
>
> Regards,
> Till
Patch against the even_simpler_sleep_methods patches.
This patch adds a hibernate_might_work function, which should return 1
if hiberante definitly will not work on this system, and 0 if it might
work.
The name was chosen because this function returning 0 does not mean that
hibernatation will succeed -- nothing short of trying to actually
hibernate the system will. :)
pm/module.d/Makefile.am | 4 +---
pm/module.d/kernel | 9 +++++++--
pm/module.d/tuxonice | 14 +++++++++++---
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/pm/module.d/Makefile.am b/pm/module.d/Makefile.am
index 636d810..6efd24d 100644
--- a/pm/module.d/Makefile.am
+++ b/pm/module.d/Makefile.am
@@ -1,10 +1,8 @@
moduledir = $(libdir)/pm-utils/module.d
-module_SCRIPTS = \
+dist_module_SCRIPTS = \
kernel \
tuxonice
-EXTRA_DIST=$(module_SCRIPTS)
-
clean-local :
rm -f *~
diff --git a/pm/module.d/kernel b/pm/module.d/kernel
index c111490..cbd42ed 100644
--- a/pm/module.d/kernel
+++ b/pm/module.d/kernel
@@ -1,5 +1,5 @@
check_suspend() {
- grep -q mem /sys/power/state; return $?
+ grep -q mem /sys/power/state
}
do_suspend()
@@ -9,7 +9,12 @@ do_suspend()
check_hibernate() {
[ -f /sys/power/disk ] && grep -q disk /sys/power/state
- return $?
+}
+
+# If this returns 0, hibernate might work.
+# If this returns 1, it probably won't.
+hibernate_might_work(){
+ grep -q partition /proc/swaps
}
do_hibernate()
diff --git a/pm/module.d/tuxonice b/pm/module.d/tuxonice
index b687d15..16c5eb6 100644
--- a/pm/module.d/tuxonice
+++ b/pm/module.d/tuxonice
@@ -6,7 +6,7 @@ for loc in "/sys/power/tuxonice" "/sys/power/suspend2"; do
done
check_suspend() {
- grep -q mem /sys/power/state; return $?
+ grep -q mem /sys/power/state
}
do_suspend() {
@@ -14,7 +14,15 @@ do_suspend() {
}
check_hibernate() {
- [ -f "${TUXONICE_LOC}/do_hibernate" ]; return $?
+ [ -f "${TUXONICE_LOC}/do_hibernate" ]
+}
+
+# if this returns 0 hibernate might work.
+# if it returns 1 it probably won't.
+# Needs lots of customization for tuxonice, someone who actually uses
+# it should take a stab at making it better.
+hibernate_might_work(){
+ grep -q 'partition|file' /proc/swaps
}
do_hibernate() {
@@ -24,7 +32,7 @@ do_hibernate() {
check_suspend_hybrid() {
grep -q mem /sys/power/state || return 1
- [ -f "${TUXONICE_LOC}/do_hibernate" ]; return $?
+ [ -f "${TUXONICE_LOC}/do_hibernate" ]
}
do_suspend_hybrid() {
echo 3 >"${TUXONICE_LOC}/powerdown_method"
> _______________________________________________
> Pm-utils mailing list
> Pm-utils at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/pm-utils
--
Victor Lowther
Ubuntu Certified Professional
More information about the Pm-utils
mailing list