summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-09-13 19:41:52 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-09-13 19:41:52 -0400
commit69ab80881552d5f79ca95f6b3be48ad122ab1ec2 (patch)
tree6b099f9f4f5693bb819ca4ac7dda4ad2798177b3 /src/shared/util.c
parente39ff1f48d7ffcf7c20f9178ec64efbd7e244cab (diff)
Advertise hibernation only if there's enough free swap
Condition that is checked is taken from upower: active(anon) < free swap * 0.98 This is really stupid, because the kernel knows the situation better, e.g. there could be two swap files, and then hibernation would be impossible despite passing this check, or the kernel could start supporting compressed swap and/or compressed hibernation images, and then this this check would be too stringent. Nevertheless, until we have something better, this should at least return a true negative if there's no swap. Logging of capabilities in the journal is changed to not strip leading zeros. I consider this more readable anyway. http://cgit.freedesktop.org/upower/tree/src/up-daemon.c#n613 https://bugzilla.redhat.com/show_bug.cgi?id=1007059
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c23
1 files changed, 1 insertions, 22 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 9a075fa163..f6f3b18bfc 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -694,9 +694,6 @@ int is_kernel_thread(pid_t pid) {
int get_process_capeff(pid_t pid, char **capeff) {
const char *p;
- _cleanup_free_ char *status = NULL;
- char *t = NULL;
- int r;
assert(capeff);
assert(pid >= 0);
@@ -706,25 +703,7 @@ int get_process_capeff(pid_t pid, char **capeff) {
else
p = procfs_file_alloca(pid, "status");
- r = read_full_file(p, &status, NULL);
- if (r < 0)
- return r;
-
- t = strstr(status, "\nCapEff:\t");
- if (!t)
- return -ENOENT;
-
- for (t += strlen("\nCapEff:\t"); t[0] == '0'; t++)
- continue;
-
- if (t[0] == '\n')
- t--;
-
- *capeff = strndup(t, strchr(t, '\n') - t);
- if (!*capeff)
- return -ENOMEM;
-
- return 0;
+ return get_status_field(p, "\nCapEff:", capeff);
}
int get_process_exe(pid_t pid, char **name) {