]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: move CrashAction enum def to crash-handler.[ch]
authorMike Yuan <me@yhndnzj.com>
Sat, 8 Mar 2025 18:27:55 +0000 (19:27 +0100)
committerMike Yuan <me@yhndnzj.com>
Sat, 8 Mar 2025 19:40:23 +0000 (20:40 +0100)
src/core/crash-handler.c
src/core/crash-handler.h
src/core/main.c
src/core/main.h

index 056ac4b347c64523bcc1cda1418613e9432ba6f6..5afd090e741cfc75c8b4432838fd754d5f880b6c 100644 (file)
@@ -13,6 +13,7 @@
 #include "raw-clone.h"
 #include "rlimit-util.h"
 #include "signal-util.h"
+#include "string-table.h"
 #include "terminal-util.h"
 #include "virt.h"
 
@@ -188,3 +189,11 @@ void install_crash_handler(void) {
         if (r < 0)
                 log_debug_errno(r, "I had trouble setting up the crash handler, ignoring: %m");
 }
+
+static const char* const crash_action_table[_CRASH_ACTION_MAX] = {
+        [CRASH_FREEZE]   = "freeze",
+        [CRASH_REBOOT]   = "reboot",
+        [CRASH_POWEROFF] = "poweroff",
+};
+
+DEFINE_STRING_TABLE_LOOKUP(crash_action, CrashAction);
index dc143354d101d24f1634ee785c8d20f3ffc12243..f156d23aa00b7d8c2a661b96f1ba9a9611279265 100644 (file)
@@ -1,7 +1,20 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include <errno.h>
+
 #include "macro.h"
 
+typedef enum CrashAction {
+        CRASH_FREEZE,
+        CRASH_REBOOT,
+        CRASH_POWEROFF,
+        _CRASH_ACTION_MAX,
+        _CRASH_ACTION_INVALID = -EINVAL,
+} CrashAction;
+
+const char* crash_action_to_string(CrashAction action);
+CrashAction crash_action_from_string(const char *action);
+
 _noreturn_ void freeze_or_exit_or_reboot(void);
 void install_crash_handler(void);
index 37054c5cb087850de120b65ee67bcbeef95e9d09..8fce4b93aede3aaf0937796bd37079eb54eba1e7 100644 (file)
@@ -93,7 +93,6 @@
 #include "special.h"
 #include "stat-util.h"
 #include "stdio-util.h"
-#include "string-table.h"
 #include "strv.h"
 #include "switch-root.h"
 #include "sysctl-util.h"
@@ -168,14 +167,6 @@ static char **saved_env = NULL;
 static int parse_configuration(const struct rlimit *saved_rlimit_nofile,
                                const struct rlimit *saved_rlimit_memlock);
 
-static const char* const crash_action_table[_CRASH_ACTION_MAX] = {
-        [CRASH_FREEZE]   = "freeze",
-        [CRASH_REBOOT]   = "reboot",
-        [CRASH_POWEROFF] = "poweroff",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(crash_action, CrashAction);
-
 static DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_crash_action, crash_action, CrashAction, CRASH_FREEZE);
 
 static int manager_find_user_config_paths(char ***ret_files, char ***ret_dirs) {
index 1949a08588905cf0aa0ff6bc590c3578be64e96c..3b770b5a3f2583b7cb3c5c0ab4c069d112a13a16 100644 (file)
@@ -1,20 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <errno.h>
 #include <stdbool.h>
 
-typedef enum CrashAction {
-        CRASH_FREEZE,
-        CRASH_REBOOT,
-        CRASH_POWEROFF,
-        _CRASH_ACTION_MAX,
-        _CRASH_ACTION_INVALID = -EINVAL,
-} CrashAction;
-
-const char* crash_action_to_string(CrashAction action);
-CrashAction crash_action_from_string(const char *action);
-
 extern bool arg_dump_core;
 extern int arg_crash_chvt;
 extern bool arg_crash_shell;