summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/sd_event_add_inotify.xml3
-rw-r--r--src/login/elogind-dbus.c6
-rw-r--r--src/login/logind-core.c2
-rw-r--r--src/login/logind-user.c1
-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
-rw-r--r--src/sleep/sleep.c24
-rw-r--r--src/sleep/sleep.h4
11 files changed, 42 insertions, 83 deletions
diff --git a/man/sd_event_add_inotify.xml b/man/sd_event_add_inotify.xml
index 1539d7bde..b28847f92 100644
--- a/man/sd_event_add_inotify.xml
+++ b/man/sd_event_add_inotify.xml
@@ -155,7 +155,6 @@
</variablelist>
</refsect1>
- <xi:include href="libelogind-pkgconfig.xml" />
<!-- 0 /// elogind has no inotify test program.
<refsect1>
<title>Examples</title>
@@ -168,6 +167,8 @@
</refsect1>
// 0 -->
+ <xi:include href="libelogind-pkgconfig.xml" />
+
<refsect1>
<title>See Also</title>
diff --git a/src/login/elogind-dbus.c b/src/login/elogind-dbus.c
index 715b28b17..39f5e8cf9 100644
--- a/src/login/elogind-dbus.c
+++ b/src/login/elogind-dbus.c
@@ -107,11 +107,11 @@ static int shutdown_or_sleep(Manager *m, HandleAction action) {
case HANDLE_KEXEC:
return run_helper(KEXEC);
case HANDLE_SUSPEND:
- return do_sleep("suspend", m->suspend_mode, m->suspend_state);
+ return do_sleep("suspend", m->suspend_mode, m->suspend_state, 0);
case HANDLE_HIBERNATE:
- return do_sleep("hibernate", m->hibernate_mode, m->hibernate_state);
+ return do_sleep("hibernate", m->hibernate_mode, m->hibernate_state, 0);
case HANDLE_HYBRID_SLEEP:
- return do_sleep("hybrid-sleep", m->hybrid_sleep_mode, m->hybrid_sleep_state);
+ return do_sleep("hybrid-sleep", m->hybrid_sleep_mode, m->hybrid_sleep_state, 0);
default:
return -EINVAL;
}
diff --git a/src/login/logind-core.c b/src/login/logind-core.c
index eecf20e9e..49c1cbcfb 100644
--- a/src/login/logind-core.c
+++ b/src/login/logind-core.c
@@ -354,7 +354,6 @@ int manager_get_session_by_pid(Manager *m, pid_t pid, Session **ret) {
not_found:
if (ret)
*ret = NULL;
-
return 0;
}
@@ -392,7 +391,6 @@ int manager_get_user_by_pid(Manager *m, pid_t pid, User **ret) {
if (ret)
*ret = s->user;
#endif // 0
-
return 1;
not_found:
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index 60e862e3b..2d27dc8dc 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -316,7 +316,6 @@ int user_load(User *u) {
return r;
}
-
static int user_start_service(User *u) {
#if 0 /// elogind can not ask systemd via dbus to start user services
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
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);
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c
index 455c14825..cf5f49bec 100644
--- a/src/sleep/sleep.c
+++ b/src/sleep/sleep.c
@@ -11,15 +11,15 @@
#include "sd-messages.h"
-//#include "parse-util.h"
+#include "parse-util.h"
#include "def.h"
#include "exec-util.h"
#include "fd-util.h"
#include "fileio.h"
//#include "log.h"
-//#include "sleep-config.h"
-//#include "stdio-util.h"
-//#include "string-util.h"
+#include "sleep-config.h"
+#include "stdio-util.h"
+#include "string-util.h"
#include "strv.h"
//#include "util.h"
@@ -219,6 +219,7 @@ static int execute_s2h(usec_t hibernate_delay_sec) {
char time_str[DECIMAL_STR_MAX(uint64_t)];
int r;
+#if 0 /// Already parsed by elogind config
r = parse_sleep_config("suspend", &suspend_modes, &suspend_states,
NULL);
if (r < 0)
@@ -228,6 +229,7 @@ static int execute_s2h(usec_t hibernate_delay_sec) {
&hibernate_states, NULL);
if (r < 0)
return r;
+#endif // 0
r = read_wakealarm(&orig_time);
if (r < 0)
@@ -347,17 +349,21 @@ int main(int argc, char *argv[]) {
if (r < 0)
goto finish;
+#else
+int do_sleep(const char *verb, char **modes, char **states, usec_t delay) {
+ int r;
+
+ assert(verb);
+ arg_verb = (char*)verb;
+#endif // 0
if (streq(arg_verb, "suspend-then-hibernate"))
r = execute_s2h(delay);
else
r = execute(modes, states);
+#if 0 /// In elogind we give the result back, no interpretation here.
finish:
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
-}
#else
-int do_sleep(const char *verb, char **modes, char **states) {
- assert(verb);
- arg_verb = (char*)verb;
- return execute(modes, states);
+ return r;
}
#endif // 0
diff --git a/src/sleep/sleep.h b/src/sleep/sleep.h
index 85669fa07..2c35d20e6 100644
--- a/src/sleep/sleep.h
+++ b/src/sleep/sleep.h
@@ -21,6 +21,8 @@
along with elogind; If not, see <http://www.gnu.org/licenses/>.
***/
-int do_sleep(const char *verb, char **modes, char **states);
+#include "time-util.h"
+
+int do_sleep(const char *verb, char **modes, char **states, usec_t delay);
#endif // ELOGIND_SRC_SLEEP_SLEEP_H_INCLUDED