From 347760af00d87762b3809111d8975023912ed7cc Mon Sep 17 00:00:00 2001 From: Sven Eden Date: Mon, 20 Aug 2018 09:32:10 +0200 Subject: Prep v239: Fix sleep-config.[hc] and sleep/sleep.c to utilize upstream updates. --- src/shared/conf-parser.c | 2 +- src/shared/pager.c | 18 ------------------ src/shared/pager.h | 19 ------------------- src/shared/sleep-config.c | 39 ++++++++++++++------------------------- src/shared/sleep-config.h | 7 ++++--- 5 files changed, 19 insertions(+), 66 deletions(-) (limited to 'src/shared') 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 . -***/ #include #include 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 . -***/ - #include #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 -//#include +#include //#include //#include //#include @@ -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 +#include //#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); -- cgit v1.2.3