]>
Commit | Line | Data |
---|---|---|
c2f1db8f | 1 | #pragma once |
1afbdcb0 LP |
2 | |
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2010 Lennart Poettering | |
7 | ||
8 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
9 | under the terms of the GNU Lesser General Public License as published by |
10 | the Free Software Foundation; either version 2.1 of the License, or | |
1afbdcb0 LP |
11 | (at your option) any later version. |
12 | ||
13 | systemd is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
5430f7f2 | 16 | Lesser General Public License for more details. |
1afbdcb0 | 17 | |
5430f7f2 | 18 | You should have received a copy of the GNU Lesser General Public License |
1afbdcb0 LP |
19 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
20 | ***/ | |
21 | ||
9a57c629 | 22 | #include <stdbool.h> |
4d7213b2 | 23 | |
11c3a366 TA |
24 | #include "hashmap.h" |
25 | #include "macro.h" | |
93cc7779 | 26 | #include "set.h" |
4d7213b2 | 27 | |
c9d81ae8 LP |
28 | /* This defines pretty names for the LSB 'start' verb exit codes. Note that they shouldn't be confused with the LSB |
29 | * 'status' verb exit codes which are defined very differently. For details see: | |
30 | * | |
31 | * https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html | |
32 | */ | |
33 | ||
65e3fd83 | 34 | enum { |
1afbdcb0 LP |
35 | /* EXIT_SUCCESS defined by libc */ |
36 | /* EXIT_FAILURE defined by libc */ | |
37 | EXIT_INVALIDARGUMENT = 2, | |
38 | EXIT_NOTIMPLEMENTED = 3, | |
39 | EXIT_NOPERMISSION = 4, | |
40 | EXIT_NOTINSTALLED = 5, | |
41 | EXIT_NOTCONFIGURED = 6, | |
42 | EXIT_NOTRUNNING = 7, | |
43 | ||
44 | /* The LSB suggests that error codes >= 200 are "reserved". We | |
45 | * use them here under the assumption that they hence are | |
c9d81ae8 | 46 | * unused by init scripts. */ |
1afbdcb0 LP |
47 | |
48 | EXIT_CHDIR = 200, | |
49 | EXIT_NICE, | |
50 | EXIT_FDS, | |
51 | EXIT_EXEC, | |
52 | EXIT_MEMORY, | |
53 | EXIT_LIMITS, | |
54 | EXIT_OOM_ADJUST, | |
55 | EXIT_SIGNAL_MASK, | |
56 | EXIT_STDIN, | |
57 | EXIT_STDOUT, | |
58 | EXIT_CHROOT, /* 210 */ | |
59 | EXIT_IOPRIO, | |
60 | EXIT_TIMERSLACK, | |
61 | EXIT_SECUREBITS, | |
62 | EXIT_SETSCHEDULER, | |
63 | EXIT_CPUAFFINITY, | |
64 | EXIT_GROUP, | |
65 | EXIT_USER, | |
66 | EXIT_CAPABILITIES, | |
67 | EXIT_CGROUP, | |
68 | EXIT_SETSID, /* 220 */ | |
69 | EXIT_CONFIRM, | |
70 | EXIT_STDERR, | |
7f8aa671 | 71 | _EXIT_RESERVED, /* used to be tcpwrap, don't reuse! */ |
ff01d048 | 72 | EXIT_PAM, |
4c2630eb | 73 | EXIT_NETWORK, |
8351ceae LP |
74 | EXIT_NAMESPACE, |
75 | EXIT_NO_NEW_PRIVILEGES, | |
7b52a628 | 76 | EXIT_SECCOMP, |
ac45f971 | 77 | EXIT_SELINUX_CONTEXT, |
eef65bf3 | 78 | EXIT_PERSONALITY, /* 230 */ |
4298d0b5 LP |
79 | EXIT_APPARMOR_PROFILE, |
80 | EXIT_ADDRESS_FAMILIES, | |
3900e5fd | 81 | EXIT_RUNTIME_DIRECTORY, |
be7e509e | 82 | _EXIT_RESERVED2, /* used to be used by kdbus, don't reuse */ |
3900e5fd | 83 | EXIT_CHOWN, |
2ca620c4 | 84 | EXIT_SMACK_PROCESS_LABEL, |
74dd6b51 | 85 | EXIT_KEYRING, |
3536f49e YW |
86 | EXIT_STATE_DIRECTORY, |
87 | EXIT_CACHE_DIRECTORY, | |
88 | EXIT_LOGS_DIRECTORY, /* 240 */ | |
89 | EXIT_CONFIGURATION_DIRECTORY, | |
65e3fd83 | 90 | }; |
1afbdcb0 LP |
91 | |
92 | typedef enum ExitStatusLevel { | |
c9d81ae8 LP |
93 | EXIT_STATUS_MINIMAL, /* only cover libc EXIT_STATUS/EXIT_FAILURE */ |
94 | EXIT_STATUS_SYSTEMD, /* cover libc and systemd's own exit codes */ | |
95 | EXIT_STATUS_LSB, /* cover libc, systemd's own and LSB exit codes */ | |
1afbdcb0 LP |
96 | EXIT_STATUS_FULL = EXIT_STATUS_LSB |
97 | } ExitStatusLevel; | |
98 | ||
96342de6 | 99 | typedef struct ExitStatusSet { |
3e2d435b | 100 | Set *status; |
96342de6 LN |
101 | Set *signal; |
102 | } ExitStatusSet; | |
103 | ||
65e3fd83 | 104 | const char* exit_status_to_string(int status, ExitStatusLevel level) _const_; |
1afbdcb0 | 105 | |
1f0958f6 LP |
106 | typedef enum ExitClean { |
107 | EXIT_CLEAN_DAEMON, | |
108 | EXIT_CLEAN_COMMAND, | |
109 | } ExitClean; | |
110 | ||
111 | bool is_clean_exit(int code, int status, ExitClean clean, ExitStatusSet *success_status); | |
37520c1b LP |
112 | |
113 | void exit_status_set_free(ExitStatusSet *x); | |
55ebf98c | 114 | bool exit_status_set_is_empty(ExitStatusSet *x); |
597466f4 | 115 | bool exit_status_set_test(ExitStatusSet *x, int code, int status); |