From abbf428bc969400e0e77e5f7474587bea5c9b31d Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Wed, 4 Apr 2012 01:42:14 +0300 Subject: [PATCH] op_power: try to handle mounted-cards-on-suspend mess --- recipes/pandora-system/pandora-scripts.bb | 2 +- .../pandora-scripts/op_power.sh | 37 +++++++++++++++++-- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/recipes/pandora-system/pandora-scripts.bb b/recipes/pandora-system/pandora-scripts.bb index b9e9303..9d4c234 100644 --- a/recipes/pandora-system/pandora-scripts.bb +++ b/recipes/pandora-system/pandora-scripts.bb @@ -6,7 +6,7 @@ COMPATIBLE_MACHINE = "omap3-pandora" DEPENDS = "zenity dbus" RDEPENDS = "zenity dbus" -PR = "r89" +PR = "r90" SRC_URI = " \ file://op_paths.sh \ diff --git a/recipes/pandora-system/pandora-scripts/op_power.sh b/recipes/pandora-system/pandora-scripts/op_power.sh index 487056f..bdfe27c 100644 --- a/recipes/pandora-system/pandora-scripts/op_power.sh +++ b/recipes/pandora-system/pandora-scripts/op_power.sh @@ -111,6 +111,13 @@ lowPowerOff(){ # switch from lowpower to normal mode echo 255 > /sys/class/leds/pandora\:\:power/brightness #power LED bright } +show_message() { + # TODO: check if desktop is visible; maybe use layer3? + xfceuser=$(ps u -C xfce4-session | tail -n1 | awk '{print $1}') + cmd="DISPLAY=:0.0 zenity --info --text \"$1\"" + su -c "$cmd" $xfceuser +} + suspend_real() { delay=0 @@ -129,6 +136,31 @@ suspend_real() { # - cards don't unmount (running PNDs will break) # - while charging too, since it stops on suspend? + if ! grep -q 'mmc_core.removable=0' /proc/cmdline; then + # must unmount cards because they will be "ejected" on suspend + # (some filesystems may even deadlock if we don't do this due to bugs) + mounts="$(grep "/dev/mmcblk" /proc/mounts | awk '{print $1}' | xargs echo)" + for mnt in $mounts; do + if ! umount $mnt; then + show_message "Could not unmount $mnt, using partial suspend only" + return 1 + fi + done + swaps="$(grep "/dev/mmcblk" /proc/swaps | awk '{print $1}' | xargs echo)" + for swp in $swaps; do + if ! swapoff $swp; then + show_message "Could not unmount $swp, using partial suspend only" + return 1 + fi + done + else + if [ ! -e /etc/pandora/suspend-warned ]; then + show_message "Pandora will now suspend.\n\n\ +Please do not remove SD cards while pandora is suspended, doing so will corrupt them." + touch /etc/pandora/suspend-warned + fi + fi + # FIXME: fix the kernel and get rid of this suspend_net @@ -145,11 +177,8 @@ suspend_real() { fi done - # must unmount cards because they will be "ejected" on suspend - # (some filesystems may even deadlock if we don't do this due to bugs) - grep "/dev/mmcblk" /proc/mounts | awk '{print $1}' | xargs umount -r - sleep $delay + sync echo mem > /sys/power/state # if we are here, either we already resumed or the suspend failed -- 2.39.2