Skip to content

Commit

Permalink
disable suspend if booting from removable storage
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansaraev committed Mar 22, 2014
1 parent 5664795 commit 803bc00
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/sysutils/busybox/scripts/init
Expand Up @@ -588,6 +588,25 @@

BOOT_STEP=final

# no suspend when booted from nonpersistent storage
STORAGE=$(cat /proc/mounts | grep " /sysroot/storage " | awk '{print $1}' | awk -F '/' '{print $3}')
if [ -n "$STORAGE" ] ; then
removable="/sys/class/block/*/$STORAGE/../removable"
if [ -e $removable ] ; then
if [ "$(cat $removable 2>/dev/null)" = "1" ] ; then
SUSPEND_DISABLED=yes
fi
fi
fi
FLASH=$(cat /proc/mounts | grep " /sysroot/flash " | awk '{print $1}' | awk -F '/' '{print $3}')
if [ -n "$FLASH" ] ; then
removable="/sys/class/block/*/$FLASH/../removable"
if [ -e $removable ] ; then
if [ "$(cat $removable 2>/dev/null)" = "1" ] ; then
SUSPEND_DISABLED=yes
fi
fi
fi
# move some special filesystems
/bin/busybox mount --move /dev /sysroot/dev
/bin/busybox mount --move /proc /sysroot/proc
Expand All @@ -601,6 +620,10 @@
if [ "$STORAGE_NETBOOT" = "yes" ] ; then
echo "" > /sysroot/dev/.storage_netboot
fi
# no suspend when booted from nonpersistent storage
if [ "$SUSPEND_DISABLED" = "yes" ] ; then
echo "" > /sysroot/dev/.suspend_disabled
fi
# switch to new sysroot and start real init
exec /bin/busybox switch_root /sysroot /usr/lib/systemd/systemd $INIT_ARGS

Expand Down
@@ -0,0 +1,27 @@
From a8ad8aadc39820594f89d43aa0f8d527b256aa99 Mon Sep 17 00:00:00 2001
From: Stefan Saraev <stefan@saraev.ca>
Date: Sat, 22 Mar 2014 13:40:55 +0200
Subject: [PATCH] disable suspend if /dev/.suspend_disabled exist

---
src/shared/sleep-config.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c
index cf1cd40..f6ad307 100644
--- a/src/shared/sleep-config.c
+++ b/src/shared/sleep-config.c
@@ -256,6 +256,10 @@ int can_sleep(const char *verb) {
streq(verb, "hibernate") ||
streq(verb, "hybrid-sleep"));

+ // boo
+ if (access("/dev/.suspend_disabled", F_OK) == 0)
+ return false;
+
r = parse_sleep_config(verb, &modes, &states);
if (r < 0)
return false;
--
1.9.1

3 comments on commit 803bc00

@LossAngeles
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too fond of the 'good reasons' here as was explained for this change:

http://openelec.tv/forum/103-infared-remotes/70122-3-95-3-power-buttons-on-remote-stopped-working#102078

Can someone elaborate the reasons here? I'm a seasoned retired technical professional so I'm not looking for quick explanations, just things we might be able to talk about and solve here =) This suspend exclusion will cause more ?? mark threads in forums IMO. Thx,
-Greg

@shidarin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to have to agree with @LossAngeles , this removal should at the very least be explained properly. The terse, dismissive replies so far are not helping.

Workaround is here: http://openelec.tv/forum/64-installation/70788-shutdown-function-greyed-out

@stefansaraev
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea. more spam.
it is explained. search github PRs. woarkaround is there too

Please sign in to comment.