summaryrefslogtreecommitdiffstats
path: root/hooks/resume
diff options
context:
space:
mode:
authorThomas Bächler <thomas@archlinux.org>2010-01-10 18:20:49 +0100
committerThomas Bächler <thomas@archlinux.org>2010-01-10 18:20:49 +0100
commit3fceb27acec3c2039639c6f9d205da24b3b68619 (patch)
treecffcdd283228f4472df7737ad9ddd2797eb69f12 /hooks/resume
parent2c5cab626d28078c3947a2883864e1c93e5b24c0 (diff)
downloadmkinitcpio-3fceb27acec3c2039639c6f9d205da24b3b68619.tar.gz
mkinitcpio-3fceb27acec3c2039639c6f9d205da24b3b68619.tar.xz
Remove parseblock usage from resume hook, also fix resuming with tuxonice
Diffstat (limited to 'hooks/resume')
-rw-r--r--hooks/resume28
1 files changed, 18 insertions, 10 deletions
diff --git a/hooks/resume b/hooks/resume
index 0632fed..cd82e1c 100644
--- a/hooks/resume
+++ b/hooks/resume
@@ -3,18 +3,26 @@ run_hook ()
{
fmtdevice () { echo "${1}:${2}"; }
- if [ -n "${resume}" ] && poll_device "${resume}" ${rootdelay}; then
- # Try resuming with tuxonice
- tuxoniceroot="/sys/power/tuxonice"
- if [ -d "${tuxoniceroot}" ]; then
- echo ${resume} > ${tuxoniceroot}/resume
- echo > ${tuxoniceroot}/do_resume
+ if [ -n "${resume}" ]; then
+ if grep -q ':' ${resume}; then
+ # Tux-on-ice syntax: swap:/dev/sda2 or file:/dev/sda2:0xdeadbeef
+ resumedev="$(echo ${resume} | cut -d: -f2)"
+ else
+ # Classical syntax: just a device
+ resumedev="${resume}"
fi
+ if poll_device "${resumedev}" ${rootdelay}; then
+ # Try resuming with tuxonice
+ tuxoniceroot="/sys/power/tuxonice"
+ if [ -d "${tuxoniceroot}" ]; then
+ echo ${resume} > ${tuxoniceroot}/resume
+ echo > ${tuxoniceroot}/do_resume
+ fi
- # Try resuming with vanilla hibernation
- if [ -e "/sys/power/resume" ]; then
- eval $(/bin/parseblock "${resume}")
- fmtdevice ${BLOCKDEVICE} > /sys/power/resume
+ # Try resuming with vanilla hibernation
+ if [ -e "/sys/power/resume" ]; then
+ printf "%d:%d" $(stat -Lc "0x%t 0x%T" ${resume}) > /sys/power/resume
+ fi
fi
fi
}