From: Mike Yuan Date: Sat, 8 Mar 2025 18:27:55 +0000 (+0100) Subject: core: move CrashAction enum def to crash-handler.[ch] X-Git-Tag: v258-rc1~1139^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fafb05451f37de69308233a6bf79c5525f560ac5;p=thirdparty%2Fsystemd.git core: move CrashAction enum def to crash-handler.[ch] --- diff --git a/src/core/crash-handler.c b/src/core/crash-handler.c index 056ac4b347c..5afd090e741 100644 --- a/src/core/crash-handler.c +++ b/src/core/crash-handler.c @@ -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); diff --git a/src/core/crash-handler.h b/src/core/crash-handler.h index dc143354d10..f156d23aa00 100644 --- a/src/core/crash-handler.h +++ b/src/core/crash-handler.h @@ -1,7 +1,20 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once +#include + #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); diff --git a/src/core/main.c b/src/core/main.c index 37054c5cb08..8fce4b93aed 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -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) { diff --git a/src/core/main.h b/src/core/main.h index 1949a085889..3b770b5a3f2 100644 --- a/src/core/main.h +++ b/src/core/main.h @@ -1,20 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include #include -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;