summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorSven Eden <yamakuzure@gmx.net>2018-08-20 09:32:10 +0200
committerSven Eden <yamakuzure@gmx.net>2018-08-24 16:47:08 +0200
commit347760af00d87762b3809111d8975023912ed7cc (patch)
tree84e9df7ff0cac68c6ef50fd1006607292e054aaa /src/shared
parent6655bb15f39fd491516671932c867864aca20869 (diff)
Prep v239: Fix sleep-config.[hc] and sleep/sleep.c to utilize upstream updates.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/conf-parser.c2
-rw-r--r--src/shared/pager.c18
-rw-r--r--src/shared/pager.h19
-rw-r--r--src/shared/sleep-config.c39
-rw-r--r--src/shared/sleep-config.h7
5 files changed, 19 insertions, 66 deletions
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index 472c99642..aa6238ae5 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -1137,7 +1137,7 @@ int config_parse_join_controllers(
return 0;
}
-x
+
int config_parse_mtu(
const char *unit,
const char *filename,
diff --git a/src/shared/pager.c b/src/shared/pager.c
index 2598c1eaa..c0ad0bb3b 100644
--- a/src/shared/pager.c
+++ b/src/shared/pager.c
@@ -1,22 +1,4 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
-/***
- This file is part of systemd.
-
- Copyright 2010 Lennart Poettering
-
- systemd is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
#include <errno.h>
#include <signal.h>
diff --git a/src/shared/pager.h b/src/shared/pager.h
index 12fdcdbdc..edeae3a11 100644
--- a/src/shared/pager.h
+++ b/src/shared/pager.h
@@ -1,25 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
-/***
- This file is part of systemd.
-
- Copyright 2010 Lennart Poettering
-
- systemd is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
#include <stdbool.h>
#include "macro.h"
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c
index d9f6d9402..3cb917358 100644
--- a/src/shared/sleep-config.c
+++ b/src/shared/sleep-config.c
@@ -4,7 +4,7 @@
***/
//#include <errno.h>
-//#include <linux/fs.h>
+#include <linux/fs.h>
//#include <stdbool.h>
//#include <stddef.h>
//#include <stdio.h>
@@ -347,8 +347,11 @@ int read_fiemap(int fd, struct fiemap **ret) {
return 0;
}
-#if 0 /// elogind has to do, or better, *can* do it differently
+#if 0 /// elogind has to ask the manager for some stuff
static bool can_s2h(void) {
+#else
+static bool can_s2h(Manager *m) {
+#endif // 0
const char *p;
int r;
@@ -360,7 +363,7 @@ static bool can_s2h(void) {
}
FOREACH_STRING(p, "suspend", "hibernate") {
- r = can_sleep(p);
+ r = can_sleep(m, p);
if (IN_SET(r, 0, -ENOSPC)) {
log_debug("Unable to %s system.", p);
return false;
@@ -371,49 +374,35 @@ static bool can_s2h(void) {
return true;
}
-#else
-int can_sleep(Manager *m, const char *verb) {
- assert(streq(verb, "suspend") ||
- streq(verb, "hibernate") ||
- streq(verb, "hybrid-sleep"));
+
+#if 0 /// elogind has to ask the manager for some stuff
int can_sleep(const char *verb) {
+#else
+int can_sleep(Manager *m, const char *verb) {
+#endif // 0
_cleanup_strv_free_ char **modes = NULL, **states = NULL;
int r;
- if ( streq(verb, "suspend")
- && ( !can_sleep_state(m->suspend_state)
- || !can_sleep_disk(m->suspend_mode) ) )
- return false;
- assert(STR_IN_SET(verb, "suspend", "hibernate", "hybrid-sleep", "suspend-to-hibernate"));
assert(STR_IN_SET(verb, "suspend", "hibernate", "hybrid-sleep", "suspend-then-hibernate"));
- if ( streq(verb, "hibernate")
- && ( !can_sleep_state(m->hibernate_state)
- || !can_sleep_disk(m->hibernate_mode) ) )
- return false;
- if (streq(verb, "suspend-to-hibernate"))
if (streq(verb, "suspend-then-hibernate"))
- return can_s2h();
+ return can_s2h(m);
- if ( streq(verb, "hybrid-sleep")
- && ( !can_sleep_state(m->hybrid_sleep_state)
- || !can_sleep_disk(m->hybrid_sleep_mode) ) )
+#if 0 /// already parsed by elogind config
r = parse_sleep_config(verb, &modes, &states, NULL);
if (r < 0)
return false;
+#endif // 0
if (!can_sleep_state(states) || !can_sleep_disk(modes))
return false;
- return streq(verb, "suspend") || enough_memory_for_hibernation();
if (streq(verb, "suspend"))
return true;
- if (!enough_memory_for_hibernation())
if (!enough_swap_for_hibernation())
return -ENOSPC;
return true;
}
-#endif // 0
diff --git a/src/shared/sleep-config.h b/src/shared/sleep-config.h
index ea46689e5..026849cb8 100644
--- a/src/shared/sleep-config.h
+++ b/src/shared/sleep-config.h
@@ -1,15 +1,16 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
-
-#if 0 /// UNNEEDED by elogind
-//#include <linux/fiemap.h>
+#include <linux/fiemap.h>
//#include "time-util.h"
int read_fiemap(int fd, struct fiemap **ret);
+#if 0 /// UNNEEDED by elogind
int parse_sleep_config(const char *verb, char ***modes, char ***states, usec_t *delay);
+#endif // 0
int find_hibernate_location(char **device, char **type, size_t *size, size_t *used);
+#if 0 /// UNNEEDED by elogind
int can_sleep(const char *verb);
int can_sleep_disk(char **types);
int can_sleep_state(char **types);