summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Eden <sven.eden@prydeworx.com>2018-11-08 07:53:08 +0100
committerSven Eden <sven.eden@prydeworx.com>2018-11-08 08:02:57 +0100
commit68a05fa61dabdecc9fce9eb406c5386c57bdd82c (patch)
tree6d1f1fff08d25af7d5fdb42b9365df5dafe619b6
parent918e88d5024ce206d678799d4e455fb6d980db49 (diff)
Prep v239.2: Fix migration errors in shared
-rw-r--r--src/shared/enable-mempool.c2
-rw-r--r--src/shared/meson.build10
-rw-r--r--src/shared/sleep-config.c40
-rw-r--r--src/shared/sleep-config.h2
4 files changed, 37 insertions, 17 deletions
diff --git a/src/shared/enable-mempool.c b/src/shared/enable-mempool.c
index 68d817f..a571b43 100644
--- a/src/shared/enable-mempool.c
+++ b/src/shared/enable-mempool.c
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
-//#include "mempool.h"
+#include "mempool.h"
const bool mempool_use_allowed = true;
diff --git a/src/shared/meson.build b/src/shared/meson.build
index a48bee9..389ecec 100644
--- a/src/shared/meson.build
+++ b/src/shared/meson.build
@@ -114,6 +114,7 @@ shared_sources = '''
clean-ipc.h
conf-parser.c
conf-parser.h
+ enable-mempool.c
musl_missing.c
musl_missing.h
nsflags.c
@@ -150,10 +151,11 @@ endif
#endif // 0
libshared_name = 'elogind-shared-@0@'.format(meson.project_version())
-if conf.get('HAVE_KMOD') == 1
- shared_sources += files('module-util.c')
-endif
-
+#if 0 /// elogind does not play around with kernel modules. Not its job.
+# if conf.get('HAVE_KMOD') == 1
+# shared_sources += files('module-util.c')
+# endif
+#endif // 0
#if 0 /// elogind doesn't need all this
# libshared_deps = [threads,
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c
index 74ed2bd..8045816 100644
--- a/src/shared/sleep-config.c
+++ b/src/shared/sleep-config.c
@@ -22,8 +22,8 @@
//#include "log.h"
//#include "macro.h"
#include "parse-util.h"
-//#include "path-util.h"
-//#include "proc-cmdline.h"
+#include "path-util.h"
+#include "proc-cmdline.h"
#include "sleep-config.h"
#include "string-util.h"
#include "strv.h"
@@ -298,6 +298,7 @@ static bool enough_swap_for_hibernation(void) {
return r;
}
+#if 0 /// elogind is not init and can not check boot devices and partitions.
static int check_resume_keys(const char *key, const char *value, void *data) {
assert_se(key);
assert_se(data);
@@ -379,6 +380,7 @@ static int resume_configured(void) {
log_debug("Couldn't detect any resume mechanism, hibernation is disabled.");
return false;
}
+#endif // 0
int read_fiemap(int fd, struct fiemap **ret) {
_cleanup_free_ struct fiemap *fiemap = NULL, *result_fiemap = NULL;
@@ -464,7 +466,11 @@ int read_fiemap(int fd, struct fiemap **ret) {
return 0;
}
+#if 0 /// elogind has to ask the manager for some stuff
static int can_sleep_internal(const char *verb, bool check_allowed);
+#else
+static int can_sleep_internal(Manager *m, const char *verb, bool check_allowed);
+#endif // 0
#if 0 /// elogind has to ask the manager for some stuff
static bool can_s2h(void) {
@@ -484,10 +490,10 @@ static bool can_s2h(Manager *m) {
FOREACH_STRING(p, "suspend", "hibernate") {
#if 0 /// elogind must transport a pointer to its managers instance
r = can_sleep_internal(p, false);
- if (IN_SET(r, 0, -ENOSPC, -EADV)) {
#else
r = can_sleep(m, p);
#endif // 0
+ if (IN_SET(r, 0, -ENOSPC, -EADV)) {
log_debug("Unable to %s system.", p);
return false;
}
@@ -504,8 +510,11 @@ static int can_sleep_internal(const char *verb, bool check_allowed) {
bool allow;
_cleanup_strv_free_ char **modes = NULL, **states = NULL;
int r;
+
+
+ assert(STR_IN_SET(verb, "suspend", "hibernate", "hybrid-sleep", "suspend-then-hibernate"));
#else
-int can_sleep(Manager *m, const char *verb) {
+static int can_sleep_internal(Manager *m, const char *verb, bool check_allowed) {
assert(m);
char **modes = streq(verb, "suspend") ? m->suspend_mode :
@@ -516,26 +525,27 @@ int can_sleep(Manager *m, const char *verb) {
m->hybrid_sleep_state;
#endif // 0
- assert(STR_IN_SET(verb, "suspend", "hibernate", "hybrid-sleep", "suspend-then-hibernate"));
-
-#if 0 /// elogind must transport a pointer to its managers instance
-#else
- return can_s2h(m);
-#endif // 0
#if 0 /// already parsed by elogind config
r = parse_sleep_config(verb, &allow, &modes, &states, NULL);
if (r < 0)
return false;
-#endif // 0
if (check_allowed && !allow) {
+#else
+ if (check_allowed && !STR_IN_SET(verb, "suspend", "hibernate", "hybrid-sleep", "suspend-then-hibernate")) {
+#endif // 0
+
log_debug("Sleep mode \"%s\" is disabled by configuration.", verb);
return false;
}
if (streq(verb, "suspend-then-hibernate"))
+#if 0 /// elogind must transport a pointer to its managers instance
return can_s2h();
+#else
+ return can_s2h(m);
+#endif // 0
if (!can_sleep_state(states) || !can_sleep_disk(modes))
return false;
@@ -546,14 +556,22 @@ int can_sleep(Manager *m, const char *verb) {
if (!enough_swap_for_hibernation())
return -ENOSPC;
+#if 0 /// elogind is not init and can not check this
r = resume_configured();
if (r <= 0)
/* We squash all errors (e.g. EPERM) into a single value for reporting. */
return -EADV;
+#endif // 0
return true;
}
+#if 0 /// elogind has to ask the manager for some stuff
int can_sleep(const char *verb) {
return can_sleep_internal(verb, true);
}
+#else
+int can_sleep(Manager *m, const char *verb) {
+ return can_sleep_internal(m, verb, true);
+}
+#endif // 0
diff --git a/src/shared/sleep-config.h b/src/shared/sleep-config.h
index e3eceb9..19bbaa4 100644
--- a/src/shared/sleep-config.h
+++ b/src/shared/sleep-config.h
@@ -6,8 +6,8 @@
int read_fiemap(int fd, struct fiemap **ret);
#if 0 /// UNNEEDED by elogind
-#endif // 0
int parse_sleep_config(const char *verb, bool *ret_allow, char ***ret_modes, char ***ret_states, usec_t *ret_delay);
+#endif // 0
int find_hibernate_location(char **device, char **type, size_t *size, size_t *used);
#if 0 /// elogind has to transport its manager instance