logind: support for hybrid sleep (i.e. suspend+hibernate at the same time)

This commit is contained in:
Lennart Poettering
2012-10-28 00:50:35 +02:00
parent 2001208c2a
commit 6524990fdc
18 changed files with 263 additions and 44 deletions
+24
View File
@@ -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);
+1
View File
@@ -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);