summaryrefslogtreecommitdiff
path: root/src/shared
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
parent2001208c2ab631a69896d1f670c26846b70d1fb7 (diff)
logind: support for hybrid sleep (i.e. suspend+hibernate at the same time)
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/util.c24
-rw-r--r--src/shared/util.h1
2 files changed, 25 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);
diff --git a/src/shared/util.h b/src/shared/util.h
index f6a4c1ea6c..f726263dd3 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -529,6 +529,7 @@ int setrlimit_closest(int resource, const struct rlimit *rlim);
int getenv_for_pid(pid_t pid, const char *field, char **_value);
int can_sleep(const char *type);
+int can_sleep_disk(const char *type);
bool is_valid_documentation_url(const char *url);