chiark / gitweb /
Prep v239: Fix sleep-config.[hc] and sleep/sleep.c to utilize upstream updates.
authorSven Eden <yamakuzure@gmx.net>
Mon, 20 Aug 2018 07:32:10 +0000 (09:32 +0200)
committerSven Eden <yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000 (16:47 +0200)
man/sd_event_add_inotify.xml
src/login/elogind-dbus.c
src/login/logind-core.c
src/login/logind-user.c
src/shared/conf-parser.c
src/shared/pager.c
src/shared/pager.h
src/shared/sleep-config.c
src/shared/sleep-config.h
src/sleep/sleep.c
src/sleep/sleep.h

index 1539d7bde70d07ce30d383b14b6688a5752b6cd9..b28847f92f1975bfec57e864e533c36da43b8f51 100644 (file)
     </variablelist>
   </refsect1>
 
-  <xi:include href="libelogind-pkgconfig.xml" />
   <!-- 0 /// elogind has no inotify test program.
   <refsect1>
     <title>Examples</title>
   </refsect1>
   // 0 -->
 
+  <xi:include href="libelogind-pkgconfig.xml" />
+
   <refsect1>
     <title>See Also</title>
 
index 715b28b177ec1ced9a0d5a31e192ac1ca040d0f2..39f5e8cf9161e94340a01b9be951af3046f8a6da 100644 (file)
@@ -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;
         }
index eecf20e9e83808bd41ca88f61feafba2ac211458..49c1cbcfb20337a886e4fbefaca0eeb61e41c69c 100644 (file)
@@ -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:
index 60e862e3b0b296b029f8a1de94246db178f43d94..2d27dc8dc909c0d6656b9693a12fa3c731b3eb3a 100644 (file)
@@ -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;
index 472c996423be58577a478487b86f725d9cc655b1..aa6238ae50e6043bd049b4f0d87fde607e8ad884 100644 (file)
@@ -1137,7 +1137,7 @@ int config_parse_join_controllers(
 
         return 0;
 }
-x
+
 int config_parse_mtu(
                 const char *unit,
                 const char *filename,
index 2598c1eaa4a86d395063644dc32e9b05f451128e..c0ad0bb3b96810fa18ba8eee4484c868032924dd 100644 (file)
@@ -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>
index 12fdcdbdc6f533c6240a8f936101041ff768bc09..edeae3a114ffe392813dd03a61b2bfeb0476b535 100644 (file)
@@ -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"
index d9f6d9402a82eb9b2f799da6cc6633a91d3d79bd..3cb917358c6ea214c5aa5ef3019b8e1a00babb53 100644 (file)
@@ -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
index ea46689e52762775b701fd2fa35ad114db90663a..026849cb8f4fbed8ab7df051e69b086b93a31f16 100644 (file)
@@ -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);
index 455c14825ac42f75b692e39a778233915279ce19..cf5f49bec65b003c763720921a2ece6f61521cec 100644 (file)
 
 #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
index 85669fa07dbfef0aa4bcf2ad497756dbdbf40aa3..2c35d20e6f3ada6eb88ff738c3e511bdce8690eb 100644 (file)
@@ -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