summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-10-28 00:49:04 +0200
committerLennart Poettering <lennart@poettering.net>2012-10-28 00:50:35 +0200
commit6524990fdc98370ecba5d9f73e67161e8798c010 (patch)
tree870ed57ed3c756dd34a0223692d1ec5b9e5ef44d /src/shared/util.c
parent2001208c2ab631a69896d1f670c26846b70d1fb7 (diff)
logind: support for hybrid sleep (i.e. suspend+hibernate at the same time)
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index db8e75b628..2d4a4c1102 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -5691,6 +5691,30 @@ int can_sleep(const char *type) {
return false;
}
+int can_sleep_disk(const char *type) {
+ char *w, *state;
+ size_t l, k;
+ int r;
+ _cleanup_free_ char *p = NULL;
+
+ assert(type);
+
+ r = read_one_line_file("/sys/power/disk", &p);
+ if (r < 0)
+ return r == -ENOENT ? 0 : r;
+
+ k = strlen(type);
+ FOREACH_WORD_SEPARATOR(w, l, p, WHITESPACE, state) {
+ if (l == k && memcmp(w, type, l) == 0)
+ return true;
+
+ if (l == k + 2 && w[0] == '[' && memcmp(w + 1, type, l - 2) == 0 && w[l-1] == ']')
+ return true;
+ }
+
+ return false;
+}
+
bool is_valid_documentation_url(const char *url) {
assert(url);