Debian Codegraph @

src/core/emergency-action.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "core-forward.h"
5
6 typedef enum EmergencyAction {
7 EMERGENCY_ACTION_NONE,
8 EMERGENCY_ACTION_EXIT,
9 EMERGENCY_ACTION_EXIT_FORCE,
10 _EMERGENCY_ACTION_LAST_USER_ACTION = EMERGENCY_ACTION_EXIT_FORCE,
11 EMERGENCY_ACTION_REBOOT,
12 EMERGENCY_ACTION_REBOOT_FORCE,
13 EMERGENCY_ACTION_REBOOT_IMMEDIATE,
14 EMERGENCY_ACTION_POWEROFF,
15 EMERGENCY_ACTION_POWEROFF_FORCE,
16 EMERGENCY_ACTION_POWEROFF_IMMEDIATE,
17 EMERGENCY_ACTION_SOFT_REBOOT,
18 EMERGENCY_ACTION_SOFT_REBOOT_FORCE,
19 EMERGENCY_ACTION_KEXEC,
20 EMERGENCY_ACTION_KEXEC_FORCE,
21 EMERGENCY_ACTION_HALT,
22 EMERGENCY_ACTION_HALT_FORCE,
23 EMERGENCY_ACTION_HALT_IMMEDIATE,
24 _EMERGENCY_ACTION_MAX,
25 _EMERGENCY_ACTION_INVALID = -EINVAL,
26 } EmergencyAction;
27
28 typedef enum EmergencyActionFlags {
29 EMERGENCY_ACTION_IS_WATCHDOG = 1 << 0, /* this action triggered by a watchdog or other kind of timeout */
30 EMERGENCY_ACTION_WARN = 1 << 1, /* log at LOG_WARNING + write to system console */
31 EMERGENCY_ACTION_SLEEP_5S = 1 << 2, /* wait 5s before executing action; only honoured together with EMERGENCY_ACTION_WARN */
32 _EMERGENCY_ACTION_FLAGS_MAX = (1 << 3) - 1,
33 } EmergencyActionFlags;
34
35 void emergency_action(
36 Manager *m,
37 EmergencyAction action,
38 EmergencyActionFlags flags,
39 const char *reboot_arg,
40 int exit_status,
41 const char *reason);
42
43 DECLARE_STRING_TABLE_LOOKUP(emergency_action, EmergencyAction);
44
45 int parse_emergency_action(const char *value, RuntimeScope runtime_scope, EmergencyAction *ret);