[Pm-utils] [Patch] uswsusp support

Stefan Seyfried seife at suse.de
Tue Feb 20 10:46:57 PST 2007


Hi,

This adds basic support for uswsusp (http://suspend.sf.net)

More work needs to be done let the s2ram use the newly added commandline
parameters.

Index: pm/functions
===================================================================
RCS file: /cvs/pm-utils/pm-utils/pm/functions,v
retrieving revision 1.32
diff -u -r1.32 functions
--- pm/functions	30 Nov 2006 20:07:04 -0000	1.32
+++ pm/functions	20 Feb 2007 18:43:43 -0000
@@ -12,6 +12,9 @@
 INHIBIT=/var/run/pm-utils.inhibit
 PM_LOGFILE=${PM_LOGFILE:=/var/log/pm-suspend.log}
 SUSPEND_MODULES=""
+HIBERNATE_METHOD=""
+S2DISK_BIN=/usr/sbin/s2disk
+S2DISK_CONF=/etc/suspend.conf
 
 [ -f /etc/pm/config ] && . /etc/pm/config
 
@@ -28,6 +31,9 @@
 add_global PM_CMDLINE
 add_global RESUME_MODULES
 add_global SUSPEND_MODULES
+add_global HIBERNATE_METHOD
+add_global S2DISK_BIN
+add_global S2DISK_CONF
 
 source_configs()
 {
@@ -123,13 +129,31 @@
 
 do_suspend()
 {
-	pm-pmu --suspend || echo -n "mem" > /sys/power/state
+	if [ -x /usr/sbin/s2ram ]; then
+		/usr/sbin/s2ram $S2RAM_OPTS
+	else
+		pm-pmu --suspend || echo -n "mem" > /sys/power/state
+	fi
 }
 
 do_hibernate()
 {
-	echo -n "platform" > /sys/power/disk
-	echo -n "disk" > /sys/power/state
+	if [ -z "$HIBERNATE_METHOD" ]; then
+		if [ -x $S2DISK_BIN -a -c /dev/snapshot ]; then
+			HIBERNATE_METHOD="userspace"
+		else
+			HIBERNATE_METHOD="kernel"
+		fi
+	fi
+	case $HIBERNATE_METHOD in
+		userspace)
+			$S2DISK_BIN -f $S2DISK_CONF
+			;;
+		kernel)
+			echo -n "platform" > /sys/power/disk
+			echo -n "disk" > /sys/power/state
+			;;
+	esac
 }
 
 pm_main()
-- 
Stefan Seyfried

"Any ideas, John?"
"Well, surrounding them's out." 


More information about the Pm-utils mailing list