chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
11dc5d2
)
util: if /sys mounted read-only we can't suspend/hibernate
author
Lennart Poettering
<lennart@poettering.net>
Sun, 23 Dec 2012 20:58:37 +0000
(21:58 +0100)
committer
Lennart Poettering
<lennart@poettering.net>
Sun, 23 Dec 2012 23:29:40 +0000
(
00:29
+0100)
src/shared/util.c
patch
|
blob
|
history
diff --git
a/src/shared/util.c
b/src/shared/util.c
index 59d8544d053b9eca14e917e5c51c45ad5bb76603..1779625c77916ccb10b1d8ceca99d3b40688acc9 100644
(file)
--- a/
src/shared/util.c
+++ b/
src/shared/util.c
@@
-5282,9
+5282,13
@@
int can_sleep(const char *type) {
assert(type);
assert(type);
+ /* If /sys is read-only we cannot sleep */
+ if (access("/sys/power/state", W_OK) < 0)
+ return false;
+
r = read_one_line_file("/sys/power/state", &p);
if (r < 0)
r = read_one_line_file("/sys/power/state", &p);
if (r < 0)
- return
r == -ENOENT ? 0 : r
;
+ return
false
;
k = strlen(type);
FOREACH_WORD_SEPARATOR(w, l, p, WHITESPACE, state)
k = strlen(type);
FOREACH_WORD_SEPARATOR(w, l, p, WHITESPACE, state)
@@
-5302,9
+5306,14
@@
int can_sleep_disk(const char *type) {
assert(type);
assert(type);
+ /* If /sys is read-only we cannot sleep */
+ if (access("/sys/power/state", W_OK) < 0 ||
+ access("/sys/power/disk", W_OK) < 0)
+ return false;
+
r = read_one_line_file("/sys/power/disk", &p);
if (r < 0)
r = read_one_line_file("/sys/power/disk", &p);
if (r < 0)
- return
r == -ENOENT ? 0 : r
;
+ return
false
;
k = strlen(type);
FOREACH_WORD_SEPARATOR(w, l, p, WHITESPACE, state) {
k = strlen(type);
FOREACH_WORD_SEPARATOR(w, l, p, WHITESPACE, state) {